Example usage for javax.xml.namespace QName getPrefix

List of usage examples for javax.xml.namespace QName getPrefix

Introduction

In this page you can find the example usage for javax.xml.namespace QName getPrefix.

Prototype

public String getPrefix() 

Source Link

Document

Get the prefix of this QName.

The prefix assigned to a QName might NOT be valid in a different context.

Usage

From source file:org.apache.padaf.xmpbox.parser.XMPDocumentBuilder.java

/**
 * Parse a bag property (unordered array) with the specific type defined in
 * schema or complex property and add it to the object representation
 * /*from  ww w .  ja va 2 s  .c o  m*/
 * @param metadata
 *            Metadata to attach new elements
 * @param bagName
 *            name of bag property
 * @param stype
 *            type of values contained in this bag
 * @param container
 *            the entity where place the property representation
 * @throws XmpUnexpectedTypeException
 *             When DOM Element type found unexpected
 * @throws XmpParsingException
 *             When element expected not found
 * @throws XMLStreamException
 *             When error during reading the rest of xmp stream
 * @throws XmpUnknownPropertyTypeException
 *             Value Type property is incorrect or the basic value type
 *             can't be treat at the moment
 * @throws XmpPropertyFormatException
 *             Unexpected type found (IllegalArgumentException)
 */
protected void parseBagProperty(XMPMetadata metadata, QName bagName, XmpPropertyType stype,
        ComplexPropertyContainer container) throws XmpUnexpectedTypeException, XmpParsingException,
        XMLStreamException, XmpUnknownPropertyTypeException, XmpPropertyFormatException {
    ComplexProperty bag = new ComplexProperty(metadata, bagName.getPrefix(), bagName.getLocalPart(),
            ComplexProperty.UNORDERED_ARRAY);
    container.addProperty(bag);
    // <rdf:Bag>
    expectNextSpecificTag(XMLStreamReader.START_ELEMENT, BAG_NAME, "Expected Bag Declaration");
    // Each property definition
    int elmtType = reader.get().nextTag();
    while ((elmtType != XMLStreamReader.END_ELEMENT)
            && !reader.get().getName().getLocalPart().equals(BAG_NAME)) {
        parseXmpSimpleProperty(metadata, reader.get().getName(), stype, bag.getContainer());
        elmtType = reader.get().nextTag();

    }
    expectNextSpecificTag(XMLStreamReader.END_ELEMENT, bagName.getLocalPart(), "Expected end of Bag property");

}

From source file:org.apache.padaf.xmpbox.parser.XMPDocumentBuilder.java

protected void parseComplexBagProperty(XMPMetadata metadata, QName bagName,
        StructuredPropertyParser complexParser, ComplexPropertyContainer container)
        throws XmpUnexpectedTypeException, XmpParsingException, XMLStreamException,
        XmpUnknownPropertyTypeException, XmpPropertyFormatException {
    ComplexProperty bag = new ComplexProperty(metadata, bagName.getPrefix(), bagName.getLocalPart(),
            ComplexProperty.UNORDERED_ARRAY);
    container.addProperty(bag);/*from   w w w.  j  a v a2  s. com*/
    // <rdf:Bag>
    expectNextSpecificTag(XMLStreamReader.START_ELEMENT, BAG_NAME, "Expected Bag Declaration");
    // Each property definition
    int elmtType = reader.get().nextTag();
    while ((elmtType != XMLStreamReader.END_ELEMENT)
            && !reader.get().getName().getLocalPart().equals(BAG_NAME)) {
        complexParser.parse(metadata, reader.get().getName(), bag.getContainer());
        elmtType = reader.get().nextTag();

    }
    expectNextSpecificTag(XMLStreamReader.END_ELEMENT, bagName.getLocalPart(), "Expected end of Bag property");

}

From source file:org.apache.padaf.xmpbox.parser.XMPDocumentBuilder.java

/**
 * Parse a seq property (ordered array) with the specific type defined in
 * schema or complex property and add it to the object representation
 * /*from  w  w w  . java 2 s  .c o  m*/
 * @param metadata
 *            Metadata to attach new elements
 * @param seqName
 *            name of the seq
 * @param stype
 *            type of values contained in this bag
 * @param container
 *            the entity where place the property representation
 * @throws XmpUnexpectedTypeException
 *             When DOM Element type found unexpected
 * @throws XmpParsingException
 *             When element expected not found
 * @throws XMLStreamException
 *             When error during reading the rest of xmp stream
 * @throws XmpUnknownPropertyTypeException
 *             Value Type property is incorrect or the basic value type
 *             can't be treat at the moment
 * @throws XmpPropertyFormatException
 *             Unexpected type found (IllegalArgumentException)
 */
