/** For internal use only. */ private static Object makeDerivedWrapper(Element elt, String baseTypeName) { synchronized (DOMUtils.getDOMLock(elt)) { QName typeName = XArchUtils.getXSIType(elt); if (typeName == null) { return null; } else { if (!DOMUtils.hasXSIType( elt, "http://www.ics.uci.edu/pub/arch/xArch/changesets.xsd", baseTypeName)) { try { String packageTitle = XArchUtils.getPackageTitle(typeName.getNamespaceURI()); String packageName = XArchUtils.getPackageName(packageTitle); String implName = XArchUtils.getImplName(packageName, typeName.getName()); Class c = Class.forName(implName); java.lang.reflect.Constructor con = c.getConstructor(new Class[] {Element.class}); Object o = con.newInstance(new Object[] {elt}); return o; } catch (Exception e) { // Lots of bad things could happen, but this // is OK, because this is best-effort anyway. } } return null; } } }
static QName create(Namespace namespace, String localName) { // A null namespace indicates a wild-card match for any namespace // A null localName indicates "*" from the point of view of ECMA357 if (localName != null && localName.equals("*")) throw new RuntimeException("* is not valid localName"); QName rv = new QName(); rv.namespace = namespace; rv.localName = localName; return rv; }
/** GetBindingFromInterfaceName Method. */ public TBinding getBindingFromInterfaceName(TDefinitions descriptionType, String interfaceName) { for (TDocumented nextElement : descriptionType.getAnyTopLevelOptionalElement()) { // Create the service type if (nextElement instanceof TBinding) { QName qname = ((TBinding) nextElement).getType(); if (interfaceName.equalsIgnoreCase(qname.getLocalPart())) return (TBinding) nextElement; } } return null; }
void invalidateNamespacePrefix() { if (!(dom instanceof Element)) throw new IllegalStateException(); String prefix = this.dom.getPrefix(); QName after = QName.create(this.dom.getNamespaceURI(), this.dom.getLocalName(), null); renameNode(after); NamedNodeMap attrs = this.dom.getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { if (attrs.item(i).getPrefix().equals(prefix)) { createImpl(attrs.item(i)) .renameNode( QName.create(attrs.item(i).getNamespaceURI(), attrs.item(i).getLocalName(), null)); } } }
/** Search through the messages for this one and return the element name. */ public String getElementNameFromMessageName(TDefinitions descriptionType, TParam message) { QName qName = message.getMessage(); String name = qName.getLocalPart(); for (TDocumented nextElement : descriptionType.getAnyTopLevelOptionalElement()) { // Create the service type if (nextElement instanceof TMessage) { String msgName = ((TMessage) nextElement).getName(); for (TPart part : ((TMessage) nextElement).getPart()) { if (name.equals(part.getName())) { return part.getElement().getLocalPart(); } } } } return null; }
final void setLocalName(String localName) { if (dom instanceof ProcessingInstruction) { setProcessingInstructionName(localName); } else { String prefix = dom.getPrefix(); if (prefix == null) prefix = ""; this.dom = dom.getOwnerDocument() .renameNode(dom, dom.getNamespaceURI(), QName.qualify(prefix, localName)); } }
void setAttribute(QName name, String value) { if (!(dom instanceof Element)) throw new IllegalStateException("Can only set attribute on elements."); name.setAttribute((Element) dom, value); }
final QName getQname() { String uri = (dom.getNamespaceURI()) == null ? "" : dom.getNamespaceURI(); String prefix = (dom.getPrefix() == null) ? "" : dom.getPrefix(); return QName.create(uri, dom.getLocalName(), prefix); }
final void renameNode(QName qname) { this.dom = dom.getOwnerDocument().renameNode(dom, qname.getUri(), qname.qualify(dom)); }