|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.subversion.javahl.SVNUtil
public class SVNUtil
| Nested Class Summary | |
|---|---|
static class |
SVNUtil.ConflictDisplayStyle
Style for displaying conflicts in merge output. |
static class |
SVNUtil.Credential
Generic credential description. |
static class |
SVNUtil.CredentialTypeMismatch
Exception used by calling the wrong accessor on Credential for the given credential type. |
static class |
SVNUtil.DiffOptions
Options to control the behaviour of the file diff routines. |
| Field Summary | |
|---|---|
static byte[] |
EOL_CR
Use the carraige-return code point (' \x0d')
for the newline separator. |
static byte[] |
EOL_CRLF
Use carriage-return/linefeed sequence (' \x0d\x0a')
for the newline separator. |
static byte[] |
EOL_LF
Use the linefeed code point (' \x0a')
for the newline separator. |
| Constructor Summary | |
|---|---|
SVNUtil()
|
|
| Method Summary | |
|---|---|
static Map<String,byte[]> |
buildKeywords(byte[] keywordsValue,
long revision,
String url,
String reposRootUrl,
Date date,
String author)
Build a dictionary of expanded keyword values, given the contents of a file's svn:keywords property, its
revision, URL, the date it was committed on, the author of the
commit and teh URL of the repository root. |
static byte[] |
canonicalizeNodeProperty(String name,
byte[] value,
String path,
NodeKind kind,
String mimeType)
Validate the value of an svn: property on file or
directory and return a canonical representation of its value. |
static byte[] |
canonicalizeNodeProperty(String name,
byte[] value,
String path,
NodeKind kind,
String mimeType,
InputStream fileContents)
Validate the value of an svn: property on file or
directory and return a canonical representation of its value. |
static void |
disableNativeCredentialsStore()
Disable storing authentication credentials in Subversion's standard credentials store in the configuration directory and system-specific secure locations. |
static void |
enableNativeCredentialsStore()
Enable storing authentication credentials in Subversion's standard credentials store in the configuration directory and system-specific secure locations. |
static boolean |
fileDiff(String originalFile,
String modifiedFile,
SVNUtil.DiffOptions diffOptions,
String originalHeader,
String modifiedHeader,
String headerEncoding,
String relativeToDir,
OutputStream resultStream)
Given two versions of a file, base ( originalFile)
and current (modifiedFile), show differences between
them in unified diff format. |
static boolean |
fileMerge(String originalFile,
String modifiedFile,
String latestFile,
SVNUtil.DiffOptions diffOptions,
String conflictOriginal,
String conflictModified,
String conflictLatest,
String conflictSeparator,
SVNUtil.ConflictDisplayStyle conflictStyle,
OutputStream resultStream)
Given three versions of a file, base ( originalFile),
incoming (modifiedFile) and current
(latestFile, produce a merged result, possibly
displaying conflict markers. |
static SVNUtil.Credential |
getCredential(String configDir,
SVNUtil.Credential.Kind kind,
String realm)
Find a stored credential. |
static boolean |
isNativeCredentialsStoreEnabled()
Find out if the standard credentials store is enabled. |
static List<ExternalItem> |
parseExternals(byte[] description,
String parentDirectory,
boolean canonicalizeUrl)
Parse description, assuming it is an externals
specification in the format required for the
svn:externals property, and return a list of
parsed external items. |
static SVNUtil.Credential |
removeCredential(String configDir,
SVNUtil.Credential.Kind kind,
String realm)
Remove a stored credential. |
static String |
resolveExternalsUrl(ExternalItem external,
String reposRootUrl,
String parentDirUrl)
If the URL in external is relative, resolve it to
an absolute URL, using reposRootUrl and
parentDirUrl to provide contest. |
static List<SVNUtil.Credential> |
searchCredentials(String configDir,
SVNUtil.Credential.Kind kind,
String realmPattern,
String usernamePattern,
String hostnamePattern,
String textPattern)
Find stored credentials that match the given search criteria. |
static InputStream |
translateStream(InputStream source,
byte[] eolMarker,
boolean repairEol,
boolean expandKeywords,
byte[] keywordsValue,
long revision,
String url,
String reposRootUrl,
Date date,
String author)
Expand keywords and return a stream which performs end-of-line translation and keyword expansion when read from. |
static InputStream |
translateStream(InputStream source,
byte[] eolMarker,
boolean repairEol,
Map<String,byte[]> keywords,
boolean expandKeywords)
Return a stream which performs end-of-line translation and keyword expansion when read from. |
static OutputStream |
translateStream(OutputStream destination,
byte[] eolMarker,
boolean repairEol,
boolean expandKeywords,
byte[] keywordsValue,
long revision,
String url,
String reposRootUrl,
Date date,
String author)
Expand keywords and return a stream which performs end-of-line translation and keyword expansion when written to. |
static OutputStream |
translateStream(OutputStream destination,
byte[] eolMarker,
boolean repairEol,
Map<String,byte[]> keywords,
boolean expandKeywords)
Return a stream which performs end-of-line translation and keyword expansion when written to. |
static byte[] |
unparseExternals(List<ExternalItem> items,
String parentDirectory)
Unparse and list of external items into a format suitable for the value of the svn:externals property and
validate the result. |
static byte[] |
unparseExternalsForAncientUnsupportedClients(List<ExternalItem> items,
String parentDirectory)
Unparse and list of external items into a format suitable for the value of the svn:externals property compatible
with Subversion clients older than release 1.5, and validate
the result. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final byte[] EOL_LF
\x0a')
for the newline separator.
translateStream,
untranslateStreampublic static final byte[] EOL_CR
\x0d')
for the newline separator.
translateStream,
untranslateStreampublic static final byte[] EOL_CRLF
\x0d\x0a')
for the newline separator.
translateStream,
untranslateStream| Constructor Detail |
|---|
public SVNUtil()
| Method Detail |
|---|
public static void enableNativeCredentialsStore()
throws ClientException
The standard credentials store is enabled by default.
This setting will be inherited by all ISVNClient and ISVNRemote objects. Changing the setting will not affect existing such objects.
ClientException
public static void disableNativeCredentialsStore()
throws ClientException
ISVNClient.setPrompt(org.apache.subversion.javahl.callback.AuthnCallback) and RemoteFactory.setPrompt(org.apache.subversion.javahl.callback.AuthnCallback)) will be called every time the
underlying library needs access to the credentials.
This mode is intented to support client implementations that use their own credentials store.
The standard credentials store is enabled by default.
This setting will be inherited by all ISVNClient and ISVNRemote objects. Changing the setting will not affect existing such objects.
ClientException
public static boolean isNativeCredentialsStoreEnabled()
throws ClientException
ClientException
public static SVNUtil.Credential getCredential(String configDir,
SVNUtil.Credential.Kind kind,
String realm)
throws ClientException,
SubversionException
searchCredentials(java.lang.String, org.apache.subversion.javahl.SVNUtil.Credential.Kind, java.lang.String, java.lang.String, java.lang.String, java.lang.String), the the realm name is not
a glob pattern.
Note: If the native credentials store is disabled, this
method will always return null.
configDir - The path to the configuration directory; if
null, the default (system-specific) user
configuration path will be used.kind - The kind of the credential; may not be null.realm - The realm name; may not be null.
null if not found.
ClientException
SubversionException
public static SVNUtil.Credential removeCredential(String configDir,
SVNUtil.Credential.Kind kind,
String realm)
throws ClientException,
SubversionException
#deleteCredentials, the the realm name is not
a glob pattern.
Note: If the native credentials store is disabled, this
method will always return null.
configDir - The path to the configuration directory; if
null, the default (system-specific) user
configuration path will be used.kind - The kind of the credential; may not be null.realm - The realm name; may not be null.
null if not found.
ClientException
SubversionException
public static List<SVNUtil.Credential> searchCredentials(String configDir,
SVNUtil.Credential.Kind kind,
String realmPattern,
String usernamePattern,
String hostnamePattern,
String textPattern)
throws ClientException,
SubversionException
Note: If the native credentials store is disabled, this
method will always return null.
configDir - The path to the configuration directory; if
null, the default (system-specific) user
configuration path will be used.kind - The kind of the credential; if null,
all matching credential types will be returned.realmPattern - A glob pattern for the realm string;
if null, all realms will be considered;
otherwise, only those credentials whose realm matches
the pattern will be returned.usernamePattern - A glob pattern for the username;
if null, all credentials will be considered;
otherwise, only those credentials that have a username,
and where the username matches the pattern, will be
returned.hostnamePattern - A glob pattern for the hostnames of a
server certificate; if null, all
credntials will be considered; otherwise, only
those credentials that have a server certificate
with a hostname that matches the pattern will be
returned.textPattern - A glob pattern that must match any textual
information in a credential, for example, a realm,
username, certificate details, etc; passwords, passphrases
and other info considered secret will not be matched;
ClientException
SubversionException
public static boolean fileDiff(String originalFile,
String modifiedFile,
SVNUtil.DiffOptions diffOptions,
String originalHeader,
String modifiedHeader,
String headerEncoding,
String relativeToDir,
OutputStream resultStream)
throws ClientException
originalFile)
and current (modifiedFile), show differences between
them in unified diff format.
originalFile - The base file version (unmodified)modifiedFile - The incoming file version (locally modified)diffOptions - Options controlling how files are compared.
May be null.originalHeader - The header to display for the base file
in the unidiff index block. If it is null,
the originalFile path and its modification
time will be used instead.modifiedHeader - The header to display for the current
file in the unidiff index block. If it is null,
the currentFile path and its modification
time will be used instead.headerEncoding - The character encoding of the unidiff headers.relativeToDir - If this parameter is not originalFile and modifiedFile.
This path will be stripped from the beginning of those
file names if they are used in the unidiff index header.resultStream - The stream that receives the merged output.
true if there were differences between the files.
ClientException
public static boolean fileMerge(String originalFile,
String modifiedFile,
String latestFile,
SVNUtil.DiffOptions diffOptions,
String conflictOriginal,
String conflictModified,
String conflictLatest,
String conflictSeparator,
SVNUtil.ConflictDisplayStyle conflictStyle,
OutputStream resultStream)
throws ClientException
originalFile),
incoming (modifiedFile) and current
(latestFile, produce a merged result, possibly
displaying conflict markers.
originalFile - The base file version (common ancestor)modifiedFile - The incoming file version (modified elsewhere)latestFile - The current file version (locally modified)diffOptions - Options controlling how files are compared.
May be null.conflictOriginal - Optional custom conflict marker for
the originalFile contents.conflictModified - Optional custom conflict marker for
the modifiedFile contents.conflictLatest - Optional custom conflict marker for
the latestFile contents.conflictSeparator - Optional custom conflict separator.conflictStyle - Determines how conflicts are displayed.resultStream - The stream that receives the merged output.
true if there were any conflicts.
ClientException
public static byte[] canonicalizeNodeProperty(String name,
byte[] value,
String path,
NodeKind kind,
String mimeType)
throws ClientException
svn: property on file or
directory and return a canonical representation of its value.
name - The name of the property (must be a valid svn: property)value - The property's valuepath - The path or URL of the file or directory that
owns the property; only used for error messageskind - The node kind of the file or dir that owns the propertymimeType - If kind is NodeKind.file, this is
tye file's mime-type, used for extra validation for the
svn:eol-style property. If it is null,
the extra validation will be skipped.
ClientExceptionhttp://subversion.apache.org/docs/api/latest/group__svn__wc__properties.html#ga83296313ec59cc825176224ac8282ec2
public static byte[] canonicalizeNodeProperty(String name,
byte[] value,
String path,
NodeKind kind,
String mimeType,
InputStream fileContents)
throws ClientException
svn: property on file or
directory and return a canonical representation of its value.
name - The name of the property (must be a valid svn: property)value - The property's valuepath - The path or URL of the file or directory that
owns the property; only used for error messageskind - The node kind of the file or dir that owns the propertymimeType - If kind is NodeKind.file, this is
tye file's mime-type, used for extra validation for the
svn:eol-style property. If it is null,
the extra validation will be skipped.fileContents - A stream with the file's contents. Only used
to check for line-ending consistency when validating the
svn:eol-style property, and only when
kind is NodeKind.file and
mimeType is not null.
ClientExceptionhttp://subversion.apache.org/docs/api/latest/group__svn__wc__properties.html#ga83296313ec59cc825176224ac8282ec2
public static List<ExternalItem> parseExternals(byte[] description,
String parentDirectory,
boolean canonicalizeUrl)
throws ClientException
description, assuming it is an externals
specification in the format required for the
svn:externals property, and return a list of
parsed external items.
description - The externals description.parentDirectory - Used to construct error messages.canonicalizeUrl - Whe true, canonicalize the
url member of the returned objects. If the
url member refers to an absolute URL, it will
be canonicalized as URL consistent with the way URLs are
canonicalized throughout the Subversion API. If, however,
the url member makes use of the recognized
(SVN-specific) relative URL syntax for
svn:externals, "canonicalization" is an
ill-defined concept which may even result in munging the
relative URL syntax beyond recognition. You've been warned.
ExternalItems
ClientException
public static byte[] unparseExternals(List<ExternalItem> items,
String parentDirectory)
throws SubversionException
svn:externals property and
validate the result.
items - The list of ExternalItemsparentDirectory - Used to construct error messages.compatibleWithSvn1_5 - When true, the format
of the returned property value will be compatible with
clients older than Subversion 1.5.
SubversionException
public static byte[] unparseExternalsForAncientUnsupportedClients(List<ExternalItem> items,
String parentDirectory)
throws SubversionException
svn:externals property compatible
with Subversion clients older than release 1.5, and validate
the result.
items - The list of ExternalItemsparentDirectory - Used to construct error messages.
SubversionException
public static String resolveExternalsUrl(ExternalItem external,
String reposRootUrl,
String parentDirUrl)
throws ClientException
external is relative, resolve it to
an absolute URL, using reposRootUrl and
parentDirUrl to provide contest.
Regardless if the URL is absolute or not, if there are no errors, the returned URL will be canonicalized.
The following relative URL formats are supported:
../^////
The
The external URL should not be canonicalized before calling
this function, as otherwise the scheme relative URL
'
../ and ^/ relative URLs may use ..
to remove path elements up to the server root.
//host/some/path' would have been canonicalized
to '/host/some/path' and we would not be able to
match on the leading '//'.
ClientException
public static Map<String,byte[]> buildKeywords(byte[] keywordsValue,
long revision,
String url,
String reposRootUrl,
Date date,
String author)
throws SubversionException,
ClientException
svn:keywords property, its
revision, URL, the date it was committed on, the author of the
commit and teh URL of the repository root.
Custom keywords defined in svn:keywords properties
are expanded using the provided parameters and in accordance
with the following format substitutions in the
keywordsValue:
%a%b%d%D%P%r%R%u%_%%%H%P%_%r%_%d%_%a.%I%b%_%r%_%d%_%a.Custom keywords are defined by appending '=' to the keyword name, followed by a string containing any combination of the format substitutions.
Any of the revision, url,
reposRootUrl, date and
author parameters may be null, or
Revision.SVN_INVALID_REVNUM for revision,
to indicate that the information is not present. Each piece of
information that is not present expands to the empty string
wherever it appears in an expanded keyword value. (This can
result in multiple adjacent spaces in the expansion of a
multi-valued keyword such as "Id".)
SubversionException
ClientException
public static InputStream translateStream(InputStream source,
byte[] eolMarker,
boolean repairEol,
Map<String,byte[]> keywords,
boolean expandKeywords)
throws SubversionException,
ClientException
Important: Make sure you close the returned stream to ensure all data are flushed and cleaned up (this will also close the provided stream and dispose the related netive object).
If eolMarker is not null, replace
whatever any end-of-line sequences in the input with
eolMarker. If the input has an inconsistent line
ending style, then:
repairEol is false, then a
subsequent read or other operation on the stream will
generate an error when the inconsistency is detected;repaorEol is true, convert any
line ending to eolMarker.\n",
"\r", and "\r\n".
Expand or contract keywords using the contents of
keywords as the new values. If
expandKeywords is true, expand
contracted keywords and re-expand expanded keywords; otherwise,
contract expanded keywords and ignore contracted ones.
Keywords not found in the dictionary are ignored (not
contracted or expanded). If the keywords itself
is null, keyword substitution will be altogether
ignored.
Detect only keywords that are no longer than
SVN_KEYWORD_MAX_LEN bytes (currently: 255),
including the delimiters and the keyword itself.
Recommendation: if expandKeywords is
false, then you don't care about the keyword
values, so just put null values into the
keywords dictionary.
If the inner stream implements marking and seeking via
InputStream.mark(int) and InputStream.reset(), the
translated stream will too.
source - the source (untranslated) stream.eolMarker - the byte sequence to use as the end-of-line marker;
must be one of EOL_LF, EOL_CR
or EOL_CRLF.repairEol - flag to repair end-of-lines; see abovekeywords - the keyword dictionary; see buildKeywordsexpandKeywords - flag to expand keywords
SubversionException
ClientException
public static InputStream translateStream(InputStream source,
byte[] eolMarker,
boolean repairEol,
boolean expandKeywords,
byte[] keywordsValue,
long revision,
String url,
String reposRootUrl,
Date date,
String author)
throws SubversionException,
ClientException
SubversionException
ClientExceptionbuildKeywords,
translateStream(InputStream,byte[],boolean,Map,boolean)
public static OutputStream translateStream(OutputStream destination,
byte[] eolMarker,
boolean repairEol,
Map<String,byte[]> keywords,
boolean expandKeywords)
throws SubversionException,
ClientException
translateStream(InputStream,byte[],boolean,Map,boolean),
except that it translates an OutputStream and never
supports marking and seeking.
SubversionException
ClientException
public static OutputStream translateStream(OutputStream destination,
byte[] eolMarker,
boolean repairEol,
boolean expandKeywords,
byte[] keywordsValue,
long revision,
String url,
String reposRootUrl,
Date date,
String author)
throws SubversionException,
ClientException
SubversionException
ClientExceptionbuildKeywords,
translateStream(OutputStream,byte[],boolean,Map,boolean)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||