protected void parseSeqProperty(XMPMetadata metadata, QName seqName, XmpPropertyType stype,
        ComplexPropertyContainer container) throws XmpUnexpectedTypeException, XmpParsingException,
        XMLStreamException, XmpUnknownPropertyTypeException, XmpPropertyFormatException {
    ComplexProperty seq = new ComplexProperty(metadata, seqName.getPrefix(), seqName.getLocalPart(),
            ComplexProperty.ORDERED_ARRAY);
    container.addProperty(seq);
    // <rdf:Bag>
    expectNextSpecificTag(XMLStreamReader.START_ELEMENT, SEQ_NAME, "Expected Seq Declaration");
    // Each property definition
    int elmtType = reader.get().nextTag();
    while ((elmtType != XMLStreamReader.END_ELEMENT)
            && !reader.get().getName().getLocalPart().equals(SEQ_NAME)) {
        parseXmpSimpleProperty(metadata, reader.get().getName(), stype, seq.getContainer());
        elmtType = reader.get().nextTag();

    }
    expectNextSpecificTag(XMLStreamReader.END_ELEMENT, seqName.getLocalPart(), "Expected end of Seq property");
}

From source file:org.apache.padaf.xmpbox.parser.XMPDocumentBuilder.java

/**
 * Parse Alt property (Alternative language property) with the specific type
 * defined in schema or complex property and add it to the object
 * representation//  w ww  .  j av  a2s. c  om
 * 
 * @param metadata
 *            Metadata to attach new elements
 * @param altName
 *            name of Alt property
 * @param stype
 *            type of values contained in this bag
 * @param container
 *            the entity where place the property representation
 * @throws XmpUnexpectedTypeException
 *             When DOM Element type found unexpected
 * @throws XmpParsingException
 *             When element expected not found
 * @throws XMLStreamException
 *             When error during reading the rest of xmp stream
 * @throws XmpUnknownPropertyTypeException
 *             Value Type property is incorrect or the basic value type
 *             can't be treat at the moment
 * @throws XmpPropertyFormatException
 *             Unexpected type found (IllegalArgumentException)
 */
protected void parseAltProperty(XMPMetadata metadata, QName altName, XmpPropertyType stype,
        ComplexPropertyContainer container) throws XmpUnexpectedTypeException, XmpParsingException,
        XMLStreamException, XmpUnknownPropertyTypeException, XmpPropertyFormatException {
    ComplexProperty alt = new ComplexProperty(metadata, altName.getPrefix(), altName.getLocalPart(),
            ComplexProperty.ALTERNATIVE_ARRAY);
    container.addProperty(alt);
    // <rdf:Alt>
    expectNextSpecificTag(XMLStreamReader.START_ELEMENT, ALT_NAME, "Expected Alt Declaration");
    int elmtType = reader.get().nextTag();
    while (!((elmtType == XMLStreamReader.END_ELEMENT)
            && reader.get().getName().getLocalPart().equals(ALT_NAME))) {
        parseXmpSimpleProperty(metadata, reader.get().getName(), stype, alt.getContainer());
        elmtType = reader.get().nextTag();

    }
    // <dc:description><rdf:Alt><rdf:li>sujet</rdf:li></rdf:Alt></dc:description>
    expectNextSpecificTag(XMLStreamReader.END_ELEMENT, altName.getLocalPart(), "Expected end of alt property");

}

From source file:org.apache.padaf.xmpbox.parser.XMPDocumentBuilder.java

/**
 * Parse a specific field// w  w  w  .j  av a2s  . c o m
 * 
 * @param metadata
 *            Metadata to attach new elements
 * @param propertyName
 *            the full qualified name of this property
 * @param schema
 *            The schema where save this property
 * @throws XmpUnexpectedTypeException
 *             When DOM Element type found unexpected
 * @throws XmpParsingException
 *             When element expected not found
 * @throws XMLStreamException
 *             When error during reading the rest of xmp stream
 * @throws XmpUnknownPropertyTypeException
 *             Value Type property is incorrect or the basic value type
 *             can't be treat at the moment
 * @throws XmpPropertyFormatException
 *             Unexpected type found (IllegalArgumentException)
 */
