Example usage for org.xml.sax Attributes getValue

List of usage examples for org.xml.sax Attributes getValue

Introduction

In this page you can find the example usage for org.xml.sax Attributes getValue.

Prototype

public abstract String getValue(String qName);

Source Link

Document

Look up an attribute's value by XML qualified (prefixed) name.

Usage

From source file:com.bellman.bible.service.format.osistohtml.taghandler.TitleHandler.java

@Override
public void start(Attributes attrs) {
    //JSword adds the chapter no at the top but hide this because the chapter is in the Embedded Bible header
    boolean addedByJSword = attrs.getLength() == 1
            && OSISUtil.GENERATED_CONTENT.equals(attrs.getValue(OSISUtil.OSIS_ATTR_TYPE));
    // otherwise show if user wants Titles or the title is canonical
    isShowTitle = !addedByJSword && (parameters.isShowTitles()
            || "true".equalsIgnoreCase(attrs.getValue(OSISUtil.OSIS_ATTR_CANONICAL)));

    if (isShowTitle) {
        // ESV has subType butcom.bellmantext has lower case subtype so concatenate both and search with contains()
        String subtype = attrs.getValue(OSISUtil.OSIS_ATTR_SUBTYPE)
                + attrs.getValue(OSISUtil.OSIS_ATTR_SUBTYPE.toLowerCase(Locale.ENGLISH));
        isMoveBeforeVerse = (StringUtils.containsIgnoreCase(subtype, PREVERSE)
                || (!verseInfo.isTextSinceVerse && verseInfo.currentVerseNo > 0));
        if (isMoveBeforeVerse) {
            // section Titles normally come before a verse, so overwrite the, already written verse, which is rewritten on writer.finishedInserting
            writer.beginInsertAt(verseInfo.positionToInsertBeforeVerse);
        }// www . j  a v a 2  s . co  m

        // get title type from level
        String titleClass = "heading" + TagHandlerHelper.getAttribute(OSISUtil.OSIS_ATTR_LEVEL, attrs, "1");

        writer.write("<h1 class='" + titleClass + "'>");
    } else {
        writer.setDontWrite(true);
    }
}

From source file:net.bible.service.format.osistohtml.taghandler.TitleHandler.java

@Override
public void start(Attributes attrs) {
    //JSword adds the chapter no at the top but hide this because the chapter is in the And Bible header
    boolean addedByJSword = attrs.getLength() == 1
            && OSISUtil.GENERATED_CONTENT.equals(attrs.getValue(OSISUtil.OSIS_ATTR_TYPE));
    // otherwise show if user wants Titles or the title is canonical
    isShowTitle = !addedByJSword && (parameters.isShowTitles()
            || "true".equalsIgnoreCase(attrs.getValue(OSISUtil.OSIS_ATTR_CANONICAL)));

    if (isShowTitle) {
        // ESV has subType butNETtext has lower case subtype so concatenate both and search with contains() 
        String subtype = attrs.getValue(OSISUtil.OSIS_ATTR_SUBTYPE)
                + attrs.getValue(OSISUtil.OSIS_ATTR_SUBTYPE.toLowerCase(Locale.ENGLISH));
        isMoveBeforeVerse = (StringUtils.containsIgnoreCase(subtype, PREVERSE)
                || (!verseInfo.isTextSinceVerse && verseInfo.currentVerseNo > 0));
        if (isMoveBeforeVerse) {
            // section Titles normally come before a verse, so overwrite the, already written verse, which is rewritten on writer.finishedInserting
            writer.beginInsertAt(verseInfo.positionToInsertBeforeVerse);
        }// w  ww . j  ava2  s. c  om

        // get title type from level
        String titleClass = "heading" + TagHandlerHelper.getAttribute(OSISUtil.OSIS_ATTR_LEVEL, attrs, "1");

        writer.write("<h1 class='" + titleClass + "'>");
    } else {
        writer.setDontWrite(true);
    }
}

From source file:com.truven.runtime.DataTablesParser.java

