|
|||||||||
| 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
Routines to validate/parse an exhibit name. 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).
It is possible to build a ParsedName which is split into its consitituent parts, and is Comparable with the sort order given above.
| 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.String> |
SIMPLE_SMART_ORDER
A simple invariant comparator that sorts (String) 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 character used to separate words as a string. |
| Constructor Summary | |
|---|---|
ExhibitName()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
getAttributeWordsComponent(java.lang.String 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.String 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.String 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.String |
getAuthorComponent(java.lang.String exhibitName)
Extract the author component of a full exhibit name, assuming the name is valid. |
static java.lang.String |
getCategoryComponent(java.lang.String fullExhibitName)
Extract the category component (top directory) of a full exhibit name, assuming the name is valid. |
static java.lang.String |
getDirComponent(java.lang.String fullExhibitName)
Extract the full directory component of a full exhibit name, assuming the name is valid. |
static java.lang.String |
getExtensionComponent(java.lang.String exhibitName)
Extract the extension (without dot) of a full exhibit name, assuming the name is valid. |
static java.lang.String |
getFileComponent(java.lang.String fullExhibitName)
Extract the file component (short name) of a full exhibit name, assuming the name is valid. |
static int[] |
getMainAndAttrWordComponentBoundaries(java.lang.String fullExhibitName,
java.util.Set<java.lang.String> allAttrWords)
Find end of main stem and of attribute words of the supplied full exhibit name. |
static java.util.Enumeration<?> |
getMainWords(java.lang.String fullExhibitName,
java.util.Set<java.lang.String> allAttrWords)
Return Enumeration over main words; never null, never empty if the name is well-formed. |
static java.lang.String |
getMainWordsComponent(java.lang.String fullExhibitName,
java.util.Set<java.lang.String> allAttrWords)
Extract the main words (stem) component of a full exhibit name, assuming the name is valid; never null nor empty. |
static int |
getNumberInSeriesComponent(java.lang.String 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.String |
getNumberInSeriesComponentAsString(java.lang.String exhibitName)
Extract the number-in-series component of a full exhibit name as a String, assuming the name is valid. |
static java.lang.String |
getVirtualExhibitName(java.lang.String fullExhibitName)
Get the "virtual" name consisting of the category directory and then the file component. |
static boolean |
validAttributeWord(java.lang.String s)
Checks that the String passed to it is a valid attribute word. |
static boolean |
validAuthorSyntax(java.lang.String s)
Validates a set of author's initials for syntax; returns true if valid. |
static boolean |
validAuthorSyntax(java.lang.String s,
int start,
int end)
Validates a set of author's initials for syntax; returns true if valid. |
static boolean |
validNameFinalComponentSyntax(java.lang.String finalNameComponent)
Validates the syntax of the last component of a name; returns true if valid. |
static boolean |
validNameInitialComponentSyntax(java.lang.String initialNameComponent)
Validates the syntax of the first component of a name; returns true if valid. |
static boolean |
validNameInitialComponentSyntax(java.lang.String initialNameComponent,
int len)
Validates the syntax of the first component of a name; returns true if valid. |
static boolean |
validNameSyntax(java.lang.String name)
Fully validates the syntax of a name; returns true if valid. |
static boolean |
validNameSyntaxBasic(java.lang.String name)
Very quick basic set of name validity checks; returns true if valid. |
static boolean |
validWord(java.lang.String s)
Checks that the String 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.String> SIMPLE_SMART_ORDER
Ties are broken by a normal String 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.String 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.String s,
int start,
int end)
Characters from start to end-1 are checked.
The start and end positions must be valid in the String 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.String s)
public static boolean validWord(java.lang.String s)
public static boolean validAttributeWord(java.lang.String 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.String initialNameComponent)
public static boolean validWordCharacter(char c)
We test the most common cases first for speed.
public static boolean validNameFinalComponentSyntax(java.lang.String 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(java.lang.String name)
public static boolean validNameSyntax(java.lang.String name)
This does not attempt to check a name against current databases nor return any parsed components.
public static java.lang.String getFileComponent(java.lang.String fullExhibitName)
If the argument is not a valid full exhibit name, the result is undefined.
public static java.lang.String getCategoryComponent(java.lang.String fullExhibitName)
public static java.lang.String getDirComponent(java.lang.String fullExhibitName)
If the argument is not a valid full exhibit name, the result is undefined.
public static java.lang.String getVirtualExhibitName(java.lang.String fullExhibitName)
If the argument is not a valid full exhibit name, the result is undefined.
public static int[] getMainAndAttrWordComponentBoundaries(java.lang.String fullExhibitName,
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);
can be empty but not null
public static java.lang.String getMainWordsComponent(java.lang.String fullExhibitName,
java.util.Set<java.lang.String> allAttrWords)
(This does not end nor start with a separator.)
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<?> getMainWords(java.lang.String fullExhibitName,
java.util.Set<java.lang.String> allAttrWords)
public static java.lang.String getAttributeWordsComponent(java.lang.String 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.String 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.String 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.String getNumberInSeriesComponentAsString(java.lang.String exhibitName)
A missing number-in-series value causes us to return null.
This is:
public static int getNumberInSeriesComponent(java.lang.String fullExhibitName)
A missing number-in-series value causes us to return zero.
This is:
public static java.lang.String getAuthorComponent(java.lang.String exhibitName)
public static java.lang.String getExtensionComponent(java.lang.String exhibitName)
|
DHD Multimedia Gallery V1.50.55 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||