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.npower.dm.setup.task.digester.ModelItemObjectCreationFactory.java

public Object createObject(Attributes attributes) throws Exception {
    ModelItem result = new ModelItem();

    String familyID = attributes.getValue("family");
    if (StringUtils.isNotEmpty(familyID)) {
        familyID = familyID.trim();/*from ww  w.  ja v a2s .  c o  m*/
        ModelFamilyManager manager = ModelFamilyManager.getInstance();
        ModelFamilyItem family = manager.findModelFamily(familyID);
        if (family != null) {
            PropertyUtils.copyProperties(result, family);

            List<String> cpTemplatesFiles = new ArrayList<String>();
            cpTemplatesFiles.addAll(family.getCpTemplatesFiles());
            result.setCpTemplatesFiles(cpTemplatesFiles);

            List<String> ddfFiles = new ArrayList<String>();
            ddfFiles.addAll(family.getDdfFiles());
            result.setDdfFiles(ddfFiles);

            List<FirmwareItem> firmwares = new ArrayList<FirmwareItem>();
            firmwares.addAll(family.getFirmwares());
            result.setFirmwares(firmwares);

            List<String> profileMappingFiles = new ArrayList<String>();
            profileMappingFiles.addAll(family.getProfileMappingFiles());
            result.setProfileMappingFiles(profileMappingFiles);

            Map<String, String> specifications = new LinkedHashMap<String, String>();
            specifications.putAll(family.getSpecifications());
            result.setSpecifications(specifications);

            List<String> tacs = new ArrayList<String>();
            tacs.addAll(family.getTacs());
            result.setTacs(tacs);
        }
        result.setFamilyID(familyID);
    }
    return result;
}

From source file:com.npower.dm.setup.task.digester.ModelFamilyItemObjectCreationFactory.java

public Object createObject(Attributes attributes) throws Exception {
    ModelFamilyItem result = new ModelFamilyItem();
    String parentID = attributes.getValue("parent");
    if (StringUtils.isNotEmpty(parentID)) {
        parentID = parentID.trim();/* www.  ja va  2  s.c o  m*/
        ModelFamilyManager manager = ModelFamilyManager.getInstance();
        ModelFamilyItem family = manager.findModelFamily(parentID);
        if (family != null) {
            PropertyUtils.copyProperties(result, family);

            List<String> cpTemplatesFiles = new ArrayList<String>();
            cpTemplatesFiles.addAll(family.getCpTemplatesFiles());
            result.setCpTemplatesFiles(cpTemplatesFiles);

            List<String> ddfFiles = new ArrayList<String>();
            ddfFiles.addAll(family.getDdfFiles());
            result.setDdfFiles(ddfFiles);

            List<FirmwareItem> firmwares = new ArrayList<FirmwareItem>();
            firmwares.addAll(family.getFirmwares());
            result.setFirmwares(firmwares);

            List<String> profileMappingFiles = new ArrayList<String>();
            profileMappingFiles.addAll(family.getProfileMappingFiles());
            result.setProfileMappingFiles(profileMappingFiles);

            Map<String, String> specifications = new LinkedHashMap<String, String>();
            specifications.putAll(family.getSpecifications());
            result.setSpecifications(specifications);

            List<String> tacs = new ArrayList<String>();
            tacs.addAll(family.getTacs());
            result.setTacs(tacs);

        }
        result.setParentID(parentID);
    }
    return result;
}

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

public void start(Attributes attrs) {
    // store the osisRef attribute for use with the note
    String target = attrs.getValue(OSISUtil.OSIS_ATTR_REF);
    start(target);// ww w.  j a  v  a  2 s.co m
}

From source file:com.w20e.socrates.factories.GroupFactory.java

/**
 * Create WoliWeb specific <code>ItemWrapper</code>s.
 * // ww w.  j  av a  2 s .c om
 * @author Duco Dokter
 * @param attrs
 *            Attributes of the items stumbled upon.
 * @throws Exception
 *             if stuff fails
 * @return an ItemWrapper
 */
