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


Java TreeElement.getAttributeValue方法代码示例

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


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

示例1: extractFormParameters

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
/**
 * Extract the form id, version and uiVersion.
 *
 * @param rootElement
 *          - the tree element that is the root submission.
 * @param defaultFormIdValue
 *          - used if no "id" attribute found. This should already be
 *          slash-substituted.
 * @return
 */
private XFormParameters extractFormParameters(TreeElement rootElement, String defaultFormIdValue) {

  String formIdValue = null;
  String versionString = rootElement.getAttributeValue(null, "version");

  // search for the "id" attribute
  for (int i = 0; i < rootElement.getAttributeCount(); i++) {
    String name = rootElement.getAttributeName(i);
    if (name.equals(ParserConsts.FORM_ID_ATTRIBUTE_NAME)) {
      formIdValue = rootElement.getAttributeValue(i);
      formIdValue = formIdValue.replaceAll(ParserConsts.FORWARD_SLASH,
          ParserConsts.FORWARD_SLASH_SUBSTITUTION);
      break;
    }
  }

  return new XFormParameters((formIdValue == null) ? defaultFormIdValue : formIdValue,
      versionString);
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:30,代码来源:BaseFormParserForJavaRosa.java

示例2: visit

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
public void visit(FormInstance tree) {
	nodeSet = new String();

	TreeElement root = tree.getRoot();
	// TreeElement root = tree.resolveReference(rootRef);

	instanceID = root.getAttributeValue("", "id");
	xmlns = root.getAttributeValue("", "xmlns");
	delimiter = root.getAttributeValue("", "delimiter");
	if ( delimiter == null ) {
		// for the spelling-impaired...
		delimiter = root.getAttributeValue("", "delimeter");
	}
	prefix = root.getAttributeValue("", "prefix");

	instanceID = (instanceID != null)? instanceID : "unknown";
	xmlns = (xmlns != null)? xmlns : " ";
	delimiter = (delimiter != null ) ? delimiter : "#";
	prefix = (prefix != null) ? prefix : "J1!"+instanceID+"!";

	//Don't bother adding any delimiters, yet. Delimiters are
	//added before tags/data
	theSmsStr = prefix;

	// serialize each node (and it's children) to get it's answers
	serializeTree(root);
	theSmsStr = theSmsStr.trim();
}
 
开发者ID:medic,项目名称:javarosa,代码行数:29,代码来源:SMSSerializingVisitor.java

示例3: getAdditionalAttribute

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
public String getAdditionalAttribute(String namespace, String name) {
	TreeElement e = TreeElement.getAttribute(additionalAttributes, namespace, name);
	if ( e != null ) {
		return e.getAttributeValue();
	}
	return null;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:8,代码来源:GroupDef.java

示例4: serializeNode

import org.javarosa.core.model.instance.TreeElement; //导入方法依赖的package包/类
public String serializeNode(TreeElement instanceNode) {
	StringBuilder b = new StringBuilder();
	// don't serialize template nodes or non-relevant nodes
	if (!instanceNode.isRelevant()
			|| instanceNode.getMult() == TreeReference.INDEX_TEMPLATE)
		return null;

	if (instanceNode.getValue() != null) {
		Object serializedAnswer = serializer.serializeAnswerData(
				instanceNode.getValue(), instanceNode.getDataType());

		if (serializedAnswer instanceof Element) {
			// DON"T handle this.
			throw new RuntimeException("Can't handle serialized output for"
					+ instanceNode.getValue().toString() + ", "
					+ serializedAnswer);
		} else if (serializedAnswer instanceof String) {
			Element e = new Element();
			e.addChild(Node.TEXT, (String) serializedAnswer);

			String tag = instanceNode.getAttributeValue("", "tag");
			if ( tag != null ) {
				b.append(tag);
			}
			else {
				String name = instanceNode.getName();
				if ( name != null ) {
					b.append(name);
				}
			}
			b.append(delimiter);

			for (int k = 0; k < e.getChildCount(); k++) {
				b.append(e.getChild(k).toString().replace("\\", "\\\\").replace(delimiter, "\\" + delimiter));
				b.append(delimiter);
			}

		} else {
			throw new RuntimeException("Can't handle serialized output for"
					+ instanceNode.getValue().toString() + ", "
					+ serializedAnswer);
		}

		if (serializer.containsExternalData(instanceNode.getValue())
				.booleanValue()) {
			IDataPointer[] pointer = serializer
					.retrieveExternalDataPointer(instanceNode.getValue());
			for (int i = 0; i < pointer.length; ++i) {
				dataPointers.add(pointer[i]);
			}
		}
	}
	return b.toString();
}
 
开发者ID:medic,项目名称:javarosa,代码行数:55,代码来源:SMSSerializingVisitor.java


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