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


Java XMLNode.getAttribute方法代码示例

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


在下文中一共展示了XMLNode.getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例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: 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

示例5: 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

示例6: getint

import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Returns 0 if the attribute doesn't exist, or is malformed. */
private static int getint(XMLNode x, String attr) {
   String value=x.getAttribute(attr);
   int i;
   try {
      i=Integer.parseInt(value);
   } catch(NumberFormatException ex) {
      i=0;
   }
   return i;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:12,代码来源:StaticThemeReaderWriter.java

示例7: getbool

import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Returns null if the attribute doesn't exist, or is malformed. */
private static Boolean getbool(XMLNode x, String attr) {
	String value = x.getAttribute(attr);
	if (value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("true"))
		return Boolean.TRUE;
	if (value.equalsIgnoreCase("no") || value.equalsIgnoreCase("false"))
		return Boolean.FALSE;
	return null;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:10,代码来源:StaticThemeReaderWriter.java

示例8: getint

import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Returns 0 if the attribute doesn't exist, or is malformed. */
private static int getint(XMLNode x, String attr) {
	String value = x.getAttribute(attr);
	int i;
	try {
		i = Integer.parseInt(value);
	} catch (NumberFormatException ex) {
		i = 0;
	}
	return i;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:12,代码来源:StaticThemeReaderWriter.java

示例9: getbool

import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Returns null if the attribute doesn't exist, or is malformed. */
private static Boolean getbool(XMLNode x, String attr) {
   String value=x.getAttribute(attr);
   if (value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("true")) return Boolean.TRUE;
   if (value.equalsIgnoreCase("no") || value.equalsIgnoreCase("false")) return Boolean.FALSE;
   return null;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:8,代码来源:StaticThemeReaderWriter.java

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

示例11: 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:ModelWriter,项目名称:Tarski,代码行数:15,代码来源:StaticThemeReaderWriter.java

示例12: has

import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Returns true if the XML element has the given attribute. */
private static boolean has(XMLNode x, String attr) {
	return x.getAttribute(attr, null) != null;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:5,代码来源:StaticThemeReaderWriter.java

示例13: 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:AlloyTools,项目名称:org.alloytools.alloy,代码行数:42,代码来源:A4SolutionReader.java

示例14: label

import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Helper method that returns an XML node's "label" attribute. */
private static String label(XMLNode node) { return node.getAttribute("label"); }
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:3,代码来源:A4SolutionReader.java

示例15: has

import edu.mit.csail.sdg.alloy4.XMLNode; //导入方法依赖的package包/类
/** Returns true if the XML element has the given attribute. */
private static boolean has(XMLNode x, String attr) {
   return x.getAttribute(attr,null)!=null;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:5,代码来源:StaticThemeReaderWriter.java


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