/** {@inheritDoc} */ @Override protected void doParse( @Nonnull final Element config, @Nonnull final ParserContext parserContext, @Nonnull final BeanDefinitionBuilder builder) { log.warn("PrincipalConnector feature is DEPRECATED in favor of subject c14n flows"); builder.setInitMethodName("initialize"); builder.setDestroyMethodName("destroy"); super.doParse(config, parserContext, builder); // First up, add the per type decoders addSAMLDecoders(config, parserContext, builder); final String format = StringSupport.trimOrNull(config.getAttributeNS(null, "nameIDFormat")); builder.addConstructorArgValue(format); final String id = StringSupport.trimOrNull(config.getAttributeNS(null, "id")); builder.addPropertyValue("id", id); final List<Element> children = ElementSupport.getChildElements(config, RELYING_PARTY); final List<String> relyingParties = new ManagedList<>(children.size()); for (Element child : children) { relyingParties.add(child.getTextContent()); } builder.addPropertyValue("relyingParties", relyingParties); }
public Attribute unmarshal(Object value) { if (value instanceof org.w3c.dom.Element) { org.w3c.dom.Element el = (org.w3c.dom.Element) value; String prefix = el.getPrefix(); String namespace = el.getNamespaceURI(); String local = el.getLocalName(); String child = el.getTextContent(); String typeAsString = el.getAttributeNS(NamespacePrefixMapper.XSI_NS, "type"); String lang = el.getAttributeNS(NamespacePrefixMapper.XML_NS, "lang"); QName type = ((typeAsString == null) || (typeAsString.equals(""))) ? null : stringToQName(typeAsString, el); if (type == null) type = ValueConverter.QNAME_XSD_STRING; if (type.equals(ValueConverter.QNAME_XSD_QNAME)) { QName qn = stringToQName(child, el); // TODO: not robust to prefix not predeclared return pFactory.newAttribute(namespace, local, prefix, qn, type); } else if ((lang == null) || (lang.equals(""))) { return pFactory.newAttribute( namespace, local, prefix, vconv.convertToJava(type, child), type); } else { return pFactory.newAttribute( namespace, local, prefix, pFactory.newInternationalizedString(child, lang), type); } } if (value instanceof JAXBElement) { JAXBElement<?> je = (JAXBElement<?>) value; return pFactory.newAttribute(je.getName(), je.getValue(), vconv); } return null; }
/** Determine if not can grow due to localization or not. */ public boolean fixedWidth() { String width = mNode.getAttributeNS(ANDROID_URI, ATTR_LAYOUT_WIDTH); if (width.equals(VALUE_WRAP_CONTENT)) { // First check child nodes. If at least one of them is not // fixed-width, // treat whole layout as non-fixed-width NodeList childNodes = mNode.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { LayoutNode childLayout = new LayoutNode((Element) child, i); if (!childLayout.fixedWidth()) { return false; } } } // If node contains text attribute, consider it fixed-width if // text is hard-coded, otherwise it is not fixed-width. String text = mNode.getAttributeNS(ANDROID_URI, ATTR_TEXT); if (!text.isEmpty()) { return !text.startsWith(PREFIX_RESOURCE_REF) && !text.startsWith(PREFIX_THEME_REF); } String nodeName = mNode.getTagName(); if (nodeName.contains("Image") || nodeName.contains("Progress") || nodeName.contains("Radio")) { return true; } else if (nodeName.contains("Button") || nodeName.contains("Text")) { return false; } } return true; }
/** * Returns the transformation matrix to apply to initalize a viewport or null if the specified * viewBox disables the rendering of the element. * * @param e the element with a viewbox * @param w the width of the effective viewport * @param h The height of the effective viewport */ public static AffineTransform getPreserveAspectRatioTransform(Element e, float w, float h) { String viewBox = e.getAttributeNS(null, SVG_VIEW_BOX_ATTRIBUTE); String aspectRatio = e.getAttributeNS(null, SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE); return getPreserveAspectRatioTransform(e, viewBox, aspectRatio, w, h); }
public void testSendRequest_rpc_nil() throws Exception { String requestText = "<env:Envelope xmlns:env='" + SOAPConstants.URI_NS_SOAP_ENVELOPE + "'>" + "<env:Body>" + "<tns:op xmlns:tns='" + BpelConstants.NS_EXAMPLES + "' xmlns:xsi='" + BpelConstants.NS_XML_SCHEMA_INSTANCE + "'>" + " <simplePart xsi:nil='true'>wazabi</simplePart>" + " <complexPart xsi:nil='1'>" + " <b on='true'>true</b>" + " <c name='venus'/>" + " <d amount='20'/>" + " <e>30</e>" + " </complexPart>" + "</tns:op>" + "</env:Body>" + "</env:Envelope>"; SOAPMessage soapMessage = MessageFactory.newInstance() .createMessage(null, new ByteArrayInputStream(requestText.getBytes())); Connection connection = integrationControl.getJmsConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); try { SoapHandler soapHandler = createRpcHandler(); soapHandler.sendRequest(soapMessage, session, jbpmContext); PartnerLinkEntry entry = integrationControl.getPartnerLinkEntry(Q_RPC_PORT_TYPE, Q_SERVICE, RPC_PORT); MessageConsumer consumer = session.createConsumer(entry.getDestination()); ObjectMessage message = (ObjectMessage) consumer.receiveNoWait(); Map requestParts = (Map) message.getObject(); // simple part Element simplePart = (Element) requestParts.get("simplePart"); assertTrue( DatatypeUtil.toBoolean( simplePart.getAttributeNS( BpelConstants.NS_XML_SCHEMA_INSTANCE, BpelConstants.ATTR_NIL))); assertFalse(simplePart.hasChildNodes()); // complex part Element complexPart = (Element) requestParts.get("complexPart"); assertTrue( DatatypeUtil.toBoolean( complexPart.getAttributeNS( BpelConstants.NS_XML_SCHEMA_INSTANCE, BpelConstants.ATTR_NIL))); assertFalse(complexPart.hasChildNodes()); } finally { session.close(); } }
/** {@inheritDoc} */ protected void doParse(Element config, BeanDefinitionBuilder builder) { log.info("Parsing configuration for JSP error handler."); super.doParse(config, builder); if (config.hasAttributeNS(null, "jspPagePath")) { builder.addConstructorArgValue(config.getAttributeNS(null, "jspPagePath")); } else { builder.addConstructorArgValue(config.getAttributeNS(null, "/error.jsp")); } }
/** * Build the POJO with the username and password. * * @param element the HTTPMetadataProvider parser. * @return the bean definition with the username and password. */ private BeanDefinition buildBasicCredentials(Element element) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(UsernamePasswordCredentials.class); builder.setLazyInit(true); builder.addConstructorArgValue( StringSupport.trimOrNull(element.getAttributeNS(null, BASIC_AUTH_USER))); builder.addConstructorArgValue( StringSupport.trimOrNull(element.getAttributeNS(null, BASIC_AUTH_PASSWORD))); return builder.getBeanDefinition(); }
/** Removes the scripting listeners from the given element. */ protected void removeScriptingListenersOn(Element elt) { String eltNS = elt.getNamespaceURI(); String eltLN = elt.getLocalName(); if (SVGConstants.SVG_NAMESPACE_URI.equals(eltNS) && SVG12Constants.SVG_HANDLER_TAG.equals(eltLN)) { // For this 'handler' element, remove the handler for the given // event type. AbstractElement tgt = (AbstractElement) elt.getParentNode(); String eventType = elt.getAttributeNS( XMLConstants.XML_EVENTS_NAMESPACE_URI, XMLConstants.XML_EVENTS_EVENT_ATTRIBUTE); String eventNamespaceURI = XMLConstants.XML_EVENTS_NAMESPACE_URI; if (eventType.indexOf(':') != -1) { String prefix = DOMUtilities.getPrefix(eventType); eventType = DOMUtilities.getLocalName(eventType); eventNamespaceURI = ((AbstractElement) elt).lookupNamespaceURI(prefix); } EventListener listener = (EventListener) handlerScriptingListeners.put(eventNamespaceURI, eventType, elt, null); tgt.removeEventListenerNS(eventNamespaceURI, eventType, listener, false); } super.removeScriptingListenersOn(elt); }
private int getApiVersion(Element usesSdk, String attribute, int defaultApiLevel) { String valueString = null; if (usesSdk.hasAttributeNS(NS_RESOURCES, attribute)) { valueString = usesSdk.getAttributeNS(NS_RESOURCES, attribute); } if (valueString != null) { int apiLevel = -1; try { apiLevel = Integer.valueOf(valueString); } catch (NumberFormatException e) { // Handle codename if (Sdk.getCurrent() != null) { IAndroidTarget target = Sdk.getCurrent().getTargetFromHashString("android-" + valueString); // $NON-NLS-1$ if (target != null) { // codename future API level is current api + 1 apiLevel = target.getVersion().getApiLevel() + 1; } } if (usesSdk.getTagName().equals(ATTRIBUTE_MIN_SDK_VERSION)) { mMinSdkName = valueString; } } return apiLevel; } return defaultApiLevel; }
/** * Returns the specular exponent of the specular feSpecularLighting filter primitive element. * * @param filterElement the feSpecularLighting filter primitive element * @param ctx the BridgeContext to use for error information */ protected static float convertSpecularExponent(Element filterElement, BridgeContext ctx) { String s = filterElement.getAttributeNS(null, SVG_SPECULAR_EXPONENT_ATTRIBUTE); if (s.length() == 0) { return 1; // default is 1 } else { try { float v = SVGUtilities.convertSVGNumber(s); if (v < 1 || v > 128) { throw new BridgeException( ctx, filterElement, ERR_ATTRIBUTE_VALUE_MALFORMED, new Object[] {SVG_SPECULAR_CONSTANT_ATTRIBUTE, s}); } return v; } catch (NumberFormatException nfEx) { throw new BridgeException( ctx, filterElement, nfEx, ERR_ATTRIBUTE_VALUE_MALFORMED, new Object[] {SVG_SPECULAR_CONSTANT_ATTRIBUTE, s, nfEx}); } } }
/** * Updates the filterMap according to the specified parameters. * * @param filterElement the filter primitive element * @param filter the filter that is part of the filter chain * @param filterMap the filter map to update */ protected static void updateFilterMap(Element filterElement, Filter filter, Map filterMap) { String s = filterElement.getAttributeNS(null, SVG_RESULT_ATTRIBUTE); if ((s.length() != 0) && (s.trim().length() != 0)) { filterMap.put(s, filter); } }
/** Runs the script. */ public void handleEvent(Event evt) { Element elt = (Element) evt.getCurrentTarget(); // Evaluate the script String script = handlerElement.getTextContent(); if (script.length() == 0) return; DocumentLoader dl = bridgeContext.getDocumentLoader(); AbstractDocument d = (AbstractDocument) handlerElement.getOwnerDocument(); int line = dl.getLineNumber(handlerElement); final String desc = Messages.formatMessage( HANDLER_SCRIPT_DESCRIPTION, new Object[] {d.getDocumentURI(), eventNamespaceURI, eventType, new Integer(line)}); // Find the scripting language String lang = handlerElement.getAttributeNS(null, SVGConstants.SVG_CONTENT_SCRIPT_TYPE_ATTRIBUTE); if (lang.length() == 0) { Element e = elt; while (e != null && (!SVGConstants.SVG_NAMESPACE_URI.equals(e.getNamespaceURI()) || !SVGConstants.SVG_SVG_TAG.equals(e.getLocalName()))) { e = SVGUtilities.getParentElement(e); } if (e == null) return; lang = e.getAttributeNS(null, SVGConstants.SVG_CONTENT_SCRIPT_TYPE_ATTRIBUTE); } runEventHandler(script, evt, lang, desc); }
// private? public static Set<AimQuantification> parseQuantifications( Element rootElement, AimImagingObservationCharacteristic aimImagingObservationCharacteristic) { System.out.println( "aimImagingObservationCharacteristic:" + aimImagingObservationCharacteristic); Set<AimQuantification> results = new HashSet<AimQuantification>(); // ns1:ImagingObservationCharacteristic NodeList imagingQuantifications = rootElement.getElementsByTagNameNS(AIM_NS, "CharacteristicQuantification"); for (int i = 0; i < imagingQuantifications.getLength(); i++) { Element imagingQuantification = (Element) imagingQuantifications.item(i); String name = imagingQuantification.getAttribute("name"); String value = imagingQuantification.getAttribute("value"); String type = imagingQuantification.getAttributeNS(XSI_NS, "type"); AimQuantification aimQuantification = new AimQuantification(); aimQuantification.setName(name); aimQuantification.setValue(value); aimQuantification.setType(filterNameSpace(type)); aimQuantification.setAimImagingObservationCharacteristic(aimImagingObservationCharacteristic); results.add(aimQuantification); } return results; }
@Test public void testElementGetAPIs() throws Exception { // builderFactory = DocumentBuilderFactory.newInstance(); builderFactory.setNamespaceAware(true); String xml = "<?xml version=\"1.0\"?>" + "<t:root xmlns=\"http://void.com/\" xmlns:t=\"http://t.com/\" id=\"stella\" t:type=\"police\">" + "<t:item id=\"a\"/>" + "<child id=\"1\"/>" + "<t:item id=\"b\"/>" + "<child id=\"2\"/>" + "</t:root>"; DocumentBuilder builder = builderFactory.newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes())); Element root = doc.getDocumentElement(); Assert.assertEquals("tagName", "t:root", root.getTagName()); Assert.assertEquals("attribute", "stella", root.getAttribute("id")); Assert.assertEquals("attributeNS", "police", root.getAttributeNS("http://t.com/", "type")); Assert.assertEquals("attribute(has)", true, root.hasAttribute("id")); Assert.assertEquals("attribute(has)", false, root.hasAttribute("__id__")); Assert.assertEquals("attributeNS(has)", true, root.hasAttributeNS("http://t.com/", "type")); Assert.assertEquals("attributeNS(has)", false, root.hasAttributeNS("http://t.com/", "tipe")); }
@Override public void visitElement(XmlContext context, Element element) { assert element.getTagName().equals(TAG_APPLICATION); mApplicationIcon = element.getAttributeNS(ANDROID_URI, ATTR_ICON); if (mApplicationIcon.startsWith(DRAWABLE_RESOURCE_PREFIX)) { mApplicationIcon = mApplicationIcon.substring(DRAWABLE_RESOURCE_PREFIX.length()); } }
/** * Returns the Signature method URI * * @return the Signature method URI */ public String getSignatureMethodURI() { Element signatureElement = this.getSignatureMethodElement(); if (signatureElement != null) { return signatureElement.getAttributeNS(null, Constants._ATT_ALGORITHM); } return null; }
@NonNull public String getNodeId() { String nodeid = mNode.getAttributeNS(ANDROID_URI, ATTR_ID); if (nodeid.isEmpty()) { return String.format("%1$s-%2$d", mNode.getTagName(), mIndex); } else { return uniformId(nodeid); } }
@NonNull public String getNodeTextId() { String text = mNode.getAttributeNS(ANDROID_URI, ATTR_TEXT); if (text.isEmpty()) { return getNodeId(); } else { return uniformId(text); } }
private static boolean matchesVersion(Element element) { String schemaLocation = element.getAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"); return !StringUtils.hasText(schemaLocation) // no namespace on this element || schemaLocation.matches( "(?m).*spring-integration-[a-z-]*" + VERSION + ".xsd.*") // correct version || schemaLocation.matches("(?m).*spring-integration[a-z-]*.xsd.*") // version-less schema || !schemaLocation.matches("(?m).*spring-integration.*"); // no spring-integration schemas }
@Nullable private LayoutNode findNodeByAttr( @NonNull Map<String, LayoutNode> nodes, @NonNull String attrName) { String value = mNode.getAttributeNS(ANDROID_URI, attrName); if (!value.isEmpty()) { return nodes.get(uniformId(value)); } else { return null; } }
public Object convertAttributeValue(Element a) { String type = a.getAttributeNS(XSI_NS, "type"); if ((type == null) || ("".equals(type))) { System.out.println( "----> convertAttributeValue " + type + " " + a.getFirstChild().getNodeValue()); return a.getFirstChild().getNodeValue(); } else { System.out.println("----> convertAttributeValue " + type); return c.convertTypedLiteral(type, "\"" + a.getFirstChild().getNodeValue() + "\""); } }
private void setWhitespaceHandling(Element e) { final String wsSetting = e.getAttributeNS(Namespaces.XML_NS, "space"); if ("preserve".equals(wsSetting)) { this.spaceStack.push(wsSetting); this.preserveWhitespace = true; } else if ("default".equals(wsSetting)) { this.spaceStack.push(wsSetting); this.preserveWhitespace = preserveWhitespaceTemp; } // Otherwise, don't change what's currently in effect! }
private static int getInt(Element element, String attribute, int defaultValue) { String valueString = element.getAttributeNS(ANDROID_URI, attribute); if (valueString != null && !valueString.isEmpty()) { try { return Integer.decode(valueString); } catch (NumberFormatException nufe) { // Ignore - error in user's XML } } return defaultValue; }
/** Tells whether the given SVG document is dynamic. */ public static boolean isDynamicDocument(BridgeContext ctx, Document doc) { Element elt = doc.getDocumentElement(); if ((elt != null) && SVGConstants.SVG_NAMESPACE_URI.equals(elt.getNamespaceURI())) { if (elt.getAttributeNS(null, SVGConstants.SVG_ONABORT_ATTRIBUTE).length() > 0) { return true; } if (elt.getAttributeNS(null, SVGConstants.SVG_ONERROR_ATTRIBUTE).length() > 0) { return true; } if (elt.getAttributeNS(null, SVGConstants.SVG_ONRESIZE_ATTRIBUTE).length() > 0) { return true; } if (elt.getAttributeNS(null, SVGConstants.SVG_ONUNLOAD_ATTRIBUTE).length() > 0) { return true; } if (elt.getAttributeNS(null, SVGConstants.SVG_ONSCROLL_ATTRIBUTE).length() > 0) { return true; } if (elt.getAttributeNS(null, SVGConstants.SVG_ONZOOM_ATTRIBUTE).length() > 0) { return true; } return isDynamicElement(ctx, doc.getDocumentElement()); } return false; }
/** * Creates a <tt>GraphicsNode</tt> according to the specified parameters. * * @param ctx the bridge context to use * @param e the element that describes the graphics node to build * @return a graphics node that represents the specified element */ public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) { // 'requiredFeatures', 'requiredExtensions' and 'systemLanguage' if (!SVGUtilities.matchUserAgent(e, ctx.getUserAgent())) { return null; } CompositeGraphicsNode cgn = new CompositeGraphicsNode(); // 'transform' String s = e.getAttributeNS(null, SVG_TRANSFORM_ATTRIBUTE); if (s.length() != 0) { cgn.setTransform(SVGUtilities.convertTransform(e, SVG_TRANSFORM_ATTRIBUTE, s, ctx)); } // 'visibility' cgn.setVisible(CSSUtilities.convertVisibility(e)); // 'text-rendering' and 'color-rendering' RenderingHints hints = null; hints = CSSUtilities.convertColorRendering(e, hints); hints = CSSUtilities.convertTextRendering(e, hints); if (hints != null) { cgn.setRenderingHints(hints); } // first child holds the flow region nodes CompositeGraphicsNode cgn2 = new CompositeGraphicsNode(); cgn.add(cgn2); // second child is the text node FlowTextNode tn = (FlowTextNode) instantiateGraphicsNode(); tn.setLocation(getLocation(ctx, e)); // specify the text painter to use if (ctx.getTextPainter() != null) { tn.setTextPainter(ctx.getTextPainter()); } textNode = tn; cgn.add(tn); associateSVGContext(ctx, e, cgn); // traverse the children to add SVGContext Node child = getFirstChild(e); while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE) { addContextToChild(ctx, (Element) child); } child = getNextSibling(child); } return cgn; }
/** @see org.newdawn.slick.svg.inkscape.ElementProcessor#handles(org.w3c.dom.Element) */ public boolean handles(Element element) { if (element.getNodeName().equals("polygon")) { return true; } if (element.getNodeName().equals("path")) { if (!"arc".equals(element.getAttributeNS(Util.SODIPODI, "type"))) { return true; } } return false; }
private void resetWhitespaceHandling(Element e) { final String wsSetting = e.getAttributeNS(Namespaces.XML_NS, "space"); if ("preserve".equals(wsSetting) || "default".equals(wsSetting)) { // Since an opinion was expressed, restore what was previously set: this.spaceStack.pop(); if (0 == this.spaceStack.size()) { // This is the default... this.preserveWhitespace = preserveWhitespaceTemp; } else { this.preserveWhitespace = ("preserve".equals(this.spaceStack.peek())); } } }
/** * Converts on the specified filter primitive element, the specified attribute that represents an * integer and with the specified default value. * * @param filterElement the filter primitive element * @param attrName the name of the attribute * @param defaultValue the default value of the attribute * @param ctx the BridgeContext to use for error information */ protected static int convertInteger( Element filterElement, String attrName, int defaultValue, BridgeContext ctx) { String s = filterElement.getAttributeNS(null, attrName); if (s.length() == 0) { return defaultValue; } else { try { return SVGUtilities.convertSVGInteger(s); } catch (NumberFormatException nfEx) { throw new BridgeException( ctx, filterElement, nfEx, ERR_ATTRIBUTE_VALUE_MALFORMED, new Object[] {attrName, s}); } } }
private static void getElementsWithAttribute( Element element, String namespaceURI, String localName, String value, Collection elements) { if (element.hasAttributeNS(namespaceURI, localName)) { String attr = element.getAttributeNS(namespaceURI, localName); if (attr.equals(value)) elements.add(element); } NodeList childs = element.getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { Node node = childs.item(i); if (Node.ELEMENT_NODE == node.getNodeType()) getElementsWithAttribute((Element) node, namespaceURI, localName, value, elements); } }
/** * Returns the input source of the specified filter primitive element defined by its 'in2' * attribute. The 'in2' attribute is assumed to be required if the subclasses ask for it. * * @param filterElement the filter primitive element * @param filteredElement the element on which the filter is referenced * @param filteredNode the graphics node on which the filter is applied * @param inputFilter the default input filter * @param filterMap the map that containes the named filter primitives * @param ctx the bridge context */ protected static Filter getIn2( Element filterElement, Element filteredElement, GraphicsNode filteredNode, Filter inputFilter, Map filterMap, BridgeContext ctx) { String s = filterElement.getAttributeNS(null, SVG_IN2_ATTRIBUTE); if (s.length() == 0) { throw new BridgeException( ctx, filterElement, ERR_ATTRIBUTE_MISSING, new Object[] {SVG_IN2_ATTRIBUTE}); } return getFilterSource(filterElement, s, filteredElement, filteredNode, filterMap, ctx); }