/**
 * Start element./*from ww w  .  j av  a2  s.  com*/
 * 
 * @param uri
 *            the url
 * @param localName
 *            the local name
 * @param qName
 *            the q name
 * @param attributes
 *            the attributes
 * @throws SAXException
 *             the SAX exception
 * @see 
 *      org.xml.sax.helpers.DefaultHandler#startElement(.String,.String,.String
 *      , org.xml.sax.Attributes)
 * @Override startElement in DefaultHandler Object.
 */
@Override
public final void startElement(final String uri, final String localName, final String qName,
        final Attributes attributes) throws SAXException {

    if ("TABLE".equalsIgnoreCase(qName)) {
        testDataTable = new DataTable();
        tables.put(attributes.getValue("name"), testDataTable);
        rowIndex = -1;
    } else if ("COLUMN".equalsIgnoreCase(qName)) {
        testDataTable.addColumn(attributes.getValue("name"));
        testDataTable.addDataTypes(attributes.getValue("type"));
    } else if ("ROW".equalsIgnoreCase(qName)) {
        rowIndex++;
        columnIndex = -1;
    } else if ("VALUE".equalsIgnoreCase(qName)) {
        columnIndex++;
        isValue = true;
    }

}

From source file:fr.lip6.move.coloane.projects.its.io.ModelHandler.java

private void handleFormula(Attributes attributes) {
    String name = attributes.getValue("name");
    String comment = attributes.getValue("description");
    String form = StringEscapeUtils.unescapeXml(attributes.getValue("formula"));
    CheckList cl = (CheckList) stack.peek();
    cl.addCTLFormula(name, form, comment);
}

From source file:net.sf.joost.instruction.MessageFactory.java

public NodeBase createNode(NodeBase parent, String qName, Attributes attrs, ParseContext context)
        throws SAXParseException {
    Tree selectExpr = parseExpr(attrs.getValue("select"), context);
    Tree terminateAVT = parseAVT(attrs.getValue("terminate"), context);
    int level = getEnumAttValue("level", attrs, LEVEL_VALUES, context);

    String loggerAtt = attrs.getValue("logger");

    // if one of 'level' or 'logger' is present, we need both
    if ((level != -1) ^ (loggerAtt != null))
        throw new SAXParseException(level != -1 ? "Missing 'logger' attribute when 'level' is present"
                : "Missing 'level' attribute when 'logger' is present", context.locator);

    checkAttributes(qName, attrs, attrNames, context);
    return new Instance(qName, parent, context, selectExpr, terminateAVT, level, loggerAtt);
}

From source file:com.florianmski.tracktoid.image.Fanart.java

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    if (localName.equals("fanart")) {
        urls = new ArrayList<String>();
    } else if (localName.equals(this.type)) {
        urls.add(attributes.getValue("url"));
    }/*from w w  w. jav  a 2  s  . c o m*/
}

From source file:catalina.startup.LifecycleListenerRule.java

/**
 * Handle the beginning of an XML element.
 *
 * @param attributes The attributes of this element
 *
 * @exception Exception if a processing error occurs
 *///from  w  w  w  . j  a  v  a2s  .  co  m
public void begin(Attributes attributes) throws Exception {

    // Instantiate a new LifecyleListener implementation object
    String className = listenerClass;
    if (attributeName != null) {
        String value = attributes.getValue(attributeName);
        if (value != null)
            className = value;
    }
    Class clazz = Class.forName(className);
    LifecycleListener listener = (LifecycleListener) clazz.newInstance();

    // Add this LifecycleListener to our associated component
    Lifecycle lifecycle = (Lifecycle) digester.peek();
    lifecycle.addLifecycleListener(listener);

}

From source file:net.ontopia.topicmaps.nav2.plugins.PluginContentHandler.java

