Example usage for org.xml.sax.helpers AttributesImpl AttributesImpl

List of usage examples for org.xml.sax.helpers AttributesImpl AttributesImpl

Introduction

In this page you can find the example usage for org.xml.sax.helpers AttributesImpl AttributesImpl.

Prototype

public AttributesImpl() 

Source Link

Document

Construct a new, empty AttributesImpl object.

Usage

From source file:de.interactive_instruments.ShapeChange.Target.FeatureCatalogue.FeatureCatalogue.java

private void appendImageInfo(List<ImageMetadata> images) throws SAXException {

    if (!includeDiagrams) {
        return;//from   w  w w  . ja  v a2s .co m
    }

    Collections.sort(images, new Comparator<ImageMetadata>() {

        @Override
        public int compare(ImageMetadata o1, ImageMetadata o2) {
            return o1.getId().compareTo(o2.getId());
        }
    });

    writer.startElement("images");

    for (ImageMetadata img : images) {

        // TBD: at the moment this is only used by the docx transformation
        // the information could therefore be moved to a separate file
        AttributesImpl atts = new AttributesImpl();
        atts.addAttribute("", "id", "", "CDATA", img.getId());
        atts.addAttribute("", "idAsInt", "", "CDATA", "" + imgIntegerIdCounter);
        imgIntegerIdCounter = imgIntegerIdCounter + imgIntegerIdStepwidth;
        atts.addAttribute("", "name", "", "CDATA", img.getName());
        atts.addAttribute("", "height", "", "CDATA", "" + img.getHeight());
        atts.addAttribute("", "width", "", "CDATA", "" + img.getWidth());
        atts.addAttribute("", "relPath", "", "CDATA", img.getRelPathToFile());

        writer.emptyElement("image", atts);

        // also keep track of the image metadata for later use
        imageSet.add(img);
    }

    writer.endElement("images");
}

From source file:com.jkoolcloud.tnt4j.streams.configure.sax.ConfigParserHandlerTest.java

@Test(expected = SAXParseException.class)
public void processJavaObjectNameExceptionTest() throws Exception {
    ConfigParserHandler test = Mockito.mock(ConfigParserHandler.class, Mockito.CALLS_REAL_METHODS);
    test.startDocument();/*from   ww  w  . j av  a2s.  c  om*/
    AttributesImpl attrs = new AttributesImpl();
    attrs.addAttribute("", "", "name", "", "Stream name value"); // NON-NLS
    attrs.addAttribute("", "", "source", "", "Stream source value"); // NON-NLS
    attrs.addAttribute("", "", "target", "", "Stream target value"); // NON-NLS
    attrs.addAttribute("", "", "value", "", ""); // NON-NLS
    attrs.addAttribute("", "", "class", "", "com.jkoolcloud.tnt4j.streams.parsers.ActivityTokenParser"); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "parser", attrs); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "field", attrs); // NON-NLS
    attrs.addAttribute("", "", "name", "", ""); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "java-object", attrs); // NON-NLS
}

From source file:com.jkoolcloud.tnt4j.streams.configure.sax.ConfigParserHandlerTest.java

@Test(expected = SAXParseException.class)
public void processJavaObjectClassExceptionTest() throws Exception {
    ConfigParserHandler test = Mockito.mock(ConfigParserHandler.class, Mockito.CALLS_REAL_METHODS);
    test.startDocument();/*from   ww w .  j a v a2s. c  o  m*/
    AttributesImpl attrs = new AttributesImpl();
    attrs.addAttribute("", "", "name", "", "Stream name value"); // NON-NLS
    attrs.addAttribute("", "", "source", "", "Stream source value"); // NON-NLS
    attrs.addAttribute("", "", "target", "", "Stream target value"); // NON-NLS
    attrs.addAttribute("", "", "value", "", ""); // NON-NLS
    attrs.addAttribute("", "", "class", "", "com.jkoolcloud.tnt4j.streams.parsers.ActivityTokenParser"); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "parser", attrs); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "field", attrs); // NON-NLS
    attrs.addAttribute("", "", "class", "", ""); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "java-object", attrs); // NON-NLS
}

From source file:com.jkoolcloud.tnt4j.streams.configure.sax.ConfigParserHandlerTest.java

@Test(expected = SAXParseException.class)
public void processParamTypeExceptionTest() throws Exception {
    ConfigParserHandler test = Mockito.mock(ConfigParserHandler.class, Mockito.CALLS_REAL_METHODS);
    test.startDocument();//  w  w w  .  j  a v a2  s  . c o  m
    AttributesImpl attrs = new AttributesImpl();
    attrs.addAttribute("", "", "name", "", "Stream name value"); // NON-NLS
    attrs.addAttribute("", "", "source", "", "Stream source value"); // NON-NLS
    attrs.addAttribute("", "", "target", "", "Stream target value"); // NON-NLS
    attrs.addAttribute("", "", "value", "", ""); // NON-NLS
    attrs.addAttribute("", "", "class", "", "com.jkoolcloud.tnt4j.streams.parsers.ActivityTokenParser"); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "parser", attrs); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "field", attrs); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "java-object", attrs); // NON-NLS
    attrs.addAttribute("", "", "type", "", "TEST TYPE"); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "param", attrs); // NON-NLS
}

