Package org.apache.cocoon.components.source.helpers

Examples of org.apache.cocoon.components.source.helpers.SourceProperty


        return null
    }

    public SourceProperty[] getSourceProperties(Source source) throws SourceException {

        SourceProperty property = getSourceProperty(source, this.propertynamespace, this.propertyname);
        if (property!=null)
            return new SourceProperty[]{property};
        return null;
    }
View Full Code Here


            throw new SourceException("Could not parse property", e);
        } finally {
            this.manager.release(parser);
        }

        return new SourceProperty(doc.getDocumentElement());
    }
View Full Code Here

                xml = pre+property.getValue().toString()+post;
                StringReader reader = new StringReader(xml);

                Document doc = parser.parseDocument(new InputSource(reader));

                SourceProperty srcProperty = new SourceProperty(doc.getDocumentElement());

                sourceproperties.addElement(srcProperty);
            }
        } catch (Exception e) {
            throw new SourceException("Could not parse property "+xml, e);
View Full Code Here

     * Get the source property on the wrapped source. If the wrapped source implements
     * InspectableSource the implementation will first try to get it from there.
     * If it doesn't exist on the delegate it will try to find it using the source descriptor.
     */
    public SourceProperty getSourceProperty(String uri, String name) throws SourceException {
        SourceProperty property = null;
        if (m_delegate instanceof InspectableSource) {
            property = ((InspectableSource) m_delegate).getSourceProperty(uri,name);
        }
        if (property == null) {
            property = m_descriptor.getSourceProperty(m_delegate,uri,name);
View Full Code Here

        while (properties.hasNext()) {
            String property = (String) properties.next();
            int index = property.indexOf('#');
            String namespace = property.substring(0,index);
            String name      = property.substring(index+1);
            SourceProperty sp = getSourceProperty(source,namespace,name);
            if (sp != null) {
                result.add(sp);
            }
        }
        return (SourceProperty[]) result.toArray(new SourceProperty[result.size()]);
View Full Code Here

    public final SourceProperty getSourceProperty(Source source, String namespace, String name)
        throws SourceException {

        if (handlesProperty(namespace,name) && isImageMimeType(source) && isImageFileType(source)) {
            if (name.equals(IMAGE_WIDTH_PROPERTY_NAME))
                return new SourceProperty(PROPERTY_NS, IMAGE_WIDTH_PROPERTY_NAME,
                                          String.valueOf(getImageSize(source)[0]));
            if (name.equals(IMAGE_HEIGHT_PROPERTY_NAME))
                return new SourceProperty(PROPERTY_NS, IMAGE_HEIGHT_PROPERTY_NAME,
                                          String.valueOf(getImageSize(source)[1]));
        }
        return null;
    }
View Full Code Here

   
    public final SourceProperty[] getSourceProperties(Source source) throws SourceException {
        if (isImageMimeType(source) && isImageFileType(source)) {
            int[] size = getImageSize(source);
            return new SourceProperty[] {
                new SourceProperty(PROPERTY_NS, IMAGE_WIDTH_PROPERTY_NAME, String.valueOf(size[0])),
                new SourceProperty(PROPERTY_NS, IMAGE_HEIGHT_PROPERTY_NAME, String.valueOf(size[1]))
            };
        }
        return null;
    }
View Full Code Here

    throws ProcessingException, IOException, SAXException {
        if (src != null && element != null) {
            try {
                Source source = this.resolver.resolveURI(src);
                if (source instanceof InspectableSource) {
                    SourceProperty property = new SourceProperty(element);
                    ((InspectableSource)source).setSourceProperty(property);

                } else {
                    this.getLogger().error("Cannot set properties on " + src +
                                           ": not an inspectable source");
View Full Code Here

    private void pushSourceProperties(InspectableSource source)
        throws SAXException, SourceException {
       
        SourceProperty[] properties = source.getSourceProperties();
        if (properties != null && properties.length > 0) {
            SourceProperty property;
            AttributesImpl attributes = new AttributesImpl();
            this.contentHandler.startElement(URI, PROPERTIES_NODE_NAME,
                                             PROPERTIES_NODE_QNAME, attributes);
            for (int i = 0; i < properties.length; i++) {
                property = properties[i];
                this.contentHandler.startPrefixMapping("",property.getNamespace());
                property.toSAX(this.contentHandler);
                this.contentHandler.endPrefixMapping("");
            }
            this.contentHandler.endElement(URI, PROPERTIES_NODE_NAME,
                                           PROPERTIES_NODE_QNAME);
        }
View Full Code Here

     * @param source Source.
     */
    private void pushLiveSourceProperties(InspectableSource source)
      throws SAXException, SourceException {
        SourceProperty[] properties = source.getSourceProperties();
        SourceProperty property;

        AttributesImpl attributes = new AttributesImpl();

        attributes.addAttribute("", PROPERTY_TYPE_ATTR_NAME,
                                PROPERTY_TYPE_ATTR_NAME, "CDATA", "live");
        this.contentHandler.startElement(SOURCE_NS, PROPERTIES_NODE_NAME,
                                         PROPERTIES_NODE_QNAME, attributes);

        IncludeXMLConsumer consumer = new IncludeXMLConsumer(this.contentHandler);

        for (int i = 0; i<properties.length; i++) {
            property = properties[i];

            this.contentHandler.startPrefixMapping("",
                                                   property.getNamespace());
            property.toSAX(consumer);
            this.contentHandler.endPrefixMapping("");
        }

        this.contentHandler.endElement(SOURCE_NS, PROPERTIES_NODE_NAME,
                                       PROPERTIES_NODE_QNAME);
View Full Code Here

TOP

Related Classes of org.apache.cocoon.components.source.helpers.SourceProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.