List of usage examples for javax.xml.namespace QName getNamespaceURI
public String getNamespaceURI()
Get the Namespace URI of this QName
.
From source file:com.bradmcevoy.property.BeanPropertySource.java
@Override public PropertyMetaData getPropertyMetaData(QName name, Resource r) { log.debug("getPropertyMetaData"); BeanPropertyResource anno = getAnnotation(r); if (anno == null) { log.debug(" no annotation: ", r.getClass().getCanonicalName()); return PropertyMetaData.UNKNOWN; }//ww w. j ava 2s. co m if (!name.getNamespaceURI().equals(anno.value())) { log.debug("different namespace", anno.value(), name.getNamespaceURI()); return PropertyMetaData.UNKNOWN; } PropertyDescriptor pd = getPropertyDescriptor(r, name.getLocalPart()); if (pd == null || pd.getReadMethod() == null) { LogUtils.debug(log, "getPropertyMetaData: no read method:", name.getLocalPart(), r.getClass()); return PropertyMetaData.UNKNOWN; } else { BeanPropertyAccess propAnno = pd.getReadMethod().getAnnotation(BeanPropertyAccess.class); if (propAnno != null) { if (!propAnno.value()) { log.trace( "getPropertyMetaData: property is annotated and value is false, so do not allow access"); return PropertyMetaData.UNKNOWN; } else { log.trace("getPropertyMetaData: property is annotated and value is true, so allow access"); } } else { if (anno.enableByDefault()) { log.trace( "getPropertyMetaData: no property annotation, property annotation is enable by default so allow access"); } else { log.trace( "getPropertyMetaData:no property annotation, class annotation says disable by default, decline access"); return PropertyMetaData.UNKNOWN; } } if (log.isDebugEnabled()) { log.debug("writable: " + anno.writable() + " - " + (pd.getWriteMethod() != null)); } boolean writable = anno.writable() && (pd.getWriteMethod() != null); if (writable) { return new PropertyMetaData(PropertyAccessibility.WRITABLE, pd.getPropertyType()); } else { return new PropertyMetaData(PropertyAccessibility.READ_ONLY, pd.getPropertyType()); } } }
From source file:io.milton.property.BeanPropertySource.java
@Override public PropertyMetaData getPropertyMetaData(QName name, Resource r) { log.debug("getPropertyMetaData"); BeanPropertyResource anno = getAnnotation(r); if (anno == null) { log.debug(" no annotation: ", r.getClass().getCanonicalName()); return PropertyMetaData.UNKNOWN; }/* www . j a v a2s . c o m*/ if (!name.getNamespaceURI().equals(anno.value())) { log.debug("different namespace", anno.value(), name.getNamespaceURI()); return PropertyMetaData.UNKNOWN; } PropertyDescriptor pd = getPropertyDescriptor(r, name.getLocalPart()); if (pd == null || pd.getReadMethod() == null) { LogUtils.debug(log, "getPropertyMetaData: no read method:", name.getLocalPart(), r.getClass()); return PropertyMetaData.UNKNOWN; } else { BeanProperty propAnno = pd.getReadMethod().getAnnotation(BeanProperty.class); if (propAnno != null) { if (!propAnno.value()) { log.trace( "getPropertyMetaData: property is annotated and value is false, so do not allow access"); return PropertyMetaData.UNKNOWN; } else { log.trace("getPropertyMetaData: property is annotated and value is true, so allow access"); } } else { if (anno.enableByDefault()) { log.trace( "getPropertyMetaData: no property annotation, property annotation is enable by default so allow access"); } else { log.trace( "getPropertyMetaData:no property annotation, class annotation says disable by default, decline access"); return PropertyMetaData.UNKNOWN; } } if (log.isDebugEnabled()) { log.debug("writable: " + anno.writable() + " - " + (pd.getWriteMethod() != null)); } boolean writable = anno.writable() && (pd.getWriteMethod() != null); if (writable) { return new PropertyMetaData(PropertyAccessibility.WRITABLE, pd.getPropertyType()); } else { return new PropertyMetaData(PropertyAccessibility.READ_ONLY, pd.getPropertyType()); } } }
From source file:com.evolveum.midpoint.util.DOMUtil.java
/** * Sets QName value for a given element. * * Contrary to standard XML semantics, namespace-less QNames are specified as simple names without prefix * (regardless of default prefix used in the XML document). * * @param element Element whose text content should be set to represent QName value * @param elementValue QName value to be stored into the element *//*from ww w . ja v a 2s .c o m*/ public static void setQNameValue(Element element, QName elementValue) { if (elementValue == null) { setElementTextContent(element, ""); } else if (XMLConstants.NULL_NS_URI.equals(elementValue.getNamespaceURI())) { if (QNameUtil.isPrefixUndeclared(elementValue.getPrefix())) { setElementTextContent(element, elementValue.getPrefix() + ":" + elementValue.getLocalPart()); } else { setElementTextContent(element, elementValue.getLocalPart()); } } else { String prefix = lookupOrCreateNamespaceDeclaration(element, elementValue.getNamespaceURI(), elementValue.getPrefix(), element, false); assert StringUtils.isNotBlank(prefix); String stringValue = prefix + ":" + elementValue.getLocalPart(); setElementTextContent(element, stringValue); } }
From source file:com.evolveum.midpoint.prism.ItemDefinition.java
protected QName addNamespaceIfApplicable(QName name) { if (StringUtils.isEmpty(name.getNamespaceURI())) { if (QNameUtil.match(name, this.name)) { return this.name; }/*from w ww . jav a 2s . c o m*/ } return name; }
From source file:com.evolveum.midpoint.util.DOMUtil.java
public static void setQNameAttribute(Element element, QName attributeName, QName attributeValue, Element definitionElement) { Document doc = element.getOwnerDocument(); Attr attr = doc.createAttributeNS(attributeName.getNamespaceURI(), attributeName.getLocalPart()); String namePrefix = lookupOrCreateNamespaceDeclaration(element, attributeName.getNamespaceURI(), attributeName.getPrefix(), element, true); attr.setPrefix(namePrefix);//from w w w .j a va2s .co m setQNameAttribute(element, attr, attributeValue, definitionElement); }
From source file:com.centeractive.ws.builder.soap.XmlUtils.java
public static NodeList getChildElementsNS(Element elm, QName name) { return getChildElementsByTagNameNS(elm, name.getNamespaceURI(), name.getLocalPart()); }
From source file:com.centeractive.ws.builder.soap.XmlUtils.java
public static void setXsiType(Element elm, QName name) { String prefix = findPrefixForNamespace(elm, name.getNamespaceURI()); if (prefix == null) { prefix = generatePrefixForNamespace(name.getNamespaceURI()); while (findNamespaceForPrefix(elm, prefix) != null) { prefix = generatePrefixForNamespace(name.getNamespaceURI()); }/*from ww w .j av a 2 s. co m*/ elm.setAttribute("xmlns:" + prefix, name.getNamespaceURI()); } elm.setAttributeNS(Constants.XSI_NS, "type", prefix + ":" + name.getLocalPart()); }
From source file:com.evolveum.midpoint.prism.schema.PrismSchema.java
protected QName toElementQName(QName qname) { return new QName(qname.getNamespaceURI(), toElementName(qname.getLocalPart())); }
From source file:no.digipost.api.interceptors.Wss4jInterceptor.java
private boolean wasSigned(final Document doc, final List<WSSecurityEngineResult> results, final QName... qnamePath) { String path = "/" + doc.getDocumentElement().getPrefix() + ":Envelope"; for (QName qn : qnamePath) { Node n = doc.getDocumentElement().getElementsByTagNameNS(qn.getNamespaceURI(), qn.getLocalPart()) .item(0);/*w w w .j a v a2 s.c o m*/ if (n == null) { return false; } path += "/" + n.getPrefix() + ":" + n.getLocalName(); } for (WSSecurityEngineResult r : results) { if (r.containsKey("data-ref-uris")) { List<WSDataRef> refs = (List<WSDataRef>) r.get("data-ref-uris"); for (WSDataRef ref : refs) { if (ref.getName().equals(qnamePath[qnamePath.length - 1])) { if (ref.getXpath().equals(path)) { return true; } } } } } return false; }
From source file:com.evolveum.midpoint.prism.marshaller.PrismMarshaller.java
private boolean shouldPutTypeInExportMode(SerializationContext ctx, ItemDefinition definition) { if (!SerializationContext.isSerializeForExport(ctx) || definition == null || !definition.isRuntimeSchema()) { return false; }/*from w w w . java2s .c om*/ QName itemName = definition.getName(); if (StringUtils.isEmpty(itemName.getNamespaceURI())) { return true; // ambiguous item name - let's put xsi:type, to be on the safe side } // we assume that all runtime elements which are part of the schema registry are retrievable by element name // (might not be the case for sub-items of custom extension containers! we hope providing xsi:type there will cause no harm) List<ItemDefinition> definitionsInRegistry = getSchemaRegistry().findItemDefinitionsByElementName(itemName, ItemDefinition.class); return definitionsInRegistry.isEmpty(); // no definition in registry => xsi:type should be put }