dip.world.variant
Class VariantManager

java.lang.Object
  extended bydip.world.variant.VariantManager

public class VariantManager
extends java.lang.Object

Finds Variant-packs, which are of the format:

  1. *Variant.zip
  2. *Variants.zip
  3. *Variant.jar
  4. *Variants.jar
Faciliates loading of variant resources. Within the above file, the variants.xml file is parsed to determine the required information.

Also finds all SymbolPacks, which end in:

  1. *Symbols.zip
  2. *Symbols.jar

TODO: deconflict code may work better if we include the preceding "/" before the .jar name.


Field Summary
static float VERSION_NEWEST
          Version Constant representing the most recent version of a Variant or SymbolPack
static float VERSION_OLDEST
          Version Constant representing the most oldest version of a Variant or SymbolPack
 
Method Summary
static java.net.URL getResource(SymbolPack symbolPack, java.net.URI uri)
          Gets a specific resource by properly resolving the URI to this SymbolPack.
static java.net.URL getResource(java.net.URL packURL, java.net.URI uri)
          Gets a specific resource for a Variant or a SymbolPack, given a URL to the package and a reference URI.
static java.net.URL getResource(Variant variant, java.net.URI uri)
          Gets a specific resource by properly resolving the URI to this Variant.
static SymbolPack getSymbolPack(MapGraphic mg, java.lang.String symbolPackName, float symbolPackVersion)
          Obtains a SymbolPack via the following criteria: If matching SymbolPack name and Version found, that is returned; otherwise Returns SymbolPack of same name but of the newest available version; otherwise Returns the newest available SymbolPack preferred by the MapGraphic (if set); otherwise Returns the first SymbolPack in the list of SymbolPacks.
static SymbolPack getSymbolPack(java.lang.String name, float version)
          Finds SymbolPack with the given name, or null if no SymbolPack is found.
static SymbolPack[] getSymbolPacks()
          Returns the known SymbolPacks.
static float[] getSymbolPackVersions(java.lang.String name)
          Returns the versions of a SymbolPack that are available.
static Variant getVariant(java.lang.String name, float version)
          Finds Variant with the given name, or null if no Variant is found.
static java.net.URL getVariantPackageJarURL(Variant variant)
          Gets the URL to the Variant package (plugin).
static Variant[] getVariants()
          Returns the known Variants.
static float[] getVariantVersions(java.lang.String name)
          Returns the versions of a variant that are available.
static boolean hasSymbolPackVersion(java.lang.String name, float version)
          Returns true if the desired version was found.
static boolean hasVariantVersion(java.lang.String name, float version)
          Returns true if the desired version was found.
static void init(java.io.File[] searchPaths, boolean isValidating)
          Initiaize the VariantManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_NEWEST

public static final float VERSION_NEWEST
Version Constant representing the most recent version of a Variant or SymbolPack

See Also:
Constant Field Values

VERSION_OLDEST

public static final float VERSION_OLDEST
Version Constant representing the most oldest version of a Variant or SymbolPack

See Also:
Constant Field Values
Method Detail

init

public static void init(java.io.File[] searchPaths,
                        boolean isValidating)
                 throws javax.xml.parsers.ParserConfigurationException,
                        NoVariantsException
Initiaize the VariantManager.

An exception is thrown if no File paths are specified. A "." may be used to specify th ecurrent directory.

Loaded XML may be validated if the isValidating flag is set to true.

Throws:
javax.xml.parsers.ParserConfigurationException
NoVariantsException

getVariants

public static Variant[] getVariants()
Returns the known Variants. If multiple versions of a Variant exist, only the latest version is returned. The list is sorted in alphabetic order.


getSymbolPacks

public static SymbolPack[] getSymbolPacks()
Returns the known SymbolPacks. If multiple versions of a SymbolPack exist, only the latest version is returned. The list is sorted in alphabetic order.


getVariant

public static Variant getVariant(java.lang.String name,
                                 float version)
Finds Variant with the given name, or null if no Variant is found. Attempts to find the version specified. Versions must be > 0.0f or the version constants VERSION_NEWEST or VERSION_OLDEST.

Note: Name is not case-sensitive.


getSymbolPack

public static SymbolPack getSymbolPack(java.lang.String name,
                                       float version)
Finds SymbolPack with the given name, or null if no SymbolPack is found. Attempts to find the version specified. Versions must be > 0.0f or the version constants VERSION_NEWEST or VERSION_OLDEST.

Note: Name is not case-sensitive.


getSymbolPack

public static SymbolPack getSymbolPack(MapGraphic mg,
                                       java.lang.String symbolPackName,
                                       float symbolPackVersion)
Obtains a SymbolPack via the following criteria:
  1. If matching SymbolPack name and Version found, that is returned; otherwise
  2. Returns SymbolPack of same name but of the newest available version; otherwise
  3. Returns the newest available SymbolPack preferred by the MapGraphic (if set); otherwise
  4. Returns the first SymbolPack in the list of SymbolPacks.

Thus it is assured that a SymbolPack will always be obtained.


hasVariantVersion

public static boolean hasVariantVersion(java.lang.String name,
                                        float version)
Returns true if the desired version was found. Version must be a positive floating point value, or, a defined constant. Returns false if the version is not available or the variant is not found.


hasSymbolPackVersion

public static boolean hasSymbolPackVersion(java.lang.String name,
                                           float version)
Returns true if the desired version was found. Version must be a positive floating point value, or, a defined constant. Returns false if the version is not available or the SymbolPack is not found.


getVariantVersions

public static float[] getVariantVersions(java.lang.String name)
Returns the versions of a variant that are available. If the variant is not found, a zero-length array is returned.


getSymbolPackVersions

public static float[] getSymbolPackVersions(java.lang.String name)
Returns the versions of a SymbolPack that are available. If the SymbolPack is not found, a zero-length array is returned.


getResource

public static java.net.URL getResource(java.net.URL packURL,
                                       java.net.URI uri)
Gets a specific resource for a Variant or a SymbolPack, given a URL to the package and a reference URI. Threadsafe.

Typically, getResource(Variant, URI) or getResource(SymbolPack, URI) is preferred to this method.


getResource

public static java.net.URL getResource(Variant variant,
                                       java.net.URI uri)
Gets a specific resource by properly resolving the URI to this Variant. Null arguments are illegal. Returns null if the resource cannot be resolved. Threadsafe.


getResource

public static java.net.URL getResource(SymbolPack symbolPack,
                                       java.net.URI uri)
Gets a specific resource by properly resolving the URI to this SymbolPack. Null arguments are illegal. Returns null if the resource cannot be resolved. Threadsafe.


getVariantPackageJarURL

public static java.net.URL getVariantPackageJarURL(Variant variant)
Gets the URL to the Variant package (plugin). This is typically only needed in special circumstances. Returns null if null variant input OR variant not found.

Note that this will always return a URL with a JAR prefix. e.g.: jar:http:/the.location/ajar.zip!/ or jar:file:/c:/plugins/ajar.zip!/



Copyright 2002-2004 Zachary DelProposto / jDip Development Team. All Rights Reserved.