org.openide.filesystems 7.21.1 1

org.openide.filesystems.annotations
Class LayerBuilder.File

java.lang.Object
  extended by org.openide.filesystems.annotations.LayerBuilder.File
Enclosing class:
LayerBuilder

public final class LayerBuilder.File
extends Object

Builder for creating a single file entry.


Method Summary
 LayerBuilder.File boolvalue(String attr, boolean value)
          Adds a boolean-valued attribute.
 LayerBuilder.File bundlevalue(String attr, String label)
          Adds an attribute for a possibly localized string.
 LayerBuilder.File bundlevalue(String attr, String bundle, String key)
          Adds an attribute loaded from a resource bundle.
 LayerBuilder.File bytevalue(String attr, byte value)
          Adds a byte-valued attribute.
 LayerBuilder.File charvalue(String attr, char value)
          Adds a character-valued attribute.
 LayerBuilder.File contents(String contents)
          Configures the file to have inline text contents.
 LayerBuilder.File doublevalue(String attr, double value)
          Adds a double-valued attribute.
 LayerBuilder.File floatvalue(String attr, float value)
          Adds a float-valued attribute.
 String getPath()
          Gets the path this file is to be created under.
 LayerBuilder.File instanceAttribute(String attr, Class type)
          Adds an attribute to load the associated class or method.
 LayerBuilder.File intvalue(String attr, int value)
          Adds an int-valued attribute.
 LayerBuilder.File longvalue(String attr, long value)
          Adds a long-valued attribute.
 LayerBuilder.File methodvalue(String attr, String clazz, String method)
          Adds an attribute loaded from a Java method.
 LayerBuilder.File newvalue(String attr, String clazz)
          Adds an attribute loaded from a Java constructor.
 LayerBuilder.File position(int position)
          Sets a position attribute.
 LayerBuilder.File serialvalue(String attr, byte[] data)
          Adds an attribute which deserializes a Java value.
 LayerBuilder.File shortvalue(String attr, short value)
          Adds a short-valued attribute.
 LayerBuilder.File stringvalue(String attr, String value)
          Adds a string-valued attribute.
 LayerBuilder.File url(String url)
          Configures the file to have external contents.
 LayerBuilder.File urlvalue(String attr, String value)
          Adds a URL-valued attribute.
 LayerBuilder.File urlvalue(String attr, URI value)
          Adds a URL-valued attribute.
 LayerBuilder write()
          Writes the file to the layer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getPath

public String getPath()
Gets the path this file is to be created under.

Returns:
the configured path, as in LayerBuilder.file(java.lang.String)

contents

public LayerBuilder.File contents(String contents)
Configures the file to have inline text contents.

Parameters:
contents - text to use as the body of the file
Returns:
this builder

url

public LayerBuilder.File url(String url)
Configures the file to have external contents.

Parameters:
url - a URL to the body of the file, e.g. "nbresloc:/org/my/module/resources/definition.xml" or more commonly an absolute resource path such as "/org/my/module/resources/definition.xml"
Returns:
this builder

stringvalue

public LayerBuilder.File stringvalue(String attr,
                                     String value)
Adds a string-valued attribute.

Parameters:
attr - the attribute name
value - the attribute value
Returns:
this builder

bytevalue

public LayerBuilder.File bytevalue(String attr,
                                   byte value)
Adds a byte-valued attribute.

Parameters:
attr - the attribute name
value - the attribute value
Returns:
this builder

shortvalue

public LayerBuilder.File shortvalue(String attr,
                                    short value)
Adds a short-valued attribute.

Parameters:
attr - the attribute name
value - the attribute value
Returns:
this builder

intvalue

public LayerBuilder.File intvalue(String attr,
                                  int value)
Adds an int-valued attribute.

Parameters:
attr - the attribute name
value - the attribute value
Returns:
this builder

longvalue

public LayerBuilder.File longvalue(String attr,
                                   long value)
Adds a long-valued attribute.

Parameters:
attr - the attribute name
value - the attribute value
Returns:
this builder

floatvalue

public LayerBuilder.File floatvalue(String attr,
                                    float value)
Adds a float-valued attribute.

Parameters:
attr - the attribute name
value - the attribute value
Returns:
this builder

doublevalue

public LayerBuilder.File doublevalue(String attr,
                                     double value)
