Package org.mycore.common.xml
Class MCRXMLResource
java.lang.Object
org.mycore.common.xml.MCRXMLResource
provides a cache for reading XML resources.
Cache size can be configured by property
MCR.MCRXMLResouce.Cache.Size
which defaults to 100
.- Author:
- Thomas Scheffler (yagee)
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
exists
(String name, ClassLoader classLoader) long
getLastModified
(String name, ClassLoader classLoader) getModifiedHandle
(String name, ClassLoader classLoader, long checkPeriod) byte[]
getRawResource
(String name) returns xml as byte array using ClassLoader of MCRXMLResource classbyte[]
getRawResource
(String name, ClassLoader classLoader) Returns raw XML resource as byte array.getResource
(String name) Returns MCRContent using ClassLoader of MCRXMLResource classgetResource
(String name, ClassLoader classLoader) Returns MCRContent of resource.getURL
(String name, ClassLoader classLoader) static MCRXMLResource
instance()
-
Method Details
-
instance
- Returns:
- singleton instance
-
getURL
- Throws:
IOException
-
getURL
- Throws:
IOException
-
getResource
Returns MCRContent using ClassLoader of MCRXMLResource class- Parameters:
name
- resource name- Throws:
IOException
JDOMException
- See Also:
-
getRawResource
returns xml as byte array using ClassLoader of MCRXMLResource class- Parameters:
name
- resource name- Throws:
IOException
- See Also:
-
getResource
Returns MCRContent of resource. A cache is used to avoid reparsing if the source of the resource did not change.- Parameters:
name
- the resource nameclassLoader
- a ClassLoader that should be used to locate the resource- Returns:
- a parsed Document of the resource or
null
if the resource is not found - Throws:
IOException
- if resource cannot be loaded
-
getModifiedHandle
public MCRXMLResource.ResourceModifiedHandle getModifiedHandle(String name, ClassLoader classLoader, long checkPeriod) -
getRawResource
Returns raw XML resource as byte array. Note that no cache will be used.- Parameters:
name
- the resource nameclassLoader
- a ClassLoader that should be used to locate the resource- Returns:
- unparsed xml of the resource or
null
if the resource is not found - Throws:
IOException
- if resource cannot be loaded
-
getLastModified
- Throws:
IOException
-
exists
- Throws:
IOException
-