Class Clientlib
- java.lang.Object
-
- com.composum.sling.clientlibs.handle.Clientlib
-
- All Implemented Interfaces:
ClientlibElement
public class Clientlib extends Object implements ClientlibElement
Models a client library, containing one or several ClientlibResourceFolders.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Clientlib.Type
Type of the element:Clientlib.Type.link
,Clientlib.Type.css
,Clientlib.Type.js
,Clientlib.Type.img
.
-
Field Summary
Fields Modifier and Type Field Description static String
CATEGORYNAME_CHARS
Allowed characters in a category name, for use in regex character classesstatic String
PROP_CATEGORY
Attribute for Client libraries (only the uppermost folder withRESOURCE_TYPE
) that gives a list of categories this client library belongs to.static String
PROP_ORDER
Attribute for Client libraries (only the uppermost folder withRESOURCE_TYPE
) that gives an integer that orders the client libraries if there are several belonging to the samePROP_CATEGORY
.ResourceHandle
resource
static String
RESOURCE_TYPE
Resource type of client libraries.
-
Constructor Summary
Constructors Constructor Description Clientlib(Clientlib.Type type, org.apache.sling.api.resource.Resource resource)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(ClientlibVisitor visitor, ClientlibVisitor.VisitorMode mode, ClientlibResourceFolder parent)
Dispatcher for the appropriate method of visitor: just callsvisitor.visit(this, mode, parent);
.boolean
equals(Object o)
@NotNull List<String>
getCategories()
String
getDescription()
int
getOrder()
ClientlibRef
getRef()
A reference that matches this.ClientlibResourceFolder
getResourceFolder()
Clientlib.Type
getType()
The resource-type for which it was created.int
hashCode()
boolean
isValid()
ClientlibLink
makeLink()
A link that matches this.static String
sanitizeCategory(String category)
Removes invalid chars (according toCATEGORYNAME_CHARS
) from a category; returns null if there is nothing left / was empty, anyway.String
toString()
-
-
-
Field Detail
-
CATEGORYNAME_CHARS
public static final String CATEGORYNAME_CHARS
Allowed characters in a category name, for use in regex character classes- See Also:
- Constant Field Values
-
PROP_CATEGORY
public static final String PROP_CATEGORY
Attribute for Client libraries (only the uppermost folder withRESOURCE_TYPE
) that gives a list of categories this client library belongs to.- See Also:
- Constant Field Values
-
PROP_ORDER
public static final String PROP_ORDER
Attribute for Client libraries (only the uppermost folder withRESOURCE_TYPE
) that gives an integer that orders the client libraries if there are several belonging to the samePROP_CATEGORY
. Default value (that is, if not present) is 0.- See Also:
- Constant Field Values
-
RESOURCE_TYPE
public static final String RESOURCE_TYPE
Resource type of client libraries.- See Also:
- Constant Field Values
-
resource
public final ResourceHandle resource
-
-
Constructor Detail
-
Clientlib
public Clientlib(Clientlib.Type type, org.apache.sling.api.resource.Resource resource)
-
-
Method Detail
-
getRef
public ClientlibRef getRef()
A reference that matches this.- Specified by:
getRef
in interfaceClientlibElement
-
makeLink
public ClientlibLink makeLink()
A link that matches this.- Specified by:
makeLink
in interfaceClientlibElement
-
getType
public Clientlib.Type getType()
Description copied from interface:ClientlibElement
The resource-type for which it was created.- Specified by:
getType
in interfaceClientlibElement
-
isValid
public boolean isValid()
-
getResourceFolder
public ClientlibResourceFolder getResourceFolder()
-
getOrder
public int getOrder()
-
accept
public void accept(ClientlibVisitor visitor, ClientlibVisitor.VisitorMode mode, ClientlibResourceFolder parent) throws IOException, javax.jcr.RepositoryException
Description copied from interface:ClientlibElement
Dispatcher for the appropriate method of visitor: just callsvisitor.visit(this, mode, parent);
.- Specified by:
accept
in interfaceClientlibElement
- Parameters:
visitor
- the visitor we want to dispatch tomode
- processing modeparent
- if applicable, the parent of the visited resource- Throws:
IOException
javax.jcr.RepositoryException
-
sanitizeCategory
public static String sanitizeCategory(String category)
Removes invalid chars (according toCATEGORYNAME_CHARS
) from a category; returns null if there is nothing left / was empty, anyway.
-
-