public final Group createObject(final Attributes attrs) throws Exception {

    // Create group
    GroupImpl group;

    LOGGER.finer("Creating new group with id " + attrs.getValue("id"));

    if ("matrix".equals(attrs.getValue("layout"))) {
        group = new Matrix(attrs.getValue("id"));

    } else if ("grid".equals(attrs.getValue("layout"))) {
        group = new GridGroup(attrs.getValue("id"));

        LOGGER.finest("It's a grid!");

        try {
            LOGGER.finest("Setting cols to " + attrs.getValue("cols"));
            ((GridGroup) group).setCols(Integer.parseInt(attrs.getValue("cols")));
        } catch (Exception e) {
            LOGGER.severe("Didna happen");
            // no worries
        }
    } else if ("page".equals(attrs.getValue("layout"))) {
        group = new Page(attrs.getValue("id"));
    } else {
        // If it's nothing else, it's a flow.
        group = new FlowGroup(attrs.getValue("id"));

        if (attrs.getValue("orientation") != null) {
            try {
                ((FlowGroup) group).setOrientation(attrs.getValue("orientation"));

            } catch (Exception e) {
                LOGGER.fine("Couldn't set orientation for flowgroup");
                // no worries
            }
        }
    }

    return group;
}

From source file:com.xhsoft.framework.common.init.ConfigLoad.java

/**
 * <p>Description:</p>//ww w  .  j  a  v a2s .c om
 * @param namespaceURI   
 * @param localName  
 * @param rawName  
 * @param attrs  
 * @return String
 * @author wenzhi
 * @version 1.0
 * @exception SAXException
 */
public void startElement(String namespaceURI, String localName, String rawName, Attributes attrs)
        throws SAXException {
    /** ?config*/
    if (rawName.equals("config")) {
        String name = attrs.getValue("name");
        String value = attrs.getValue("value");
        if (name == null || value == null) {
            throw new SAXException("xml format error");
        }
        configMap.put(name, value);
    }
}

From source file:com.markhwood.jndi.EphemeralContext.objectProviders.CommonsDBCPDataSource.java

public Object interpret(String uri, String localName, String qName, Attributes attributes) {
    // FIXME where does wrapped datasource come in?
    GenericObjectPool connectionPool = new GenericObjectPool(null);
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(attributes.getValue("url"),
            attributes.getValue("user"), attributes.getValue("password"));
    PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,
            connectionPool, null, null, false, true);
    PoolingDataSource dataSource = new PoolingDataSource(connectionPool);
    return dataSource;
}

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

@Override
public Object createObject(Attributes atts) {
    JRDesignGraphicElement graphicElement = (JRDesignGraphicElement) digester.peek();

    StretchTypeEnum stretchType = StretchTypeEnum
            .getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_stretchType));
    if (stretchType != null) {
        if (log.isWarnEnabled()) {
            log.warn(/*  w w w  .  j  ava 2s  . co  m*/
                    "The 'stretchType' attribute in <graphicElement> tag is deprecated. Use the same attribut in <reportElement> tag instead.");
        }

        graphicElement.setStretchType(stretchType);
    }

    PenEnum pen = PenEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_pen));
    if (pen != null) {
        if (log.isWarnEnabled()) {
            log.warn("The 'pen' attribute is deprecated. Use the <pen> tag instead.");
        }

        JRPenUtil.setLinePenFromPen(pen, graphicElement.getLinePen());
    }

    FillEnum fill = FillEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_fill));
    if (fill != null) {
        graphicElement.setFill(fill);
    }

    return graphicElement;
}

From source file:com.alibaba.toolkit.util.configuration.digester.SetContextRule.java

/**
 * ?, context.//ww  w  .j ava2 s  .  c  om
 *
 * @param attributes XML
 * @throws Exception 
 */
@Override
public void begin(String namespace, String name, Attributes attributes) throws Exception {
    String context = null;

    if (attributeName != null) {
        context = attributes.getValue(attributeName);
    }

    if (context == null && getFactory() != null) {
        context = getFactory().getContext(attributes);
    }

    if (context != null) {
        if (digester.getLogger().isDebugEnabled()) {
            digester.getLogger().debug("[SetContextRule]{" + digester.getMatch() + "} New " + context);
        }

        ContextSensitiveRules rules = (ContextSensitiveRules) digester.getRules();

        rules.pushContext(context);
    }
}

