本文整理汇总了Java中edu.mit.csail.sdg.alloy4.XMLNode.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java XMLNode.getChildren方法的具体用法?Java XMLNode.getChildren怎么用?Java XMLNode.getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.mit.csail.sdg.alloy4.XMLNode
的用法示例。
在下文中一共展示了XMLNode.getChildren方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseAlloyRelation
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Return null if the element is malformed. */
private static AlloyRelation parseAlloyRelation(VizState now, XMLNode x) {
/*
* <relation name="name"> 2 or more <type name=".."/> </relation>
*/
List<AlloyType> ans = new ArrayList<AlloyType>();
if (!x.is("relation"))
return null;
String name = x.getAttribute("name");
if (name.length() == 0)
return null;
for (XMLNode sub : x.getChildren("type")) {
String typename = sub.getAttribute("name");
if (typename.length() == 0)
return null;
AlloyType t = now.getCurrentModel().hasType(typename);
if (t == null)
return null;
ans.add(t);
}
if (ans.size() < 2)
return null;
else
return now.getCurrentModel().hasRelation(name, ans);
}
示例2: parseProjectionList
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Always returns a nonnull (though possibly empty) set of AlloyType. */
private static Set<AlloyType> parseProjectionList(VizState now, XMLNode x) {
/*
* <projection> 0 or more <type name=".."/> </projection>
*/
Set<AlloyType> ans = new TreeSet<AlloyType>();
if (x.is("projection"))
for (XMLNode sub : x.getChildren("type")) {
String name = sub.getAttribute("name");
if (name.length() == 0)
continue;
AlloyType t = now.getOriginalModel().hasType(name);
if (t != null)
ans.add(t);
}
return ans;
}
示例3: parseAlloyRelation
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Return null if the element is malformed. */
private static AlloyRelation parseAlloyRelation(VizState now, XMLNode x) {
/*
* <relation name="name">
* 2 or more <type name=".."/>
* </relation>
*/
List<AlloyType> ans=new ArrayList<AlloyType>();
if (!x.is("relation")) return null;
String name=x.getAttribute("name");
if (name.length()==0) return null;
for(XMLNode sub:x.getChildren("type")) {
String typename=sub.getAttribute("name");
if (typename.length()==0) return null;
AlloyType t = now.getCurrentModel().hasType(typename);
if (t==null) return null;
ans.add(t);
}
if (ans.size()<2) return null; else return now.getCurrentModel().hasRelation(name, ans);
}
示例4: parseProjectionList
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Always returns a nonnull (though possibly empty) set of AlloyType. */
private static Set<AlloyType> parseProjectionList(VizState now, XMLNode x) {
/*
* <projection>
* 0 or more <type name=".."/>
* </projection>
*/
Set<AlloyType> ans=new TreeSet<AlloyType>();
if (x.is("projection")) for(XMLNode sub:x.getChildren("type")) {
String name=sub.getAttribute("name");
if (name.length()==0) continue;
AlloyType t = now.getOriginalModel().hasType(name);
if (t!=null) ans.add(t);
}
return ans;
}
示例5: readAlloy
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/**
* Read the XML file and merge its settings into an existing VizState
* object.
*/
public static void readAlloy(String filename, VizState theme) throws IOException {
File file = new File(filename);
try {
XMLNode elem = new XMLNode(file);
for (XMLNode sub : elem.getChildren("view"))
parseView(sub, theme);
} catch (Throwable e) {
throw new IOException(
"The file \"" + file.getPath() + "\" is not a valid XML file, or an error occurred in reading.");
}
}
示例6: readAlloy
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Read the XML file and merge its settings into an existing VizState object. */
public static void readAlloy(String filename, VizState theme) throws IOException {
File file = new File(filename);
try {
XMLNode elem = new XMLNode(file);
for(XMLNode sub: elem.getChildren("view")) parseView(sub,theme);
} catch(Throwable e) {
throw new IOException("The file \""+file.getPath()+"\" is not a valid XML file, or an error occurred in reading.");
}
}