Class ApiRegions
- java.lang.Object
-
- org.apache.sling.feature.extension.apiregions.api.ApiRegions
-
public class ApiRegions extends Object
Configuration of API regions for Java API. This class is not thread safe.
-
-
Field Summary
Fields Modifier and Type Field Description static String
EXTENSION_NAME
The name of the api regions extension.
-
Constructor Summary
Constructors Constructor Description ApiRegions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(int idx, ApiRegion region)
Add the region.boolean
add(ApiRegion region)
Add the region.boolean
equals(Object obj)
static ApiRegions
getApiRegions(org.apache.sling.feature.Extension ext)
Get the api regions from the extension.static ApiRegions
getApiRegions(org.apache.sling.feature.Feature feature)
Get the api regions from the feature - if it exists.ApiRegion
getRegionByName(String name)
Get a named regionList<String>
getRegionNames()
Get the names of the regionsApiRegion[]
getRegionsByFeature(org.apache.sling.feature.ArtifactId featureId)
ApiRegion
getRoot()
Get the root regions.int
hashCode()
boolean
isEmpty()
Check if any region existsList<ApiRegion>
listRegions()
Return the list of regionsstatic ApiRegions
parse(String json)
Parse a JSON array into an api regions objectstatic ApiRegions
parse(javax.json.JsonArray json)
Parse a JSON array into an api regions objectString
toJSON()
Convert regions into jsonjavax.json.JsonArray
toJSONArray()
Convert regions into jsonString
toString()
-
-
-
Field Detail
-
EXTENSION_NAME
public static final String EXTENSION_NAME
The name of the api regions extension.- See Also:
- Constant Field Values
-
-
Method Detail
-
listRegions
public List<ApiRegion> listRegions()
Return the list of regions- Returns:
- Unmodifiable list of regions, might be empty
-
getRoot
public ApiRegion getRoot()
Get the root regions. The root is the region which does not have a parent- Returns:
- The root region or
null
-
isEmpty
public boolean isEmpty()
Check if any region exists- Returns:
true
if it has any region
-
add
public boolean add(ApiRegion region)
Add the region. The region is only added if there isn't already a region with the same name- Parameters:
region
- The region to add- Returns:
true
if the region could be added,false
otherwise
-
add
public boolean add(int idx, ApiRegion region)
Add the region. The region is only added if there isn't already a region with the same name- Parameters:
idx
- The position to addregion
- The region to add- Returns:
true
if the region could be added,false
otherwise
-
getRegionByName
public ApiRegion getRegionByName(String name)
Get a named region- Parameters:
name
- The name- Returns:
- The region or
null
-
getRegionsByFeature
public ApiRegion[] getRegionsByFeature(org.apache.sling.feature.ArtifactId featureId)
-
getRegionNames
public List<String> getRegionNames()
Get the names of the regions- Returns:
- The list of regions, might be empty
-
toJSONArray
public javax.json.JsonArray toJSONArray() throws IOException
Convert regions into json- Returns:
- The json array
- Throws:
IOException
- If generating the JSON fails
-
toJSON
public String toJSON() throws IOException
Convert regions into json- Returns:
- The json array as a string
- Throws:
IOException
- If generating the JSON fails
-
parse
public static ApiRegions parse(String json) throws IOException
Parse a JSON array into an api regions object- Parameters:
json
- The json as a string- Returns:
- The api regions
- Throws:
IOException
- If the json could not be parsed
-
parse
public static ApiRegions parse(javax.json.JsonArray json) throws IOException
Parse a JSON array into an api regions object- Parameters:
json
- The json- Returns:
- The api regions
- Throws:
IOException
- If the json could not be parsed
-
getApiRegions
public static ApiRegions getApiRegions(org.apache.sling.feature.Feature feature)
Get the api regions from the feature - if it exists.- Parameters:
feature
- The feature- Returns:
- The api regions or
null
. - Throws:
IllegalArgumentException
- If the extension is wrongly formatted- Since:
- 1.1
-
getApiRegions
public static ApiRegions getApiRegions(org.apache.sling.feature.Extension ext)
Get the api regions from the extension.- Parameters:
ext
- The extension- Returns:
- The api regions or
null
. - Throws:
IllegalArgumentException
- If the extension is wrongly formatted- Since:
- 1.1
-
-