Adds a double-valued attribute.

Parameters:
attr - the attribute name
value - the attribute value
Returns:
this builder

boolvalue

public LayerBuilder.File boolvalue(String attr,
                                   boolean value)
Adds a boolean-valued attribute.

Parameters:
attr - the attribute name
value - the attribute value
Returns:
this builder

charvalue

public LayerBuilder.File charvalue(String attr,
                                   char value)
Adds a character-valued attribute.

Parameters:
attr - the attribute name
value - the attribute value
Returns:
this builder

urlvalue

public LayerBuilder.File urlvalue(String attr,
                                  URI value)
                           throws LayerGenerationException
Adds a URL-valued attribute.

Parameters:
attr - the attribute name
value - the attribute value, e.g. "/my/module/resource.html" or "nbresloc:/my/module/resource.html"; relative values permitted but not likely useful as base URL would be e.g. "jar:...!/META-INF/"
Returns:
this builder
Throws:
LayerGenerationException - in case an opaque URI is passed as value

urlvalue

public LayerBuilder.File urlvalue(String attr,
                                  String value)
                           throws LayerGenerationException
Adds a URL-valued attribute.

Parameters:
attr - the attribute name
value - the attribute value, e.g. "/my/module/resource.html" or "nbresloc:/my/module/resource.html"; relative values permitted but not likely useful as base URL would be e.g. "jar:...!/META-INF/"
Returns:
this builder
Throws:
LayerGenerationException - in case value cannot be parsed as a URI or is opaque

methodvalue

public LayerBuilder.File methodvalue(String attr,
                                     String clazz,
                                     String method)
Adds an attribute loaded from a Java method.

Parameters:
attr - the attribute name
clazz - the fully-qualified binary name of the factory class
method - the name of a static method
Returns:
this builder

newvalue

public LayerBuilder.File newvalue(String attr,
                                  String clazz)
Adds an attribute loaded from a Java constructor.

Parameters:
attr - the attribute name
clazz - the fully-qualified binary name of a class with a no-argument constructor
Returns:
this builder

instanceAttribute

public LayerBuilder.File instanceAttribute(String attr,
                                           Class type)
                                    throws IllegalArgumentException,
                                           LayerGenerationException
Adds an attribute to load the associated class or method. Useful for LayerGeneratingProcessors which define layer fragments which instantiate Java objects from the annotated code.

Parameters:
attr - the attribute name
type - a type to which the instance ought to be assignable, or null to skip this check
Returns:
this builder
Throws:
IllegalArgumentException - if the associated element is not a class or method
LayerGenerationException - if the associated element would not be loadable as an instance of the specified type

bundlevalue

public LayerBuilder.File bundlevalue(String attr,
                                     String bundle,
                                     String key)
Adds an attribute loaded from a resource bundle.

Parameters:
attr - the attribute name
bundle - the full name of the bundle, e.g. "org.my.module.Bundle"
key - the key to look up inside the bundle
Returns:
this builder

bundlevalue

public LayerBuilder.File bundlevalue(String attr,
                                     String label)
                              throws LayerGenerationException
Adds an attribute for a possibly localized string.

Parameters:
attr - the attribute name
label - either a general string to store as is, or a resource bundle reference such as "my.module.Bundle#some_key", or just "#some_key" to load from a "Bundle" in the same package as the element associated with this builder (if exactly one)
Returns:
this builder
Throws:
LayerGenerationException - if a bundle key is requested but it cannot be found in sources

serialvalue

public LayerBuilder.File serialvalue(String attr,
                                     byte[] data)
Adds an attribute which deserializes a Java value.

Parameters:
attr - the attribute name
data - the serial data as created by ObjectOutputStream
Returns:
this builder

position

public LayerBuilder.File position(int position)
Sets a position attribute. This is a convenience method so you can define in your annotation: int position() default Integer.MAX_VALUE; and later call: fileBuilder.position(annotation.position())

Parameters:
position - a numeric position for this file, or Integer.MAX_VALUE to not define any position
Returns:
this builder

write

public LayerBuilder write()
Writes the file to the layer. Any intervening parent folders are created automatically. If the file already exists, the old copy is replaced.

Returns:
the originating layer builder, in case you want to add another file

org.openide.filesystems 7.21.1 1

Built on September 27 2009.  |  Portions Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.