Eclipse Platform
2.0

org.eclipse.update.core.model
Class ModelObject

java.lang.Object
  |
  +--org.eclipse.core.runtime.PlatformObject
        |
        +--org.eclipse.update.core.model.ModelObject
All Implemented Interfaces:
IAdaptable
Direct Known Subclasses:
ArchiveReferenceModel, CategoryModel, ContentEntryModel, FeatureModel, FeatureReferenceModel, ImportModel, InstallHandlerEntryModel, SiteModel, URLEntryModel

public abstract class ModelObject
extends PlatformObject

Root model object. Extended by all model objects.

This class cannot be instantiated and must be subclassed.


Constructor Summary
protected ModelObject()
          Creates a base model object.
 
Method Summary
protected  Object[] arrayTypeFor(List l)
          Returns a concrete array type for the elements of the specified list.
protected  Object[] arrayTypeFor(Set s)
          Returns a concrete array type for the elements of the specified set.
protected  void assertIsWriteable()
          Checks that this model object is writeable.
 boolean isReadOnly()
          Returns whether or not this model object is read-only.
protected  void markListReferenceReadOnly(ModelObject[] o)
          Delegate setting of read-only
 void markReadOnly()
          Sets this model object and all of its descendents to be read-only.
protected  void markReferenceReadOnly(ModelObject o)
          Delegate setting of read-only
 void resolve(URL base, ResourceBundle bundle)
          Resolve the model element.
protected  void resolveListReference(ModelObject[] o, URL url, ResourceBundle bundle)
          Delegate resolution to list of referenced models
protected  String resolveNLString(ResourceBundle b, String string)
          Returns a resource string corresponding to the given argument value and bundle.
protected  void resolveReference(ModelObject o, URL url, ResourceBundle bundle)
          Delegate resolution to referenced model
protected  URL resolveURL(URL context, ResourceBundle bundle, String urlString)
          Resolve a URL based on context
 
Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelObject

protected ModelObject()
Creates a base model object.

Since:
2.0
Method Detail

assertIsWriteable

protected final void assertIsWriteable()
Checks that this model object is writeable. A runtime exception is thrown if it is not.

Since:
2.0

markReadOnly

public void markReadOnly()
Sets this model object and all of its descendents to be read-only. Subclasses may extend this implementation.

Since:
2.0
See Also:
isReadOnly()

isReadOnly

public boolean isReadOnly()
Returns whether or not this model object is read-only.

Returns:
true if this model object is read-only, false otherwise
Since:
2.0
See Also:
markReadOnly()

markReferenceReadOnly

protected void markReferenceReadOnly(ModelObject o)
Delegate setting of read-only

Parameters:
o - object to delegate to. Must be of type ModelObject.
Since:
2.0
See Also:
isReadOnly()

markListReferenceReadOnly

protected void markListReferenceReadOnly(ModelObject[] o)
Delegate setting of read-only

Parameters:
o - object array to delegate to. Each element must be of type ModelObject.
Since:
2.0
See Also:
isReadOnly()

resolve

public void resolve(URL base,
                    ResourceBundle bundle)
             throws MalformedURLException
Resolve the model element. This method allows any relative URL strings to be resolved to actual URL. It also allows any translatable strings to be localized. Subclasses need to override this method to perform the actual resolution.

Parameters:
base - base URL.
bundle - resource bundle.
Throws:
MalformedURLException
Since:
2.0

resolveReference

protected void resolveReference(ModelObject o,
                                URL url,
                                ResourceBundle bundle)
                         throws MalformedURLException
Delegate resolution to referenced model

Parameters:
o - object to delegate to. Must be of type ModelObject.
bundle - resource bundle.
Throws:
MalformedURLException
Since:
2.0

resolveListReference

protected void resolveListReference(ModelObject[] o,
                                    URL url,
                                    ResourceBundle bundle)
                             throws MalformedURLException
Delegate resolution to list of referenced models

Parameters:
o - object array to delegate to. Each element must be of type ModelObject.
bundle - resource bundle.
Throws:
MalformedURLException
Since:
2.0

resolveURL

protected URL resolveURL(URL context,
                         ResourceBundle bundle,
                         String urlString)
                  throws MalformedURLException
Resolve a URL based on context

Parameters:
bundle - resource bundle.
urlString - url string from model.
Returns:
URL, or null.
Throws:
MalformedURLException
Since:
2.0

resolveNLString

protected String resolveNLString(ResourceBundle b,
                                 String string)
Returns a resource string corresponding to the given argument value and bundle. If the argument value specifies a resource key, the string is looked up in the given resource bundle. If the argument does not specify a valid key, the argument itself is returned as the resource string. The key lookup is performed against the specified resource bundle. If a resource string corresponding to the key is not found in the resource bundle the key value, or any default text following the key in the argument value is returned as the resource string. A key is identified as a string begining with the "%" character. Note that the "%" character is stripped off prior to lookup in the resource bundle.

For example, assume resource bundle plugin.properties contains name = Project Name

     resolveNLString(b,"Hello World") returns "Hello World"
     resolveNLString(b,"%name") returns "Project Name"
     resolveNLString(b,"%name Hello World") returns "Project Name"
     resolveNLString(b,"%abcd Hello World") returns "Hello World"
     resolveNLString(b,"%abcd") returns "%abcd"
     resolveNLString(b,"%%name") returns "%name"
 

Returns:
string, or null
Since:
2.0

arrayTypeFor

protected Object[] arrayTypeFor(List l)
Returns a concrete array type for the elements of the specified list. The method assumes all the elements of the list are the same concrete type as the first element in the list.

Parameters:
l - list
Returns:
concrete array type, or null if the array type could not be determined (the list is null or empty)
Since:
2.0

arrayTypeFor

protected Object[] arrayTypeFor(Set s)
Returns a concrete array type for the elements of the specified set. The method assumes all the elements of the set are the same concrete type as the first element in the set.

Parameters:
s - set
Returns:
concrete array type, or null if the array type could not be determined (the set is null or empty)
Since:
2.0

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.