FileDocCategorySizeDatePackage
DomIndexable.javaAPI DocApache Lucene 2.1.03943Wed Feb 14 10:46:04 GMT 2007org.apache.lucene.gdata.search.analysis

DomIndexable

public class DomIndexable extends Indexable
Indexable implementation using the W3C Dom API and JAXP XPath engine
author
Simon Willnauer
param
- a subtype of {@link org.w3c.dom.Node} returned by the applyPath method
param
- a subtype of {@link org.apache.lucene.gdata.data.ServerBaseEntry}

Fields Summary
private final Document
document
private final XPath
xPath
Constructors Summary
public DomIndexable(I applyAble)

param
applyAble
throws
NotIndexableException

        super(applyAble);
        if (this.applyAble.getServiceConfig() == null)
            throw new NotIndexableException("ServiceConfig is not set");
        try {
            this.document = buildDomDocument();
        } catch (ParserConfigurationException e) {
            throw new NotIndexableException("Can not create document builder",
                    e);

        } catch (IOException e) {
            throw new NotIndexableException(
                    "IO Exception occurred while building indexable", e);

        } catch (SAXException e) {
            throw new NotIndexableException("Can not parse entry", e);

        }
        this.xPath = XPathFactory.newInstance().newXPath();

    
Methods Summary
public RapplyPath(java.lang.String expression)

see
org.apache.lucene.gdata.search.analysis.Indexable#applyPath(java.lang.String)


        return (R) this.xPath.evaluate(expression, this.document,
                XPathConstants.NODE);
    
private org.w3c.dom.DocumentbuildDomDocument()

        StringWriter stringWriter = new StringWriter();
        ExtensionProfile profile = this.applyAble.getServiceConfig()
                .getExtensionProfile();
        if (profile == null)
            throw new IllegalStateException("ExtensionProfile is not set");
        XmlWriter writer = new XmlWriter(stringWriter);
        this.applyAble.generateAtom(writer, profile);
        DocumentBuilder builder = DocumentBuilderFactory.newInstance()
                .newDocumentBuilder();
        return builder.parse(new InputSource(new StringReader(stringWriter
                .toString())));