kopia lustrzana https://github.com/jameshball/osci-render
Add XML Util class
rodzic
cc8b7dd39a
commit
0b2565d981
|
@ -8,6 +8,7 @@ import javax.xml.parsers.DocumentBuilder;
|
|||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.SAXException;
|
||||
import shapes.Shape;
|
||||
|
||||
|
@ -33,6 +34,8 @@ public class SvgParser extends FileParser {
|
|||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
File file = new File(path);
|
||||
Document doc = builder.parse(file);
|
||||
|
||||
for (Node elem : doc.getElementsByTagName("path"))
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package parser;
|
||||
|
||||
import java.util.AbstractList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.RandomAccess;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
public final class XmlUtil {
|
||||
private XmlUtil(){}
|
||||
|
||||
public static List<Node> asList(NodeList n) {
|
||||
return n.getLength()==0?
|
||||
Collections.emptyList(): new NodeListWrapper(n);
|
||||
}
|
||||
static final class NodeListWrapper extends AbstractList<Node>
|
||||
implements RandomAccess {
|
||||
private final NodeList list;
|
||||
NodeListWrapper(NodeList l) {
|
||||
list=l;
|
||||
}
|
||||
public Node get(int index) {
|
||||
return list.item(index);
|
||||
}
|
||||
public int size() {
|
||||
return list.getLength();
|
||||
}
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue