public final class PackagingURIHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static PackagePartName |
CORE_PROPERTIES_PART_NAME
Core properties partname.
|
static java.net.URI |
CORE_PROPERTIES_URI
Core properties part URI.
|
static char |
FORWARD_SLASH_CHAR
Forward slash URI separator.
|
static java.lang.String |
FORWARD_SLASH_STRING
Forward slash URI separator.
|
static java.lang.String |
PACKAGE_CORE_PROPERTIES_NAME
Core package properties art name.
|
static java.lang.String |
PACKAGE_PROPERTIES_SEGMENT_NAME
Segment name of the package properties folder.
|
static PackagePartName |
PACKAGE_RELATIONSHIPS_ROOT_PART_NAME
Package relationships part name.
|
static java.net.URI |
PACKAGE_RELATIONSHIPS_ROOT_URI
Package relationships part URI
|
static PackagePartName |
PACKAGE_ROOT_PART_NAME
Root package part name.
|
static java.net.URI |
PACKAGE_ROOT_URI
Root package URI.
|
static java.lang.String |
RELATIONSHIP_PART_EXTENSION_NAME
Extension name of a relationship part.
|
static java.lang.String |
RELATIONSHIP_PART_SEGMENT_NAME
Segment name of a relationship part.
|
Constructor and Description |
---|
PackagingURIHelper() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
combine(java.lang.String prefix,
java.lang.String suffix)
Combine a string URI with a prefix and a suffix.
|
static java.net.URI |
combine(java.net.URI prefix,
java.net.URI suffix)
Combine two URIs.
|
static PackagePartName |
createPartName(java.lang.String partName)
Create an OPC compliant part name.
|
static PackagePartName |
createPartName(java.lang.String partName,
PackagePart relativePart)
Create an OPC compliant part name by resolving it using a base part.
|
static PackagePartName |
createPartName(java.net.URI partUri)
Create an OPC compliant part name by throwing an exception if the URI is
not valid.
|
static PackagePartName |
createPartName(java.net.URI partName,
PackagePart relativePart)
Create an OPC compliant part name by resolving it using a base part.
|
static java.lang.String |
decodeURI(java.net.URI uri)
Decode a URI by converting all percent encoded character into a String
character.
|
static java.lang.String |
encode(java.lang.String s)
percent-encode white spaces and characters above 0x80.
|
static java.lang.String |
getFilename(java.net.URI uri)
Get file name from the specified URI.
|
static java.lang.String |
getFilenameWithoutExtension(java.net.URI uri)
Get the file name without the trailing extension.
|
static java.net.URI |
getPackageRootUri()
Gets the URI for the package root.
|
static java.net.URI |
getPath(java.net.URI uri)
Get the directory path from the specified URI.
|
static PackagePartName |
getRelationshipPartName(PackagePartName partName)
Build a part name where the relationship should be stored ((ex
/word/document.xml -> /word/_rels/document.xml.rels)
|
static java.net.URI |
getSourcePartUriFromRelationshipPartUri(java.net.URI relationshipPartUri)
Get the source part URI from a specified relationships part.
|
static java.net.URI |
getURIFromPath(java.lang.String path)
Get URI from a string path.
|
static boolean |
isRelationshipPartURI(java.net.URI partUri)
Know if the specified URI is a relationship part name.
|
static boolean |
isValidPartName(java.net.URI partUri)
Validate a part URI by returning a boolean.
|
static java.net.URI |
relativizeURI(java.net.URI sourceURI,
java.net.URI targetURI)
Fully relativize the source part URI against the target part URI.
|
static java.net.URI |
relativizeURI(java.net.URI sourceURI,
java.net.URI targetURI,
boolean msCompatible)
Fully relativize the source part URI against the target part URI.
|
static java.net.URI |
resolvePartUri(java.net.URI sourcePartUri,
java.net.URI targetUri)
Resolve a source uri against a target.
|
static java.net.URI |
toURI(java.lang.String value)
Convert a string to
URI
If part name is not a valid URI, it is resolved as follows:
1. |
public static final java.lang.String RELATIONSHIP_PART_EXTENSION_NAME
public static final java.lang.String RELATIONSHIP_PART_SEGMENT_NAME
public static final java.lang.String PACKAGE_PROPERTIES_SEGMENT_NAME
public static final java.lang.String PACKAGE_CORE_PROPERTIES_NAME
public static final char FORWARD_SLASH_CHAR
public static final java.lang.String FORWARD_SLASH_STRING
public static final java.net.URI PACKAGE_RELATIONSHIPS_ROOT_URI
public static final PackagePartName PACKAGE_RELATIONSHIPS_ROOT_PART_NAME
public static final java.net.URI CORE_PROPERTIES_URI
public static final PackagePartName CORE_PROPERTIES_PART_NAME
public static final java.net.URI PACKAGE_ROOT_URI
public static final PackagePartName PACKAGE_ROOT_PART_NAME
public static java.net.URI getPackageRootUri()
public static boolean isRelationshipPartURI(java.net.URI partUri)
partUri
- URI to check.public static java.lang.String getFilename(java.net.URI uri)
public static java.lang.String getFilenameWithoutExtension(java.net.URI uri)
public static java.net.URI getPath(java.net.URI uri)
public static java.net.URI combine(java.net.URI prefix, java.net.URI suffix)
prefix
- the prefix URIsuffix
- the suffix URIpublic static java.lang.String combine(java.lang.String prefix, java.lang.String suffix)
public static java.net.URI relativizeURI(java.net.URI sourceURI, java.net.URI targetURI, boolean msCompatible)
sourceURI
- The source part URI.targetURI
- The target part URI.msCompatible
- if true then remove leading slash from the relativized URI.
This flag violates [M1.4]: A part name shall start with a forward slash ('/') character, but
allows generating URIs compatible with MS Office and OpenOffice.null
.public static java.net.URI relativizeURI(java.net.URI sourceURI, java.net.URI targetURI)
sourceURI
- The source part URI.targetURI
- The target part URI.null
.public static java.net.URI resolvePartUri(java.net.URI sourcePartUri, java.net.URI targetUri)
sourcePartUri
- The source URI.targetUri
- The target URI.public static java.net.URI getURIFromPath(java.lang.String path)
public static java.net.URI getSourcePartUriFromRelationshipPartUri(java.net.URI relationshipPartUri)
relationshipPartUri
- The relationship part use to retrieve the source part.public static PackagePartName createPartName(java.net.URI partUri) throws InvalidFormatException
partUri
- The part name URI to validate.null
.InvalidFormatException
- Throws if the specified URI is not OPC compliant.public static PackagePartName createPartName(java.lang.String partName) throws InvalidFormatException
partName
- The part name to validate.null
.InvalidFormatException
- Throws if the specified part name is not OPC compliant.createPartName(URI)
public static PackagePartName createPartName(java.lang.String partName, PackagePart relativePart) throws InvalidFormatException
partName
- The part name to validate.relativePart
- The relative base part.null
.InvalidFormatException
- Throws if the specified part name is not OPC compliant.createPartName(URI)
public static PackagePartName createPartName(java.net.URI partName, PackagePart relativePart) throws InvalidFormatException
partName
- The part name URI to validate.relativePart
- The relative base part.null
.InvalidFormatException
- Throws if the specified part name is not OPC compliant.createPartName(URI)
public static boolean isValidPartName(java.net.URI partUri)
partUri
- The URI to validate.createPartName(URI)
public static java.lang.String decodeURI(java.net.URI uri)
uri
- The URI to decode.public static PackagePartName getRelationshipPartName(PackagePartName partName)
partName
- Source part URIInvalidOperationException
- Throws if the specified URI is a relationshp part.public static java.net.URI toURI(java.lang.String value) throws java.net.URISyntaxException
URI
If part name is not a valid URI, it is resolved as follows:
1. Percent-encode each open bracket ([) and close bracket (]). 2. Percent-encode each percent (%) character that is not followed by a hexadecimal notation of an octet value. 3. Un-percent-encode each percent-encoded unreserved character. 4. Un-percent-encode each forward slash (/) and back slash (\). 5. Convert all back slashes to forward slashes. 6. If present in a segment containing non-dot (?.?) characters, remove trailing dot (?.?) characters from each segment. 7. Replace each occurrence of multiple consecutive forward slashes (/) with a single forward slash. 8. If a single trailing forward slash (/) is present, remove that trailing forward slash. 9. Remove complete segments that consist of three or more dots. 10. Resolve the relative reference against the base URI of the part holding the Unicode string, as it is defined in ?5.2 of RFC 3986. The path component of the resulting absolute URI is the part name.
value
- the string to be parsed into a URIjava.net.URISyntaxException
public static java.lang.String encode(java.lang.String s)
Examples: 'Apache POI' --> 'Apache%20POI' 'Apache?POI' --> 'Apache%04%10POI'
s
- the string to encodeCopyright © 2005-2010 Potix Corporation. All Rights Reserved.