Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

oracle.ide.resourcebundle
Class NodeResourceBundle

java.lang.Object
  extended by oracle.ide.resourcebundle.NodeResourceBundle
All Implemented Interfaces:
java.io.Closeable, java.util.EventListener, TextBufferListener, ResourceBundleWrapper

public abstract class NodeResourceBundle
extends java.lang.Object
implements ResourceBundleWrapper, java.io.Closeable, TextBufferListener

Implementors of ResourceBundleWrapper must extend NodeResourceBundle so that the ResourceBundleManager can properly work with their implementation.
When the ResourceBundleManager attempts to create a resource bundle it will use the NodeFactory to create a Node instance for the URL that contains the data. The ResourceBundleManager will create an instance of the implementation class using a no argument constructor and will then call setResourceBundleNode to set the Node created by the NodeFactory


Nested Class Summary
protected static class NodeResourceBundle.OperationType
           
protected static class NodeResourceBundle.SearchType
          SearchType (ALL_KEYS, EXACT_MATCH, CONTAINS_MATCH, METADATA_MATCH or CONTAINS_KEY)
 
Nested classes/interfaces inherited from interface oracle.javatools.resourcebundle.ResourceBundleWrapper
ResourceBundleWrapper.KeyInfo
 
Field Summary
 
Fields inherited from interface oracle.javatools.buffer.TextBufferListener
EDIT_BEGIN_ATTRIBUTE, EDIT_END_ATTRIBUTE, EOL_TYPE_ATTRIBUTE, MODIFIED_ATTRIBUTE, READ_ONLY_ATTRIBUTE, RELOAD_END_ATTRIBUTE, RELOAD_START_ATTRIBUTE
 
Constructor Summary
NodeResourceBundle()
           
 
Method Summary
 java.lang.String addEntry(java.lang.String text, java.util.Map<java.lang.String,java.lang.String> metadata)
          Adds a new entry (value, and optional metadata) into the resource bundle and returns an automatically generated resource bundle key.
 ResourceBundleOperationResult addEntryNoDialog(java.lang.String key, java.lang.String text, java.util.Map<java.lang.String,java.lang.String> metadata)
          This method only needs to be overridden if writing into the override bundle.
 void addResourceBundleListener(ResourceBundleListener listener)
          Adds a ResourceBundleListener to this resource bundle
 boolean allowsCreateResource()
          Determines whether the bundle allows resources to be created or updated via the select text resource ui
 boolean allowsQueryType(ResourceBundleConstants.QueryTypes queryType)
          Gets whether the specified query type is allowed by the bundle
 void attributeUpdate(TextBuffer buffer, int attribute)
          Provides notification regarding a change to one of the buffer attributes.
 void beginEditorListening(Editor editor)
          Signals the NodeResourceBundle to begin listening to the changes made in the editor in case it makes changes to the file the resource bundle is based on.
 void close()
          Called when the resource bundle is being closed by the ResourceBundleManager
 void createBaseDocument()
          Creates the base document for the resource bundle.
 void delete()
          Deletes the resource bundle
 void endEditorListening(Editor editor)
          Signals the NodeResourceBundle to stop listening to the editor.
protected  void fireKeyAdded(java.lang.String key, java.lang.String text, java.util.Map<java.lang.String,java.lang.String> metadata)
          Convenience method for notifiying all ResourceBundleListeners that a key has been added
protected  void fireKeyChanged(java.lang.String key, java.lang.String text, java.util.Map<java.lang.String,java.lang.String> metadata)
          Convenience method for notifying all ResourceBundleListeners that a key has been changed
protected  void fireKeyRemoved(java.lang.String key)
          Convenience method for notifying all ResourceBundleListeners that a key has been removed
protected  void fireMetadataChanged(java.lang.String key, java.lang.String text, java.util.Map<java.lang.String,java.lang.String> metadata)
          Convenience method for notifying all ResourceBundleListeners that the metadata for a key has been changed
protected  void fireTextChanged(java.lang.String key, java.lang.String text, java.util.Map<java.lang.String,java.lang.String> metadata)
          Convenience method for notifying all ResourceBundleListeners that the text for a key has been changed
protected  void fireUnknownChange()
           
 java.lang.String getBundleId()
          Gets the bundle id for this resource bundle
 ResourceBundleKeyGenerator getKeyGenerator()
          Gets the ResourceBundleKeyGenerator
