public final class LayerBuilder.File extends Object
Modifier and Type | Method and Description |
---|---|
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 label,
Annotation annotation,
String annotationMethod)
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 |
instanceAttribute(String attr,
Class<?> type,
Annotation annotation,
String annotationMethod)
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 or folder to the layer.
|
public String getPath()
LayerBuilder.file(java.lang.String)
public LayerBuilder.File contents(String contents)
contents
- text to use as the body of the filepublic LayerBuilder.File url(String url)
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"
public LayerBuilder.File stringvalue(String attr, String value)
attr
- the attribute namevalue
- the attribute valuepublic LayerBuilder.File bytevalue(String attr, byte value)
attr
- the attribute namevalue
- the attribute valuepublic LayerBuilder.File shortvalue(String attr, short value)
attr
- the attribute namevalue
- the attribute valuepublic LayerBuilder.File intvalue(String attr, int value)
attr
- the attribute namevalue
- the attribute valuepublic LayerBuilder.File longvalue(String attr, long value)
attr
- the attribute namevalue
- the attribute valuepublic LayerBuilder.File floatvalue(String attr, float value)
attr
- the attribute namevalue
- the attribute valuepublic LayerBuilder.File doublevalue(String attr, double value)
attr
- the attribute namevalue
- the attribute valuepublic LayerBuilder.File boolvalue(String attr, boolean value)
attr
- the attribute namevalue
- the attribute valuepublic LayerBuilder.File charvalue(String attr, char value)
attr
- the attribute namevalue
- the attribute valuepublic LayerBuilder.File urlvalue(String attr, URI value) throws LayerGenerationException
attr
- the attribute namevalue
- 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/"
LayerGenerationException
- in case an opaque URI is passed as value
public LayerBuilder.File urlvalue(String attr, String value) throws LayerGenerationException
attr
- the attribute namevalue
- 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/"
LayerGenerationException
- in case value
cannot be parsed as a URI or is opaquepublic LayerBuilder.File methodvalue(String attr, String clazz, String method)
attr
- the attribute nameclazz
- the fully-qualified binary name of the factory classmethod
- the name of a static methodpublic LayerBuilder.File newvalue(String attr, String clazz)
attr
- the attribute nameclazz
- the fully-qualified binary name of a class with a no-argument constructorpublic LayerBuilder.File instanceAttribute(String attr, Class<?> type) throws IllegalArgumentException, LayerGenerationException
LayerGeneratingProcessor
s which define layer fragments which instantiate Java objects from the annotated code.attr
- the attribute nametype
- a type to which the instance ought to be assignable, or null to skip this checkIllegalArgumentException
- if the associated element is not a class or methodLayerGenerationException
- if the associated element would not be loadable as an instance of the specified typepublic LayerBuilder.File instanceAttribute(String attr, Class<?> type, Annotation annotation, String annotationMethod) throws IllegalArgumentException, LayerGenerationException
LayerGeneratingProcessor
s which define layer fragments which instantiate Java objects from the annotated code.attr
- the attribute nametype
- a type to which the instance ought to be assignable, or null to skip this checkannotation
- as in LayerGenerationException.LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)
annotationMethod
- as in LayerGenerationException.LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)
IllegalArgumentException
- if the associated element is not a class or methodLayerGenerationException
- if the associated element would not be loadable as an instance of the specified typepublic LayerBuilder.File bundlevalue(String attr, String bundle, String key)
attr
- the attribute namebundle
- the full name of the bundle, e.g. "org.my.module.Bundle"
key
- the key to look up inside the bundlepublic LayerBuilder.File bundlevalue(String attr, String label) throws LayerGenerationException
attr
- the attribute namelabel
- 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)LayerGenerationException
- if a bundle key is requested but it cannot be found in sourcespublic LayerBuilder.File bundlevalue(String attr, String label, Annotation annotation, String annotationMethod) throws LayerGenerationException
attr
- the attribute namelabel
- 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)annotation
- as in LayerGenerationException.LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)
annotationMethod
- as in LayerGenerationException.LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)
LayerGenerationException
- if a bundle key is requested but it cannot be found in sourcespublic LayerBuilder.File serialvalue(String attr, byte[] data)
attr
- the attribute namedata
- the serial data as created by ObjectOutputStream
public LayerBuilder.File position(int position)
int position() default Integer.MAX_VALUE;
and later call:
fileBuilder.position(annotation.position())
position
- a numeric position for this file, or Integer.MAX_VALUE
to not define any positionpublic LayerBuilder write()