com.binaryfantasy.murq.source
Class SourceKey

java.lang.Object
  extended by com.binaryfantasy.murq.source.SourceKey

public final class SourceKey
extends Object

An immutable internal class that manages the translation between content's public id, locale and possibly it's internal binary id and it's String source key. SourceKey also handles the finding of internationalized candidates for a given piece of content.

Author:
Bill Weiss

Field Summary
static String SEPARATOR_BINARY
          Character used to separate the optional binary id from the content id and/or the locale.
static String SEPARATOR_LOCALE
          Character used to separate locale from content id.
 
Method Summary
 boolean equals(Object obj)
           
 String getBinaryId()
          Returns the identifier for a piece of binary data belonging to the content holding this key's contentId.
static List<SourceKey> getCandidates(String contentId, Locale locale)
          Returns SourceKey local candidates using the method described in ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader).
 String getContentId()
          Returns the base id for this key.
 Locale getLocale()
          Returns this key's specific locale, or null if it represents default content.
static SourceKey getSourceKey(IContent content)
          Returns a SourceKey represented by the specified IContent.
static SourceKey getSourceKey(String sourceKey)
          Returns a SourceKey represented by the specified String.
static SourceKey getSourceKey(String contentId, Locale locale, String binaryId)
          Returns a SourceKey representing the contentId and the optional locale and binaryId.
 int hashCode()
           
 boolean isBinary()
          Return true if this key points to binary data.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SEPARATOR_LOCALE

public static final String SEPARATOR_LOCALE
Character used to separate locale from content id.

See Also:
Constant Field Values

SEPARATOR_BINARY

public static final String SEPARATOR_BINARY
Character used to separate the optional binary id from the content id and/or the locale.

See Also:
Constant Field Values
Method Detail

getSourceKey

public static SourceKey getSourceKey(String sourceKey)
Returns a SourceKey represented by the specified String.

Parameters:
sourceKey - String representation of the SourceKey requested.
Returns:
a SourceKey represented by the specified String.
Throws:
IllegalArgumentException - if sourceKey is null.

getSourceKey

public static SourceKey getSourceKey(IContent content)
Returns a SourceKey represented by the specified IContent.

Parameters:
content - content to get a source key for.
Returns:
a SourceKey represented by the specified IContent.
Throws:
IllegalArgumentException - if content or the contentId of the content is null.

getSourceKey

public static SourceKey getSourceKey(String contentId,
                                     Locale locale,
                                     String binaryId)
Returns a SourceKey representing the contentId and the optional locale and binaryId.

Note: The binaryId argument does not relate to IBinaryContent. SourceKeys with a binaryId point to binary data that is to be recombined with other deserialized data to reform a IContent object.

Parameters:
contentId - contentId to base the SourceKey on.
locale - specific locale for the key, or null if default.
binaryId - the identifier for binary data that makes up part of an IContent.
Returns:
a SourceKey representing the contentId and the optional locale and binaryId.
Throws:
IllegalArgumentException - if the contentId is null.

getCandidates

public static List<SourceKey> getCandidates(String contentId,
                                            Locale locale)
Returns SourceKey local candidates using the method described in ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader).

Parameters:
contentId - the id to get candidates for.
locale - the specific locale desired, from which alternate candidates will be generated.
Returns:
SourceKey local candidates using the method described in ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader).

getContentId

public String getContentId()
Returns the base id for this key.

Returns:
the base id for this key.

getLocale

public Locale getLocale()
Returns this key's specific locale, or null if it represents default content.

Returns:
this key's specific locale, or null if it represents default content.

getBinaryId

public String getBinaryId()
Returns the identifier for a piece of binary data belonging to the content holding this key's contentId.

Returns:
the identifier for a piece of binary data belonging to the content holding this key's contentId.

isBinary

public boolean isBinary()
Return true if this key points to binary data.

Returns:
true if this key points to binary data.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright (c) 2000-2006, BinaryFantasy.com