Example usage for org.xml.sax Attributes toString

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

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:edu.uci.ics.jung.io.GraphMLReader.java

@SuppressWarnings("unchecked")
protected void createVertex(Attributes atts) throws SAXNotSupportedException {
    Map<String, String> vertex_atts = getAttributeMap(atts);
    String id = vertex_atts.remove("id");
    if (id == null)
        throw new SAXNotSupportedException("node attribute list missing " + "'id': " + atts.toString());
    V v = vertex_ids.getKey(id);//  w  w w.  j  a va 2 s  .co  m

    if (v == null) {
        if (vertex_factory != null)
            v = vertex_factory.create();
        else
            v = (V) id;
        vertex_ids.put(v, id);
        this.current_graph.addVertex(v);

        // put remaining attribute/value pairs in vertex_data
        addExtraData(vertex_atts, vertex_metadata, v);
    } else
        throw new SAXNotSupportedException("Node id \"" + id + " is a duplicate of an existing node ID");

    this.current_vertex = v;
}

From source file:edu.uci.ics.jung.io.GraphMLReader.java

protected void assignEdgeSourceTarget(E e, Attributes atts, Map<String, String> edge_atts)//, String id)
        throws SAXNotSupportedException {
    String source_id = edge_atts.remove("source");
    if (source_id == null)
        throw new SAXNotSupportedException("edge attribute list missing " + "'source': " + atts.toString());
    V source = vertex_ids.getKey(source_id);
    if (source == null)
        throw new SAXNotSupportedException(
                "specified 'source' attribute " + "\"" + source_id + "\" does not match any node ID");

    String target_id = edge_atts.remove("target");
    if (target_id == null)
        throw new SAXNotSupportedException("edge attribute list missing " + "'target': " + atts.toString());
    V target = vertex_ids.getKey(target_id);
    if (target == null)
        throw new SAXNotSupportedException(
                "specified 'target' attribute " + "\"" + target_id + "\" does not match any node ID");

    String directed = edge_atts.remove("directed");
    EdgeType edge_type;/*  w  w  w  .jav  a 2 s . c  o m*/
    if (directed == null)
        edge_type = default_edgetype;
    else if (directed.equals("true"))
        edge_type = EdgeType.DIRECTED;
    else if (directed.equals("false"))
        edge_type = EdgeType.UNDIRECTED;
    else
        throw new SAXNotSupportedException("Unrecognized edge direction specifier 'direction=\"" + directed
                + "\"': " + "source: " + source_id + ", target: " + target_id);

    if (current_graph instanceof Graph)
        ((Graph<V, E>) this.current_graph).addEdge(e, source, target, edge_type);
    else
        this.current_graph.addEdge(e, new Pair<V>(source, target));
}

From source file:org.betaconceptframework.astroboa.engine.jcr.io.contenthandler.ImportContentHandler.java

private boolean processOwner(Attributes atts) throws SAXException {

    ImportedEntity currentImportedEntity = cmsRepositoryEntityQueue.peek();

    if (currentImportedEntity == null) {
        throw new CmsException("No parent entity found for element 'owner' with attributes " + atts.toString());
    }/*from  w  w  w .  j av a2 s .  c  om*/

    if (currentImportedEntity.hasOwnerElement()) {
        RepositoryUser owner = createNewRepositoryUser(atts, CmsConstants.OWNER_ELEMENT_NAME);

        if (currentImportedEntity.getEntity() instanceof ContentObject) {
            ((ContentObject) currentImportedEntity.getEntity()).setOwner(owner);
        } else if (currentImportedEntity.getEntity() instanceof Topic) {
            ((Topic) currentImportedEntity.getEntity()).setOwner(owner);
        } else if (currentImportedEntity.getEntity() instanceof Space) {
            ((Space) currentImportedEntity.getEntity()).setOwner(owner);
        } else {
            logger.debug("Owner {} has not been assigned to parent entity {}", owner.toString(),
                    currentImportedEntity.getEntity());
        }

        pushEntity(CmsConstants.OWNER_ELEMENT_NAME, owner, atts);

        return true;
    }

    return false;
}

From source file:org.piraso.api.io.PirasoEntryReader.java

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    validateStopped();/*from w w w .  ja  va 2s .c  o m*/

    if (qName.equals("piraso")) {
        id = attributes.getValue("id");
        watchedAddr = attributes.getValue("watched-address");

        fireEntryReadStartedEvent(new EntryReadEvent(this, id, watchedAddr));
    } else if (qName.equals("entry")) {
        try {
            currentEntryClassName = attributes.getValue("class-name");
            currentEntryDate = mapper.readValue(attributes.getValue("date"), Date.class);
            currentEntryId = Long.valueOf(attributes.getValue("id"));
        } catch (Exception e) {
            LOG.warn(String.format("Unable to parse entry with attributes '%s'", attributes.toString()));

            currentEntryClassName = null;
            currentEntryDate = null;
            currentEntryId = null;
        }
    }
}