From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement.java

/**
 * Gets the attributes of the element in the form of a {@link org.xml.sax.Attributes}.
 * @param element the element to read the attributes from
 * @return the attributes/*w ww .ja  v  a 2 s .c  om*/
 */
protected AttributesImpl readAttributes(final HtmlElement element) {
    final AttributesImpl attributes = new AttributesImpl();
    for (final DomAttr entry : element.getAttributesMap().values()) {
        final String name = entry.getName();
        final String value = entry.getValue();
        attributes.addAttribute(null, name, name, null, value);
    }

    return attributes;
}

From source file:com.jkoolcloud.tnt4j.streams.configure.sax.ConfigParserHandlerTest.java

@Test(expected = SAXParseException.class)
public void processParamNameExceptionTest() throws Exception {
    ConfigParserHandler test = Mockito.mock(ConfigParserHandler.class, Mockito.CALLS_REAL_METHODS);
    test.startDocument();//from   w w  w . j  ava 2s.c o  m
    AttributesImpl attrs = new AttributesImpl();
    attrs.addAttribute("", "", "name", "", "Stream name value"); // NON-NLS
    attrs.addAttribute("", "", "source", "", "Stream source value"); // NON-NLS
    attrs.addAttribute("", "", "target", "", "Stream target value"); // NON-NLS
    attrs.addAttribute("", "", "value", "", ""); // NON-NLS
    attrs.addAttribute("", "", "class", "", "com.jkoolcloud.tnt4j.streams.parsers.ActivityTokenParser"); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "parser", attrs); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "field", attrs); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "java-object", attrs); // NON-NLS
    attrs.addAttribute("", "", "type", "", "java.lang.String"); // NON-NLS
    attrs.addAttribute("", "", "name", "", ""); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "param", attrs); // NON-NLS
}

From source file:com.jkoolcloud.tnt4j.streams.configure.sax.ConfigParserHandlerTest.java

@Test(expected = SAXParseException.class)
public void processParamEmptyTypeExceptionTest() throws Exception {
    ConfigParserHandler test = Mockito.mock(ConfigParserHandler.class, Mockito.CALLS_REAL_METHODS);
    test.startDocument();//from  www.  ja va 2s .co  m
    AttributesImpl attrs = new AttributesImpl();
    attrs.addAttribute("", "", "name", "", "Stream name value"); // NON-NLS
    attrs.addAttribute("", "", "source", "", "Stream source value"); // NON-NLS
    attrs.addAttribute("", "", "target", "", "Stream target value"); // NON-NLS
    attrs.addAttribute("", "", "value", "", ""); // NON-NLS
    attrs.addAttribute("", "", "class", "", "com.jkoolcloud.tnt4j.streams.parsers.ActivityTokenParser"); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "parser", attrs); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "field", attrs); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "java-object", attrs); // NON-NLS
    attrs.addAttribute("", "", "type", "", ""); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "param", attrs); // NON-NLS
}

From source file:com.jkoolcloud.tnt4j.streams.configure.sax.ConfigParserHandlerTest.java

@Test
public void processParamEmptyValueExceptionTest() throws Exception {
    ConfigParserHandler test = Mockito.mock(ConfigParserHandler.class, Mockito.CALLS_REAL_METHODS);
    test.startDocument();/*from   w  w  w . j  ava 2 s .  co  m*/
    AttributesImpl attrs = new AttributesImpl();
    attrs.addAttribute("", "", "name", "", "Stream name value"); // NON-NLS
    attrs.addAttribute("", "", "source", "", "Stream source value"); // NON-NLS
    attrs.addAttribute("", "", "target", "", "Stream target value"); // NON-NLS
    attrs.addAttribute("", "", "value", "", ""); // NON-NLS
    attrs.addAttribute("", "", "class", "", "com.jkoolcloud.tnt4j.streams.parsers.ActivityTokenParser"); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "parser", attrs); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "field", attrs); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "java-object", attrs); // NON-NLS
    attrs.addAttribute("", "", "type", "", "java.lang.String"); // NON-NLS
    attrs.addAttribute("", "", "value", "", ""); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "param", attrs); // NON-NLS
}

From source file:gov.va.vinci.leo.descriptors.LeoAEDescriptor.java

/**
 * Generate the XML for the analysisEngine section of the deployment descriptor.
 *
 * @param thd    the xml transform handler.
 * @param isTopDescriptor   true if this is a top level descriptor, else false.
 * @throws SAXException  if there is no descriptor to output
 * @return this Leo AE Descriptor//from w  ww . j a  v a2s .  c  o  m
 */

