Package org.docx4j.openpackaging
Class URIHelper
java.lang.Object
org.docx4j.openpackaging.URIHelper
Helper for part and pack URI.
- Version:
- 0.3
- Author:
- Julien Chable, CDubet
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PartNameCore properties partname.static final URICore properties part URI.static final charForward slash URI separator.static final StringForward slash URI separator.static final StringCore package properties art name.static final StringSegment name of the package properties folder.static final PartNamePackage relationships part name.static final URIPackage relationships part URIstatic final PartNameRoot package part name.static final URIRoot package URI.static final StringExtension name of a relationship part.static final StringSegment name of a relationship part. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringCombine a string URI with a prefix and a suffix.static URICombine two URI.static PartNamecreatePartName(String partName) Create an OPC compliant part name by throwing an exception if the specified name is not valid.static PartNamecreatePartName(URI partUri) Create an OPC compliant part name by throwing an exception if the URI is not valid.static StringDecode a URI by converting all percent encoded character into a String character.static StringgetFilename(URI uri) Get file name from the specified URI.static StringGet the file name without the trailing extension.static URIGets the URI for the package root.static URIGet the directory path from the specified URI.static URIgetSourcePartUriFromRelationshipPartUri(URI relationshipPartUri) static URIgetURIFromPath(String path) Get URI from a string path.static booleanisValidPartName(URI partUri) Validate a part URI by returning a boolean.static URIrelativizeURI(URI sourceURI, URI targetURI) Fully relativize the target part URI against the source part URI.static URIresolvePartUri(URI sourcePartUri, URI targetUri) Resolve a target uri against a source.
-
Field Details
-
RELATIONSHIP_PART_EXTENSION_NAME
Extension name of a relationship part. -
RELATIONSHIP_PART_SEGMENT_NAME
Segment name of a relationship part. -
PACKAGE_PROPERTIES_SEGMENT_NAME
Segment name of the package properties folder. -
PACKAGE_CORE_PROPERTIES_NAME
Core package properties art name. -
FORWARD_SLASH_CHAR
public static final char FORWARD_SLASH_CHARForward slash URI separator. -
FORWARD_SLASH_STRING
Forward slash URI separator. -
PACKAGE_RELATIONSHIPS_ROOT_URI
Package relationships part URI -
PACKAGE_RELATIONSHIPS_ROOT_PART_NAME
Package relationships part name. -
CORE_PROPERTIES_URI
Core properties part URI. -
CORE_PROPERTIES_PART_NAME
Core properties partname. -
PACKAGE_ROOT_URI
Root package URI. -
PACKAGE_ROOT_PART_NAME
Root package part name.
-
-
Constructor Details
-
URIHelper
public URIHelper()
-
-
Method Details
-
getPackageRootUri
Gets the URI for the package root.- Returns:
- URI of the package root.
-
getFilename
Get file name from the specified URI. -
getFilenameWithoutExtension
Get the file name without the trailing extension. -
getPath
Get the directory path from the specified URI. -
combine
Combine two URI.- Parameters:
prefix-suffix-- Returns:
-
combine
Combine a string URI with a prefix and a suffix. -
relativizeURI
Fully relativize the target part URI against the source part URI.- Parameters:
sourceURI- The source part URI.targetURI- The target part URI.- Returns:
- A fully relativize part name URI ('word/media/image1.gif',
'/word/document.xml' => 'media/image1.gif') else
null.
-
resolvePartUri
Resolve a target uri against a source.- Parameters:
sourcePartUri- The source URI.targetUri- The target URI.- Returns:
- The resolved URI.
-
getURIFromPath
Get URI from a string path. -
getSourcePartUriFromRelationshipPartUri
-
createPartName
Create an OPC compliant part name by throwing an exception if the URI is not valid.- Parameters:
partUri- The part name URI to validate.- Returns:
- A valid part name object, else
null. - Throws:
InvalidFormatException- Throws if the specified URI is not OPC compliant.
-
createPartName
Create an OPC compliant part name by throwing an exception if the specified name is not valid.- Parameters:
partName- The part name to validate.- Returns:
- The correspondant part name if valid, else
null. - Throws:
InvalidFormatException- Throws if the specified part name is not OPC compliant.- See Also:
-
isValidPartName
Validate a part URI by returning a boolean. ([M1.1],[M1.3],[M1.4],[M1.5],[M1.6]) (OPC Specifications 8.1.1 Part names) : Part Name Syntax The part name grammar is defined as follows: part_name = 1*( "/" segment ) segment = 1*( pchar ) (pchar is defined in RFC 3986)- Parameters:
partUri- The URI to validate.- Returns:
- true if the URI is valid to the OPC Specifications, else false
- See Also:
-
decodeURI
Decode a URI by converting all percent encoded character into a String character.- Parameters:
uri- The URI to decode.- Returns:
- The specified URI in a String with converted percent encoded characters.
-