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.discursive.jccook.xml.bean.ReplaceRule.java

public void begin(Attributes attributes) throws Exception {
    Message message = (Message) digester.getRoot();

    String repl = attributes.getValue("search");
    String with = attributes.getValue("replace");
    String text = message.getText();

    String translated = StringUtils.replace(text, repl, with);
    message.setText(translated);//from  w w  w.  j a va  2  s  .  c o m
}

From source file:at.tuwien.minimee.registry.xml.PreservationActionServiceFactory.java

@Override
public Object createObject(Attributes arg0) throws Exception {
    PreservationActionService service = new PreservationActionService();
    String type = arg0.getValue("type");
    service.setMigration(!"emulation".equals(type));

    return service;
}

From source file:eu.scape_project.planning.xml.plan.OrdinalTransformerMappingFactory.java

@Override
public TargetValueObject createObject(Attributes arg0) throws Exception {
    TargetValueObject o = new TargetValueObject();
    o.setValue(Double.parseDouble(arg0.getValue("target")));
    return o;/*from  ww w .  j  ava 2  s .co  m*/
}

From source file:net.sf.jasperreports.engine.xml.JRPartFactory.java

protected PartEvaluationTime readEvaluationTime(Attributes atts) {
    PartEvaluationTime evaluationTime = null;
    String evaluationTimeAttr = atts.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime);
    if (evaluationTimeAttr != null) {
        if (evaluationTimeAttr.equals(PartEvaluationTimeType.GROUP.getName())) {
            String evaluationGroupAttr = atts.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup);
            evaluationTime = StandardPartEvaluationTime.forGroup(evaluationGroupAttr);
        } else {//from   www.j  a  v a2s .  c  om
            evaluationTime = StandardPartEvaluationTime.forType(evaluationTimeAttr);
        }
    }
    return evaluationTime;
}

From source file:net.sf.jasperreports.engine.xml.JRPropertyDigesterRule.java

@Override
public void begin(String namespace, String name, Attributes attributes) {
    JRPropertiesHolder propertiesHolder = (JRPropertiesHolder) digester.peek();
    String key = attributes.getValue(JRXmlConstants.ATTRIBUTE_name);
    String value = attributes.getValue(JRXmlConstants.ATTRIBUTE_value);
    propertiesHolder.getPropertiesMap().setProperty(key, value);
}

From source file:net.sf.jasperreports.engine.xml.JRBandFactory.java

@Override
public Object createObject(Attributes atts) {
    JRDesignBand band = new JRDesignBand();

    String height = atts.getValue(JRXmlConstants.ATTRIBUTE_height);
    if (height != null && height.length() > 0) {
        band.setHeight(Integer.parseInt(height));
    }/* w ww  . j  av  a 2s .  c o  m*/

    String isSplitAllowed = atts.getValue(JRXmlConstants.ATTRIBUTE_isSplitAllowed);
    if (isSplitAllowed != null && isSplitAllowed.length() > 0) {
        if (log.isWarnEnabled()) {
            log.warn("The 'isSplitAllowed' attribute is deprecated. Use the 'splitType' attribute instead.");
        }

        if (Boolean.valueOf(isSplitAllowed)) {
            band.setSplitType(SplitTypeEnum.STRETCH);
        } else {
            band.setSplitType(SplitTypeEnum.PREVENT);
        }
    }

    SplitTypeEnum splitType = SplitTypeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_splitType));
    if (splitType != null) {
        band.setSplitType(splitType);
    }

    return band;
}

From source file:com.notesrender.templatej.TemplateProcessor.java

private void processStartTemplateTag(Attributes attrs) {
    _ref = attrs.getValue(_ATTR_REF);
    _out = attrs.getValue(_ATTR_OUT);
}

From source file:com.w20e.socrates.workflow.ActionFactory.java

/**
 * Create a new ProcessAction.//www  . j  a  v  a  2  s .c om
 * 
 * @param attrs
 *            the attributes on this element.
 * @return an new ProcessAction
 * @exception Exception
 *                if the action has no class attribute or no id attribute.
 */
public final Object createObject(final Attributes attrs) throws Exception {

    if (actions.containsKey(attrs.getValue("idref"))) {
        return ActionFactory.getAction(attrs.getValue("idref"));
    }

    if (attrs.getValue("class") == null || attrs.getValue("id") == null || "".equals(attrs.getValue("class"))
            || "".equals(attrs.getValue("id"))) {
        throw new Exception("No class or id specified!");
    }

    final Class<?>[] args = { Class.forName(String.class.getName()) };

    final Constructor<?> constr = Class.forName(attrs.getValue("class")).getConstructor(args);

    final Object[] objArgs = { attrs.getValue("id") };

    final ProcessAction action = (ProcessAction) constr.newInstance(objArgs);

    actions.put(action.getId(), action);

    return action;
}

From source file:com.acciente.induction.init.config.xmlconfigloader.IncludeConfigRule.java

public void begin(String sNamespace, String sName, Attributes oAttributes) throws XMLConfigLoaderException {
    String sConfigResourceName = oAttributes.getValue(Config_LoadConfig_Resource);
    InputStream oResourceStream = null;

    if (sConfigResourceName == null) {
        throw new XMLConfigLoaderException("config > load-config > a value must be specified for attribute > "
                + Config_LoadConfig_Resource);
    }//  ww  w .  j av  a 2 s.  c  o  m

    try {
        oResourceStream = _oResourceLoader.getResourceAsStream(sConfigResourceName);

        if (oResourceStream == null) {
            throw new XMLConfigLoaderException(
                    "config > load-config > " + sConfigResourceName + " > open error");
        }

        // cumulate the "included" configuration into _oConfig
        DigesterFactory.getDigester(_oConfig, _oResourceLoader).parse(oResourceStream);
    } catch (IOException e) {
        throw new XMLConfigLoaderException("config > load-config > I/O error > " + sConfigResourceName, e);
    } catch (SAXException e) {
        throw new XMLConfigLoaderException("config > load-config> XML parse error > " + sConfigResourceName, e);
    } finally {
        try {
            if (oResourceStream != null) {
                oResourceStream.close();
            }
        } catch (IOException e) {
            throw new XMLConfigLoaderException(
                    "config > load-config > error closing resource > " + sConfigResourceName + "", e);
        }
    }
}

From source file:cucumber.templates.xml.PropertyElementFactory.java

/**
 * <p>Factory method called by {@link org.apache.commons.digester.FactoryCreateRule} to supply an
 * object based on the element's attributes.
 *
 * @param attributes the element's attributes
 * @throws Exception any exception thrown will be propagated upwards
 *///from  w  w  w. j  a  va2s . c  om
@Override
public Object createObject(@NotNull final Attributes attributes) throws Exception {
    final @Nullable String t_strName = attributes.getValue("name");

    return new PropertyElement(t_strName);
}