Package overit.geocall.util
Class Code
java.lang.Object
overit.geocall.util.Code
Definition of a generic Code, useful most of all for error codes.
The static part of this class has a in-memory sotage capabilitiy of Code objects.
It is possible to register Codes with the
This in-meomry capability is deprecated so don't use it if not for backward capabilities. Each Code can be defined as a public static final obect inside a global-use file.
register(java.lang.String, overit.geocall.util.Code) or
with the file codes.xml in the root of the application layer, with the following format:
<code id = "100" code = "undefined" description = "undefined error, can not continue" type = "" httpStatus = "404"/>This in-meomry capability is deprecated so don't use it if not for backward capabilities. Each Code can be defined as a public static final obect inside a global-use file.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncode()Deprecated.@return The code attribute of the CodeDeprecated.usegetDescription()insteadgetCode()Returns the code attribute of the Codestatic Codestatic CodeStarting from the name of a Code it returns theCodeobject registered in memory.static CodeDeprecated.usegetCode(java.lang.String)insteadReturns the description of the CodeReturns the httpStatus attribute of the CodegetType()Returns the type (that is optional) of the Codeprotected static ConcurrentHashMap<String, Code> parseCodes(Identity identity) static CodeDeprecated.static voidregisterClass(Class<?> c) Creates a copy of Code with the HttpStatus passed as parameter
-
Field Details
-
code
-
description
-
type
-
httpStatus
-
-
Constructor Details
-
Code
Constructor method for Code- Parameters:
code- The code attribute of the Codedescription- The description of the Codetype- The type (that is optional) of the Code
-
Code
Copy Constructor- Parameters:
c- An instance of Code
-
-
Method Details
-
withHttpStatus
Creates a copy of Code with the HttpStatus passed as parameter- Parameters:
n- The HttpStatus- Returns:
- A copy of Code with the HttpStatus passed as parameter
-
getCode
Starting from the name of a Code it returns theCodeobject registered in memory. It first searches from theCodeobjects registered vie theregister(java.lang.String, overit.geocall.util.Code)method. If the code is not found, it searches on all thepublic static finalCodeobjects registered withregisterClass(java.lang.Class).- Parameters:
id- The unique identifier of the Code- Returns:
- The Code associated with the specific id
-
getCode
Deprecated.usegetCode(java.lang.String)insteadStarting from the name of a Code and theIdentity, it returns theCodeobject registered inside the in-memory table. It searches first of all the Code objects loaded from thecodes.xmlfile. Secondly it searches on all thepublic static finalCodeobjects registered withregisterClass(java.lang.Class). If the code is not found, it searches from theCodeobjects registered vie theregister(java.lang.String, overit.geocall.util.Code)method.- Parameters:
id- The unique identifier of the Codeidentity- TheIdentityof the user currently logged in the application- Returns:
- The Code associated with the specific id
-
getCode
- Parameters:
clz- the class to be inspected for codescode- the name of the code- Returns:
- the Code if present,
nullotherwise
-
parseCodes
-
register
Deprecated.This is only for backward compatibility. If a Code is registered i/e then it will be searchable git thegetCode(java.lang.String, overit.geocall.util.Identity)method, otherwise it won't. Stop using it and define apublic static finalCodeinstead.- Parameters:
id- The global identificator for the Codecode- The Code- Returns:
- The Code associated with the specific id if the registration was successfull, otherwise the already registered code
-
registerClass
- Parameters:
c- the Class providing codes in the form ofpublic static finalCodeobjects.
-
getCode
Returns the code attribute of the Code- Returns:
- The code attribute of the Code
-
code
Deprecated.@return The code attribute of the Code -
getHttpStatus
Returns the httpStatus attribute of the Code- Returns:
- The httpStatus attribute of the Code
-
getDescription
Returns the description of the Code- Returns:
- The description of the Code
-
description
Deprecated.usegetDescription()instead- Returns:
- The description of the Code
-
getType
Returns the type (that is optional) of the Code- Returns:
- The type of the Code
-