当前位置: 首页>>代码示例>>Java>>正文


Java XMLNode类代码示例

本文整理汇总了Java中edu.mit.csail.sdg.alloy4.XMLNode的典型用法代码示例。如果您正苦于以下问题:Java XMLNode类的具体用法?Java XMLNode怎么用?Java XMLNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XMLNode类属于edu.mit.csail.sdg.alloy4包,在下文中一共展示了XMLNode类的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);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:18,代码来源:StaticThemeReaderWriter.java

示例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);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:26,代码来源:StaticThemeReaderWriter.java

示例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;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:18,代码来源:StaticThemeReaderWriter.java

示例4: test2

import edu.mit.csail.sdg.alloy4.XMLNode; //导入依赖的package包/类
public void test2() throws Exception {
	test1();
	XMLNode xml = new XMLNode(new StringReader("<alloy builddate='unknown'>"
			+ "<instance bitwidth='2' maxseq='1' command='Run Deadlock' filename='dijkstra.als'>"
			+ "<sig label='univ' ID='0' builtin='yes'> <atom label='-2'/> <atom label='-1'/> <atom label='0'/> <atom label='1'/> <atom label='State$0'/> <atom label='State$1'/> <atom label='State$2'/> </sig>"
			+ "<sig label='Int' ID='1' parentID='0' builtin='yes'> <atom label='-2'/> <atom label='-1'/> <atom label='0'/> <atom label='1'/> </sig>"
			+ "<sig label='seq/Int' ID='2' parentID='1' builtin='yes'> <atom label='0'/> </sig>"
			+ "<sig label='Act' ID='5' parentID='0'> <atom label='Act$0'/> <atom label='Act$1'/> <atom label='Act$2'/> </sig>"
			+ "<skolem label='$x' ID='16'>" + "   <tuple> <atom label='0'/> <atom label='Act$1'/> </tuple>"
			+ "   <types> <type ID='2'/> <type ID='5'/> </types>" + "</skolem>" + "</instance>" + "</alloy>"));
	Sig activity = new Sig.PrimSig("Act");
	A4Solution sol = A4SolutionReader.read(Arrays.asList(activity), xml);
	SafeList<ExprVar> skolems = new SafeList<ExprVar>(sol.getAllSkolems());
	check(skolems.size() == 1);
	check(skolems.get(0).label, "$x");
	check(skolems.get(0).type(), Sig.SEQIDX.type().product(activity.type()));
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:18,代码来源:InternalTest.java

示例5: test3

import edu.mit.csail.sdg.alloy4.XMLNode; //导入依赖的package包/类
public void test3() throws Exception {
	XMLNode xml = new XMLNode(new StringReader("<alloy builddate='unknown'>"
			+ "<instance bitwidth='2' maxseq='1' command='Run Deadlock' filename='dijkstra.als'>"
			+ "<sig label='univ' ID='0' builtin='yes'> <atom label='-2'/> <atom label='-1'/> <atom label='0'/> <atom label='1'/> <atom label='State$0'/> <atom label='State$1'/> <atom label='State$2'/> </sig>"
			+ "<sig label='Int' ID='1' parentID='0' builtin='yes'> <atom label='-2'/> <atom label='-1'/> <atom label='0'/> <atom label='1'/> </sig>"
			+ "<sig label='seq/Int' ID='2' parentID='1' builtin='yes'> <atom label='0'/> </sig>"
			+ "<sig label='State' ID='5' parentID='6'> <atom label='State$0'/> </sig>"
			+ "<sig label='Mutex' ID='6' parentID='5'> <atom label='Mutex$0'/> </sig>" + "</instance>"
			+ "</alloy>"));
	String err = "";
	try {
		A4SolutionReader.read(null, xml);
	} catch (Throwable ex) {
		err = ex.toString();
	}
	check(err.contains("cyclic inheritance"));
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:18,代码来源:InternalTest.java

示例6: 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);
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:22,代码来源:A4SolutionReader.java

示例7: 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;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:18,代码来源:A4SolutionReader.java

示例8: 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;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:26,代码来源:A4SolutionReader.java

示例9: 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);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:21,代码来源:StaticThemeReaderWriter.java

