本文整理汇总了Java中org.kxml2.kdom.Element.setName方法的典型用法代码示例。如果您正苦于以下问题:Java Element.setName方法的具体用法?Java Element.setName怎么用?Java Element.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kxml2.kdom.Element
的用法示例。
在下文中一共展示了Element.setName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeChoices
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private static void writeChoices (Element e, String typeName, List<SelectChoice> choices) {
Element st = new Element();
st.setName("simpleType");
st.setAttribute(null, "name", typeName);
e.addChild(Node.ELEMENT, st);
Element restr = new Element();
restr.setName("restriction");
restr.setAttribute(null, "base", "string");
st.addChild(Node.ELEMENT, restr);
for (int i = 0; i < choices.size(); i++) {
String value = choices.get(i).getValue();
Element choice = new Element();
choice.setName("enumeration");
choice.setAttribute(null, "value", value);
restr.addChild(Node.ELEMENT, choice);
}
}
示例2: serializeAnswerData
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
/**
* @param data The AnswerDataObject to be serialized
* @return A String which contains a reference to the
* data
*/
public Object serializeAnswerData(MultiPointerAnswerData data) {
//Note: In order to override this default behavior, a
//new serializer should be used, and then registered
//with this serializer
IDataPointer[] pointers = (IDataPointer[])data.getValue();
if(pointers.length == 1) {
return pointers[0].getDisplayText();
}
Element parent = new Element();
for(int i = 0; i < pointers.length; ++i) {
Element datael = new Element();
datael.setName("data");
datael.addChild(Element.TEXT, pointers[i].getDisplayText());
parent.addChild(Element.ELEMENT, datael);
}
return parent;
}
示例3: writeChoices
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private static void writeChoices (Element e, String typeName, Vector<SelectChoice> choices) {
Element st = new Element();
st.setName("simpleType");
st.setAttribute(null, "name", typeName);
e.addChild(Node.ELEMENT, st);
Element restr = new Element();
restr.setName("restriction");
restr.setAttribute(null, "base", "string");
st.addChild(Node.ELEMENT, restr);
for (int i = 0; i < choices.size(); i++) {
String value = choices.elementAt(i).getValue();
Element choice = new Element();
choice.setName("enumeration");
choice.setAttribute(null, "value", value);
restr.addChild(Node.ELEMENT, choice);
}
}
示例4: generateInstanceSchema
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public static Document generateInstanceSchema (FormDef f) {
init();
Element schema = new Element();
schema.setName("schema");
schema.setNamespace("http://www.w3.org/2001/XMLSchema");
schema.setPrefix("", "http://www.w3.org/2001/XMLSchema");
schema.setPrefix("jr", "http://openrosa.org/javarosa");
if (f.getInstance().schema != null) {
schema.setAttribute(null, "targetNamespace", f.getInstance().schema);
} else {
System.err.println("Warning: instance has no schema");
}
schema.setAttribute(null, "elementFormDefault", "qualified");
String formVersion = f.getInstance().formVersion;
String uiVersion = f.getInstance().uiVersion;
if (formVersion != null)
schema.setAttribute(null, "version", formVersion);
if (uiVersion != null)
schema.setAttribute(null, "uiVersion", uiVersion);
processSelectChoices(schema, f, f);
schema.addChild(Node.ELEMENT, schemizeInstance(f.getInstance().getRoot()));
Document schemaXML = new Document();
schemaXML.addChild(Node.ELEMENT, schema);
return schemaXML;
}
示例5: writeListType
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private static void writeListType (Element e, String typeName) {
Element st = new Element();
st.setName("simpleType");
st.setAttribute(null, "name", "list." + typeName);
e.addChild(Node.ELEMENT, st);
Element list = new Element();
list.setName("list");
list.setAttribute(null, "itemType", typeName);
st.addChild(Node.ELEMENT, list);
}
示例6: serializeLog
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private Element serializeLog(LogEntry log) {
Element entry = new Element();
entry.setName("log");
entry.setAttribute(null, "date", DateUtils.formatDateTime(log.getTime(), DateUtils.FORMAT_ISO8601));
Element type = entry.createElement(null,"type");
type.addChild(Element.TEXT, log.getType());
entry.addChild(Element.ELEMENT, type);
Element message = entry.createElement(null,"msg");
message.addChild(Element.TEXT, log.getMessage());
entry.addChild(Element.ELEMENT, message);
return entry;
}
示例7: serializeLogs
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public Element serializeLogs(LogEntry[] logs) {
Element report = new Element();
report.setName(topElementName);
for(int i = 0; i < logs.length; ++i ) {
report.addChild(Element.ELEMENT, this.serializeLog(logs[i]));
}
return report;
}
示例8: generateInstanceSchema
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
public static Document generateInstanceSchema (FormDef f) {
init();
Element schema = new Element();
schema.setName("schema");
schema.setNamespace("http://www.w3.org/2001/XMLSchema");
schema.setPrefix("", "http://www.w3.org/2001/XMLSchema");
schema.setPrefix("jr", "http://openrosa.org/javarosa");
if (f.getInstance().schema != null) {
schema.setAttribute(null, "targetNamespace", f.getInstance().schema);
} else {
System.err.println("Warning: instance has no schema");
}
schema.setAttribute(null, "elementFormDefault", "qualified");
String formVersion = f.getInstance().formVersion;
String uiVersion = f.getInstance().uiVersion;
if (formVersion != null)
schema.setAttribute(null, "version", formVersion);
if (uiVersion != null)
schema.setAttribute(null, "uiVersion", uiVersion);
processSelectChoices(schema, f, f);
schema.addChild(Node.ELEMENT, schemizeInstance(f.getInstance().getRoot()));
Document schemaXML = new Document();
schemaXML.addChild(Node.ELEMENT, schema);
return schemaXML;
}
示例9: writeListType
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private static void writeListType (Element e, String typeName) {
Element st = new Element();
st.setName("simpleType");
st.setAttribute(null, "name", "list." + typeName);
e.addChild(Node.ELEMENT, st);
Element list = new Element();
list.setName("list");
list.setAttribute(null, "itemType", typeName);
st.addChild(Node.ELEMENT, list);
}
示例10: schemizeInstance
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private static Element schemizeInstance (TreeElement node) {
String name = node.getName();
boolean terminal = node.isLeaf();
boolean repeatable = node.isRepeatable();
if (repeatable && node.getMult() != TreeReference.INDEX_TEMPLATE) {
return null;
}
Element e = new Element();
e.setName("element");
e.setAttribute(null, "name", name);
e.setAttribute(null, "minOccurs", "0"); //technically only needed if node has a 'relevant' attribute bound to it, but no easy way to tell
if (repeatable) {
e.setAttribute(null, "maxOccurs", "unbounded");
}
if (!terminal) {
Element ct = new Element();
ct.setName("complexType");
e.addChild(Node.ELEMENT, ct);
Element seq = new Element();
seq.setName("sequence");
ct.addChild(Node.ELEMENT, seq);
for (int i = 0; i < node.getNumChildren(); i++) {
Element child = schemizeInstance((TreeElement)node.getChildAt(i));
if (child != null) {
seq.addChild(Node.ELEMENT, child);
}
}
} else {
String type;
switch (node.getDataType()) {
case Constants.DATATYPE_NULL:
case Constants.DATATYPE_TEXT:
type = "string";
break;
case Constants.DATATYPE_INTEGER: type = "integer"; break;
case Constants.DATATYPE_LONG: type = "long"; break;
case Constants.DATATYPE_DECIMAL: type = "decimal"; break;
case Constants.DATATYPE_BOOLEAN: type = "boolean"; break;
case Constants.DATATYPE_DATE: type = "date"; break;
case Constants.DATATYPE_DATE_TIME: type = "dateTime"; break;
case Constants.DATATYPE_TIME: type = "time"; break;
case Constants.DATATYPE_CHOICE:
case Constants.DATATYPE_CHOICE_LIST:
type = (String)choiceTypeMapping.get(node);
if (type == null) {
System.err.println("can't find choices for select-type question [" + node.getName() + "]");
}
break;
case Constants.DATATYPE_GEOPOINT: type = "jr:geopoint"; break;
case Constants.DATATYPE_GEOSHAPE: type = "jr:geoshape"; break;
case Constants.DATATYPE_GEOTRACE: type = "jr:geotrace"; break;
default:
type = null;
System.err.println("unrecognized type [" + node.getDataType() + ";" + node.getName() + "]");
break;
}
if (type != null) {
e.setAttribute(null, "type", type);
}
}
return e;
}
示例11: schemizeInstance
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
private static Element schemizeInstance (TreeElement node) {
String name = node.getName();
boolean terminal = node.isLeaf();
boolean repeatable = node.isRepeatable();
if (repeatable && node.getMult() != TreeReference.INDEX_TEMPLATE) {
return null;
}
Element e = new Element();
e.setName("element");
e.setAttribute(null, "name", name);
e.setAttribute(null, "minOccurs", "0"); //technically only needed if node has a 'relevant' attribute bound to it, but no easy way to tell
if (repeatable) {
e.setAttribute(null, "maxOccurs", "unbounded");
}
if (!terminal) {
Element ct = new Element();
ct.setName("complexType");
e.addChild(Node.ELEMENT, ct);
Element seq = new Element();
seq.setName("sequence");
ct.addChild(Node.ELEMENT, seq);
for (int i = 0; i < node.getNumChildren(); i++) {
Element child = schemizeInstance(node.getChildAt(i));
if (child != null) {
seq.addChild(Node.ELEMENT, child);
}
}
} else {
String type;
switch (node.getDataType()) {
case Constants.DATATYPE_NULL:
case Constants.DATATYPE_TEXT:
type = "string";
break;
case Constants.DATATYPE_INTEGER: type = "integer"; break;
case Constants.DATATYPE_LONG: type = "long"; break;
case Constants.DATATYPE_DECIMAL: type = "decimal"; break;
case Constants.DATATYPE_BOOLEAN: type = "boolean"; break;
case Constants.DATATYPE_DATE: type = "date"; break;
case Constants.DATATYPE_DATE_TIME: type = "dateTime"; break;
case Constants.DATATYPE_TIME: type = "time"; break;
case Constants.DATATYPE_CHOICE:
case Constants.DATATYPE_CHOICE_LIST:
type = (String)choiceTypeMapping.get(node);
if (type == null) {
System.err.println("can't find choices for select-type question [" + node.getName() + "]");
}
break;
case Constants.DATATYPE_GEOPOINT: type = "jr:geopoint"; break;
default:
type = null;
System.err.println("unrecognized type [" + node.getDataType() + ";" + node.getName() + "]");
break;
}
if (type != null) {
e.setAttribute(null, "type", type);
}
}
return e;
}
示例12: parse
import org.kxml2.kdom.Element; //导入方法依赖的package包/类
@Override
public FormRecord parse() throws InvalidStructureException, IOException, XmlPullParserException {
String xmlns = parser.getNamespace();
//Parse this subdocument into a dom
Element element = new Element();
element.setName(parser.getName());
element.setNamespace(parser.getNamespace());
element.parse(this.parser);
//Consume the end tag.
//this.parser.next();
//create an actual document out of it.
Document document = new Document();
document.addChild(Node.ELEMENT, element);
KXmlSerializer serializer = new KXmlSerializer();
String filePath = getInstanceDestination(namespaceToInstallPath.get(xmlns));
//Register this instance for inspection
ContentValues values = new ContentValues();
values.put(InstanceColumns.DISPLAY_NAME, "Historical Form");
values.put(InstanceColumns.SUBMISSION_URI, "");
values.put(InstanceColumns.INSTANCE_FILE_PATH, filePath);
values.put(InstanceColumns.JR_FORM_ID, xmlns);
values.put(InstanceColumns.STATUS, InstanceProviderAPI.STATUS_COMPLETE);
values.put(InstanceColumns.CAN_EDIT_WHEN_COMPLETE, false);
// Unindexed flag tells content provider to link this instance to a
// new, unindexed form record that isn't attached to the
// AndroidSessionWrapper
values.put(InstanceProviderAPI.UNINDEXED_SUBMISSION, true);
Uri instanceRecord =
c.getContentResolver().insert(InstanceColumns.CONTENT_URI, values);
// Find the form record attached to the form instance during insertion
IStorageUtilityIndexed<FormRecord> storage = cachedStorage();
FormRecord attachedRecord =
storage.getRecordForValue(FormRecord.META_INSTANCE_URI,
instanceRecord.toString());
if (attachedRecord == null) {
throw new RuntimeException("No FormRecord was attached to the inserted form instance");
}
OutputStream o = new FileOutputStream(filePath);
BufferedOutputStream bos = null;
try {
Cipher encrypter = Cipher.getInstance("AES");
SecretKeySpec key = new SecretKeySpec(attachedRecord.getAesKey(), "AES");
encrypter.init(Cipher.ENCRYPT_MODE, key);
CipherOutputStream cos = new CipherOutputStream(o, encrypter);
bos = new BufferedOutputStream(cos, 1024 * 256);
serializer.setOutput(bos, "UTF-8");
document.write(serializer);
} catch (InvalidKeyException | NoSuchPaddingException | NoSuchAlgorithmException e) {
// writing the form instance to xml failed, so remove the record
storage.remove(attachedRecord);
throw new RuntimeException(e.getMessage());
} finally {
//since bos might not have even been created.
if (bos != null) {
bos.close();
} else {
o.close();
}
}
return attachedRecord;
}