-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FORGE-2438: Introduces AbstractXMLResource
- Loading branch information
Showing
3 changed files
with
55 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...xml/api/src/main/java/org/jboss/forge/addon/parser/xml/resources/AbstractXMLResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.addon.parser.xml.resources; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.jboss.forge.addon.resource.AbstractFileResource; | ||
import org.jboss.forge.addon.resource.Resource; | ||
import org.jboss.forge.addon.resource.ResourceFactory; | ||
import org.jboss.forge.parser.xml.Node; | ||
import org.jboss.forge.parser.xml.XMLParser; | ||
|
||
/** | ||
* Created abstract class for {@link XMLResource} | ||
* | ||
* @author <a href="mailto:ggastald@redhat.com">George Gastaldi</a> | ||
*/ | ||
public abstract class AbstractXMLResource extends AbstractFileResource<XMLResource>implements XMLResource | ||
{ | ||
public AbstractXMLResource(final ResourceFactory factory, final File file) | ||
{ | ||
super(factory, file); | ||
} | ||
|
||
@Override | ||
public XMLResource setContents(Node node) | ||
{ | ||
setContents(XMLParser.toXMLString(node)); | ||
return this; | ||
} | ||
|
||
@Override | ||
public Node getXmlSource() throws FileNotFoundException | ||
{ | ||
return XMLParser.parse(getResourceInputStream()); | ||
} | ||
|
||
@Override | ||
protected List<Resource<?>> doListResources() | ||
{ | ||
return Collections.emptyList(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters