Class CatalogEntry
- java.lang.Object
-
- org.jvnet.jaxb2.maven2.resolver.CatalogEntry
-
public class CatalogEntry extends Object
Represents a Catalog entry.Instances of this class represent individual entries in a Catalog.
Each catalog entry has a unique name and is associated with an arbitrary number of arguments (all strings). For example, the TR9401 catalog entry "PUBLIC" has two arguments, a public identifier and a system identifier. Each entry has a unique numeric type, assigned automatically when the entry type is created.
The number and type of catalog entries is maintained statically. Catalog classes, or their subclasses, can add new entry types, but all Catalog objects share the same global pool of types.
Initially there are no valid entries.
- Version:
- 1.0
- Author:
- Norman Walsh Norman.Walsh@Sun.COM
- See Also:
Catalog
-
-
Field Summary
Fields Modifier and Type Field Description protected List<String>argsThe arguments associated with this entryprotected static List<Integer>ENTRY_ARGSThe entryTypes vector maps catalog entry types to the number of arguments they're required to have.protected static Map<String,Integer>ENTRY_TYPESThe entryTypes vector maps catalog entry names (e.g., 'BASE' or 'SYSTEM') to their type (1, 2, etc.).protected intentryTypeThe entry type of this entryprotected static ints_nNextEntryThe nextEntry is the ordinal number of the next entry type.
-
Constructor Summary
Constructors Constructor Description CatalogEntry()Null constructor; something for subclasses to call.CatalogEntry(int type, List<String> args)Construct a catalog entry of the specified type.CatalogEntry(String name, List<String> args)Construct a catalog entry of the specified type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intaddEntryType(String name, int numArgs)Adds a new catalog entry type.StringgetEntryArg(int argNum)Get an entry argument.static intgetEntryArgCount(int type)Find out how many arguments an entry is required to have.static intgetEntryArgCount(String name)Find out how many arguments an entry is required to have.intgetEntryType()Get the entry type.static intgetEntryType(String name)Lookup an entry typevoidsetEntryArg(int argNum, String newspec)Set an entry argument.
-
-
-
Field Detail
-
s_nNextEntry
protected static int s_nNextEntry
The nextEntry is the ordinal number of the next entry type.
-
ENTRY_TYPES
protected static final Map<String,Integer> ENTRY_TYPES
The entryTypes vector maps catalog entry names (e.g., 'BASE' or 'SYSTEM') to their type (1, 2, etc.). Names are case sensitive.
-
ENTRY_ARGS
protected static final List<Integer> ENTRY_ARGS
The entryTypes vector maps catalog entry types to the number of arguments they're required to have.
-
entryType
protected int entryType
The entry type of this entry
-
-
Constructor Detail
-
CatalogEntry
public CatalogEntry()
Null constructor; something for subclasses to call.
-
CatalogEntry
public CatalogEntry(String name, List<String> args) throws CatalogException
Construct a catalog entry of the specified type.- Parameters:
name- The name of the entry typeargs- A String Vector of arguments- Throws:
CatalogException- if no such entry type exists or if the wrong number of arguments is passed.
-
CatalogEntry
public CatalogEntry(int type, List<String> args) throws CatalogExceptionConstruct a catalog entry of the specified type.- Parameters:
type- The entry typeargs- A String Vector of arguments- Throws:
CatalogException- if no such entry typeor if the wrong number of arguments is passed.
-
-
Method Detail
-
addEntryType
public static int addEntryType(String name, int numArgs)
Adds a new catalog entry type.- Parameters:
name- The name of the catalog entry type. This must be unique among all types and is case-sensitive. (Adding a duplicate name effectively replaces the old type with the new type.)numArgs- The number of arguments that this entry type is required to have. There is no provision for variable numbers of arguments.- Returns:
- The type for the new entry.
-
getEntryType
public static int getEntryType(String name) throws CatalogException
Lookup an entry type- Parameters:
name- The name of the catalog entry type.- Returns:
- The type of the catalog entry with the specified name.
- Throws:
CatalogException- if no entry has the specified name.
-
getEntryArgCount
public static int getEntryArgCount(String name) throws CatalogException
Find out how many arguments an entry is required to have.- Parameters:
name- The name of the catalog entry type.- Returns:
- The number of arguments that entry type is required to have.
- Throws:
CatalogException- if no entry has the specified name.
-
getEntryArgCount
public static int getEntryArgCount(int type) throws CatalogExceptionFind out how many arguments an entry is required to have.- Parameters:
type- A valid catalog entry type.- Returns:
- The number of arguments that entry type is required to have.
- Throws:
CatalogException- if the type is invalid.
-
getEntryType
public int getEntryType()
Get the entry type.- Returns:
- The entry type of the CatalogEntry
-
getEntryArg
public String getEntryArg(int argNum)
Get an entry argument.- Parameters:
argNum- The argument number (arguments are numbered from 0).- Returns:
- The specified argument or null if an invalid argNum is provided.
-
setEntryArg
public void setEntryArg(int argNum, String newspec) throws ArrayIndexOutOfBoundsExceptionSet an entry argument.Catalogs sometimes need to adjust the catalog entry parameters, for example to make a relative URI absolute with respect to the current base URI. But in general, this function should only be called shortly after object creation to do some sort of cleanup. Catalog entries should not mutate over time.
- Parameters:
argNum- The argument number (arguments are numbered from 0).newspec- new argument- Throws:
ArrayIndexOutOfBoundsException- if an invalid argument number is provided.
-
-