本文整理汇总了Java中edu.mit.csail.sdg.alloy4.XMLNode.is方法的典型用法代码示例。如果您正苦于以下问题:Java XMLNode.is方法的具体用法?Java XMLNode.is怎么用?Java XMLNode.is使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.mit.csail.sdg.alloy4.XMLNode
的用法示例。
在下文中一共展示了XMLNode.is方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseAlloySet
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Return null if the element is malformed. */
private static AlloySet parseAlloySet(VizState now, XMLNode x) {
/*
* class AlloySet implements AlloyNodeElement { String name; AlloyType
* type; } <set name="name" type="name"/>
*/
if (!x.is("set"))
return null;
String name = x.getAttribute("name"), type = x.getAttribute("type");
if (name.length() == 0 || type.length() == 0)
return null;
AlloyType t = now.getCurrentModel().hasType(type);
if (t == null)
return null;
else
return now.getCurrentModel().hasSet(name, t);
}
示例2: 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);
}
示例3: 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;
}
示例4: parseTuple
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Parse tuple. */
private Tuple parseTuple(XMLNode tuple, int arity) throws Err {
Tuple ans = null;
try {
for (XMLNode sub : tuple)
if (sub.is("atom")) {
Tuple x = factory.tuple(sub.getAttribute("label"));
if (ans == null)
ans = x;
else
ans = ans.product(x);
}
if (ans == null)
throw new ErrorFatal("Expecting: <tuple> <atom label=\"..\"/> .. </tuple>");
if (ans.arity() != arity)
throw new ErrorFatal("Expecting: tuple of arity " + arity + " but got tuple of arity " + ans.arity());
return ans;
} catch (Throwable ex) {
throw new ErrorFatal("Expecting: <tuple> <atom label=\"..\"/> .. </tuple>", ex);
}
}
示例5: parseType
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Parse type. */
private Expr parseType(XMLNode node) throws IOException, Err {
Expr expr = null;
if (!node.is("types"))
throw new IOException("<types>...</type> expected");
for (XMLNode n : node)
if (n.is("type")) {
Sig sig = parseSig(n.getAttribute("ID"), 0);
if (expr == null)
expr = sig;
else
expr = expr.product(sig);
}
if (expr == null)
throw new IOException("<type ID=../> expected");
return expr;
}
示例6: parseSkolem
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Parse skolem. */
private ExprVar parseSkolem(String id) throws IOException, Err {
final XMLNode node = nmap.get(id);
if (node == null)
throw new IOException("Unknown ID " + id + " encountered.");
if (!node.is("skolem"))
throw new IOException("ID " + id + " is not a skolem.");
String label = label(node);
Expr type = null;
for (XMLNode sub : node)
if (sub.is("types")) {
Expr t = parseType(sub);
if (type == null)
type = t;
else
type = type.plus(t);
}
int arity;
if (type == null || (arity = type.type().arity()) < 1)
throw new IOException("Skolem " + label + " is maltyped.");
ExprVar var = ExprVar.make(Pos.UNKNOWN, label, type.type());
TupleSet ts = parseTuples(node, arity);
expr2ts.put(var, ts);
return var;
}
示例7: 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);
}
示例8: 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;
}
示例9: parseField
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Parse field. */
private Field parseField(String id) throws IOException, Err {
final XMLNode node = nmap.get(id);
if (node==null) throw new IOException("Unknown FieldID "+id+" encountered.");
if (!node.is("field")) throw new IOException("ID "+id+" is not a field.");
String label = label(node);
Pos isPrivate = yes(node,"private") ? Pos.UNKNOWN : null;
Pos isMeta = yes(node,"meta") ? Pos.UNKNOWN : null;
Expr type = null;
for(XMLNode sub:node) if (sub.is("types")) { Expr t=parseType(sub); if (type==null) type=t; else type=type.plus(t); }
int arity;
if (type==null || (arity=type.type().arity())<2) throw new IOException("Field "+label+" is maltyped.");
String parentID = node.getAttribute("parentID");
Sig parent = id2sig.get(parentID);
if (parent==null) throw new IOException("ID "+parentID+" is not a sig.");
Field field = null;
for(Field f: parent.getFields())
if (f.label.equals(label) && f.type().arity()==arity && choices.contains(f))
{ field=f; choices.remove(f); break; }
if (field==null) field = parent.addTrickyField(Pos.UNKNOWN, isPrivate, null, null, isMeta, new String[] {label}, UNIV.join(type)) [0];
TupleSet ts = parseTuples(node, arity);
expr2ts.put(field, ts);
return field;
}
示例10: parseAlloyType
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Return null if the element is malformed. */
private static AlloyType parseAlloyType(VizState now, XMLNode x) {
/*
* class AlloyType implements AlloyNodeElement { String name; } <type
* name="the type name"/>
*/
if (!x.is("type"))
return null;
String name = x.getAttribute("name");
if (name.length() == 0)
return null;
else
return now.getCurrentModel().hasType(name);
}
示例11: parseTuples
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Parse tuples. */
private TupleSet parseTuples(XMLNode tuples, int arity) throws Err {
TupleSet ans = factory.noneOf(arity);
for (XMLNode sub : tuples)
if (sub.is("tuple"))
ans.add(parseTuple(sub, arity));
return ans;
}
示例12: parseAlloyType
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Return null if the element is malformed. */
private static AlloyType parseAlloyType(VizState now, XMLNode x) {
/* class AlloyType implements AlloyNodeElement {
* String name;
* }
* <type name="the type name"/>
*/
if (!x.is("type")) return null;
String name=x.getAttribute("name");
if (name.length()==0) return null; else return now.getCurrentModel().hasType(name);
}
示例13: parseAlloySet
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Return null if the element is malformed. */
private static AlloySet parseAlloySet(VizState now, XMLNode x) {
/* class AlloySet implements AlloyNodeElement {
* String name;
* AlloyType type;
* }
* <set name="name" type="name"/>
*/
if (!x.is("set")) return null;
String name=x.getAttribute("name"), type=x.getAttribute("type");
if (name.length()==0 || type.length()==0) return null;
AlloyType t=now.getCurrentModel().hasType(type);
if (t==null) return null; else return now.getCurrentModel().hasSet(name, t);
}
示例14: parseSkolem
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Parse skolem. */
private ExprVar parseSkolem(String id) throws IOException, Err {
final XMLNode node = nmap.get(id);
if (node==null) throw new IOException("Unknown ID "+id+" encountered.");
if (!node.is("skolem")) throw new IOException("ID "+id+" is not a skolem.");
String label = label(node);
Expr type = null;
for(XMLNode sub:node) if (sub.is("types")) { Expr t=parseType(sub); if (type==null) type=t; else type=type.plus(t); }
int arity;
if (type==null || (arity=type.type().arity())<1) throw new IOException("Skolem "+label+" is maltyped.");
ExprVar var = ExprVar.make(Pos.UNKNOWN, label, type.type());
TupleSet ts = parseTuples(node, arity);
expr2ts.put(var, ts);
return var;
}
示例15: parseTuple
import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Parse tuple. */
private Tuple parseTuple(XMLNode tuple, int arity) throws Err {
Tuple ans = null;
try {
for(XMLNode sub:tuple) if (sub.is("atom")) {
Tuple x = factory.tuple(sub.getAttribute("label"));
if (ans==null) ans=x; else ans=ans.product(x);
}
if (ans==null) throw new ErrorFatal("Expecting: <tuple> <atom label=\"..\"/> .. </tuple>");
if (ans.arity()!=arity) throw new ErrorFatal("Expecting: tuple of arity "+arity+" but got tuple of arity "+ans.arity());
return ans;
} catch(Throwable ex) {
throw new ErrorFatal("Expecting: <tuple> <atom label=\"..\"/> .. </tuple>", ex);
}
}