From source file:com.mirth.connect.plugins.datatypes.edi.EDIXMLHandler.java

public void startElement(String uri, String name, String qName, Attributes atts) {
    if (sawHeader == false) {
        segmentDelimiter = atts.getValue("segmentDelimiter");
        elementDelimiter = atts.getValue("elementDelimiter");
        subelementDelimiter = atts.getValue("subelementDelimiter");

        if (segmentDelimiter == null) {
            segmentDelimiter = "~";
        }/*from  www.j ava  2  s.  com*/
        if (elementDelimiter == null) {
            elementDelimiter = "*";
        }
        if (subelementDelimiter == null) {
            subelementDelimiter = ":";
        }
        sawHeader = true;
    } else {
        if (currentLocation.equals(Location.DOCUMENT)) {
            output.append(name);
            currentLocation = Location.SEGMENT;
            lastInSubelement = false;

            previousSegmentNameArray = null;
        } else if (currentLocation.equals(Location.SEGMENT)) {
            String[] currentNameArray = StringUtils.split(name, ".");
            int currentDelimeterCount = currentNameArray.length - 1;

            if (currentDelimeterCount == 1) {
                int previousId = 0;

                if (previousSegmentNameArray != null) {
                    previousId = NumberUtils.toInt(previousSegmentNameArray[1]);
                }

                int currentId = NumberUtils.toInt(currentNameArray[1]);

                for (int i = 1; i < (currentId - previousId); i++) {
                    output.append(elementDelimiter);
                }

                previousSegmentNameArray = currentNameArray;
            }

            output.append(elementDelimiter);
            currentLocation = Location.ELEMENT;
            lastInSubelement = false;

            previousElementNameArray = null;
        } else if (currentLocation.equals(Location.ELEMENT)) {
            String[] currentNameArray = StringUtils.split(name, ".");
            int currentDelimeterCount = currentNameArray.length - 1;

            if (currentDelimeterCount == 2) {
                int previousId = 0;

                if (previousElementNameArray != null) {
                    previousId = NumberUtils.toInt(previousElementNameArray[2]);
                }

                int currentId = NumberUtils.toInt(currentNameArray[2]);

                for (int i = 1; i < (currentId - previousId); i++) {
                    output.append(subelementDelimiter);
                }

                previousElementNameArray = currentNameArray;
            }

            if (lastInSubelement) {
                output.append(subelementDelimiter);
            }

            currentLocation = Location.SUBELEMENT;
            lastInSubelement = true;
        }
    }
}

From source file:com.panet.imeta.core.config.KettleConfig.java

private Digester createDigester() {
    Digester digester = new Digester();
    digester.addObjectCreate(KETTLE_CONFIG, TempConfig.class);
    digester.addBeanPropertySetter(KETTLE_CONFIG_CLASS, "clazz");
    digester.addSetProperties(KETTLE_CONFIG, "id", "id");
    digester.addRule(KETTLE_CONFIG_PROPERTY, new SetPropertiesRule() {
        @Override//from w  w  w . ja  v  a  2s  .  c  om
        public void begin(String name, String namespace, Attributes attrs) throws Exception {
            ((TempConfig) digester.peek()).parms.put(attrs.getValue("name"), attrs.getValue("value"));
        }
    });

    digester.addRule(KETTLE_CONFIG, new SetNextRule("") {
        @SuppressWarnings("unchecked")
        public void end(String nameSpace, String name) throws Exception {
            TempConfig cfg = (TempConfig) digester.peek();

            // do the conversion here.
            Class<? extends ConfigManager> cfclass = Class.forName(cfg.clazz).asSubclass(ConfigManager.class);

            ConfigManager parms = cfclass.newInstance();
            // method injection
            inject(cfclass.getMethods(), cfg, parms);
            // field injection
            inject(cfclass.getDeclaredFields(), cfg, parms);
            KettleConfig.this.configs.put(cfg.id, parms);
        }
    });

    return digester;
}