Example usage for javax.xml.namespace QName QName

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

Introduction

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

Prototype

public QName(String localPart) 

Source Link

Document

QName constructor specifying the local part.

If the local part is null an IllegalArgumentException is thrown.

Usage

From source file:com.sportpm.mapper.JaxbMapper.java

/**
 * Java Collection->Xml with encoding, ?Root ElementCollection.
 *///ww w . java2  s . c  om
@SuppressWarnings("rawtypes")
public static String toXml(Collection<?> root, String rootName, Class clazz, String encoding) {
    try {
        CollectionWrapper wrapper = new CollectionWrapper();
        wrapper.collection = root;

        JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName),
                CollectionWrapper.class, wrapper);

        StringWriter writer = new StringWriter();
        createMarshaller(clazz, encoding).marshal(wrapperElement, writer);

        return writer.toString();
    } catch (JAXBException e) {
        throw Exceptions.unchecked(e);
    }
}

From source file:cn.newtouch.util.utils.encode.JaxbBinder.java

/**
 * Java Object->Xml, ?Root ElementCollection.
 *///from w  w w  . j  a va2s.  co  m
@SuppressWarnings("unchecked")
public String toXml(Collection root, String rootName, String encoding) {
    try {
        CollectionWrapper wrapper = new CollectionWrapper();
        wrapper.collection = root;

        JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName),
                CollectionWrapper.class, wrapper);

        StringWriter writer = new StringWriter();
        createMarshaller(encoding).marshal(wrapperElement, writer);

        return writer.toString();
    } catch (JAXBException e) {
        throw new RuntimeException(e);
    }
}

From source file:$.JaxbMapper.java

/**
     * Java Collection->Xml with encoding, ?Root ElementCollection.
     *//*w ww.  j a v a 2s . c  om*/
    public static String toXml(Collection<?> root, String rootName, Class clazz, String encoding) {
        try {
            CollectionWrapper wrapper = new CollectionWrapper();
            wrapper.collection = root;

            JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName),
                    CollectionWrapper.class, wrapper);

            StringWriter writer = new StringWriter();
            createMarshaller(clazz, encoding).marshal(wrapperElement, writer);

            return writer.toString();
        } catch (JAXBException e) {
            throw Exceptions.unchecked(e);
        }
    }

From source file:net.cloudkit.enterprises.infrastructure.utilities.JaxbMapperHelper.java

/**
 * Java Collection->Xml with encoding, ?Root ElementCollection.
 *//*from ww  w.  jav  a2 s . c  om*/
public static String toXml(Collection<?> root, String rootName, Class<?> clazz, String encoding) {
    try {
        CollectionWrapper wrapper = new CollectionWrapper();
        wrapper.collection = root;

        JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName),
                CollectionWrapper.class, wrapper);

        StringWriter writer = new StringWriter();
        createMarshaller(clazz, encoding).marshal(wrapperElement, writer);

        return writer.toString();
    } catch (JAXBException e) {
        throw ExceptionHelper.unchecked(e);
    }
}

From source file:loanbroker.CreditAgencyTest.java

public void testCreditHistory() throws Exception {
    drools = new DroolsComponent();
    DroolsEndpoint endpoint = new DroolsEndpoint(drools.getServiceUnit(), new QName("drools"), "endpoint");
    endpoint.setRuleBaseResource(new ClassPathResource("credit-agency.drl"));
    drools.setEndpoints(new DroolsEndpoint[] { endpoint });
    jbi.activateComponent(drools, "servicemix-drools");

    jbi.start();//from  w  w w . java 2 s .  c o  m

    InOut me = client.createInOutExchange();
    me.setService(new QName("drools"));
    me.setOperation(new QName("urn:logicblaze:soa:creditagency", "getCreditHistoryLength"));
    me.getInMessage().setContent(new StringSource(
            "<getCreditHistoryLengthRequest xmlns='urn:logicblaze:soa:creditagency'><ssn>123456</ssn></getCreditHistoryLengthRequest>"));
    client.sendSync(me);
    Element e = new SourceTransformer().toDOMElement(me.getOutMessage());
    assertEquals("getCreditHistoryLengthResponse", e.getLocalName());
    client.done(me);

    Thread.sleep(50);
}

From source file:com.marklogic.client.test.KeyValueSearchTest.java

@Test
public void testKVSearch() throws IOException {
    QueryManager queryMgr = Common.client.newQueryManager();
    KeyValueQueryDefinition qdef = queryMgr.newKeyValueDefinition(null);

    qdef.put(queryMgr.newElementLocator(new QName("leaf")), "leaf3");
    SearchHandle results = queryMgr.search(qdef, new SearchHandle());
    assertNotNull(results);/*from   www .  j  a va2  s.  c om*/
    assertFalse(results.getMetrics().getTotalTime() == -1);

    MatchDocumentSummary[] summaries = results.getMatchResults();
    assertNotNull(summaries);
    assertEquals("expected 1 result", 1, summaries.length);
    for (MatchDocumentSummary summary : summaries) {
        MatchLocation[] locations = summary.getMatchLocations();
        assertEquals("expected 1 match location", 1, locations.length);
        for (MatchLocation location : locations) {
            assertNotNull(location.getAllSnippetText());
        }
    }
}

From source file:com.framework.infrastructure.mapper.JaxbMapper.java

/**
 * Java Collection->Xml with encoding, Root ElementCollection.
 *//* ww w  . ja v  a  2 s  .co m*/
public String toXml(Collection<?> root, String rootName, String encoding) {
    try {
        CollectionWrapper wrapper = new CollectionWrapper();
        wrapper.collection = root;

        JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName),
                CollectionWrapper.class, wrapper);

        StringWriter writer = new StringWriter();
        createMarshaller(encoding).marshal(wrapperElement, writer);

        return writer.toString();
    } catch (JAXBException e) {
        throw Exceptions.unchecked(e);
    }
}

From source file:gdv.xport.satz.xml.FeldReferenz.java

/**
 * Instantiiert eine Objekt mit den Werten, die ueber den uebergebenen
 * Parser gelesen werden.//from ww  w  . j  av a  2  s . c o m
 *
 * @param parser the parser
 * @param element das Start-Element <feldreferenz referenz=... >
 * @throws XMLStreamException the XML stream exception
 */
public FeldReferenz(final XMLEventReader parser, final StartElement element) throws XMLStreamException {
    id = element.getAttributeByName(new QName("referenz")).getValue();
    Properties props = XmlHelper.parseSimpleElements(element.getName(), parser);
    this.bezeichner = new Bezeichner(props);
    this.bemerkung = props.getProperty("bemerkung", "");
    this.auspraegung = props.getProperty("auspraegung", "");
    LOG.debug("{} created.", this);
}

From source file:com.govsoft.framework.common.util.encode.JaxbBinder.java

/**
 * Java Object->Xml with encoding, ?Root ElementCollection.
 *///from  w  w  w  .  java2 s  . c o  m
public String toXml(Collection<?> root, String rootName, String encoding) {
    try {
        CollectionWrapper wrapper = new CollectionWrapper();
        wrapper.collection = root;

        JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName),
                CollectionWrapper.class, wrapper);

        StringWriter writer = new StringWriter();
        createMarshaller(encoding).marshal(wrapperElement, writer);

        return writer.toString();
    } catch (JAXBException e) {
        throw new RuntimeException(e);
    }
}