public LeoAEDescriptor analysisEngineSection(TransformerHandler thd, boolean isTopDescriptor)
        throws SAXException {
    //validate we have something to output
    if (this.mAEDescriptor == null)
        throw new MissingResourceException("No Descriptor available for XML output",
                AnalysisEngineDescription.class.getCanonicalName(), "mAEDescriptor");

    AttributesImpl atts = new AttributesImpl();
    //<analysisEngine>
    if (!isTopDescriptor)
        atts.addAttribute("", "", "key", "CDATA", mAEDescriptor.getMetaData().getName());
    if (mIsAsync) {
        atts.addAttribute("", "", "async", "CDATA", "true");
    } else {
        atts.addAttribute("", "", "async", "CDATA", "false");
    } //else

    atts.addAttribute("", "", "async", "CDATA", Boolean.toString(mIsAsync));
    thd.startElement("", "", "analysisEngine", atts);
    atts.clear();

    //<scaleout .../>
    atts.addAttribute("", "", "numberOfInstances", "CDATA", Integer.toString(mNumberOfInstances));
    thd.startElement("", "", "scaleout", atts);
    thd.endElement("", "", "scaleout");
    atts.clear();

    //Handle delegate tags for aggregate engines
    if (this.isAggregate() && mIsAsync) {
        //<delegates>
        thd.startElement("", "", "delegates", atts);

        //output all the delegate engines
        for (LeoDelegate delegate : mDelegates) {
            delegate.analysisEngineSection(thd, false);
        } //for

        //</delegates>
        thd.endElement("", "", "delegates");
    } //if

    //<asyncPrimitiveErrorConfiguration> or <asyncAggregateErrorConfiguration>
    if (isTopDescriptor)
        thd.startElement("", "", "asyncPrimitiveErrorConfiguration", atts);
    else
        thd.startElement("", "", "asyncAggregateErrorConfiguration", atts);

    //<getMetadataErrors .../>
    if (!isTopDescriptor) {
        atts.addAttribute("", "", "maxRetries", "CDATA", "0");
        atts.addAttribute("", "", "timeout", "CDATA", "0");
        atts.addAttribute("", "", "errorAction", "CDATA", "terminate");
        thd.startElement("", "", "getMetadataErrors", atts);
        thd.endElement("", "", "getMetadataErrors");
        atts.clear();
    } //if

    //<processCasErrors .../>
    atts.addAttribute("", "", "thresholdCount", "CDATA", "0");
    atts.addAttribute("", "", "thresholdWindow", "CDATA", "0");
    atts.addAttribute("", "", "thresholdAction", "CDATA", "terminate");
    thd.startElement("", "", "processCasErrors", atts);
    thd.endElement("", "", "processCasErrors");
    atts.clear();

    //<collectionProcessCompleteErrors .../>
    atts.addAttribute("", "", "timeout", "CDATA", "0");
    atts.addAttribute("", "", "additionalErrorAction", "CDATA", "terminate");
    thd.startElement("", "", "collectionProcessCompleteErrors", atts);
    thd.endElement("", "", "collectionProcessCompleteErrors");
    atts.clear();

    //</asyncPrimitiveErrorConfiguration> or <asyncAggregateErrorConfiguration>
    if (isTopDescriptor)
        thd.endElement("", "", "asyncPrimitiveErrorConfiguration");
    else
        thd.endElement("", "", "asyncAggregateErrorConfiguration");

    //</analysisEngine>
    thd.endElement("", "", "analysisEngine");
    return this;
}

From source file:com.jkoolcloud.tnt4j.streams.configure.sax.ConfigParserHandlerTest.java

@Test(expected = SAXParseException.class)
public void processTnt4jPropertiesExceptionTest() throws Exception {
    ConfigParserHandler test = Mockito.mock(ConfigParserHandler.class, Mockito.CALLS_REAL_METHODS);
    test.startDocument();/*from  w  w  w .  j av  a 2s  . c o m*/
    AttributesImpl attrs = new AttributesImpl();
    attrs.addAttribute("", "", "name", "", "Stream name value"); // NON-NLS
    attrs.addAttribute("", "", "source", "", "Stream source value"); // NON-NLS
    attrs.addAttribute("", "", "target", "", "Stream target value"); // NON-NLS
    attrs.addAttribute("", "", "value", "", ""); // NON-NLS
    attrs.addAttribute("", "", "class", "", "com.jkoolcloud.tnt4j.streams.parsers.ActivityTokenParser"); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "parser", attrs); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "field", attrs); // NON-NLS
    attrs.addAttribute("", "", "class", "", "com.jkoolcloud.tnt4j.streams.inputs.RedirectTNT4JStream"); // NON-NLS
    test.startElement("TEST_URL", "TEST_LOCALNAME", "stream", attrs); // NON-NLS
    test.currStream = null;
    test.startElement("TEST_URL", "TEST_LOCALNAME", "tnt4j-properties", attrs); // NON-NLS
}