本文整理汇总了Java中org.exolab.castor.types.AnyNode类的典型用法代码示例。如果您正苦于以下问题:Java AnyNode类的具体用法?Java AnyNode怎么用?Java AnyNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnyNode类属于org.exolab.castor.types包,在下文中一共展示了AnyNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addExtension
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
/**
* Adds an extension to this track.
* <br>
* The extension element must have an "application" attribute.
* It's the URI of a resource defining the structure and purpose of the nested XML.
* <br>
* The input type is an {@link Object} just because it's what the Castor framework expects.
* @param extension an extension. Shall not be <code>null</code>.
* @throws NullPointerException if <code>extension</code> is <code>null</code>.
* @throws IllegalArgumentException if <code>extension</code> is not an {@link AnyNode} instance.
* @throws IllegalArgumentException if no "application" attribute can be found in the specified extension element.
* @see #getExtensions
*/
public void addExtension(final Object extension)
{
if (!(extension instanceof AnyNode)) // Throws NullPointerException if extension is null.
{
throw new IllegalArgumentException(AnyNode.class + " expected");
}
final AnyNode anyNode = (AnyNode) extension;
final AnyNode attr = anyNode.getFirstAttribute();
if (attr == null)
{
throw new IllegalArgumentException("No application attribute");
}
if (!"application".equals(attr.getLocalName()))
{
throw new IllegalArgumentException("Unknown attribute");
}
_extensions.add(anyNode);
}
示例2: addExtension
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
/**
* Adds an extension to this playlist.
* <br>
* The extension element must have an "application" attribute.
* It's the URI of a resource defining the structure and purpose of the nested XML.
* <br>
* The input type is an {@link Object} just because it's what the Castor framework expects.
* @param extension an extension. Shall not be <code>null</code>.
* @throws NullPointerException if <code>extension</code> is <code>null</code>.
* @throws IllegalArgumentException if <code>extension</code> is not an {@link AnyNode} instance.
* @throws IllegalArgumentException if no "application" attribute can be found in the specified extension element.
* @see #getExtensions
*/
public void addExtension(final Object extension)
{
if (!(extension instanceof AnyNode)) // Throws NullPointerException if extension is null.
{
throw new IllegalArgumentException(AnyNode.class + " expected");
}
final AnyNode anyNode = (AnyNode) extension;
final AnyNode attr = anyNode.getFirstAttribute();
if (attr == null)
{
throw new IllegalArgumentException("No application attribute");
}
if (!"application".equals(attr.getLocalName()))
{
throw new IllegalArgumentException("Unknown attribute");
}
_extensions.add(anyNode);
}
示例3: extractHelp
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
public static String extractHelp(Annotated model) {
Enumeration<?> e = model.getAnnotations();
StringBuffer doc = new StringBuffer();
if (e.hasMoreElements()) { // look for HTML
Annotation note = (Annotation)e.nextElement();
for (Enumeration<?> g = note.getDocumentation(); g.hasMoreElements();) {
Documentation thisDoc = (Documentation)g.nextElement();
for (Enumeration<?> h = thisDoc.getObjects(); h.hasMoreElements();) {
AnyNode node = (AnyNode)h.nextElement();
String line = node.toString();
if (line.length() == 0)
line = node.getStringValue();
if (line.length() > 0) {
doc.append(line).append("\n");
}
}
}
}
return doc.toString();
}
示例4: next
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
public synchronized Object next() {
if (currentIndex >= results.length - 1) {
// works because on first call, currentIndex == -1
throw new NoSuchElementException();
}
Object value = null;
currentIndex++;
AnyNode node = results[currentIndex].get_any();
try {
if (xmlOnly) {
value = AnyNodeHelper.convertAnyNodeToString(node);
} else {
value = deserializeObject(node);
}
} catch (Exception ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
}
return value;
}
示例5: convertStringToAnyNode
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
public static AnyNode convertStringToAnyNode(String text) throws Exception {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
SAXParser saxParser = factory.newSAXParser();
XMLReader reader = saxParser.getXMLReader();
SAX2ANY handler = new SAX2ANY();
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
InputSource source = new InputSource(new StringReader(text));
reader.parse(source);
AnyNode anyNode = handler.getStartingNode();
return anyNode;
}
示例6: anysEqual
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
private boolean anysEqual(CQLObjectResult other) {
AnyNode oAny = other.get_any();
if (this._any == null && oAny == null) {
return true;
} else if ((this._any != null && oAny == null)
|| (this._any == null && oAny != null)) {
return false;
} else {
try {
//MessageElement myAnyElement = AnyNodeHelper.convertAnyNodeToMessageElement(_any);
// MessageElement theirAnyElement = AnyNodeHelper.convertAnyNodeToMessageElement(oAny);
// return myAnyElement.equals(theirAnyElement);
// HACK:
return true;
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
}
}
示例7: testObjectResult
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
public void testObjectResult() {
CQLQueryResults cqlResults = new CQLQueryResults();
cqlResults.setTargetClassname("foo.bar");
CQLObjectResult obj = new CQLObjectResult();
AnyNode node = null;
try {
node = AnyNodeHelper.convertStringToAnyNode("<foo>here's some text</foo>");
} catch (Exception e) {
e.printStackTrace();
fail("Error creating node: " + e.getMessage());
}
obj.set_any(node);
cqlResults.setObjectResult(new CQLObjectResult[] {obj});
DCQLResult dcqlResult = new DCQLResult(cqlResults, "http://fake.com");
DCQLQueryResultsCollection collection = new DCQLQueryResultsCollection(new DCQLResult[] {dcqlResult});
validate(collection);
}
示例8: ComboField
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
public ComboField(SimpleType type, AnyNode listNode) {
super();
comboField = new JComboBox();
content = type;
this.listNode = listNode;
createLOV();
}
示例9: checkForObjectResults
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
private void checkForObjectResults(CQLQueryResults results) throws Exception {
CQLObjectResult[] objResults = results.getObjectResult();
if (objResults == null || objResults.length == 0) {
fail("No object results returned");
}
for (int i = 0; i < objResults.length; i++) {
Object any = objResults[i].get_any();
if (any == null) {
fail("Object result returned with null object contents");
}
assertTrue("Unknown type returned in object results. Expected "
+ AnyNode.class.getName() + ", found " + any.getClass().getName(),
any instanceof AnyNode);
}
}
示例10: verifyResults
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
private void verifyResults(List<SOAPElement> results) {
LOG.debug("Verifying test results");
LOG.debug("Loading gold results from " + getGoldFilenname());
DCQLQueryResultsCollection goldResults = loadGoldDcqlResults();
// convert the list of elements into DCQL results
DCQLQueryResultsCollection testResults = new DCQLQueryResultsCollection();
DCQLResult testResult = new DCQLResult();
testResult.setTargetServiceURL("http://fake.service");
CQLQueryResults cqlResults = new CQLQueryResults();
// what's the target classname supposed to be?
String targetName = deserializeQuery().getTargetObject().getName();
LOG.debug("Setting test results target classname to " + targetName);
cqlResults.setTargetClassname(targetName);
CQLObjectResult[] objectResults = new CQLObjectResult[results.size()];
for (int i = 0; i < results.size(); i++) {
CQLObjectResult obj = new CQLObjectResult();
AnyNode node = null;
try {
node = AnyNodeHelper.convertMessageElementToAnyNode(new MessageElement(results.get(i)));
} catch (Exception ex) {
ex.printStackTrace();
fail("Error reading DCQL 2 results: " + ex.getMessage());
}
obj.set_any(node);
objectResults[i] = obj;
}
cqlResults.setObjectResult(objectResults);
testResult.setCQLQueryResults(cqlResults);
testResults.setDCQLResult(new DCQLResult[] {testResult});
QueryResultsVerifier.verifyDcql2Results(testResults, goldResults);
}
示例11: wrapObjectResults
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
private Iterator<CQLResult> wrapObjectResults(List<Object> rawObjects, final QName targetQName) {
final Iterator<Object> rawObjectIter = rawObjects.iterator();
Iterator<CQLResult> objectIter = new Iterator<CQLResult>() {
public boolean hasNext() {
return rawObjectIter.hasNext();
}
public CQLResult next() {
CQLObjectResult obj = new CQLObjectResult();
Object rawObject = rawObjectIter.next();
StringWriter writer = new StringWriter();
AnyNode node = null;
try {
InputStream wsdd = getDisposableWsdd();
Utils.serializeObject(rawObject, targetQName, writer, wsdd);
node = AnyNodeHelper.convertStringToAnyNode(
writer.getBuffer().toString());
} catch (Exception ex) {
String message = "Error creating AnyNode for object results: " + ex.getMessage();
LOG.error(message, ex);
NoSuchElementException nse = new NoSuchElementException(message);
nse.initCause(ex);
throw nse;
}
obj.set_any(node);
return obj;
}
public void remove() {
throw new UnsupportedOperationException("remove() is not supported");
}
};
return objectIter;
}
示例12: convertObjectResult
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
private static CQLObjectResult convertObjectResult(org.cagrid.cql2.results.CQLObjectResult newObject) throws ResultsConversionException {
CQLObjectResult oldObject = new CQLObjectResult();
AnyNode node = (AnyNode) newObject.get_any();
// TODO: verify no associations populated
MessageElement elem = null;
try {
elem = AnyNodeHelper.convertAnyNodeToMessageElement(node);
} catch (Exception e) {
throw new ResultsConversionException("Error converting object result: " + e.getMessage(), e);
}
oldObject.set_any(new MessageElement[] {elem});
return oldObject;
}
示例13: next
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
public CQLResult next() {
CQLResult result = null;
if (queryModifier == null) {
// object result
Object instance = cqlResultsIterator.next();
try {
// serialize the object so it can go into an AnyNode
StringWriter xmlWriter = new StringWriter();
if (wsddStream == null) {
Utils.serializeObject(instance, targetQName, xmlWriter);
} else {
wsddStream.reset();
Utils.serializeObject(instance, targetQName, xmlWriter, wsddStream);
}
AnyNode node = AnyNodeHelper.convertStringToAnyNode(xmlWriter.toString());
result = new CQLObjectResult(node);
} catch (Exception ex) {
NoSuchElementException nse = new NoSuchElementException("Unable to convert object to AnyNode: " + ex.getMessage());
nse.initCause(ex);
throw nse;
}
} else {
if (queryModifier.isCountOnly()) {
String value = String.valueOf(cqlResultsIterator.next());
result = new CQLAggregateResult(Aggregation.COUNT, "id", value);
} else {
// distinct or multiple attribute results
String[] attributeNames = queryModifier.getDistinctAttribute() != null
? new String[] {queryModifier.getDistinctAttribute()} : queryModifier.getAttributeNames();
Object[] values = (Object[]) cqlResultsIterator.next();
TargetAttribute[] tas = new TargetAttribute[attributeNames.length];
for (int i = 0; i < attributeNames.length; i++) {
tas[i] = new TargetAttribute(attributeNames[i], String.valueOf(values[i]));
}
result = new CQLAttributeResult(tas);
}
}
return result;
}
示例14: convertObjectResult
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
private static CQLObjectResult convertObjectResult(gov.nih.nci.cagrid.cqlresultset.CQLObjectResult oldObjectResult)
throws ResultsConversionException {
CQLObjectResult newObjectResult = new CQLObjectResult();
AnyNode node = null;
try {
node = AnyNodeHelper.convertMessageElementToAnyNode(oldObjectResult.get_any()[0]);
} catch (Exception ex) {
throw new ResultsConversionException("Error converting object result: " + ex.getMessage(), ex);
}
newObjectResult.set_any(node);
return newObjectResult;
}
示例15: deserializeObject
import org.exolab.castor.types.AnyNode; //导入依赖的package包/类
private Object deserializeObject(AnyNode any) throws Exception {
// MessageElement element = AnyNodeHelper.convertAnyNodeToMessageElement(any);
String xml = AnyNodeHelper.convertAnyNodeToString(any);
InputSource source = new InputSource(new StringReader(xml));
MessageContext context = getMessageContext();
ConfigurableObjectDeserializationContext desContext = new ConfigurableObjectDeserializationContext(
context, source, getTargetClass());
return getTargetClass().cast(desContext.getValue());
}