protected  java.lang.String getMessageText(NodeResourceBundle.OperationType opType, java.lang.String key)
           
 Node getResourceBundleNode()
          Gets the Node that represents the resource bundle
 ResourceBundleConstants.SearchMode getSearchMode()
          Gets the search mode the bundle should use
 java.lang.String getTooltipText()
          Gets a string that can be used as a tool tip
 ResourceBundleConstants.BundleTypes getType()
          Gets the type of resource bundle
 void insertUpdate(TextBuffer buffer, int offset, int count, char[] insertedData)
          Provides notification about an insertion into the TextBuffer.
protected static boolean isHeadless()
           
protected  boolean preUpdateValidation(java.lang.String key, java.lang.String text, boolean showWarningDialog)
          Does basic validation of key and text and provides a warning dialog to let the user know that they are modifying an existing key.
 void removeResourceBundleListener(ResourceBundleListener listener)
          Removes the specified ResourceBundleListener from this resource bundle
 void removeUpdate(TextBuffer buffer, int offset, int count, char[] removedData)
          Provides notification about a removal from the TextBuffer.
protected  void sendEditorChanges()
           
 void setBundleId(java.lang.String bundleId)
          Sets the bundle id for this resource bundle
 void setKeyGenerator(ResourceBundleKeyGenerator keyGenerator)
          Sets the ResourceBundleKeyGenerator
 void setResourceBundleNode(Node resourceBundleNode)
          Sets the Node that represents the resource bundle
 void setType(java.lang.String type)
          Sets the identifier for the type of resource bundle (for example: listResourceBundleId for list resource bundles, propertiesBundleId for properties resource bundles, or xliffResourceBundleId for xliff resource bundles
protected  void showReadOnlyDialog()
           
protected  boolean showWarningDialog(java.lang.String key, java.lang.String text, NodeResourceBundle.OperationType opType)
          Displays a warning message that a key is about to be overwritten
 java.lang.String toString()
          Gets a string that can be used for display purposes
 ResourceBundleOperationResult updateEntryNoDialog(java.lang.String key, java.lang.String text, java.util.Map<java.lang.String,java.lang.String> metadata)
          This should be overridden by classes that implement NodeResourceBundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.javatools.resourcebundle.ResourceBundleWrapper
addEntry, deleteEntry, findKeysByMetaData, findKeysByText, findKeysLikeKey, findKeysLikeText, getMetadata, getString, keySet, updateEntry
 

Constructor Detail

NodeResourceBundle

public NodeResourceBundle()
Method Detail

setBundleId

public void setBundleId(java.lang.String bundleId)
Sets the bundle id for this resource bundle

Specified by:
setBundleId in interface ResourceBundleWrapper
Parameters:
bundleId - string that identifies this bundle

getBundleId

public java.lang.String getBundleId()
Gets the bundle id for this resource bundle

Specified by:
getBundleId in interface ResourceBundleWrapper
Returns:
the string that identifies this bundle

setType

public void setType(java.lang.String type)
Sets the identifier for the type of resource bundle (for example: listResourceBundleId for list resource bundles, propertiesBundleId for properties resource bundles, or xliffResourceBundleId for xliff resource bundles

Parameters:
type - string which identifies the type of bundle

getType

public ResourceBundleConstants.BundleTypes getType()
Gets the type of resource bundle

Returns:
enum representing the type of bundle

close

public void close()
           throws java.io.IOException
Called when the resource bundle is being closed by the ResourceBundleManager

Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException

delete

public void delete()
            throws java.io.IOException
Deletes the resource bundle

Throws:
java.io.IOException - if the delete fails

addEntry

public java.lang.String addEntry(java.lang.String text,
                                 java.util.Map<java.lang.String,java.lang.String> metadata)
Adds a new entry (value, and optional metadata) into the resource bundle and returns an automatically generated resource bundle key.

Specified by:
addEntry in interface ResourceBundleWrapper
Parameters:
text - The text to be translated.
metadata - Any associated metadata about the translation string. This parameter may be null
Returns:
the automatically generated key name
Throws:
java.lang.NullPointerException - If text is null

addEntryNoDialog

public ResourceBundleOperationResult addEntryNoDialog(java.lang.String key,
                                                      java.lang.String text,
                                                      java.util.Map<java.lang.String,java.lang.String> metadata)
This method only needs to be overridden if writing into the override bundle. This can only be done in one place so the standard implementation here should be good for everyone.

Specified by:
addEntryNoDialog in interface ResourceBundleWrapper
Parameters:
key - The key name to use in the resource bundle.
text - The text to be translated.
metadata - Any associated metadata about the translation string This parameter may be null
Returns:
result object that contains whether the operation was successful or not and potentially a warning message

preUpdateValidation

protected boolean preUpdateValidation(java.lang.String key,
                                      java.lang.String text,
                                      boolean showWarningDialog)
Does basic validation of key and text and provides a warning dialog to let the user know that they are modifying an existing key.


updateEntryNoDialog

public ResourceBundleOperationResult updateEntryNoDialog(java.lang.String key,
                                                         java.lang.String text,
                                                         java.util.Map<java.lang.String,java.lang.String> metadata)
                                                  throws java.lang.NullPointerException
This should be overridden by classes that implement NodeResourceBundle. This implementation is only to provide compatibility with implementations that have not overridden this method so they can work, though they may show or not show a dialog properly if the user needs to be warned of an update occuring.

Specified by:
updateEntryNoDialog in interface ResourceBundleWrapper
Parameters:
key - The key to update
text - The new text for the given key
metadata - Any metadata to change. Existing metadata is merged with the new metadata, unless there is a key with a null value, then the existing metadata for that key is removed. If metadata is null then the existing metadata will be unchanged.
Returns:
result object that contains whether the operation was successful or not and potentially a warning message
Throws:
java.lang.NullPointerException

getResourceBundleNode

public Node getResourceBundleNode()
Gets the Node that represents the resource bundle

Returns:
the node that represents the resource bundle

setResourceBundleNode

public void setResourceBundleNode(Node resourceBundleNode)
Sets the Node that represents the resource bundle

Parameters:
resourceBundleNode - the node that represents the resource bundle

setKeyGenerator

public void setKeyGenerator(ResourceBundleKeyGenerator keyGenerator)
Sets the ResourceBundleKeyGenerator

Specified by:
setKeyGenerator in interface ResourceBundleWrapper
Parameters:
keyGenerator - the resource bundle key generator

getKeyGenerator

public ResourceBundleKeyGenerator getKeyGenerator()
Gets the ResourceBundleKeyGenerator

Specified by:
getKeyGenerator in interface ResourceBundleWrapper
Returns:
the resource bundle key generator, may be null

toString

public java.lang.String toString()
Gets a string that can be used for display purposes

Overrides:
toString in class java.lang.Object
Returns:
name to use for display purposes

getTooltipText

public java.lang.String getTooltipText()
Gets a string that can be used as a tool tip

Returns:
string to use as a tool tip

allowsCreateResource

public boolean allowsCreateResource()
Determines whether the bundle allows resources to be created or updated via the select text resource ui

Returns:
true if resource creation/updating is allowed from the select text resource ui; false otherwise

getSearchMode

public ResourceBundleConstants.SearchMode getSearchMode()
Gets the search mode the bundle should use

Returns:
ResourceBundleConstants.SearchMode.FILTER if the bundle should auto-query data when the bundle is selected and should only filter the data when a query is performed; ResourceBundleConstants.SearchMode.SEARCH if the bundle should not query data until the user performs a query and each query replaces the data set rather than filtering the existing data

allowsQueryType

public boolean allowsQueryType(ResourceBundleConstants.QueryTypes queryType)
Gets whether the specified query type is allowed by the bundle

Parameters:
queryType - supported types are ResourceBundleConstants.QueryType.ALL, ResourceBundleConstants.QueryType.KEY, ResourceBundleContants.QueryType.TEXT, and ResourceBundleContants.QueryType.COMMENT
Returns:
true if the specified queryType is allowed; false otherwise

addResourceBundleListener

public void addResourceBundleListener(ResourceBundleListener listener)
                               throws java.lang.NullPointerException
Adds a ResourceBundleListener to this resource bundle

Specified by:
addResourceBundleListener in interface ResourceBundleWrapper
Parameters:
listener - the listener to add
Throws:
java.lang.NullPointerException
See Also:
ResourceBundleListener, ResourceBundleEvent

removeResourceBundleListener

public void removeResourceBundleListener(ResourceBundleListener listener)
                                  throws java.lang.NullPointerException
Removes the specified ResourceBundleListener from this resource bundle

Specified by:
removeResourceBundleListener in interface ResourceBundleWrapper
Parameters:
listener - the listener to remove
Throws:
java.lang.NullPointerException
See Also:
ResourceBundleListener, ResourceBundleEvent

createBaseDocument

public void createBaseDocument()
Creates the base document for the resource bundle. Each implementation of a NodeResourceBundle will need to provide an implementation of createBaseDocument() if they allow a document to be created.


isHeadless

protected static boolean isHeadless()

getMessageText

protected java.lang.String getMessageText(NodeResourceBundle.OperationType opType,
                                          java.lang.String key)

showReadOnlyDialog

protected void showReadOnlyDialog()

showWarningDialog

protected boolean showWarningDialog(java.lang.String key,
                                    java.lang.String text,
                                    NodeResourceBundle.OperationType opType)
Displays a warning message that a key is about to be overwritten

Parameters:
key - the key that will be overwritten
text - the text that will be used to overwrite the existing text
opType - the type of operation being performed
Returns:
true if the user wants to continue; false otherwise

beginEditorListening

public void beginEditorListening(Editor editor)
Signals the NodeResourceBundle to begin listening to the changes made in the editor in case it makes changes to the file the resource bundle is based on. The default implementation listens to changes in the text buffer and sets the hasChanged to true when there are changes.

Parameters:
editor - the editor to begin listening to

endEditorListening

public void endEditorListening(Editor editor)
Signals the NodeResourceBundle to stop listening to the editor. text buffer the resource bundle is based on because the node has been closed in an Editor.

Parameters:
editor - the editor to stop listening to

sendEditorChanges

protected void sendEditorChanges()

fireKeyAdded

protected void fireKeyAdded(java.lang.String key,
                            java.lang.String text,
                            java.util.Map<java.lang.String,java.lang.String> metadata)
Convenience method for notifiying all ResourceBundleListeners that a key has been added

Parameters:
key - the key that has been added
text - the text for the key
metadata - the metadata for the key

fireKeyRemoved

protected void fireKeyRemoved(java.lang.String key)
Convenience method for notifying all ResourceBundleListeners that a key has been removed

Parameters:
key - the key that has been removed

fireKeyChanged

protected void fireKeyChanged(java.lang.String key,
                              java.lang.String text,
                              java.util.Map<java.lang.String,java.lang.String> metadata)
Convenience method for notifying all ResourceBundleListeners that a key has been changed

Parameters:
key - the key that has been changed
text - the text for the key that has been changed
metadata - the metadata for the key that has been changed

fireTextChanged

protected void fireTextChanged(java.lang.String key,
                               java.lang.String text,
                               java.util.Map<java.lang.String,java.lang.String> metadata)
Convenience method for notifying all ResourceBundleListeners that the text for a key has been changed

Parameters:
key - the key that has been changed
text - the text for the key that has been changed
metadata - the metadata for the key that has been changed

fireUnknownChange

protected void fireUnknownChange()

fireMetadataChanged

protected void fireMetadataChanged(java.lang.String key,
                                   java.lang.String text,
                                   java.util.Map<java.lang.String,java.lang.String> metadata)
Convenience method for notifying all ResourceBundleListeners that the metadata for a key has been changed

Parameters:
key - the key that has been changed
text - the text for the key that has been changed
metadata - the metadata for the key that has been changed

insertUpdate

public void insertUpdate(TextBuffer buffer,
                         int offset,
                         int count,
                         char[] insertedData)
Description copied from interface: TextBufferListener
Provides notification about an insertion into the TextBuffer.

Specified by:
insertUpdate in interface TextBufferListener
Parameters:
buffer - the TextBuffer that changed.
offset - the offset where the insert took place
count - the number of characters inserted (insertedData.length)
insertedData - an array of the removed characters.

removeUpdate

public void removeUpdate(TextBuffer buffer,
                         int offset,
                         int count,
                         char[] removedData)
Description copied from interface: TextBufferListener
Provides notification about a removal from the TextBuffer.

Specified by:
removeUpdate in interface TextBufferListener
Parameters:
buffer - the TextBuffer that changed.
offset - the offset of the first removed character.
count - the number of characters removed (removedData.length)
removedData - an array of the removed characters

attributeUpdate

public void attributeUpdate(TextBuffer buffer,
                            int attribute)
Description copied from interface: TextBufferListener
Provides notification regarding a change to one of the buffer attributes. The possible attributes are defined in this interface.

Specified by:
attributeUpdate in interface TextBufferListener
Parameters:
buffer - the TextBuffer that changed.
attribute - the attribute that changed

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.1.0)

E17493-02

Copyright © 1997, 2011, Oracle. All rights reserved.