protected void parseFieldProperty(XMPMetadata metadata, QName propertyName, XMPSchema schema)
        throws XmpUnexpectedTypeException, XmpPropertyFormatException, XmpParsingException, XMLStreamException,
        XmpUnknownPropertyTypeException {
    ComplexPropertyContainer field = new ComplexPropertyContainer(metadata, propertyName.getPrefix(),
            propertyName.getLocalPart());
    schema.addProperty(field);
    field.setAttribute(new Attribute(null, "rdf", "parseType", "Resource"));
    String type;
    int elmtType = reader.get().nextTag();
    while ((elmtType != XMLStreamReader.END_ELEMENT)
            && !reader.get().getName().getLocalPart().equals(SEQ_NAME)) {

        type = getPropertyDeclarationInNamespaces(schema, reader.get().getName());
        if (!createAndAddPropertyToContainer(metadata, type, field)) {
            if (type.equals("Field")) {
                String stype = getPropertyDeclarationInNamespaces(schema, reader.get().getName());
                createAndAddPropertyToContainer(metadata, stype, field);
            } else {
                throw new XmpUnknownPropertyTypeException("Unknown type : " + type);
            }
        }
        elmtType = reader.get().nextTag();
    }
    expectCurrentLocalName(propertyName.getLocalPart());

    // expectNextSpecificTag(XMLStreamReader.END_ELEMENT,
    // propertyName.getLocalPart(), "Expected end of field declaration");

}

From source file:org.apache.padaf.xmpbox.parser.XMPDocumentBuilder.java

/**
 * Treat Alternative Thumbnails property
 * /* w  ww. j av  a2s.  co m*/
 * @param metadata
 *            Metadata to attach new elements
 * @param altName
 *            name of thumbnails alternative property
 * @param container
 *            the container where record this representation
 * @throws XmpUnexpectedTypeException
 *             When DOM Element type found unexpected
 * @throws XmpParsingException
 *             When element expected not found
 * @throws XMLStreamException
 *             When error during reading the rest of xmp stream
 * @throws XmpUnknownPropertyTypeException
 *             Value Type property is incorrect or the basic value type
 *             can't be treat at the moment
 * @throws XmpPropertyFormatException
 *             Unexpected type found (IllegalArgumentException)
 */
private void parseAltThumbnailProperty(XMPMetadata metadata, QName altName, ComplexPropertyContainer container)
        throws XmpUnexpectedTypeException, XmpParsingException, XMLStreamException,
        XmpUnknownPropertyTypeException, XmpPropertyFormatException {
    ComplexProperty alt = new ComplexProperty(metadata, altName.getPrefix(), altName.getLocalPart(),
            ComplexProperty.ALTERNATIVE_ARRAY);
    container.addProperty(alt);
    // <rdf:Alt>
    expectNextSpecificTag(XMLStreamReader.START_ELEMENT, ALT_NAME, "Expected Alt Declaration");
    int elmtType = reader.get().nextTag();
    while (!((elmtType == XMLStreamReader.END_ELEMENT)
            && reader.get().getName().getLocalPart().equals(ALT_NAME))) {
        parseThumbnailProperty(metadata, reader.get().getName(), alt.getContainer());
        elmtType = reader.get().nextTag();
    }

    // <dc:description><rdf:Alt><rdf:li>sujet</rdf:li></rdf:Alt></dc:description>
    expectNextSpecificTag(XMLStreamReader.END_ELEMENT, altName.getLocalPart(), "Expected end of alt property");
}

From source file:org.apache.padaf.xmpbox.parser.XMPDocumentBuilder.java

/**
 * * Treat a thumbnail property//from w w  w .j av  a  2  s . com
 * 
 * @param metadata
 *            Metadata to attach new elements
 * @param altName
 *            name of thumbnail property
 * @param container
 *            The container where save property representation
 * @throws XmpUnexpectedTypeException
 *             When DOM Element type found unexpected
 * @throws XmpParsingException
 *             When element expected not found
 * @throws XMLStreamException
 *             When error during reading the rest of xmp stream
 * @throws XmpUnknownPropertyTypeException
 *             Value Type property is incorrect or the basic value type
 *             can't be treat at the moment
 * @throws XmpPropertyFormatException
 *             Unexpected type found (IllegalArgumentException)
 */