@Override
public void startElement(String nsuri, String lname, String qname, Attributes attrs) throws SAXException {
    super.startElement(nsuri, lname, qname, attrs);

    if ("plugin".equals(qname)) {
        String klass = attrs.getValue("class");
        if (klass == null)
            cplugin = new DefaultPlugin();
        else/*from   w  w  w.jav  a 2 s.c om*/
            cplugin = createPlugin(klass);

        if (cplugin == null)
            return; // createPlugin may fail...

        cplugin.setId(attrs.getValue("id"));
        String str_groups = attrs.getValue("groups");
        // split group containing string into elements
        if (str_groups != null && !str_groups.equals("")) {
            String[] grpArray = StringUtils.split(str_groups, ",");
            List groups = new ArrayList(grpArray.length);
            for (int i = 0; i < grpArray.length; i++)
                groups.add(grpArray[i].trim());
            cplugin.setGroups(groups);
        }

    } else if ("parameter".equals(qname)) {
        param_name = attrs.getValue("name");
        if (attrs.getValue("value") != null)
            cplugin.setParameter(attrs.getValue("name"), attrs.getValue("value"));
    }
}

From source file:hydrograph.ui.engine.parsing.XMLHandler.java

/**
 * @param uri//from   w ww  .  ja  va 2 s  .c  om
 * @param localName
 * @param qName
 * @param attributes
 * @throws SAXException
 */
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    List<ParameterData> tempParammeterList;
    Matcher matcher = null;
    if (isComponent(qName)) {
        currentComponent = attributes.getValue(ID);
        List<ParameterData> emptyList = new ArrayList<>();
        componentRepo.getParammeterFactory().put(currentComponent, emptyList);
    }
    if (qName.equalsIgnoreCase(INSOCKET_TAG)) {
        storeInSocket(attributes);
    }

    if (attributes.getValue(VALUE) != null) {
        matcher = Pattern.compile(REGEX).matcher(attributes.getValue(VALUE));
        if (matcher.matches()) {
            tempParammeterList = componentRepo.getParammeterFactory().get(currentComponent);
            if (tempParammeterList != null) {
                if (StringUtils.equals(qName, PropertyNameConstants.PROPERTY_TAG.value())) {
                    tempParammeterList.add(new ParameterData(qName,
                            attributes.getValue(NAME) + "=" + attributes.getValue(VALUE)));
                } else
                    tempParammeterList.add(new ParameterData(qName, attributes.getValue(VALUE)));
            }
        }
    }
}

From source file:cn.afterturn.easypoi.excel.imports.sax.SheetHandler.java

@Override
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
    //   /*from w w w  .j a va  2  s. c o  m*/
    lastContents = "";
    if (COL.equals(name)) {
        String cellType = attributes.getValue(TYPE);
        if (STRING.equals(cellType)) {
            type = CellValueType.String;
            return;
        }
        if (BOOLEAN.equals(cellType)) {
            type = CellValueType.Boolean;
            return;
        }
        if (DATE.equals(cellType)) {
            type = CellValueType.Date;
            return;
        }
        if (INLINE_STR.equals(cellType)) {
            type = CellValueType.InlineStr;
            return;
        }
        if (FORMULA.equals(cellType)) {
            type = CellValueType.Formula;
            return;
        }
        if (NUMBER.equals(cellType)) {
            type = CellValueType.Number;
            return;
        }
        try {
            short nfId = (short) stylesTable.getCellXfAt(Integer.parseInt(attributes.getValue(STYLE)))
                    .getNumFmtId();
            String numberFormat = stylesTable.getNumberFormats().get(nfId).toUpperCase();
            if (StringUtils.isNotEmpty(numberFormat)) {
                if (numberFormat.contains("Y") || numberFormat.contains("M") || numberFormat.contains("D")
                        || numberFormat.contains("H") || numberFormat.contains("S")
                        || numberFormat.contains("") || numberFormat.contains("")
                        || numberFormat.contains("") || numberFormat.contains("")
                        || numberFormat.contains("") || numberFormat.contains("")) {
                    type = CellValueType.Date;
                    return;
                }
            }
        } catch (Exception e) {

        }
        // 
        type = CellValueType.Number;
    } else if (T_ELEMENT.equals(name)) {
        type = CellValueType.TElement;
    }

}