|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.ExhibitName
public final class ExhibitName
Utility routines to validate/parse an exhibit name as a String/CharSequence. An exhibit name is a (relative) path name in a filesystem representation, and a (relative) URL in a Web presentation.
This is based on the assumption that we use the String name everywhere as a sort of universal currency, rather than pre-parsing everything as in the old Attributes.ItemName.
The syntax of the file name is:
The syntax of a Gallery image name is as follows: {word-}+{discardableword-}*[number-]AUTH.ext where word is an alphanumeric sequence containing at least one letter (there must be at least one such word in the name), discardableword is like word in syntax but comes from a small list of words that can trail the main image description and indicate some gross features of the image, eg `bg' and `mono' (these words are optional and will only be recognised as discardable if after all non-discardable words), number is a optional decimal number consisting purely of the digits 0-9 (with any leading zeros ignored rather than indicating octal), AUTH being the all-upper-case all-alpha author's initials (this is compulsory), and ext being the extension indicating the image type (this is compulsory).
Note that other than the extension, all components are delimited by dashes, and there must be no spaces in the name. The extension may contain dots, and dots are not allowed elsewhere in the name.
For the purposes of sorting, the sort order is first by the [word-]+ portion (ASCII order), then by the author (ASCII order), then by the number portion (numerically), then by the {discardableword-}* portion (ASCII order), then by the extension (ASCII order).
| Field Summary | |
|---|---|
private static int |
_iDirPrefixLen
Length of prefix of intermediate directory components in name. |
private static int |
_minFileLen
Minimum length of file component of any valid name. |
static java.lang.String |
intermediateDirPrefix
Prefix of intermediate directory components in name. |
static int |
MAX_ATTR_WORD_LENGTH
|
static int |
MAX_AUTH_INITIALS_LENGTH
Maximum length of author-initial component. |
static int |
MAX_NAME_LENGTH
Maximum valid name length. |
static int |
MAX_STEM_LENGTH
Maximum allowable length of any name stem (ie just main words). |
static int |
MAX_WORD_LENGTH
Maximum allowable length of any single word. |
static int |
MIN_AUTH_INITIALS_LENGTH
Minimum length of author-initial component; strictly positive. |
static int |
MIN_NAME_LENGTH
Minimum valid name length. |
private static java.util.SortedSet<java.lang.String> |
NO_ATTR_WORDS
Immutable empty attribute word set. |
static java.util.Comparator<java.lang.CharSequence> |
SIMPLE_SMART_ORDER
A simple invariant comparator that sorts full exhibit names in a human-friendly order. |
static char |
WORD_SEP
The character used to separate words. |
static java.lang.String |
WORD_SEPS
The single character used to separate words as a String value for convenience. |
| Constructor Summary | |
|---|---|
ExhibitName()
|
|
| Method Summary | |
|---|---|
static java.lang.CharSequence |
getAttributeWordsComponent(java.lang.CharSequence fullExhibitName,
java.util.Set<java.lang.String> allAttrWords)
Extract the attribute words component of a full exhibit name, assuming the name is valid. |
static java.util.Enumeration<?> |
getAttributeWordsComponentEnumeration(java.lang.CharSequence fullExhibitName,
java.util.Set<java.lang.String> allAttrWords)
Extract the attribute words component of a full exhibit name as an Enumeration of String, assuming the name is valid. |
static java.util.SortedSet<java.lang.String> |
getAttributeWordsComponentSortedSet(java.lang.CharSequence fullExhibitName,
java.util.Set<java.lang.String> allAttrWords)
Extract the attribute words component of a full exhibit name as a SortedSet of String, assuming the name is valid; never null. |
static java.lang.CharSequence |
getAuthorComponent(java.lang.CharSequence exhibitName)
Extract the author component of a valid full or short exhibit name, assuming the name is valid. |
static java.lang.CharSequence |
getCategoryComponent(java.lang.CharSequence fullExhibitName)
Extract the category component (top directory) of a full exhibit name, assuming the name is valid. |
static java.lang.CharSequence |
getDirComponent(java.lang.CharSequence fullExhibitName)
Extract the full directory component of a full exhibit name, assuming the name is valid. |
static int |
getEndOfAttrWords(java.lang.CharSequence exhibitName)
Find the index of the end of the attribute words for a short or long exhibit name; strictly positive. |
static int |
getEndOfMainWords(java.lang.CharSequence exhibitName,
int lastSlash,
int endOfAttrWords,
java.util.Set<java.lang.String> allAttrWords)
Find the index of the end of the main words for a short or long exhibit name; strictly positive. |
static java.lang.CharSequence |
getExtensionComponent(java.lang.CharSequence exhibitName)
Extract the extension (without dot) of a valid full or short exhibit name, assuming the name is valid. |
static java.lang.CharSequence |
getFileComponent(java.lang.CharSequence fullExhibitName)
Extract the file component (short name) of a full exhibit name, assuming the name is valid. |
static int[] |
getMainAndAttrWordComponentBoundaries(java.lang.CharSequence exhibitName,
java.util.Set<java.lang.String> allAttrWords)
Find end of main stem and of attribute words of the supplied short or full exhibit name. |
static java.util.Enumeration<?> |
getMainWords(java.lang.CharSequence exhibitName,
java.util.Set<java.lang.String> allAttrWords)
Return Enumeration over main words of a valid full or short name; never null, never empty if the name is well-formed. |
static java.lang.CharSequence |
getMainWordsComponent(java.lang.CharSequence exhibitName,
java.util.Set<java.lang.String> allAttrWords)
Extract the main words (stem) component of a valid full or short exhibit name; never null nor empty. |
static java.lang.CharSequence |
getMainWordsComponentFromShortName(java.lang.CharSequence shortExhibitName,
java.util.Set<java.lang.String> allAttrWords)
Extract the main words (stem) component of a valid short exhibit name; never null nor empty. |
static int |
getMainWordsCount(java.lang.CharSequence exhibitName,
java.util.Set<java.lang.String> allAttrWords)
Count the main words int the (stem) component of a valid full or short exhibit name; strictly positive. |
static int |
getNumberInSeriesComponent(java.lang.CharSequence fullExhibitName)
Extract the number-in-series component of a full exhibit name as a non-negative int, assuming the name is valid. |
static java.lang.CharSequence |
getNumberInSeriesComponentAsString(java.lang.CharSequence exhibitName)
Extract the number-in-series component of a full exhibit name as a String, assuming the name is valid. |
static boolean |
validAttributeWord(java.lang.CharSequence s)
Checks that the CharSequence passed to it is a valid attribute word. |
static boolean |
validAuthorSyntax(java.lang.CharSequence s)
Validates a set of author's initials for syntax; returns true if valid. |
static boolean |
validAuthorSyntax(java.lang.CharSequence s,
int start,
int end)
Validates a set of author's initials for syntax; returns true if valid. |
static boolean |
validNameFinalComponentSyntax(java.lang.CharSequence finalNameComponent)
Validates the syntax of the last component of a name; returns true if valid. |
static boolean |
validNameInitialComponentSyntax(java.lang.CharSequence initialNameComponent)
Validates the syntax of the first component of a name; returns true if valid. |
static boolean |
validNameInitialComponentSyntax(java.lang.CharSequence initialNameComponent,
int len)
Validates the syntax of the first component of a name; returns true if valid. |
static boolean |
validNameSyntax(java.lang.CharSequence name)
Fully validates the syntax of a name; returns true if valid. |
static boolean |
validNameSyntax(Name.ExhibitFull name)
Fully validates the syntax of a name; returns true if valid. |
static boolean |
validNameSyntaxBasic(java.lang.CharSequence name)
Very quick basic set of name validity checks; returns true if valid. |
static boolean |
validNameSyntaxBasic(Name.ExhibitFull name)
Very quick basic set of name validity checks; returns true if valid. |
static boolean |
validWord(java.lang.CharSequence s)
Checks that the CharSequence passed to it is a valid word (main or attribute). |
static boolean |
validWordCharacter(char c)
Returns true if the character passed is a valid word character. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char WORD_SEP
public static final java.lang.String WORD_SEPS
public static final int MAX_NAME_LENGTH
private static final int _minFileLen
public static final int MIN_NAME_LENGTH
public static final int MAX_WORD_LENGTH
public static final int MAX_STEM_LENGTH
public static final int MAX_ATTR_WORD_LENGTH
public static final java.lang.String intermediateDirPrefix
private static final int _iDirPrefixLen
public static final int MIN_AUTH_INITIALS_LENGTH
public static final int MAX_AUTH_INITIALS_LENGTH
public static final java.util.Comparator<java.lang.CharSequence> SIMPLE_SMART_ORDER
Ties are broken by a normal lexical ordering on the full names.
Discardable/attribute words are not discarded nor otherwise treated specially for this comparison.
private static final java.util.SortedSet<java.lang.String> NO_ATTR_WORDS
| Constructor Detail |
|---|
public ExhibitName()
| Method Detail |
|---|
public static boolean validNameInitialComponentSyntax(java.lang.CharSequence initialNameComponent,
int len)
This ignores any characters from len onwards, so the portion from 0--len-1 must be a complete valid initial directory, and the string passed must be at least len characters long.
Designed to be efficiently callable from validNameSyntax() without requiring creation of any objects.
public static boolean validAuthorSyntax(java.lang.CharSequence s,
int start,
int end)
Characters from start to end-1 are checked.
The start and end positions must be valid in the CharSequence passed and start start must come before end.
Returns false if the string is null.
s - the value to be examinedstart - the starting position of the author;
must be valid offset within stringend - just after the end of the author;
must be greater than start and no greater than the string lengthpublic static boolean validAuthorSyntax(java.lang.CharSequence s)
public static boolean validWord(java.lang.CharSequence s)
public static boolean validAttributeWord(java.lang.CharSequence s)
Maximum attribute word must be at most long enough to allow for a single-letter main word and dash, so is two less than the longest allowable main word.
public static boolean validNameInitialComponentSyntax(java.lang.CharSequence initialNameComponent)
public static boolean validWordCharacter(char c)
We test the most common cases first for speed.
public static boolean validNameFinalComponentSyntax(java.lang.CharSequence finalNameComponent)
This does not check that the author's initials or the extension are actually acceptable other than that they are syntactically valid.
public static boolean validNameSyntaxBasic(Name.ExhibitFull name)
public static boolean validNameSyntaxBasic(java.lang.CharSequence name)
public static boolean validNameSyntax(Name.ExhibitFull name)
public static boolean validNameSyntax(java.lang.CharSequence name)
This does not attempt to check a name against current databases nor return any parsed components.
public static java.lang.CharSequence getFileComponent(java.lang.CharSequence fullExhibitName)
If the argument is not a valid full exhibit name, the result is undefined.
See also ExhibitFullName.getShortName().
public static java.lang.CharSequence getCategoryComponent(java.lang.CharSequence fullExhibitName)
public static java.lang.CharSequence getDirComponent(java.lang.CharSequence fullExhibitName)
If the argument is not a valid full exhibit name, the result is undefined.
public static int getEndOfAttrWords(java.lang.CharSequence exhibitName)
exhibitName - valid full or short exhibit name; never null
public static int getEndOfMainWords(java.lang.CharSequence exhibitName,
int lastSlash,
int endOfAttrWords,
java.util.Set<java.lang.String> allAttrWords)
exhibitName - valid full or short exhibit name; never nulllastSlash - position of last '/' or -1 for a short nameendOfAttrWords - as returned by getEndOfAttrWords()allAttrWords - a Set of all legal attribute words (String values);
may be empty but not null
public static java.lang.CharSequence getMainWordsComponentFromShortName(java.lang.CharSequence shortExhibitName,
java.util.Set<java.lang.String> allAttrWords)
allAttrWords - a Set of all legal attribute words (String values);
may be empty but not null
public static int[] getMainAndAttrWordComponentBoundaries(java.lang.CharSequence exhibitName,
java.util.Set<java.lang.String> allAttrWords)
This has to be passed a set of all valid attribute words (as Strings which meet the requirements of validAttributeWord()) to be able to compute this boundary.
If the argument is not a valid full exhibit name, the result is undefined.
allAttrWords - a Set of all legal attribute words (String values);
may be empty but not null
public static java.lang.CharSequence getMainWordsComponent(java.lang.CharSequence exhibitName,
java.util.Set<java.lang.String> allAttrWords)
(This does not end nor start with a separator.)
If the argument is not a valid full or short exhibit name, the result is undefined.
allAttrWords - a Set of all legal attribute words (String values)
public static int getMainWordsCount(java.lang.CharSequence exhibitName,
java.util.Set<java.lang.String> allAttrWords)
allAttrWords - a Set of all legal attribute words (String values)
public static java.util.Enumeration<?> getMainWords(java.lang.CharSequence exhibitName,
java.util.Set<java.lang.String> allAttrWords)
public static java.lang.CharSequence getAttributeWordsComponent(java.lang.CharSequence fullExhibitName,
java.util.Set<java.lang.String> allAttrWords)
If the argument is not a valid full exhibit name, the result is undefined.
allAttrWords - a Set of all legal attribute words (String values)
public static java.util.Enumeration<?> getAttributeWordsComponentEnumeration(java.lang.CharSequence fullExhibitName,
java.util.Set<java.lang.String> allAttrWords)
If the argument is not a valid full exhibit name, the result is undefined.
allAttrWords - a Set of all legal attribute words (String values)
public static java.util.SortedSet<java.lang.String> getAttributeWordsComponentSortedSet(java.lang.CharSequence fullExhibitName,
java.util.Set<java.lang.String> allAttrWords)
Duplicates attribute words are automatically eliminated
If the argument is not a valid full exhibit name, the result is undefined.
allAttrWords - a Set of all legal attribute words (String values)
public static java.lang.CharSequence getNumberInSeriesComponentAsString(java.lang.CharSequence exhibitName)
A missing number-in-series value causes us to return null.
This is:
public static int getNumberInSeriesComponent(java.lang.CharSequence fullExhibitName)
A missing number-in-series value causes us to return zero.
This is:
public static java.lang.CharSequence getAuthorComponent(java.lang.CharSequence exhibitName)
public static java.lang.CharSequence getExtensionComponent(java.lang.CharSequence exhibitName)
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||