本文整理汇总了Java中org.apache.xmlbeans.XmlCursor.getObject方法的典型用法代码示例。如果您正苦于以下问题:Java XmlCursor.getObject方法的具体用法?Java XmlCursor.getObject怎么用?Java XmlCursor.getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xmlbeans.XmlCursor
的用法示例。
在下文中一共展示了XmlCursor.getObject方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
@Override
public void render(ElementTemplate eleTemplate, Object data,
XWPFTemplate template) {
NiceXWPFDocument doc = template.getXWPFDocument();
RunTemplate runTemplate = (RunTemplate) eleTemplate;
XWPFRun run = runTemplate.getRun();
try {
XmlCursor newCursor = ((XWPFParagraph)run.getParent()).getCTP().newCursor();
newCursor.toParent();
//if (newCursor.getObject() instanceof CTTc)
newCursor.toParent();
newCursor.toParent();
XmlObject object = newCursor.getObject();
XWPFTable table = doc.getTable((CTTbl) object);
render(table, data);
} catch (Exception e) {
logger.error("dynamic table error:" + e.getMessage(), e);
}
}
示例2: getSPMDApplication
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public static SPMDApplicationType getSPMDApplication(JobDefinitionType value) {
if (value != null &&
value.getJobDescription() != null &&
value.getJobDescription().isSetApplication() ) {
XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
if (acursor.toFirstChild()) {
do {
if(acursor.getName().equals(SPMD_APPLICATION)) {
XmlObject result = acursor.getObject();
acursor.dispose();
return (SPMDApplicationType) result;
}
} while (acursor.toNextSibling());
acursor.dispose();
return null;
} else {
acursor.dispose();
return null;
}
} else {
return null;
}
}
示例3: getPOSIXApplication
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public static POSIXApplicationType getPOSIXApplication(JobDefinitionType value) {
if (value != null &&
value.getJobDescription() != null &&
value.getJobDescription().isSetApplication() ) {
XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
if (acursor.toFirstChild()) {
do {
if(acursor.getName().equals(POSIX_APPLICATION)) {
XmlObject result = acursor.getObject();
acursor.dispose();
return (POSIXApplicationType) result;
}
} while (acursor.toNextSibling());
acursor.dispose();
return null;
} else {
acursor.dispose();
return null;
}
} else {
return null;
}
}
示例4: getHPCProfileApplication
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public static HPCProfileApplicationType getHPCProfileApplication(JobDefinitionType value) {
if (value != null &&
value.getJobDescription() != null &&
value.getJobDescription().isSetApplication() ) {
XmlCursor acursor = value.getJobDescription().getApplication().newCursor();
if (acursor.toFirstChild()) {
do {
if(acursor.getName().equals(HPC_PROFILE_APPLICATION)) {
XmlObject result = acursor.getObject();
acursor.dispose();
return (HPCProfileApplicationType) result;
}
} while (acursor.toNextSibling());
acursor.dispose();
return null;
} else {
acursor.dispose();
return null;
}
} else {
return null;
}
}
示例5: getAtomParameters
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
* Retrieves all of the parameters of an atom in order (including skolems and vars)
*
* @author mdangelo
*
* @param m The mapping to get the atomParameters of
* @param foreach A boolean to determine whether to check the for each or exist clauses for the atom
* @param atomPos The position of the atom within the mapping
*
* @return An array of objects
*/
public Object[] getAtomParameters (MappingType m, boolean foreach, int atomPos)
{
MapExprType clause = foreach ? m.getForeach() : m.getExists();
RelAtomType atom = clause.getAtomArray(atomPos);
XmlCursor c = atom.newCursor();
int size = atom.sizeOfSKFunctionArray() + atom.sizeOfVarArray();
Object[] result = new Object[size];
int varPos = 0;
for(int i = 0; i < size; i++)
{
if(i == 0)
c.toChild(i);
else
c.toNextSibling();
XmlObject x = c.getObject();
if (x instanceof SKFunction)
result[i] = x;
else
result[i] = atom.getVarArray(varPos++);
}
return result;
}
示例6: getSkolemFromAtom
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public SKFunction getSkolemFromAtom (MappingType m, boolean foreach,
int atomPos, int argPos) throws Exception {
MapExprType clause = foreach ? m.getForeach() : m.getExists();
RelAtomType atom = clause.getAtomArray(atomPos);
XmlCursor c = atom.newCursor();
c.toChild(argPos);
XmlObject o = (XmlObject) c.getObject();
if (!(o instanceof SKFunction))
throw new Exception ("Expected an SK function: " + o.toString());
return (SKFunction) o;
}
示例7: argsToString
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private void argsToString(XmlCursor c, StringBuilder b, int numElements)
throws Exception {
b.append("(");
c.toChild(0);
for(int i = 0; i < numElements; i++) {
XmlObject o = (XmlObject) c.getObject();
b.append(atomArgToString(o) + ", ");
c.toNextSibling();
}
b.delete(b.length() - 2, b.length());
b.append(")");
}
示例8: getXmlObject
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
XmlObject getXmlObject()
{
XmlObject xo;
XmlCursor cursor = newCursor();
try {
xo = cursor.getObject();
} finally {
cursor.dispose();
}
return xo;
}
示例9: insertNewTable
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
* 在某个段落起始处插入表格
*
* @param run
* @param row
* @param col
* @return
*/
public XWPFTable insertNewTable(XWPFRun run, int row, int col) {
XmlCursor cursor = ((XWPFParagraph)run.getParent()).getCTP().newCursor();
// XmlCursor cursor = run.getCTR().newCursor();
if (isCursorInBody(cursor)) {
String uri = CTTbl.type.getName().getNamespaceURI();
String localPart = "tbl";
cursor.beginElement(localPart, uri);
cursor.toParent();
CTTbl t = (CTTbl) cursor.getObject();
XWPFTable newT = new XWPFTable(t, this, row, col);
XmlObject o = null;
while (!(o instanceof CTTbl) && (cursor.toPrevSibling())) {
o = cursor.getObject();
}
if (!(o instanceof CTTbl)) {
tables.add(0, newT);
} else {
int pos = tables.indexOf(getTable((CTTbl) o)) + 1;
tables.add(pos, newT);
}
int i = 0;
XmlCursor tableCursor = t.newCursor();
try {
cursor.toCursor(tableCursor);
while (cursor.toPrevSibling()) {
o = cursor.getObject();
if (o instanceof CTP || o instanceof CTTbl){
i++;
}
}
bodyElements.add(i > bodyElements.size() ? bodyElements.size() : i, newT);
// bodyElements.add(i, newT);
cursor.toCursor(tableCursor);
cursor.toEndToken();
return newT;
} finally {
tableCursor.dispose();
}
}
return null;
}
示例10: insertNewParagraph
import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
* 在某个段落起始处插入段落
* @param run
* @return
*/
public XWPFParagraph insertNewParagraph(XWPFRun run) {
// XmlCursor cursor = run.getCTR().newCursor();
XmlCursor cursor = ((XWPFParagraph)run.getParent()).getCTP().newCursor();
if (isCursorInBody(cursor)) {
String uri = CTP.type.getName().getNamespaceURI();
/*
* TODO DO not use a coded constant, find the constant in the OOXML
* classes instead, as the child of type CT_Paragraph is defined in the
* OOXML schema as 'p'
*/
String localPart = "p";
// creates a new Paragraph, cursor is positioned inside the new
// element
cursor.beginElement(localPart, uri);
// move the cursor to the START token to the paragraph just created
cursor.toParent();
CTP p = (CTP) cursor.getObject();
XWPFParagraph newP = new XWPFParagraph(p, this);
XmlObject o = null;
/*
* move the cursor to the previous element until a) the next
* paragraph is found or b) all elements have been passed
*/
while (!(o instanceof CTP) && (cursor.toPrevSibling())) {
o = cursor.getObject();
}
/*
* if the object that has been found is a) not a paragraph or b) is
* the paragraph that has just been inserted, as the cursor in the
* while loop above was not moved as there were no other siblings,
* then the paragraph that was just inserted is the first paragraph
* in the body. Otherwise, take the previous paragraph and calculate
* the new index for the new paragraph.
*/
if ((!(o instanceof CTP)) || (CTP) o == p) {
paragraphs.add(0, newP);
} else {
int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
paragraphs.add(pos, newP);
}
/*
* create a new cursor, that points to the START token of the just
* inserted paragraph
*/
XmlCursor newParaPos = p.newCursor();
try {
/*
* Calculate the paragraphs index in the list of all body
* elements
*/
int i = 0;
cursor.toCursor(newParaPos);
while (cursor.toPrevSibling()) {
o = cursor.getObject();
if (o instanceof CTP || o instanceof CTTbl)
i++;
}
bodyElements.add(i, newP);
cursor.toCursor(newParaPos);
cursor.toEndToken();
return newP;
} finally {
newParaPos.dispose();
}
}
return null;
}