net.sourceforge.wurfl.core.resource
Class XMLResource

java.lang.Object
  extended by net.sourceforge.wurfl.core.resource.XMLResource
All Implemented Interfaces:
WURFLResource

public class XMLResource
extends Object
implements WURFLResource

XMLResource

XMLResource represent a source of wurfl repository backed by XML file. XML file can be root file or patch. The XML file can be compresses by gzip or zip. In case of zip, the first entry will be processed.

The given path can be URL or filesystem path. The URL support classpath scheme to load file from java classpath.

Version:
$Id: XMLResource.java 432 2010-05-06 12:12:53Z filippo.deluca $
Author:
Fantayeneh Asres Gizaw, Filippo De Luca

Constructor Summary
XMLResource(File file)
          Build resource by File.
XMLResource(InputStream stream)
          Build resource by InputStream.
XMLResource(String path)
          Build Resource by path.
XMLResource(URI uri)
          Build resource by URI.
 
Method Summary
static URI createURI(String path)
          Creates a URI from the given String.
 ResourceData getData()
          Return ResourceData representing the data contained by the resource.
 String getInfo()
          Get info of this resource.
 boolean isReloadable()
          Return if this resource can be reloaded.
protected  InputStream openInputStream(URI uri)
          Opens the InputStream by giving URI.
protected  ResourceData readData(InputStream input)
          Read the ResourceData from given stream.
 void release()
          Release the resource.
static URI toURI(String location)
          Deprecated. use createURI(String)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLResource

public XMLResource(String path)
Build Resource by path. The path can be URI or filesystem path.

Parameters:
path - The path of source file.

XMLResource

public XMLResource(File file)
Build resource by File.

Parameters:
file - The source File

XMLResource

public XMLResource(URI uri)
Build resource by URI. It handle the 'classpath' schema also.

Parameters:
uri - The source URI

XMLResource

public XMLResource(InputStream stream)
Build resource by InputStream. The builded resource can be reloadable only if the given stream is resettable (the maskSupported method returns true).

Parameters:
stream - The source stream.
Method Detail

getData

public ResourceData getData()
Return ResourceData representing the data contained by the resource.

Specified by:
getData in interface WURFLResource
Returns:
ResourceData instance

getInfo

public String getInfo()
Get info of this resource.

If this resource is created using InputStream, the info will return Stream resource'.

Specified by:
getInfo in interface WURFLResource
Returns:
A String represent a info for this resource.

release

public void release()
Release the resource.

Specified by:
release in interface WURFLResource

isReloadable

public boolean isReloadable()
Return if this resource can be reloaded.

Returns:
true if can be reloaded, false otherwise.

createURI

public static URI createURI(String path)
                     throws URISyntaxException
Creates a URI from the given String. If the path can be an URI representation or a filesystem path. It handle the Windows path also.

Throws:
URISyntaxException

toURI

public static URI toURI(String location)
                 throws URISyntaxException
Deprecated. use createURI(String)

Convert spaces to "%20"

Parameters:
location - Location to convert.
Returns:
converted location.
Throws:
URISyntaxException

openInputStream

protected InputStream openInputStream(URI uri)
Opens the InputStream by giving URI. The given URI support the 'classpath' schema also.

Parameters:
uri - The given URI
Returns:
The InputStream opened from the given URI

readData

protected ResourceData readData(InputStream input)
Read the ResourceData from given stream.

Parameters:
input - The stream to read data from.
Returns:
Read ResourceData.


Copyright © 2008-2010 WURFL-Pro srl. All Rights Reserved.