private void parseThumbnailProperty(XMPMetadata metadata, QName altName, ComplexPropertyContainer container)
        throws XmpUnexpectedTypeException, XmpParsingException, XMLStreamException,
        XmpUnknownPropertyTypeException, XmpPropertyFormatException {
    expectCurrentLocalName("li");
    ThumbnailType thumbnail = new ThumbnailType(metadata, altName.getPrefix(), altName.getLocalPart());
    int elmtType = reader.get().nextTag();
    QName eltName;
    String eltContent;
    while (!((elmtType == XMLStreamReader.END_ELEMENT) && reader.get().getName().getLocalPart().equals("li"))) {
        eltName = reader.get().getName();
        eltContent = reader.get().getElementText();
        if (eltName.getLocalPart().equals("height")) {
            thumbnail.setHeight(eltName.getPrefix(), eltName.getLocalPart(), Integer.valueOf(eltContent));
        } else if (eltName.getLocalPart().equals("width")) {
            thumbnail.setWidth(eltName.getPrefix(), eltName.getLocalPart(), Integer.valueOf(eltContent));
        } else if (eltName.getLocalPart().equals("image")) {
            thumbnail.setImg(eltName.getPrefix(), eltName.getLocalPart(), eltContent);
        } else if (eltName.getLocalPart().equals("format")) {
            thumbnail.setFormat(eltName.getPrefix(), eltName.getLocalPart(), eltContent);
        } else {
            throw new XmpParsingException(
                    "Unknown property name for a thumbnail element : " + eltName.getLocalPart());
        }
        elmtType = reader.get().nextTag();
    }
    container.addProperty(thumbnail);
}

From source file:org.apache.rahas.impl.SAML2TokenIssuer.java

/**
 * This method is used to build the assertion elements
 * @param objectQName//from   ww w . j  a  v a  2  s . co  m
 * @return
 * @throws Exception
 */
protected static XMLObject buildXMLObject(QName objectQName) throws Exception {
    XMLObjectBuilder builder = org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(objectQName);
    if (builder == null) {
        throw new TrustException("Unable to retrieve builder for object QName " + objectQName);
    }
    return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
            objectQName.getPrefix());
}

From source file:org.apache.rahas.impl.util.CommonUtil.java

/**
 * Builds the requested XMLObject./*from www  . j  a va 2  s . co m*/
 *
 * @param objectQName name of the XMLObject
 * @return the build XMLObject
 * @throws org.apache.rahas.TrustException If unable to find the appropriate builder.
 */
public static XMLObject buildXMLObject(QName objectQName) throws TrustException {
    XMLObjectBuilder builder = Configuration.getBuilderFactory().getBuilder(objectQName);
    if (builder == null) {
        log.debug("Unable to find OpenSAML builder for object " + objectQName);
        throw new TrustException("builderNotFound", new Object[] { objectQName });
    }
    return builder.buildObject(objectQName.getNamespaceURI(), objectQName.getLocalPart(),
            objectQName.getPrefix());
}

From source file:org.apache.synapse.commons.json.JsonReaderDelegate.java

public QName getName() {
    QName qName = super.getName();
    String localName = qName.getLocalPart();
    QName newName = qName;//from   www.  j  av a  2s .  com
    if (localName == null || "".equals(localName)) {
        return qName;
    }
    boolean checked = false;
    if (Character.isDigit(localName.charAt(0))) {
        localName = Constants.PRECEDING_DIGIT + localName;
        if (buildValidNCNames) {
            localName = toValidNCName(localName);
            checked = true;
        }
        newName = new QName(qName.getNamespaceURI(), localName, qName.getPrefix());
    }
    if (localName.charAt(0) == Constants.C_DOLLOR) {
        localName = Constants.PRECEDING_DOLLOR + localName.substring(1);
        if (buildValidNCNames) {
            localName = toValidNCName(localName);
            checked = true;
        }
        newName = new QName(qName.getNamespaceURI(), localName, qName.getPrefix());
    }
    if (!checked && buildValidNCNames) {
        String newNameP = toValidNCName(localName);
        if (!localName.equals(newNameP)) {
            newName = new QName(qName.getNamespaceURI(), newNameP, qName.getPrefix());
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("#getName. old=" + localName + ", new=" + newName.getLocalPart());
    }
    return newName;
}