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 classClientlib.TypeType of the element:Clientlib.Type.link,Clientlib.Type.css,Clientlib.Type.js,Clientlib.Type.img.
-
Field Summary
Fields Modifier and Type Field Description static StringCATEGORYNAME_CHARSAllowed characters in a category name, for use in regex character classesstatic StringPROP_CATEGORYAttribute for Client libraries (only the uppermost folder withRESOURCE_TYPE) that gives a list of categories this client library belongs to.static StringPROP_ORDERAttribute 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.ResourceHandleresourcestatic StringRESOURCE_TYPEResource 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 voidaccept(ClientlibVisitor visitor, ClientlibVisitor.VisitorMode mode, ClientlibResourceFolder parent)Dispatcher for the appropriate method of visitor: just callsvisitor.visit(this, mode, parent);.booleanequals(Object o)@NotNull List<String>getCategories()StringgetDescription()intgetOrder()ClientlibRefgetRef()A reference that matches this.ClientlibResourceFoldergetResourceFolder()Clientlib.TypegetType()The resource-type for which it was created.inthashCode()booleanisValid()ClientlibLinkmakeLink()A link that matches this.static StringsanitizeCategory(String category)Removes invalid chars (according toCATEGORYNAME_CHARS) from a category; returns null if there is nothing left / was empty, anyway.StringtoString()
-
-
-
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:
getRefin interfaceClientlibElement
-
makeLink
public ClientlibLink makeLink()
A link that matches this.- Specified by:
makeLinkin interfaceClientlibElement
-
getType
public Clientlib.Type getType()
Description copied from interface:ClientlibElementThe resource-type for which it was created.- Specified by:
getTypein 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:ClientlibElementDispatcher for the appropriate method of visitor: just callsvisitor.visit(this, mode, parent);.- Specified by:
acceptin interfaceClientlibElement- Parameters:
visitor- the visitor we want to dispatch tomode- processing modeparent- if applicable, the parent of the visited resource- Throws:
IOExceptionjavax.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.
-
-