本文整理汇总了Java中org.apache.xmlbeans.XmlCursor.dispose方法的典型用法代码示例。如果您正苦于以下问题:Java XmlCursor.dispose方法的具体用法?Java XmlCursor.dispose怎么用?Java XmlCursor.dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xmlbeans.XmlCursor
的用法示例。
在下文中一共展示了XmlCursor.dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSample
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public String createSample( SchemaType sType )
{
XmlObject object = XmlObject.Factory.newInstance();
XmlCursor cursor = object.newCursor();
// Skip the document node
cursor.toNextToken();
// Using the type and the cursor, call the utility method to get a
// sample XML payload for that Schema element
createSampleForType( sType, cursor );
// Cursor now contains the sample payload
// Pretty print the result. Note that the cursor is positioned at the
// end of the doc so we use the original xml object that the cursor was
// created upon to do the xmlText() against.
cursor.dispose();
XmlOptions options = new XmlOptions();
options.put( XmlOptions.SAVE_PRETTY_PRINT );
options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
options.setSaveOuter();
String result = object.xmlText( options );
return result;
}
示例2: createSampleForType
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public static String createSampleForType( SchemaType sType )
{
XmlObject object = XmlObject.Factory.newInstance();
XmlCursor cursor = object.newCursor();
// Skip the document node
cursor.toNextToken();
// Using the type and the cursor, call the utility method to get a
// sample XML payload for that Schema element
new SampleXmlUtil( false ).createSampleForType( sType, cursor );
// Cursor now contains the sample payload
// Pretty print the result. Note that the cursor is positioned at the
// end of the doc so we use the original xml object that the cursor was
// created upon to do the xmlText() against.
cursor.dispose();
XmlOptions options = new XmlOptions();
options.put( XmlOptions.SAVE_PRETTY_PRINT );
options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
options.setSaveOuter();
String result = object.xmlText( options );
return result;
}
示例3: escapeAttributeValue
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
* Escapes the reserved characters in a value of an attribute
*
* @param value Unescaped text
* @return The escaped text
*/
public String escapeAttributeValue(Object value)
{
String text = ScriptRuntime.toString(value);
if (text.length() == 0) return "";
XmlObject xo = XmlObject.Factory.newInstance();
XmlCursor cursor = xo.newCursor();
cursor.toNextToken();
cursor.beginElement("a");
cursor.insertAttributeWithValue("a", text);
cursor.dispose();
String elementText = xo.toString();
int begin = elementText.indexOf('"');
int end = elementText.lastIndexOf('"');
return elementText.substring(begin + 1, end);
}
示例4: setLocalName
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @param name
*/
void setLocalName(String localName)
{
XmlCursor cursor = newCursor();
try
{
if(cursor.isStartdoc())
cursor.toFirstContentToken();
if(cursor.isText() || cursor.isComment()) return;
javax.xml.namespace.QName qname = cursor.getName();
cursor.setName(new javax.xml.namespace.QName(
qname.getNamespaceURI(), localName, qname.getPrefix()));
}
finally
{
cursor.dispose();
}
}
示例5: tokenType
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @return
*/
XmlCursor.TokenType tokenType()
{
XmlCursor.TokenType result;
XmlCursor curs = newCursor();
if (curs.isStartdoc())
{
curs.toFirstContentToken();
}
result = curs.currentTokenType();
curs.dispose();
return result;
}
示例6: appendChild
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @param xml
* @return
*/
XML appendChild(Object xml)
{
XmlCursor curs = newCursor();
if (curs.isStartdoc())
{
curs.toFirstContentToken();
}
// Move the cursor to the end of this element
if (curs.isStart())
{
curs.toEndToken();
}
insertChild(curs, xml);
curs.dispose();
return this;
}
示例7: escapeTextValue
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
* Escapes the reserved characters in a value of a text node
*
* @param value Unescaped text
* @return The escaped text
*/
public String escapeTextValue(Object value)
{
if (value instanceof XMLObjectImpl) {
return ((XMLObjectImpl)value).toXMLString(0);
}
String text = ScriptRuntime.toString(value);
if (text.length() == 0) return text;
XmlObject xo = XmlObject.Factory.newInstance();
XmlCursor cursor = xo.newCursor();
cursor.toNextToken();
cursor.beginElement("a");
cursor.insertChars(text);
cursor.dispose();
String elementText = xo.toString();
int begin = elementText.indexOf('>') + 1;
int end = elementText.lastIndexOf('<');
return (begin < end) ? elementText.substring(begin, end) : "";
}
示例8: AttributeTypeImpl
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public AttributeTypeImpl(AttributeType attributeType) {
this.attributeType = attributeType;
final XmlCursor xmlCursor = attributeType.newCursor();
sampleAttributeElementLineNumber = (XmlLineNumber) xmlCursor.getBookmark(XmlLineNumber.class);
xmlCursor.push();
xmlCursor.toChild("TAG");
tagElementLineNumber = (XmlLineNumber) xmlCursor.getBookmark(XmlLineNumber.class);
xmlCursor.pop();
xmlCursor.push();
xmlCursor.toChild("VALUE");
valueElementLineNumber = (XmlLineNumber) xmlCursor.getBookmark(XmlLineNumber.class);
xmlCursor.pop();
if (xmlCursor.toChild("UNITS")) {
unitsElementLineNumber = (XmlLineNumber) xmlCursor.getBookmark(XmlLineNumber.class);
}
xmlCursor.dispose();
}
示例9: addSection
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public XmlObjectBuilder addSection(String sectionName, XmlObject section){
cursor.beginElement(sectionName);
cursor.push();
XmlCursor srcCursor = section.newCursor();
srcCursor.toNextToken();
while(srcCursor.currentTokenType() != XmlCursor.TokenType.NONE && srcCursor.currentTokenType() != XmlCursor.TokenType.ENDDOC){
srcCursor.copyXml(cursor);
if(srcCursor.currentTokenType() == XmlCursor.TokenType.START) srcCursor.toEndToken();
srcCursor.toNextToken();
}
cursor.pop();
cursor.toEndToken();
cursor.toNextToken();
srcCursor.dispose();
return this;
}
示例10: prependChild
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @param xml
* @return
*/
XML prependChild (Object xml)
{
XmlCursor curs = newCursor();
if (curs.isStartdoc())
{
curs.toFirstContentToken();
}
// Move the cursor to the first content token
curs.toFirstContentToken();
insertChild(curs, xml);
curs.dispose();
return this;
}
示例11: addSection
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public XmlObjectBuilder addSection(String sectionName, XmlObject section) {
cursor.beginElement(sectionName);
cursor.push();
XmlCursor srcCursor = section.newCursor();
srcCursor.toNextToken();
while (srcCursor.currentTokenType() != XmlCursor.TokenType.NONE
&& srcCursor.currentTokenType() != XmlCursor.TokenType.ENDDOC) {
srcCursor.copyXml(cursor);
if (srcCursor.currentTokenType() == XmlCursor.TokenType.START)
srcCursor.toEndToken();
srcCursor.toNextToken();
}
cursor.pop();
cursor.toEndToken();
cursor.toNextToken();
srcCursor.dispose();
return this;
}
示例12: remove
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
*/
void remove ()
{
XmlCursor childCurs = newCursor();
if (childCurs.currentTokenType().isStartdoc())
{
// Remove on the document removes all children.
TokenType tt = childCurs.toFirstContentToken();
while (!tt.isEnd() && !tt.isEnddoc())
{
removeToken(childCurs);
tt = childCurs.currentTokenType(); // Now see where we're pointing after the delete -- next token.
}
}
else
{
removeToken(childCurs);
}
childCurs.dispose();
}
示例13: getOrCreateHPCProfileApplication
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public static HPCProfileApplicationType getOrCreateHPCProfileApplication(JobDefinitionType value) {
ApplicationType application = getOrCreateApplication(value);
if(getPOSIXApplication(value) != null){
//TODO handle: creating HPC element if POSIX already exists
return getHPCProfileApplication(value);
}
if (getHPCProfileApplication(value) == null) {
XmlCursor acursor = application.newCursor();
acursor.toEndToken();
acursor.insertElement(HPC_PROFILE_APPLICATION);
acursor.dispose();
}
return getHPCProfileApplication(value);
}
示例14: copy
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @return
*/
Object copy()
{
XmlCursor srcCurs = newCursor();
if (srcCurs.isStartdoc())
{
srcCurs.toFirstContentToken();
}
XML xml = createEmptyXML(lib);
XmlCursor destCurs = xml.newCursor();
destCurs.toFirstContentToken();
srcCurs.copyXml(destCurs);
destCurs.dispose();
srcCurs.dispose();
return xml;
}
示例15: hasSimpleContent
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
*
* @return
*/
boolean hasSimpleContent()
{
boolean simpleContent = false;
XmlCursor curs = newCursor();
if (curs.isAttr() || curs.isText()) {
return true;
}
if (curs.isStartdoc())
{
curs.toFirstContentToken();
}
simpleContent = !(curs.toFirstChild());
curs.dispose();
return simpleContent;
}