示例10: 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;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:17,代码来源:StaticThemeReaderWriter.java

示例11: parseEdgeViz

import edu.mit.csail.sdg.alloy4.XMLNode; //导入依赖的package包/类
/** Do nothing if the element is malformed; note: x can be null. */
private static void parseEdgeViz(XMLNode xml, VizState view, AlloyRelation x) {
   /*
    * <edge visible="inherit/yes/no"  label=".."  color=".."  style=".."  weight=".."  constraint=".."
    * attribute="inherit/yes/no"   merge="inherit/yes/no" layout="inherit/yes/no">
    *     zero or more RELATION
    * </edge>
    *
    * Each attribute, if omitted, means "no change".
    * Note: BOOLEAN is tristate.
    */
   if (has(xml,"visible"))    view.edgeVisible.put (x, getbool(xml,"visible"));
   if (has(xml,"attribute"))  view.attribute  .put (x, getbool(xml,"attribute"));
   if (has(xml,"merge"))      view.mergeArrows.put (x, getbool(xml,"merge"));
   if (has(xml,"layout"))     view.layoutBack .put (x, getbool(xml,"layout"));
   if (has(xml,"constraint")) view.constraint .put (x, getbool(xml,"constraint"));
   if (has(xml,"style"))      view.edgeStyle  .put (x, parseDotStyle(xml));
   if (has(xml,"color"))      view.edgeColor  .put (x, parseDotColor(xml));
   if (has(xml,"weight"))     view.weight     .put (x, getint (xml,"weight"));
   if (has(xml,"label"))      view.label      .put (x, xml.getAttribute("label"));
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:22,代码来源:StaticThemeReaderWriter.java

示例12: 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;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:25,代码来源:A4SolutionReader.java

示例13: test2

import edu.mit.csail.sdg.alloy4.XMLNode; //导入依赖的package包/类
static void test2() throws Exception {
    test1();
    XMLNode xml = new XMLNode(new StringReader(
       "<alloy builddate='unknown'>"
       + "<instance bitwidth='2' maxseq='1' command='Run Deadlock' filename='dijkstra.als'>"
       + "<sig label='univ' ID='0' builtin='yes'> <atom label='-2'/> <atom label='-1'/> <atom label='0'/> <atom label='1'/> <atom label='State$0'/> <atom label='State$1'/> <atom label='State$2'/> </sig>"
       + "<sig label='Int' ID='1' parentID='0' builtin='yes'> <atom label='-2'/> <atom label='-1'/> <atom label='0'/> <atom label='1'/> </sig>"
       + "<sig label='seq/Int' ID='2' parentID='1' builtin='yes'> <atom label='0'/> </sig>"
       + "<sig label='Act' ID='5' parentID='0'> <atom label='Act$0'/> <atom label='Act$1'/> <atom label='Act$2'/> </sig>"
       + "<skolem label='$x' ID='16'>"
       + "   <tuple> <atom label='0'/> <atom label='Act$1'/> </tuple>"
       + "   <types> <type ID='2'/> <type ID='5'/> </types>"
       + "</skolem>"
       + "</instance>"
       + "</alloy>"));
    Sig activity = new Sig.PrimSig("Act");
    A4Solution sol = A4SolutionReader.read(Arrays.asList(activity), xml);
    SafeList<ExprVar> skolems = new SafeList<ExprVar>(sol.getAllSkolems());
    check(skolems.size()==1);
    check(skolems.get(0).label, "$x");
    check(skolems.get(0).type(), Sig.SEQIDX.type().product(activity.type()));
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:23,代码来源:InternalTest.java

示例14: parseInstance

import edu.mit.csail.sdg.alloy4.XMLNode; //导入依赖的package包/类
/** Parse the file into an AlloyInstance if possible. */
public static AlloyInstance parseInstance(File file) throws Err {
	try {
		return (new StaticInstanceReader(new XMLNode(file))).ans;
	} catch (IOException ex) {
		throw new ErrorFatal("Error reading the XML file: " + ex, ex);
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:9,代码来源:StaticInstanceReader.java

示例15: 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.");
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:16,代码来源:StaticThemeReaderWriter.java


注:本文中的edu.mit.csail.sdg.alloy4.XMLNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。