id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
142,700
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ItemRule.java
ItemRule.setName
public void setName(String name) { if (name.endsWith(ARRAY_SUFFIX)) { this.name = name.substring(0, name.length() - 2); type = ItemType.ARRAY; } else if (name.endsWith(MAP_SUFFIX)) { this.name = name.substring(0, name.length() - 2); type = ItemType.MAP; } else { this.name = name; if (type == null) { type = ItemType.SINGLE; } } }
java
public void setName(String name) { if (name.endsWith(ARRAY_SUFFIX)) { this.name = name.substring(0, name.length() - 2); type = ItemType.ARRAY; } else if (name.endsWith(MAP_SUFFIX)) { this.name = name.substring(0, name.length() - 2); type = ItemType.MAP; } else { this.name = name; if (type == null) { type = ItemType.SINGLE; } } }
[ "public", "void", "setName", "(", "String", "name", ")", "{", "if", "(", "name", ".", "endsWith", "(", "ARRAY_SUFFIX", ")", ")", "{", "this", ".", "name", "=", "name", ".", "substring", "(", "0", ",", "name", ".", "length", "(", ")", "-", "2", ")", ";", "type", "=", "ItemType", ".", "ARRAY", ";", "}", "else", "if", "(", "name", ".", "endsWith", "(", "MAP_SUFFIX", ")", ")", "{", "this", ".", "name", "=", "name", ".", "substring", "(", "0", ",", "name", ".", "length", "(", ")", "-", "2", ")", ";", "type", "=", "ItemType", ".", "MAP", ";", "}", "else", "{", "this", ".", "name", "=", "name", ";", "if", "(", "type", "==", "null", ")", "{", "type", "=", "ItemType", ".", "SINGLE", ";", "}", "}", "}" ]
Sets the name of the item. @param name the name to set
[ "Sets", "the", "name", "of", "the", "item", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRule.java#L115-L128
142,701
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ItemRule.java
ItemRule.getValueList
public List<String> getValueList() { if (tokensList == null) { return null; } if (tokensList.isEmpty()) { return new ArrayList<>(); } else { List<String> list = new ArrayList<>(tokensList.size()); for (Token[] tokens : tokensList) { list.add(TokenParser.toString(tokens)); } return list; } }
java
public List<String> getValueList() { if (tokensList == null) { return null; } if (tokensList.isEmpty()) { return new ArrayList<>(); } else { List<String> list = new ArrayList<>(tokensList.size()); for (Token[] tokens : tokensList) { list.add(TokenParser.toString(tokens)); } return list; } }
[ "public", "List", "<", "String", ">", "getValueList", "(", ")", "{", "if", "(", "tokensList", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "tokensList", ".", "isEmpty", "(", ")", ")", "{", "return", "new", "ArrayList", "<>", "(", ")", ";", "}", "else", "{", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<>", "(", "tokensList", ".", "size", "(", ")", ")", ";", "for", "(", "Token", "[", "]", "tokens", ":", "tokensList", ")", "{", "list", ".", "add", "(", "TokenParser", ".", "toString", "(", "tokens", ")", ")", ";", "}", "return", "list", ";", "}", "}" ]
Returns a list of string values of this item. @return a list of string values
[ "Returns", "a", "list", "of", "string", "values", "of", "this", "item", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRule.java#L162-L175
142,702
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ItemRule.java
ItemRule.getValueMap
public Map<String, String> getValueMap() { if (tokensMap == null) { return null; } if (tokensMap.isEmpty()) { return new LinkedHashMap<>(); } else { Map<String, String> map = new LinkedHashMap<>(tokensMap.size()); for (Map.Entry<String, Token[]> entry : tokensMap.entrySet()) { map.put(entry.getKey(), TokenParser.toString(entry.getValue())); } return map; } }
java
public Map<String, String> getValueMap() { if (tokensMap == null) { return null; } if (tokensMap.isEmpty()) { return new LinkedHashMap<>(); } else { Map<String, String> map = new LinkedHashMap<>(tokensMap.size()); for (Map.Entry<String, Token[]> entry : tokensMap.entrySet()) { map.put(entry.getKey(), TokenParser.toString(entry.getValue())); } return map; } }
[ "public", "Map", "<", "String", ",", "String", ">", "getValueMap", "(", ")", "{", "if", "(", "tokensMap", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "tokensMap", ".", "isEmpty", "(", ")", ")", "{", "return", "new", "LinkedHashMap", "<>", "(", ")", ";", "}", "else", "{", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "LinkedHashMap", "<>", "(", "tokensMap", ".", "size", "(", ")", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Token", "[", "]", ">", "entry", ":", "tokensMap", ".", "entrySet", "(", ")", ")", "{", "map", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "TokenParser", ".", "toString", "(", "entry", ".", "getValue", "(", ")", ")", ")", ";", "}", "return", "map", ";", "}", "}" ]
Returns a map of string values of this item. @return a map of string values
[ "Returns", "a", "map", "of", "string", "values", "of", "this", "item", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRule.java#L191-L204
142,703
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ItemRule.java
ItemRule.setValue
public void setValue(Map<String, Token[]> tokensMap) { if (type == null) { type = ItemType.MAP; } if (!isMappableType()) { throw new IllegalArgumentException("The type of this item must be 'map' or 'properties'"); } this.tokensMap = tokensMap; }
java
public void setValue(Map<String, Token[]> tokensMap) { if (type == null) { type = ItemType.MAP; } if (!isMappableType()) { throw new IllegalArgumentException("The type of this item must be 'map' or 'properties'"); } this.tokensMap = tokensMap; }
[ "public", "void", "setValue", "(", "Map", "<", "String", ",", "Token", "[", "]", ">", "tokensMap", ")", "{", "if", "(", "type", "==", "null", ")", "{", "type", "=", "ItemType", ".", "MAP", ";", "}", "if", "(", "!", "isMappableType", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The type of this item must be 'map' or 'properties'\"", ")", ";", "}", "this", ".", "tokensMap", "=", "tokensMap", ";", "}" ]
Sets a value to this Map type item. @param tokensMap the tokens map
[ "Sets", "a", "value", "to", "this", "Map", "type", "item", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRule.java#L268-L276
142,704
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ItemRule.java
ItemRule.setValue
public void setValue(Properties properties) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); } if (type == null) { type = ItemType.PROPERTIES; } if (!isMappableType()) { throw new IllegalArgumentException("The type of this item must be 'properties' or 'map'"); } tokensMap = new LinkedHashMap<>(); for (String key : properties.stringPropertyNames()) { Object o = properties.get(key); if (o instanceof Token[]) { tokensMap.put(key, (Token[])o); } else if (o instanceof Token) { Token[] tokens = new Token[] { (Token)o }; tokensMap.put(key, tokens); } else { Token[] tokens = TokenParser.makeTokens(o.toString(), isTokenize()); putValue(name, tokens); } } }
java
public void setValue(Properties properties) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); } if (type == null) { type = ItemType.PROPERTIES; } if (!isMappableType()) { throw new IllegalArgumentException("The type of this item must be 'properties' or 'map'"); } tokensMap = new LinkedHashMap<>(); for (String key : properties.stringPropertyNames()) { Object o = properties.get(key); if (o instanceof Token[]) { tokensMap.put(key, (Token[])o); } else if (o instanceof Token) { Token[] tokens = new Token[] { (Token)o }; tokensMap.put(key, tokens); } else { Token[] tokens = TokenParser.makeTokens(o.toString(), isTokenize()); putValue(name, tokens); } } }
[ "public", "void", "setValue", "(", "Properties", "properties", ")", "{", "if", "(", "properties", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"properties must not be null\"", ")", ";", "}", "if", "(", "type", "==", "null", ")", "{", "type", "=", "ItemType", ".", "PROPERTIES", ";", "}", "if", "(", "!", "isMappableType", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The type of this item must be 'properties' or 'map'\"", ")", ";", "}", "tokensMap", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "for", "(", "String", "key", ":", "properties", ".", "stringPropertyNames", "(", ")", ")", "{", "Object", "o", "=", "properties", ".", "get", "(", "key", ")", ";", "if", "(", "o", "instanceof", "Token", "[", "]", ")", "{", "tokensMap", ".", "put", "(", "key", ",", "(", "Token", "[", "]", ")", "o", ")", ";", "}", "else", "if", "(", "o", "instanceof", "Token", ")", "{", "Token", "[", "]", "tokens", "=", "new", "Token", "[", "]", "{", "(", "Token", ")", "o", "}", ";", "tokensMap", ".", "put", "(", "key", ",", "tokens", ")", ";", "}", "else", "{", "Token", "[", "]", "tokens", "=", "TokenParser", ".", "makeTokens", "(", "o", ".", "toString", "(", ")", ",", "isTokenize", "(", ")", ")", ";", "putValue", "(", "name", ",", "tokens", ")", ";", "}", "}", "}" ]
Sets a value to this Properties type item. @param properties the properties
[ "Sets", "a", "value", "to", "this", "Properties", "type", "item", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRule.java#L283-L306
142,705
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ItemRule.java
ItemRule.setValue
public void setValue(List<Token[]> tokensList) { if (type == null) { type = ItemType.LIST; } if (!isListableType()) { throw new IllegalArgumentException("The item type must be 'array', 'list' or 'set' for this item " + this); } this.tokensList = tokensList; }
java
public void setValue(List<Token[]> tokensList) { if (type == null) { type = ItemType.LIST; } if (!isListableType()) { throw new IllegalArgumentException("The item type must be 'array', 'list' or 'set' for this item " + this); } this.tokensList = tokensList; }
[ "public", "void", "setValue", "(", "List", "<", "Token", "[", "]", ">", "tokensList", ")", "{", "if", "(", "type", "==", "null", ")", "{", "type", "=", "ItemType", ".", "LIST", ";", "}", "if", "(", "!", "isListableType", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The item type must be 'array', 'list' or 'set' for this item \"", "+", "this", ")", ";", "}", "this", ".", "tokensList", "=", "tokensList", ";", "}" ]
Sets a value to this List type item. @param tokensList the tokens list
[ "Sets", "a", "value", "to", "this", "List", "type", "item", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRule.java#L342-L350
142,706
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ItemRule.java
ItemRule.setValue
public void setValue(Set<Token[]> tokensSet) { if (tokensSet == null) { throw new IllegalArgumentException("tokensSet must not be null"); } if (type == null) { type = ItemType.SET; } if (!isListableType()) { throw new IllegalArgumentException("The type of this item must be 'set', 'array' or 'list'"); } tokensList = new ArrayList<>(tokensSet); }
java
public void setValue(Set<Token[]> tokensSet) { if (tokensSet == null) { throw new IllegalArgumentException("tokensSet must not be null"); } if (type == null) { type = ItemType.SET; } if (!isListableType()) { throw new IllegalArgumentException("The type of this item must be 'set', 'array' or 'list'"); } tokensList = new ArrayList<>(tokensSet); }
[ "public", "void", "setValue", "(", "Set", "<", "Token", "[", "]", ">", "tokensSet", ")", "{", "if", "(", "tokensSet", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"tokensSet must not be null\"", ")", ";", "}", "if", "(", "type", "==", "null", ")", "{", "type", "=", "ItemType", ".", "SET", ";", "}", "if", "(", "!", "isListableType", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The type of this item must be 'set', 'array' or 'list'\"", ")", ";", "}", "tokensList", "=", "new", "ArrayList", "<>", "(", "tokensSet", ")", ";", "}" ]
Sets a value to this Set type item. @param tokensSet the tokens set
[ "Sets", "a", "value", "to", "this", "Set", "type", "item", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRule.java#L357-L368
142,707
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ItemRule.java
ItemRule.isListableType
public boolean isListableType() { return (type == ItemType.ARRAY || type == ItemType.LIST || type == ItemType.SET); }
java
public boolean isListableType() { return (type == ItemType.ARRAY || type == ItemType.LIST || type == ItemType.SET); }
[ "public", "boolean", "isListableType", "(", ")", "{", "return", "(", "type", "==", "ItemType", ".", "ARRAY", "||", "type", "==", "ItemType", ".", "LIST", "||", "type", "==", "ItemType", ".", "SET", ")", ";", "}" ]
Return whether this item is listable type. @return true, if this item is listable type
[ "Return", "whether", "this", "item", "is", "listable", "type", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRule.java#L456-L458
142,708
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ItemRule.java
ItemRule.newInstance
public static ItemRule newInstance(String type, String name, String valueType, String defaultValue, Boolean tokenize, Boolean mandatory, Boolean secret) throws IllegalRuleException { ItemRule itemRule = new ItemRule(); ItemType itemType = ItemType.resolve(type); if (type != null && itemType == null) { throw new IllegalRuleException("No item type for '" + type + "'"); } if (itemType != null) { itemRule.setType(itemType); } else { itemRule.setType(ItemType.SINGLE); //default } if (!StringUtils.isEmpty(name)) { itemRule.setName(name); } else { itemRule.setAutoNamed(true); } if (tokenize != null) { itemRule.setTokenize(tokenize); } if (valueType != null) { ItemValueType itemValueType = ItemValueType.resolve(valueType); if (itemValueType == null) { throw new IllegalRuleException("No item value type for '" + valueType + "'"); } itemRule.setValueType(itemValueType); } if (defaultValue != null) { itemRule.setDefaultValue(defaultValue); } if (mandatory != null) { itemRule.setMandatory(mandatory); } if (secret != null) { itemRule.setSecret(secret); } return itemRule; }
java
public static ItemRule newInstance(String type, String name, String valueType, String defaultValue, Boolean tokenize, Boolean mandatory, Boolean secret) throws IllegalRuleException { ItemRule itemRule = new ItemRule(); ItemType itemType = ItemType.resolve(type); if (type != null && itemType == null) { throw new IllegalRuleException("No item type for '" + type + "'"); } if (itemType != null) { itemRule.setType(itemType); } else { itemRule.setType(ItemType.SINGLE); //default } if (!StringUtils.isEmpty(name)) { itemRule.setName(name); } else { itemRule.setAutoNamed(true); } if (tokenize != null) { itemRule.setTokenize(tokenize); } if (valueType != null) { ItemValueType itemValueType = ItemValueType.resolve(valueType); if (itemValueType == null) { throw new IllegalRuleException("No item value type for '" + valueType + "'"); } itemRule.setValueType(itemValueType); } if (defaultValue != null) { itemRule.setDefaultValue(defaultValue); } if (mandatory != null) { itemRule.setMandatory(mandatory); } if (secret != null) { itemRule.setSecret(secret); } return itemRule; }
[ "public", "static", "ItemRule", "newInstance", "(", "String", "type", ",", "String", "name", ",", "String", "valueType", ",", "String", "defaultValue", ",", "Boolean", "tokenize", ",", "Boolean", "mandatory", ",", "Boolean", "secret", ")", "throws", "IllegalRuleException", "{", "ItemRule", "itemRule", "=", "new", "ItemRule", "(", ")", ";", "ItemType", "itemType", "=", "ItemType", ".", "resolve", "(", "type", ")", ";", "if", "(", "type", "!=", "null", "&&", "itemType", "==", "null", ")", "{", "throw", "new", "IllegalRuleException", "(", "\"No item type for '\"", "+", "type", "+", "\"'\"", ")", ";", "}", "if", "(", "itemType", "!=", "null", ")", "{", "itemRule", ".", "setType", "(", "itemType", ")", ";", "}", "else", "{", "itemRule", ".", "setType", "(", "ItemType", ".", "SINGLE", ")", ";", "//default", "}", "if", "(", "!", "StringUtils", ".", "isEmpty", "(", "name", ")", ")", "{", "itemRule", ".", "setName", "(", "name", ")", ";", "}", "else", "{", "itemRule", ".", "setAutoNamed", "(", "true", ")", ";", "}", "if", "(", "tokenize", "!=", "null", ")", "{", "itemRule", ".", "setTokenize", "(", "tokenize", ")", ";", "}", "if", "(", "valueType", "!=", "null", ")", "{", "ItemValueType", "itemValueType", "=", "ItemValueType", ".", "resolve", "(", "valueType", ")", ";", "if", "(", "itemValueType", "==", "null", ")", "{", "throw", "new", "IllegalRuleException", "(", "\"No item value type for '\"", "+", "valueType", "+", "\"'\"", ")", ";", "}", "itemRule", ".", "setValueType", "(", "itemValueType", ")", ";", "}", "if", "(", "defaultValue", "!=", "null", ")", "{", "itemRule", ".", "setDefaultValue", "(", "defaultValue", ")", ";", "}", "if", "(", "mandatory", "!=", "null", ")", "{", "itemRule", ".", "setMandatory", "(", "mandatory", ")", ";", "}", "if", "(", "secret", "!=", "null", ")", "{", "itemRule", ".", "setSecret", "(", "secret", ")", ";", "}", "return", "itemRule", ";", "}" ]
Returns a new derived instance of ItemRule. @param type the item type @param name the name of the item @param valueType the type of value an item can have @param defaultValue the default value used if the item has not been assigned a value or is null @param tokenize whether to tokenize @param mandatory whether or not this item is mandatory @param secret whether or not this item requires secure input @return the item rule @throws IllegalRuleException if an illegal rule is found
[ "Returns", "a", "new", "derived", "instance", "of", "ItemRule", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRule.java#L668-L714
142,709
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ItemRule.java
ItemRule.makeReferenceToken
public static Token makeReferenceToken(String bean, String template, String parameter, String attribute, String property) { Token token; if (bean != null) { token = new Token(TokenType.BEAN, bean); } else if (template != null) { token = new Token(TokenType.TEMPLATE, template); } else if (parameter != null) { token = new Token(TokenType.PARAMETER, parameter); } else if (attribute != null) { token = new Token(TokenType.ATTRIBUTE, attribute); } else if (property != null) { token = new Token(TokenType.PROPERTY, property); } else { token = null; } return token; }
java
public static Token makeReferenceToken(String bean, String template, String parameter, String attribute, String property) { Token token; if (bean != null) { token = new Token(TokenType.BEAN, bean); } else if (template != null) { token = new Token(TokenType.TEMPLATE, template); } else if (parameter != null) { token = new Token(TokenType.PARAMETER, parameter); } else if (attribute != null) { token = new Token(TokenType.ATTRIBUTE, attribute); } else if (property != null) { token = new Token(TokenType.PROPERTY, property); } else { token = null; } return token; }
[ "public", "static", "Token", "makeReferenceToken", "(", "String", "bean", ",", "String", "template", ",", "String", "parameter", ",", "String", "attribute", ",", "String", "property", ")", "{", "Token", "token", ";", "if", "(", "bean", "!=", "null", ")", "{", "token", "=", "new", "Token", "(", "TokenType", ".", "BEAN", ",", "bean", ")", ";", "}", "else", "if", "(", "template", "!=", "null", ")", "{", "token", "=", "new", "Token", "(", "TokenType", ".", "TEMPLATE", ",", "template", ")", ";", "}", "else", "if", "(", "parameter", "!=", "null", ")", "{", "token", "=", "new", "Token", "(", "TokenType", ".", "PARAMETER", ",", "parameter", ")", ";", "}", "else", "if", "(", "attribute", "!=", "null", ")", "{", "token", "=", "new", "Token", "(", "TokenType", ".", "ATTRIBUTE", ",", "attribute", ")", ";", "}", "else", "if", "(", "property", "!=", "null", ")", "{", "token", "=", "new", "Token", "(", "TokenType", ".", "PROPERTY", ",", "property", ")", ";", "}", "else", "{", "token", "=", "null", ";", "}", "return", "token", ";", "}" ]
Returns a made reference token. @param bean the bean id @param template the template id @param parameter the parameter name @param attribute the attribute name @param property the property name @return the token
[ "Returns", "a", "made", "reference", "token", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRule.java#L726-L743
142,710
aspectran/aspectran
web/src/main/java/com/aspectran/web/support/multipart/commons/CommonsMultipartFileParameter.java
CommonsMultipartFileParameter.getInputStream
@Override public InputStream getInputStream() throws IOException { InputStream inputStream = fileItem.getInputStream(); return (inputStream != null ? inputStream : new ByteArrayInputStream(new byte[0])); }
java
@Override public InputStream getInputStream() throws IOException { InputStream inputStream = fileItem.getInputStream(); return (inputStream != null ? inputStream : new ByteArrayInputStream(new byte[0])); }
[ "@", "Override", "public", "InputStream", "getInputStream", "(", ")", "throws", "IOException", "{", "InputStream", "inputStream", "=", "fileItem", ".", "getInputStream", "(", ")", ";", "return", "(", "inputStream", "!=", "null", "?", "inputStream", ":", "new", "ByteArrayInputStream", "(", "new", "byte", "[", "0", "]", ")", ")", ";", "}" ]
Return an InputStream to read the contents of the file from. @return the contents of the file as stream, or an empty stream if empty @throws IOException in case of access errors (if the temporary store fails)
[ "Return", "an", "InputStream", "to", "read", "the", "contents", "of", "the", "file", "from", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/support/multipart/commons/CommonsMultipartFileParameter.java#L98-L102
142,711
aspectran/aspectran
web/src/main/java/com/aspectran/web/support/multipart/commons/CommonsMultipartFileParameter.java
CommonsMultipartFileParameter.saveAs
@Override public File saveAs(File destFile, boolean overwrite) throws IOException { if (destFile == null) { throw new IllegalArgumentException("destFile can not be null"); } validateFile(); try { destFile = determineDestinationFile(destFile, overwrite); fileItem.write(destFile); } catch (FileUploadException e) { throw new IllegalStateException(e.getMessage()); } catch (Exception e) { throw new IOException("Could not save as file " + destFile, e); } setSavedFile(destFile); return destFile; }
java
@Override public File saveAs(File destFile, boolean overwrite) throws IOException { if (destFile == null) { throw new IllegalArgumentException("destFile can not be null"); } validateFile(); try { destFile = determineDestinationFile(destFile, overwrite); fileItem.write(destFile); } catch (FileUploadException e) { throw new IllegalStateException(e.getMessage()); } catch (Exception e) { throw new IOException("Could not save as file " + destFile, e); } setSavedFile(destFile); return destFile; }
[ "@", "Override", "public", "File", "saveAs", "(", "File", "destFile", ",", "boolean", "overwrite", ")", "throws", "IOException", "{", "if", "(", "destFile", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"destFile can not be null\"", ")", ";", "}", "validateFile", "(", ")", ";", "try", "{", "destFile", "=", "determineDestinationFile", "(", "destFile", ",", "overwrite", ")", ";", "fileItem", ".", "write", "(", "destFile", ")", ";", "}", "catch", "(", "FileUploadException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IOException", "(", "\"Could not save as file \"", "+", "destFile", ",", "e", ")", ";", "}", "setSavedFile", "(", "destFile", ")", ";", "return", "destFile", ";", "}" ]
Save an uploaded file as a given destination file. @param destFile the destination file @param overwrite whether to overwrite if it already exists @return a saved file @throws IOException if an I/O error has occurred
[ "Save", "an", "uploaded", "file", "as", "a", "given", "destination", "file", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/support/multipart/commons/CommonsMultipartFileParameter.java#L123-L142
142,712
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/apon/AponSyntaxException.java
AponSyntaxException.makeMessage
private static String makeMessage(int lineNumber, String line, String tline, String msg) { int columnNumber = (tline != null ? line.indexOf(tline) : 0); StringBuilder sb = new StringBuilder(); if (msg != null) { sb.append(msg); } sb.append(" [lineNumber: ").append(lineNumber); if (columnNumber != -1) { String lspace = line.substring(0, columnNumber); int tabCnt = StringUtils.search(lspace, "\t"); if (tline != null && tline.length() > 33) { tline = tline.substring(0, 30) + "..."; } sb.append(", columnNumber: ").append(columnNumber + 1); if (tabCnt != 0) { sb.append(" ("); sb.append("Tabs ").append(tabCnt); sb.append(", Spaces ").append(columnNumber - tabCnt); sb.append(")"); } sb.append("] ").append(tline); } return sb.toString(); }
java
private static String makeMessage(int lineNumber, String line, String tline, String msg) { int columnNumber = (tline != null ? line.indexOf(tline) : 0); StringBuilder sb = new StringBuilder(); if (msg != null) { sb.append(msg); } sb.append(" [lineNumber: ").append(lineNumber); if (columnNumber != -1) { String lspace = line.substring(0, columnNumber); int tabCnt = StringUtils.search(lspace, "\t"); if (tline != null && tline.length() > 33) { tline = tline.substring(0, 30) + "..."; } sb.append(", columnNumber: ").append(columnNumber + 1); if (tabCnt != 0) { sb.append(" ("); sb.append("Tabs ").append(tabCnt); sb.append(", Spaces ").append(columnNumber - tabCnt); sb.append(")"); } sb.append("] ").append(tline); } return sb.toString(); }
[ "private", "static", "String", "makeMessage", "(", "int", "lineNumber", ",", "String", "line", ",", "String", "tline", ",", "String", "msg", ")", "{", "int", "columnNumber", "=", "(", "tline", "!=", "null", "?", "line", ".", "indexOf", "(", "tline", ")", ":", "0", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "msg", "!=", "null", ")", "{", "sb", ".", "append", "(", "msg", ")", ";", "}", "sb", ".", "append", "(", "\" [lineNumber: \"", ")", ".", "append", "(", "lineNumber", ")", ";", "if", "(", "columnNumber", "!=", "-", "1", ")", "{", "String", "lspace", "=", "line", ".", "substring", "(", "0", ",", "columnNumber", ")", ";", "int", "tabCnt", "=", "StringUtils", ".", "search", "(", "lspace", ",", "\"\\t\"", ")", ";", "if", "(", "tline", "!=", "null", "&&", "tline", ".", "length", "(", ")", ">", "33", ")", "{", "tline", "=", "tline", ".", "substring", "(", "0", ",", "30", ")", "+", "\"...\"", ";", "}", "sb", ".", "append", "(", "\", columnNumber: \"", ")", ".", "append", "(", "columnNumber", "+", "1", ")", ";", "if", "(", "tabCnt", "!=", "0", ")", "{", "sb", ".", "append", "(", "\" (\"", ")", ";", "sb", ".", "append", "(", "\"Tabs \"", ")", ".", "append", "(", "tabCnt", ")", ";", "sb", ".", "append", "(", "\", Spaces \"", ")", ".", "append", "(", "columnNumber", "-", "tabCnt", ")", ";", "sb", ".", "append", "(", "\")\"", ")", ";", "}", "sb", ".", "append", "(", "\"] \"", ")", ".", "append", "(", "tline", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Create a detail message. @param lineNumber the line number @param line the character line @param tline the trimmed character line @param msg the message @return the detail message
[ "Create", "a", "detail", "message", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/apon/AponSyntaxException.java#L72-L95
142,713
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/CoreActivity.java
CoreActivity.prepare
private void prepare(String requestName, MethodType requestMethod, TransletRule transletRule, Translet parentTranslet) { try { if (log.isDebugEnabled()) { log.debug("Translet " + transletRule); } newTranslet(requestMethod, requestName, transletRule, parentTranslet); if (parentTranslet == null) { if (isIncluded()) { backupCurrentActivity(); saveCurrentActivity(); } else { saveCurrentActivity(); } adapt(); } prepareAspectAdviceRule(transletRule, (parentTranslet != null)); parseRequest(); parsePathVariables(); if (parentTranslet == null) { resolveLocale(); } } catch (ActivityTerminatedException e) { throw e; } catch (Exception e) { throw new ActivityPrepareException("Failed to prepare activity for translet " + transletRule, e); } }
java
private void prepare(String requestName, MethodType requestMethod, TransletRule transletRule, Translet parentTranslet) { try { if (log.isDebugEnabled()) { log.debug("Translet " + transletRule); } newTranslet(requestMethod, requestName, transletRule, parentTranslet); if (parentTranslet == null) { if (isIncluded()) { backupCurrentActivity(); saveCurrentActivity(); } else { saveCurrentActivity(); } adapt(); } prepareAspectAdviceRule(transletRule, (parentTranslet != null)); parseRequest(); parsePathVariables(); if (parentTranslet == null) { resolveLocale(); } } catch (ActivityTerminatedException e) { throw e; } catch (Exception e) { throw new ActivityPrepareException("Failed to prepare activity for translet " + transletRule, e); } }
[ "private", "void", "prepare", "(", "String", "requestName", ",", "MethodType", "requestMethod", ",", "TransletRule", "transletRule", ",", "Translet", "parentTranslet", ")", "{", "try", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Translet \"", "+", "transletRule", ")", ";", "}", "newTranslet", "(", "requestMethod", ",", "requestName", ",", "transletRule", ",", "parentTranslet", ")", ";", "if", "(", "parentTranslet", "==", "null", ")", "{", "if", "(", "isIncluded", "(", ")", ")", "{", "backupCurrentActivity", "(", ")", ";", "saveCurrentActivity", "(", ")", ";", "}", "else", "{", "saveCurrentActivity", "(", ")", ";", "}", "adapt", "(", ")", ";", "}", "prepareAspectAdviceRule", "(", "transletRule", ",", "(", "parentTranslet", "!=", "null", ")", ")", ";", "parseRequest", "(", ")", ";", "parsePathVariables", "(", ")", ";", "if", "(", "parentTranslet", "==", "null", ")", "{", "resolveLocale", "(", ")", ";", "}", "}", "catch", "(", "ActivityTerminatedException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ActivityPrepareException", "(", "\"Failed to prepare activity for translet \"", "+", "transletRule", ",", "e", ")", ";", "}", "}" ]
Prepares a new activity for the Translet Rule by taking the results of the process that was created earlier. @param requestName the request name @param requestMethod the request method @param transletRule the translet rule @param parentTranslet the process result that was created earlier
[ "Prepares", "a", "new", "activity", "for", "the", "Translet", "Rule", "by", "taking", "the", "results", "of", "the", "process", "that", "was", "created", "earlier", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/CoreActivity.java#L144-L175
142,714
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/CoreActivity.java
CoreActivity.produce
private void produce() { ContentList contentList = getTransletRule().getContentList(); if (contentList != null) { ProcessResult processResult = translet.getProcessResult(); if (processResult == null) { processResult = new ProcessResult(contentList.size()); processResult.setName(contentList.getName()); processResult.setExplicit(contentList.isExplicit()); translet.setProcessResult(processResult); } for (ActionList actionList : contentList) { execute(actionList); if (isResponseReserved()) { break; } } } Response res = getResponse(); if (res != null) { ActionList actionList = res.getActionList(); if (actionList != null) { execute(actionList); } } }
java
private void produce() { ContentList contentList = getTransletRule().getContentList(); if (contentList != null) { ProcessResult processResult = translet.getProcessResult(); if (processResult == null) { processResult = new ProcessResult(contentList.size()); processResult.setName(contentList.getName()); processResult.setExplicit(contentList.isExplicit()); translet.setProcessResult(processResult); } for (ActionList actionList : contentList) { execute(actionList); if (isResponseReserved()) { break; } } } Response res = getResponse(); if (res != null) { ActionList actionList = res.getActionList(); if (actionList != null) { execute(actionList); } } }
[ "private", "void", "produce", "(", ")", "{", "ContentList", "contentList", "=", "getTransletRule", "(", ")", ".", "getContentList", "(", ")", ";", "if", "(", "contentList", "!=", "null", ")", "{", "ProcessResult", "processResult", "=", "translet", ".", "getProcessResult", "(", ")", ";", "if", "(", "processResult", "==", "null", ")", "{", "processResult", "=", "new", "ProcessResult", "(", "contentList", ".", "size", "(", ")", ")", ";", "processResult", ".", "setName", "(", "contentList", ".", "getName", "(", ")", ")", ";", "processResult", ".", "setExplicit", "(", "contentList", ".", "isExplicit", "(", ")", ")", ";", "translet", ".", "setProcessResult", "(", "processResult", ")", ";", "}", "for", "(", "ActionList", "actionList", ":", "contentList", ")", "{", "execute", "(", "actionList", ")", ";", "if", "(", "isResponseReserved", "(", ")", ")", "{", "break", ";", "}", "}", "}", "Response", "res", "=", "getResponse", "(", ")", ";", "if", "(", "res", "!=", "null", ")", "{", "ActionList", "actionList", "=", "res", ".", "getActionList", "(", ")", ";", "if", "(", "actionList", "!=", "null", ")", "{", "execute", "(", "actionList", ")", ";", "}", "}", "}" ]
Produce the result of the content and its subordinate actions.
[ "Produce", "the", "result", "of", "the", "content", "and", "its", "subordinate", "actions", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/CoreActivity.java#L253-L279
142,715
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/CoreActivity.java
CoreActivity.resolveRequestEncoding
protected String resolveRequestEncoding() { String encoding = getRequestRule().getEncoding(); if (encoding == null) { encoding = getSetting(RequestRule.CHARACTER_ENCODING_SETTING_NAME); } return encoding; }
java
protected String resolveRequestEncoding() { String encoding = getRequestRule().getEncoding(); if (encoding == null) { encoding = getSetting(RequestRule.CHARACTER_ENCODING_SETTING_NAME); } return encoding; }
[ "protected", "String", "resolveRequestEncoding", "(", ")", "{", "String", "encoding", "=", "getRequestRule", "(", ")", ".", "getEncoding", "(", ")", ";", "if", "(", "encoding", "==", "null", ")", "{", "encoding", "=", "getSetting", "(", "RequestRule", ".", "CHARACTER_ENCODING_SETTING_NAME", ")", ";", "}", "return", "encoding", ";", "}" ]
Determines the request encoding. @return the request encoding
[ "Determines", "the", "request", "encoding", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/CoreActivity.java#L380-L386
142,716
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/CoreActivity.java
CoreActivity.resolveResponseEncoding
protected String resolveResponseEncoding() { String encoding = getRequestRule().getEncoding(); if (encoding == null) { encoding = resolveRequestEncoding(); } return encoding; }
java
protected String resolveResponseEncoding() { String encoding = getRequestRule().getEncoding(); if (encoding == null) { encoding = resolveRequestEncoding(); } return encoding; }
[ "protected", "String", "resolveResponseEncoding", "(", ")", "{", "String", "encoding", "=", "getRequestRule", "(", ")", ".", "getEncoding", "(", ")", ";", "if", "(", "encoding", "==", "null", ")", "{", "encoding", "=", "resolveRequestEncoding", "(", ")", ";", "}", "return", "encoding", ";", "}" ]
Determines the response encoding. @return the response encoding
[ "Determines", "the", "response", "encoding", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/CoreActivity.java#L393-L399
142,717
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/CoreActivity.java
CoreActivity.resolveLocale
protected LocaleResolver resolveLocale() { LocaleResolver localeResolver = null; String localeResolverBeanId = getSetting(RequestRule.LOCALE_RESOLVER_SETTING_NAME); if (localeResolverBeanId != null) { localeResolver = getBean(localeResolverBeanId, LocaleResolver.class); localeResolver.resolveLocale(getTranslet()); localeResolver.resolveTimeZone(getTranslet()); } return localeResolver; }
java
protected LocaleResolver resolveLocale() { LocaleResolver localeResolver = null; String localeResolverBeanId = getSetting(RequestRule.LOCALE_RESOLVER_SETTING_NAME); if (localeResolverBeanId != null) { localeResolver = getBean(localeResolverBeanId, LocaleResolver.class); localeResolver.resolveLocale(getTranslet()); localeResolver.resolveTimeZone(getTranslet()); } return localeResolver; }
[ "protected", "LocaleResolver", "resolveLocale", "(", ")", "{", "LocaleResolver", "localeResolver", "=", "null", ";", "String", "localeResolverBeanId", "=", "getSetting", "(", "RequestRule", ".", "LOCALE_RESOLVER_SETTING_NAME", ")", ";", "if", "(", "localeResolverBeanId", "!=", "null", ")", "{", "localeResolver", "=", "getBean", "(", "localeResolverBeanId", ",", "LocaleResolver", ".", "class", ")", ";", "localeResolver", ".", "resolveLocale", "(", "getTranslet", "(", ")", ")", ";", "localeResolver", ".", "resolveTimeZone", "(", "getTranslet", "(", ")", ")", ";", "}", "return", "localeResolver", ";", "}" ]
Resolve the current locale. @return the current locale
[ "Resolve", "the", "current", "locale", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/CoreActivity.java#L406-L415
142,718
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/CoreActivity.java
CoreActivity.parseDeclaredParameters
protected void parseDeclaredParameters() { ItemRuleMap parameterItemRuleMap = getRequestRule().getParameterItemRuleMap(); if (parameterItemRuleMap != null && !parameterItemRuleMap.isEmpty()) { ItemEvaluator evaluator = null; ItemRuleList missingItemRules = null; for (ItemRule itemRule : parameterItemRuleMap.values()) { Token[] tokens = itemRule.getTokens(); if (tokens != null) { if (evaluator == null) { evaluator = new ItemExpression(this); } String[] values = evaluator.evaluateAsStringArray(itemRule); String[] oldValues = getRequestAdapter().getParameterValues(itemRule.getName()); if (values != oldValues) { getRequestAdapter().setParameter(itemRule.getName(), values); } } if (itemRule.isMandatory()) { String[] values = getRequestAdapter().getParameterValues(itemRule.getName()); if (values == null) { if (missingItemRules == null) { missingItemRules = new ItemRuleList(); } missingItemRules.add(itemRule); } } } if (missingItemRules != null) { throw new MissingMandatoryParametersException(missingItemRules); } } }
java
protected void parseDeclaredParameters() { ItemRuleMap parameterItemRuleMap = getRequestRule().getParameterItemRuleMap(); if (parameterItemRuleMap != null && !parameterItemRuleMap.isEmpty()) { ItemEvaluator evaluator = null; ItemRuleList missingItemRules = null; for (ItemRule itemRule : parameterItemRuleMap.values()) { Token[] tokens = itemRule.getTokens(); if (tokens != null) { if (evaluator == null) { evaluator = new ItemExpression(this); } String[] values = evaluator.evaluateAsStringArray(itemRule); String[] oldValues = getRequestAdapter().getParameterValues(itemRule.getName()); if (values != oldValues) { getRequestAdapter().setParameter(itemRule.getName(), values); } } if (itemRule.isMandatory()) { String[] values = getRequestAdapter().getParameterValues(itemRule.getName()); if (values == null) { if (missingItemRules == null) { missingItemRules = new ItemRuleList(); } missingItemRules.add(itemRule); } } } if (missingItemRules != null) { throw new MissingMandatoryParametersException(missingItemRules); } } }
[ "protected", "void", "parseDeclaredParameters", "(", ")", "{", "ItemRuleMap", "parameterItemRuleMap", "=", "getRequestRule", "(", ")", ".", "getParameterItemRuleMap", "(", ")", ";", "if", "(", "parameterItemRuleMap", "!=", "null", "&&", "!", "parameterItemRuleMap", ".", "isEmpty", "(", ")", ")", "{", "ItemEvaluator", "evaluator", "=", "null", ";", "ItemRuleList", "missingItemRules", "=", "null", ";", "for", "(", "ItemRule", "itemRule", ":", "parameterItemRuleMap", ".", "values", "(", ")", ")", "{", "Token", "[", "]", "tokens", "=", "itemRule", ".", "getTokens", "(", ")", ";", "if", "(", "tokens", "!=", "null", ")", "{", "if", "(", "evaluator", "==", "null", ")", "{", "evaluator", "=", "new", "ItemExpression", "(", "this", ")", ";", "}", "String", "[", "]", "values", "=", "evaluator", ".", "evaluateAsStringArray", "(", "itemRule", ")", ";", "String", "[", "]", "oldValues", "=", "getRequestAdapter", "(", ")", ".", "getParameterValues", "(", "itemRule", ".", "getName", "(", ")", ")", ";", "if", "(", "values", "!=", "oldValues", ")", "{", "getRequestAdapter", "(", ")", ".", "setParameter", "(", "itemRule", ".", "getName", "(", ")", ",", "values", ")", ";", "}", "}", "if", "(", "itemRule", ".", "isMandatory", "(", ")", ")", "{", "String", "[", "]", "values", "=", "getRequestAdapter", "(", ")", ".", "getParameterValues", "(", "itemRule", ".", "getName", "(", ")", ")", ";", "if", "(", "values", "==", "null", ")", "{", "if", "(", "missingItemRules", "==", "null", ")", "{", "missingItemRules", "=", "new", "ItemRuleList", "(", ")", ";", "}", "missingItemRules", ".", "add", "(", "itemRule", ")", ";", "}", "}", "}", "if", "(", "missingItemRules", "!=", "null", ")", "{", "throw", "new", "MissingMandatoryParametersException", "(", "missingItemRules", ")", ";", "}", "}", "}" ]
Parses the declared parameters.
[ "Parses", "the", "declared", "parameters", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/CoreActivity.java#L428-L459
142,719
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/CoreActivity.java
CoreActivity.parseDeclaredAttributes
protected void parseDeclaredAttributes() { ItemRuleMap attributeItemRuleMap = getRequestRule().getAttributeItemRuleMap(); if (attributeItemRuleMap != null && !attributeItemRuleMap.isEmpty()) { ItemEvaluator evaluator = new ItemExpression(this); for (ItemRule itemRule : attributeItemRuleMap.values()) { Object value = evaluator.evaluate(itemRule); getRequestAdapter().setAttribute(itemRule.getName(), value); } } }
java
protected void parseDeclaredAttributes() { ItemRuleMap attributeItemRuleMap = getRequestRule().getAttributeItemRuleMap(); if (attributeItemRuleMap != null && !attributeItemRuleMap.isEmpty()) { ItemEvaluator evaluator = new ItemExpression(this); for (ItemRule itemRule : attributeItemRuleMap.values()) { Object value = evaluator.evaluate(itemRule); getRequestAdapter().setAttribute(itemRule.getName(), value); } } }
[ "protected", "void", "parseDeclaredAttributes", "(", ")", "{", "ItemRuleMap", "attributeItemRuleMap", "=", "getRequestRule", "(", ")", ".", "getAttributeItemRuleMap", "(", ")", ";", "if", "(", "attributeItemRuleMap", "!=", "null", "&&", "!", "attributeItemRuleMap", ".", "isEmpty", "(", ")", ")", "{", "ItemEvaluator", "evaluator", "=", "new", "ItemExpression", "(", "this", ")", ";", "for", "(", "ItemRule", "itemRule", ":", "attributeItemRuleMap", ".", "values", "(", ")", ")", "{", "Object", "value", "=", "evaluator", ".", "evaluate", "(", "itemRule", ")", ";", "getRequestAdapter", "(", ")", ".", "setAttribute", "(", "itemRule", ".", "getName", "(", ")", ",", "value", ")", ";", "}", "}", "}" ]
Parses the declared attributes.
[ "Parses", "the", "declared", "attributes", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/CoreActivity.java#L464-L473
142,720
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/CoreActivity.java
CoreActivity.execute
protected void execute(ActionList actionList) { ProcessResult processResult = translet.getProcessResult(); if (processResult == null) { processResult = new ProcessResult(1); translet.setProcessResult(processResult); } ContentResult contentResult = processResult.getContentResult(actionList.getName(), actionList.isExplicit()); if (contentResult == null) { contentResult = new ContentResult(processResult, actionList.size()); contentResult.setName(actionList.getName()); if (!processResult.isExplicit()) { contentResult.setExplicit(actionList.isExplicit()); } } for (Executable action : actionList) { execute(action, contentResult); if (isResponseReserved()) { break; } } }
java
protected void execute(ActionList actionList) { ProcessResult processResult = translet.getProcessResult(); if (processResult == null) { processResult = new ProcessResult(1); translet.setProcessResult(processResult); } ContentResult contentResult = processResult.getContentResult(actionList.getName(), actionList.isExplicit()); if (contentResult == null) { contentResult = new ContentResult(processResult, actionList.size()); contentResult.setName(actionList.getName()); if (!processResult.isExplicit()) { contentResult.setExplicit(actionList.isExplicit()); } } for (Executable action : actionList) { execute(action, contentResult); if (isResponseReserved()) { break; } } }
[ "protected", "void", "execute", "(", "ActionList", "actionList", ")", "{", "ProcessResult", "processResult", "=", "translet", ".", "getProcessResult", "(", ")", ";", "if", "(", "processResult", "==", "null", ")", "{", "processResult", "=", "new", "ProcessResult", "(", "1", ")", ";", "translet", ".", "setProcessResult", "(", "processResult", ")", ";", "}", "ContentResult", "contentResult", "=", "processResult", ".", "getContentResult", "(", "actionList", ".", "getName", "(", ")", ",", "actionList", ".", "isExplicit", "(", ")", ")", ";", "if", "(", "contentResult", "==", "null", ")", "{", "contentResult", "=", "new", "ContentResult", "(", "processResult", ",", "actionList", ".", "size", "(", ")", ")", ";", "contentResult", ".", "setName", "(", "actionList", ".", "getName", "(", ")", ")", ";", "if", "(", "!", "processResult", ".", "isExplicit", "(", ")", ")", "{", "contentResult", ".", "setExplicit", "(", "actionList", ".", "isExplicit", "(", ")", ")", ";", "}", "}", "for", "(", "Executable", "action", ":", "actionList", ")", "{", "execute", "(", "action", ",", "contentResult", ")", ";", "if", "(", "isResponseReserved", "(", ")", ")", "{", "break", ";", "}", "}", "}" ]
Execute actions. @param actionList the action list
[ "Execute", "actions", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/CoreActivity.java#L521-L543
142,721
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/CoreActivity.java
CoreActivity.execute
private void execute(Executable action, ContentResult contentResult) { try { ChooseWhenRule chooseWhenRule = null; if (action.getCaseNo() > 0) { ChooseRuleMap chooseRuleMap = getTransletRule().getChooseRuleMap(); if (chooseRuleMap == null || chooseRuleMap.isEmpty()) { throw new IllegalRuleException("No defined choose rules"); } ChooseRule chooseRule = chooseRuleMap.getChooseRule(action.getCaseNo()); if (chooseRule == null) { throw new IllegalRuleException("No choose rule with case number: " + ChooseRule.toCaseGroupNo(action.getCaseNo())); } chooseWhenRule = chooseRule.getChooseWhenRule(action.getCaseNo()); if (chooseWhenRule == null) { throw new IllegalRuleException("No choose rule with case number: " + action.getCaseNo()); } if (processedChooses != null && processedChooses.contains(chooseRule.getCaseNo())) { return; } if (processedChooses == null || !processedChooses.contains(chooseWhenRule.getCaseNo())) { BooleanExpression expression = new BooleanExpression(this); if (expression.evaluate(chooseWhenRule)) { if (processedChooses == null) { processedChooses = new HashSet<>(); } processedChooses.add(chooseRule.getCaseNo()); processedChooses.add(chooseWhenRule.getCaseNo()); } else { return; } } } if (log.isDebugEnabled()) { log.debug("Action " + action); } Object resultValue = action.execute(this); if (!action.isHidden() && contentResult != null && resultValue != ActionResult.NO_RESULT) { if (resultValue instanceof ProcessResult) { contentResult.addActionResult(action, (ProcessResult) resultValue); } else { contentResult.addActionResult(action, resultValue); } } if (action.isLastInChooseWhen() && chooseWhenRule != null && chooseWhenRule.getResponse() != null) { reserveResponse(chooseWhenRule.getResponse()); } } catch (ActionExecutionException e) { throw e; } catch (Exception e) { setRaisedException(e); throw new ActionExecutionException("Failed to execute action " + action, e); } }
java
private void execute(Executable action, ContentResult contentResult) { try { ChooseWhenRule chooseWhenRule = null; if (action.getCaseNo() > 0) { ChooseRuleMap chooseRuleMap = getTransletRule().getChooseRuleMap(); if (chooseRuleMap == null || chooseRuleMap.isEmpty()) { throw new IllegalRuleException("No defined choose rules"); } ChooseRule chooseRule = chooseRuleMap.getChooseRule(action.getCaseNo()); if (chooseRule == null) { throw new IllegalRuleException("No choose rule with case number: " + ChooseRule.toCaseGroupNo(action.getCaseNo())); } chooseWhenRule = chooseRule.getChooseWhenRule(action.getCaseNo()); if (chooseWhenRule == null) { throw new IllegalRuleException("No choose rule with case number: " + action.getCaseNo()); } if (processedChooses != null && processedChooses.contains(chooseRule.getCaseNo())) { return; } if (processedChooses == null || !processedChooses.contains(chooseWhenRule.getCaseNo())) { BooleanExpression expression = new BooleanExpression(this); if (expression.evaluate(chooseWhenRule)) { if (processedChooses == null) { processedChooses = new HashSet<>(); } processedChooses.add(chooseRule.getCaseNo()); processedChooses.add(chooseWhenRule.getCaseNo()); } else { return; } } } if (log.isDebugEnabled()) { log.debug("Action " + action); } Object resultValue = action.execute(this); if (!action.isHidden() && contentResult != null && resultValue != ActionResult.NO_RESULT) { if (resultValue instanceof ProcessResult) { contentResult.addActionResult(action, (ProcessResult) resultValue); } else { contentResult.addActionResult(action, resultValue); } } if (action.isLastInChooseWhen() && chooseWhenRule != null && chooseWhenRule.getResponse() != null) { reserveResponse(chooseWhenRule.getResponse()); } } catch (ActionExecutionException e) { throw e; } catch (Exception e) { setRaisedException(e); throw new ActionExecutionException("Failed to execute action " + action, e); } }
[ "private", "void", "execute", "(", "Executable", "action", ",", "ContentResult", "contentResult", ")", "{", "try", "{", "ChooseWhenRule", "chooseWhenRule", "=", "null", ";", "if", "(", "action", ".", "getCaseNo", "(", ")", ">", "0", ")", "{", "ChooseRuleMap", "chooseRuleMap", "=", "getTransletRule", "(", ")", ".", "getChooseRuleMap", "(", ")", ";", "if", "(", "chooseRuleMap", "==", "null", "||", "chooseRuleMap", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalRuleException", "(", "\"No defined choose rules\"", ")", ";", "}", "ChooseRule", "chooseRule", "=", "chooseRuleMap", ".", "getChooseRule", "(", "action", ".", "getCaseNo", "(", ")", ")", ";", "if", "(", "chooseRule", "==", "null", ")", "{", "throw", "new", "IllegalRuleException", "(", "\"No choose rule with case number: \"", "+", "ChooseRule", ".", "toCaseGroupNo", "(", "action", ".", "getCaseNo", "(", ")", ")", ")", ";", "}", "chooseWhenRule", "=", "chooseRule", ".", "getChooseWhenRule", "(", "action", ".", "getCaseNo", "(", ")", ")", ";", "if", "(", "chooseWhenRule", "==", "null", ")", "{", "throw", "new", "IllegalRuleException", "(", "\"No choose rule with case number: \"", "+", "action", ".", "getCaseNo", "(", ")", ")", ";", "}", "if", "(", "processedChooses", "!=", "null", "&&", "processedChooses", ".", "contains", "(", "chooseRule", ".", "getCaseNo", "(", ")", ")", ")", "{", "return", ";", "}", "if", "(", "processedChooses", "==", "null", "||", "!", "processedChooses", ".", "contains", "(", "chooseWhenRule", ".", "getCaseNo", "(", ")", ")", ")", "{", "BooleanExpression", "expression", "=", "new", "BooleanExpression", "(", "this", ")", ";", "if", "(", "expression", ".", "evaluate", "(", "chooseWhenRule", ")", ")", "{", "if", "(", "processedChooses", "==", "null", ")", "{", "processedChooses", "=", "new", "HashSet", "<>", "(", ")", ";", "}", "processedChooses", ".", "add", "(", "chooseRule", ".", "getCaseNo", "(", ")", ")", ";", "processedChooses", ".", "add", "(", "chooseWhenRule", ".", "getCaseNo", "(", ")", ")", ";", "}", "else", "{", "return", ";", "}", "}", "}", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Action \"", "+", "action", ")", ";", "}", "Object", "resultValue", "=", "action", ".", "execute", "(", "this", ")", ";", "if", "(", "!", "action", ".", "isHidden", "(", ")", "&&", "contentResult", "!=", "null", "&&", "resultValue", "!=", "ActionResult", ".", "NO_RESULT", ")", "{", "if", "(", "resultValue", "instanceof", "ProcessResult", ")", "{", "contentResult", ".", "addActionResult", "(", "action", ",", "(", "ProcessResult", ")", "resultValue", ")", ";", "}", "else", "{", "contentResult", ".", "addActionResult", "(", "action", ",", "resultValue", ")", ";", "}", "}", "if", "(", "action", ".", "isLastInChooseWhen", "(", ")", "&&", "chooseWhenRule", "!=", "null", "&&", "chooseWhenRule", ".", "getResponse", "(", ")", "!=", "null", ")", "{", "reserveResponse", "(", "chooseWhenRule", ".", "getResponse", "(", ")", ")", ";", "}", "}", "catch", "(", "ActionExecutionException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Exception", "e", ")", "{", "setRaisedException", "(", "e", ")", ";", "throw", "new", "ActionExecutionException", "(", "\"Failed to execute action \"", "+", "action", ",", "e", ")", ";", "}", "}" ]
Execute action. @param action the executable action @param contentResult the content result
[ "Execute", "action", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/CoreActivity.java#L551-L607
142,722
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/bean/BeanRuleRegistry.java
BeanRuleRegistry.scanConfigurableBeans
public void scanConfigurableBeans(String... basePackages) throws BeanRuleException { if (basePackages == null || basePackages.length == 0) { return; } log.info("Auto component scanning on packages [" + StringUtils.joinCommaDelimitedList(basePackages) + "]"); for (String basePackage : basePackages) { BeanClassScanner scanner = new BeanClassScanner(classLoader); List<BeanRule> beanRules = new ArrayList<>(); scanner.scan(basePackage + ".**", (resourceName, targetClass) -> { if (targetClass.isAnnotationPresent(Component.class)) { BeanRule beanRule = new BeanRule(); beanRule.setBeanClass(targetClass); beanRule.setScopeType(ScopeType.SINGLETON); beanRules.add(beanRule); } }); for (BeanRule beanRule : beanRules) { saveConfigurableBeanRule(beanRule); } } }
java
public void scanConfigurableBeans(String... basePackages) throws BeanRuleException { if (basePackages == null || basePackages.length == 0) { return; } log.info("Auto component scanning on packages [" + StringUtils.joinCommaDelimitedList(basePackages) + "]"); for (String basePackage : basePackages) { BeanClassScanner scanner = new BeanClassScanner(classLoader); List<BeanRule> beanRules = new ArrayList<>(); scanner.scan(basePackage + ".**", (resourceName, targetClass) -> { if (targetClass.isAnnotationPresent(Component.class)) { BeanRule beanRule = new BeanRule(); beanRule.setBeanClass(targetClass); beanRule.setScopeType(ScopeType.SINGLETON); beanRules.add(beanRule); } }); for (BeanRule beanRule : beanRules) { saveConfigurableBeanRule(beanRule); } } }
[ "public", "void", "scanConfigurableBeans", "(", "String", "...", "basePackages", ")", "throws", "BeanRuleException", "{", "if", "(", "basePackages", "==", "null", "||", "basePackages", ".", "length", "==", "0", ")", "{", "return", ";", "}", "log", ".", "info", "(", "\"Auto component scanning on packages [\"", "+", "StringUtils", ".", "joinCommaDelimitedList", "(", "basePackages", ")", "+", "\"]\"", ")", ";", "for", "(", "String", "basePackage", ":", "basePackages", ")", "{", "BeanClassScanner", "scanner", "=", "new", "BeanClassScanner", "(", "classLoader", ")", ";", "List", "<", "BeanRule", ">", "beanRules", "=", "new", "ArrayList", "<>", "(", ")", ";", "scanner", ".", "scan", "(", "basePackage", "+", "\".**\"", ",", "(", "resourceName", ",", "targetClass", ")", "->", "{", "if", "(", "targetClass", ".", "isAnnotationPresent", "(", "Component", ".", "class", ")", ")", "{", "BeanRule", "beanRule", "=", "new", "BeanRule", "(", ")", ";", "beanRule", ".", "setBeanClass", "(", "targetClass", ")", ";", "beanRule", ".", "setScopeType", "(", "ScopeType", ".", "SINGLETON", ")", ";", "beanRules", ".", "add", "(", "beanRule", ")", ";", "}", "}", ")", ";", "for", "(", "BeanRule", "beanRule", ":", "beanRules", ")", "{", "saveConfigurableBeanRule", "(", "beanRule", ")", ";", "}", "}", "}" ]
Scans for annotated components. @param basePackages the base packages to scan for annotated components @throws BeanRuleException if an illegal bean rule is found
[ "Scans", "for", "annotated", "components", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/bean/BeanRuleRegistry.java#L179-L201
142,723
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/bean/BeanRuleRegistry.java
BeanRuleRegistry.addBeanRule
public void addBeanRule(final BeanRule beanRule) throws IllegalRuleException { PrefixSuffixPattern prefixSuffixPattern = PrefixSuffixPattern.parse(beanRule.getId()); String scanPattern = beanRule.getScanPattern(); if (scanPattern != null) { BeanClassScanner scanner = createBeanClassScanner(beanRule); List<BeanRule> beanRules = new ArrayList<>(); scanner.scan(scanPattern, (resourceName, targetClass) -> { BeanRule beanRule2 = beanRule.replicate(); if (prefixSuffixPattern != null) { beanRule2.setId(prefixSuffixPattern.join(resourceName)); } else { if (beanRule.getId() != null) { beanRule2.setId(beanRule.getId() + resourceName); } else if (beanRule.getMaskPattern() != null) { beanRule2.setId(resourceName); } } beanRule2.setBeanClass(targetClass); beanRules.add(beanRule2); }); for (BeanRule beanRule2 : beanRules) { dissectBeanRule(beanRule2); } } else { if (!beanRule.isFactoryOffered()) { String className = beanRule.getClassName(); if (prefixSuffixPattern != null) { beanRule.setId(prefixSuffixPattern.join(className)); } Class<?> beanClass; try { beanClass = classLoader.loadClass(className); } catch (ClassNotFoundException e) { throw new BeanRuleException("Failed to load bean class", beanRule, e); } beanRule.setBeanClass(beanClass); } dissectBeanRule(beanRule); } }
java
public void addBeanRule(final BeanRule beanRule) throws IllegalRuleException { PrefixSuffixPattern prefixSuffixPattern = PrefixSuffixPattern.parse(beanRule.getId()); String scanPattern = beanRule.getScanPattern(); if (scanPattern != null) { BeanClassScanner scanner = createBeanClassScanner(beanRule); List<BeanRule> beanRules = new ArrayList<>(); scanner.scan(scanPattern, (resourceName, targetClass) -> { BeanRule beanRule2 = beanRule.replicate(); if (prefixSuffixPattern != null) { beanRule2.setId(prefixSuffixPattern.join(resourceName)); } else { if (beanRule.getId() != null) { beanRule2.setId(beanRule.getId() + resourceName); } else if (beanRule.getMaskPattern() != null) { beanRule2.setId(resourceName); } } beanRule2.setBeanClass(targetClass); beanRules.add(beanRule2); }); for (BeanRule beanRule2 : beanRules) { dissectBeanRule(beanRule2); } } else { if (!beanRule.isFactoryOffered()) { String className = beanRule.getClassName(); if (prefixSuffixPattern != null) { beanRule.setId(prefixSuffixPattern.join(className)); } Class<?> beanClass; try { beanClass = classLoader.loadClass(className); } catch (ClassNotFoundException e) { throw new BeanRuleException("Failed to load bean class", beanRule, e); } beanRule.setBeanClass(beanClass); } dissectBeanRule(beanRule); } }
[ "public", "void", "addBeanRule", "(", "final", "BeanRule", "beanRule", ")", "throws", "IllegalRuleException", "{", "PrefixSuffixPattern", "prefixSuffixPattern", "=", "PrefixSuffixPattern", ".", "parse", "(", "beanRule", ".", "getId", "(", ")", ")", ";", "String", "scanPattern", "=", "beanRule", ".", "getScanPattern", "(", ")", ";", "if", "(", "scanPattern", "!=", "null", ")", "{", "BeanClassScanner", "scanner", "=", "createBeanClassScanner", "(", "beanRule", ")", ";", "List", "<", "BeanRule", ">", "beanRules", "=", "new", "ArrayList", "<>", "(", ")", ";", "scanner", ".", "scan", "(", "scanPattern", ",", "(", "resourceName", ",", "targetClass", ")", "->", "{", "BeanRule", "beanRule2", "=", "beanRule", ".", "replicate", "(", ")", ";", "if", "(", "prefixSuffixPattern", "!=", "null", ")", "{", "beanRule2", ".", "setId", "(", "prefixSuffixPattern", ".", "join", "(", "resourceName", ")", ")", ";", "}", "else", "{", "if", "(", "beanRule", ".", "getId", "(", ")", "!=", "null", ")", "{", "beanRule2", ".", "setId", "(", "beanRule", ".", "getId", "(", ")", "+", "resourceName", ")", ";", "}", "else", "if", "(", "beanRule", ".", "getMaskPattern", "(", ")", "!=", "null", ")", "{", "beanRule2", ".", "setId", "(", "resourceName", ")", ";", "}", "}", "beanRule2", ".", "setBeanClass", "(", "targetClass", ")", ";", "beanRules", ".", "add", "(", "beanRule2", ")", ";", "}", ")", ";", "for", "(", "BeanRule", "beanRule2", ":", "beanRules", ")", "{", "dissectBeanRule", "(", "beanRule2", ")", ";", "}", "}", "else", "{", "if", "(", "!", "beanRule", ".", "isFactoryOffered", "(", ")", ")", "{", "String", "className", "=", "beanRule", ".", "getClassName", "(", ")", ";", "if", "(", "prefixSuffixPattern", "!=", "null", ")", "{", "beanRule", ".", "setId", "(", "prefixSuffixPattern", ".", "join", "(", "className", ")", ")", ";", "}", "Class", "<", "?", ">", "beanClass", ";", "try", "{", "beanClass", "=", "classLoader", ".", "loadClass", "(", "className", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "BeanRuleException", "(", "\"Failed to load bean class\"", ",", "beanRule", ",", "e", ")", ";", "}", "beanRule", ".", "setBeanClass", "(", "beanClass", ")", ";", "}", "dissectBeanRule", "(", "beanRule", ")", ";", "}", "}" ]
Adds a bean rule. @param beanRule the bean rule to add @throws IllegalRuleException if an error occurs while adding a bean rule
[ "Adds", "a", "bean", "rule", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/bean/BeanRuleRegistry.java#L209-L248
142,724
aspectran/aspectran
core/src/main/java/com/aspectran/core/support/i18n/message/AbstractMessageSource.java
AbstractMessageSource.getMessageFromParent
protected String getMessageFromParent(String code, Object[] args, Locale locale) { MessageSource parent = getParentMessageSource(); if (parent != null) { if (parent instanceof AbstractMessageSource) { // Call internal method to avoid getting the default code back // in case of "useCodeAsDefaultMessage" being activated. return ((AbstractMessageSource) parent).getMessageInternal(code, args, locale); } else { // Check parent MessageSource, returning null if not found there. return parent.getMessage(code, args, null, locale); } } // Not found in parent either. return null; }
java
protected String getMessageFromParent(String code, Object[] args, Locale locale) { MessageSource parent = getParentMessageSource(); if (parent != null) { if (parent instanceof AbstractMessageSource) { // Call internal method to avoid getting the default code back // in case of "useCodeAsDefaultMessage" being activated. return ((AbstractMessageSource) parent).getMessageInternal(code, args, locale); } else { // Check parent MessageSource, returning null if not found there. return parent.getMessage(code, args, null, locale); } } // Not found in parent either. return null; }
[ "protected", "String", "getMessageFromParent", "(", "String", "code", ",", "Object", "[", "]", "args", ",", "Locale", "locale", ")", "{", "MessageSource", "parent", "=", "getParentMessageSource", "(", ")", ";", "if", "(", "parent", "!=", "null", ")", "{", "if", "(", "parent", "instanceof", "AbstractMessageSource", ")", "{", "// Call internal method to avoid getting the default code back", "// in case of \"useCodeAsDefaultMessage\" being activated.", "return", "(", "(", "AbstractMessageSource", ")", "parent", ")", ".", "getMessageInternal", "(", "code", ",", "args", ",", "locale", ")", ";", "}", "else", "{", "// Check parent MessageSource, returning null if not found there.", "return", "parent", ".", "getMessage", "(", "code", ",", "args", ",", "null", ",", "locale", ")", ";", "}", "}", "// Not found in parent either.", "return", "null", ";", "}" ]
Try to retrieve the given message from the parent MessageSource, if any. @param code the code to lookup up, such as 'calculator.noRateSet' @param args array of arguments that will be filled in for params within the message @param locale the Locale in which to do the lookup @return the resolved message, or {@code null} if not found @see #getParentMessageSource() #getParentMessageSource()
[ "Try", "to", "retrieve", "the", "given", "message", "from", "the", "parent", "MessageSource", "if", "any", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/support/i18n/message/AbstractMessageSource.java#L208-L222
142,725
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/assistant/BeanReferenceInspector.java
BeanReferenceInspector.reserve
public void reserve(String beanId, Class<?> beanClass, BeanReferenceable referenceable, RuleAppender ruleAppender) { RefererKey key = new RefererKey(beanClass, beanId); Set<RefererInfo> refererInfoSet = refererInfoMap.get(key); if (refererInfoSet == null) { refererInfoSet = new LinkedHashSet<>(); refererInfoSet.add(new RefererInfo(referenceable, ruleAppender)); refererInfoMap.put(key, refererInfoSet); } else { refererInfoSet.add(new RefererInfo(referenceable, ruleAppender)); } }
java
public void reserve(String beanId, Class<?> beanClass, BeanReferenceable referenceable, RuleAppender ruleAppender) { RefererKey key = new RefererKey(beanClass, beanId); Set<RefererInfo> refererInfoSet = refererInfoMap.get(key); if (refererInfoSet == null) { refererInfoSet = new LinkedHashSet<>(); refererInfoSet.add(new RefererInfo(referenceable, ruleAppender)); refererInfoMap.put(key, refererInfoSet); } else { refererInfoSet.add(new RefererInfo(referenceable, ruleAppender)); } }
[ "public", "void", "reserve", "(", "String", "beanId", ",", "Class", "<", "?", ">", "beanClass", ",", "BeanReferenceable", "referenceable", ",", "RuleAppender", "ruleAppender", ")", "{", "RefererKey", "key", "=", "new", "RefererKey", "(", "beanClass", ",", "beanId", ")", ";", "Set", "<", "RefererInfo", ">", "refererInfoSet", "=", "refererInfoMap", ".", "get", "(", "key", ")", ";", "if", "(", "refererInfoSet", "==", "null", ")", "{", "refererInfoSet", "=", "new", "LinkedHashSet", "<>", "(", ")", ";", "refererInfoSet", ".", "add", "(", "new", "RefererInfo", "(", "referenceable", ",", "ruleAppender", ")", ")", ";", "refererInfoMap", ".", "put", "(", "key", ",", "refererInfoSet", ")", ";", "}", "else", "{", "refererInfoSet", ".", "add", "(", "new", "RefererInfo", "(", "referenceable", ",", "ruleAppender", ")", ")", ";", "}", "}" ]
Reserves to bean reference inspection. @param beanId the bean id @param beanClass the bean class @param referenceable the object to be inspected @param ruleAppender the rule appender
[ "Reserves", "to", "bean", "reference", "inspection", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/assistant/BeanReferenceInspector.java#L59-L69
142,726
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/assistant/BeanReferenceInspector.java
BeanReferenceInspector.inspect
public void inspect(BeanRuleRegistry beanRuleRegistry) throws BeanReferenceException, BeanRuleException { Set<Object> brokenReferences = new LinkedHashSet<>(); for (Map.Entry<RefererKey, Set<RefererInfo>> entry : refererInfoMap.entrySet()) { RefererKey refererKey = entry.getKey(); String beanId = refererKey.getQualifier(); Class<?> beanClass = refererKey.getType(); Set<RefererInfo> refererInfoSet = entry.getValue(); BeanRule beanRule = null; BeanRule[] beanRules = null; if (beanClass != null) { beanRules = beanRuleRegistry.getBeanRules(beanClass); if (beanRules != null) { if (beanRules.length == 1) { if (beanId != null) { if (beanId.equals(beanRules[0].getId())) { beanRule = beanRules[0]; } } else { beanRule = beanRules[0]; } } else { if (beanId != null) { for (BeanRule br : beanRules) { if (beanId.equals(br.getId())) { beanRule = br; break; } } } } } if (beanRule == null && beanRules == null) { beanRule = beanRuleRegistry.getBeanRuleForConfig(beanClass); } } else if (beanId != null) { beanRule = beanRuleRegistry.getBeanRule(beanId); } if (beanRule == null) { if (beanRules != null && beanRules.length > 1) { for (RefererInfo refererInfo : refererInfoSet) { if (beanId != null) { log.error("Cannot resolve reference to bean " + refererKey + "; Referer: " + refererInfo); } else { log.error("No unique bean of type [" + beanClass + "] is defined: " + "expected single matching bean but found " + beanRules.length + ": [" + NoUniqueBeanException.getBeanDescriptions(beanRules) + "]; Referer: " + refererInfo); } } brokenReferences.add(refererKey); } else { int count = 0; for (RefererInfo refererInfo : refererInfoSet) { if (!isStaticMethodReference(refererInfo)) { count++; log.error("Cannot resolve reference to bean " + refererKey + "; Referer: " + refererInfo); } } if (count > 0) { brokenReferences.add(refererKey); } } } else { for (RefererInfo refererInfo : refererInfoSet) { if (refererInfo.getBeanRefererType() == BeanRefererType.BEAN_METHOD_ACTION_RULE) { checkTransletActionParameter((BeanMethodActionRule)refererInfo.getReferenceable(), beanRule, refererInfo); } } } } if (!brokenReferences.isEmpty()) { throw new BeanReferenceException(brokenReferences); } }
java
public void inspect(BeanRuleRegistry beanRuleRegistry) throws BeanReferenceException, BeanRuleException { Set<Object> brokenReferences = new LinkedHashSet<>(); for (Map.Entry<RefererKey, Set<RefererInfo>> entry : refererInfoMap.entrySet()) { RefererKey refererKey = entry.getKey(); String beanId = refererKey.getQualifier(); Class<?> beanClass = refererKey.getType(); Set<RefererInfo> refererInfoSet = entry.getValue(); BeanRule beanRule = null; BeanRule[] beanRules = null; if (beanClass != null) { beanRules = beanRuleRegistry.getBeanRules(beanClass); if (beanRules != null) { if (beanRules.length == 1) { if (beanId != null) { if (beanId.equals(beanRules[0].getId())) { beanRule = beanRules[0]; } } else { beanRule = beanRules[0]; } } else { if (beanId != null) { for (BeanRule br : beanRules) { if (beanId.equals(br.getId())) { beanRule = br; break; } } } } } if (beanRule == null && beanRules == null) { beanRule = beanRuleRegistry.getBeanRuleForConfig(beanClass); } } else if (beanId != null) { beanRule = beanRuleRegistry.getBeanRule(beanId); } if (beanRule == null) { if (beanRules != null && beanRules.length > 1) { for (RefererInfo refererInfo : refererInfoSet) { if (beanId != null) { log.error("Cannot resolve reference to bean " + refererKey + "; Referer: " + refererInfo); } else { log.error("No unique bean of type [" + beanClass + "] is defined: " + "expected single matching bean but found " + beanRules.length + ": [" + NoUniqueBeanException.getBeanDescriptions(beanRules) + "]; Referer: " + refererInfo); } } brokenReferences.add(refererKey); } else { int count = 0; for (RefererInfo refererInfo : refererInfoSet) { if (!isStaticMethodReference(refererInfo)) { count++; log.error("Cannot resolve reference to bean " + refererKey + "; Referer: " + refererInfo); } } if (count > 0) { brokenReferences.add(refererKey); } } } else { for (RefererInfo refererInfo : refererInfoSet) { if (refererInfo.getBeanRefererType() == BeanRefererType.BEAN_METHOD_ACTION_RULE) { checkTransletActionParameter((BeanMethodActionRule)refererInfo.getReferenceable(), beanRule, refererInfo); } } } } if (!brokenReferences.isEmpty()) { throw new BeanReferenceException(brokenReferences); } }
[ "public", "void", "inspect", "(", "BeanRuleRegistry", "beanRuleRegistry", ")", "throws", "BeanReferenceException", ",", "BeanRuleException", "{", "Set", "<", "Object", ">", "brokenReferences", "=", "new", "LinkedHashSet", "<>", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "RefererKey", ",", "Set", "<", "RefererInfo", ">", ">", "entry", ":", "refererInfoMap", ".", "entrySet", "(", ")", ")", "{", "RefererKey", "refererKey", "=", "entry", ".", "getKey", "(", ")", ";", "String", "beanId", "=", "refererKey", ".", "getQualifier", "(", ")", ";", "Class", "<", "?", ">", "beanClass", "=", "refererKey", ".", "getType", "(", ")", ";", "Set", "<", "RefererInfo", ">", "refererInfoSet", "=", "entry", ".", "getValue", "(", ")", ";", "BeanRule", "beanRule", "=", "null", ";", "BeanRule", "[", "]", "beanRules", "=", "null", ";", "if", "(", "beanClass", "!=", "null", ")", "{", "beanRules", "=", "beanRuleRegistry", ".", "getBeanRules", "(", "beanClass", ")", ";", "if", "(", "beanRules", "!=", "null", ")", "{", "if", "(", "beanRules", ".", "length", "==", "1", ")", "{", "if", "(", "beanId", "!=", "null", ")", "{", "if", "(", "beanId", ".", "equals", "(", "beanRules", "[", "0", "]", ".", "getId", "(", ")", ")", ")", "{", "beanRule", "=", "beanRules", "[", "0", "]", ";", "}", "}", "else", "{", "beanRule", "=", "beanRules", "[", "0", "]", ";", "}", "}", "else", "{", "if", "(", "beanId", "!=", "null", ")", "{", "for", "(", "BeanRule", "br", ":", "beanRules", ")", "{", "if", "(", "beanId", ".", "equals", "(", "br", ".", "getId", "(", ")", ")", ")", "{", "beanRule", "=", "br", ";", "break", ";", "}", "}", "}", "}", "}", "if", "(", "beanRule", "==", "null", "&&", "beanRules", "==", "null", ")", "{", "beanRule", "=", "beanRuleRegistry", ".", "getBeanRuleForConfig", "(", "beanClass", ")", ";", "}", "}", "else", "if", "(", "beanId", "!=", "null", ")", "{", "beanRule", "=", "beanRuleRegistry", ".", "getBeanRule", "(", "beanId", ")", ";", "}", "if", "(", "beanRule", "==", "null", ")", "{", "if", "(", "beanRules", "!=", "null", "&&", "beanRules", ".", "length", ">", "1", ")", "{", "for", "(", "RefererInfo", "refererInfo", ":", "refererInfoSet", ")", "{", "if", "(", "beanId", "!=", "null", ")", "{", "log", ".", "error", "(", "\"Cannot resolve reference to bean \"", "+", "refererKey", "+", "\"; Referer: \"", "+", "refererInfo", ")", ";", "}", "else", "{", "log", ".", "error", "(", "\"No unique bean of type [\"", "+", "beanClass", "+", "\"] is defined: \"", "+", "\"expected single matching bean but found \"", "+", "beanRules", ".", "length", "+", "\": [\"", "+", "NoUniqueBeanException", ".", "getBeanDescriptions", "(", "beanRules", ")", "+", "\"]; Referer: \"", "+", "refererInfo", ")", ";", "}", "}", "brokenReferences", ".", "add", "(", "refererKey", ")", ";", "}", "else", "{", "int", "count", "=", "0", ";", "for", "(", "RefererInfo", "refererInfo", ":", "refererInfoSet", ")", "{", "if", "(", "!", "isStaticMethodReference", "(", "refererInfo", ")", ")", "{", "count", "++", ";", "log", ".", "error", "(", "\"Cannot resolve reference to bean \"", "+", "refererKey", "+", "\"; Referer: \"", "+", "refererInfo", ")", ";", "}", "}", "if", "(", "count", ">", "0", ")", "{", "brokenReferences", ".", "add", "(", "refererKey", ")", ";", "}", "}", "}", "else", "{", "for", "(", "RefererInfo", "refererInfo", ":", "refererInfoSet", ")", "{", "if", "(", "refererInfo", ".", "getBeanRefererType", "(", ")", "==", "BeanRefererType", ".", "BEAN_METHOD_ACTION_RULE", ")", "{", "checkTransletActionParameter", "(", "(", "BeanMethodActionRule", ")", "refererInfo", ".", "getReferenceable", "(", ")", ",", "beanRule", ",", "refererInfo", ")", ";", "}", "}", "}", "}", "if", "(", "!", "brokenReferences", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "BeanReferenceException", "(", "brokenReferences", ")", ";", "}", "}" ]
Inspect bean reference. @param beanRuleRegistry the bean rule registry @throws BeanReferenceException the bean reference exception @throws BeanRuleException if an illegal bean rule is found
[ "Inspect", "bean", "reference", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/assistant/BeanReferenceInspector.java#L78-L158
142,727
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/ItemRuleMap.java
ItemRuleMap.putItemRule
public ItemRule putItemRule(ItemRule itemRule) { if (itemRule.isAutoNamed()) { autoNaming(itemRule); } return put(itemRule.getName(), itemRule); }
java
public ItemRule putItemRule(ItemRule itemRule) { if (itemRule.isAutoNamed()) { autoNaming(itemRule); } return put(itemRule.getName(), itemRule); }
[ "public", "ItemRule", "putItemRule", "(", "ItemRule", "itemRule", ")", "{", "if", "(", "itemRule", ".", "isAutoNamed", "(", ")", ")", "{", "autoNaming", "(", "itemRule", ")", ";", "}", "return", "put", "(", "itemRule", ".", "getName", "(", ")", ",", "itemRule", ")", ";", "}" ]
Adds a item rule. @param itemRule the item rule @return the item rule
[ "Adds", "a", "item", "rule", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/ItemRuleMap.java#L52-L57
142,728
aspectran/aspectran
web/src/main/java/com/aspectran/web/support/cors/DefaultCorsProcessor.java
DefaultCorsProcessor.rejectRequest
protected void rejectRequest(Translet translet, CorsException ce) throws CorsException { HttpServletResponse res = translet.getResponseAdaptee(); res.setStatus(ce.getHttpStatusCode()); translet.setAttribute(CORS_HTTP_STATUS_CODE, ce.getHttpStatusCode()); translet.setAttribute(CORS_HTTP_STATUS_TEXT, ce.getMessage()); throw ce; }
java
protected void rejectRequest(Translet translet, CorsException ce) throws CorsException { HttpServletResponse res = translet.getResponseAdaptee(); res.setStatus(ce.getHttpStatusCode()); translet.setAttribute(CORS_HTTP_STATUS_CODE, ce.getHttpStatusCode()); translet.setAttribute(CORS_HTTP_STATUS_TEXT, ce.getMessage()); throw ce; }
[ "protected", "void", "rejectRequest", "(", "Translet", "translet", ",", "CorsException", "ce", ")", "throws", "CorsException", "{", "HttpServletResponse", "res", "=", "translet", ".", "getResponseAdaptee", "(", ")", ";", "res", ".", "setStatus", "(", "ce", ".", "getHttpStatusCode", "(", ")", ")", ";", "translet", ".", "setAttribute", "(", "CORS_HTTP_STATUS_CODE", ",", "ce", ".", "getHttpStatusCode", "(", ")", ")", ";", "translet", ".", "setAttribute", "(", "CORS_HTTP_STATUS_TEXT", ",", "ce", ".", "getMessage", "(", ")", ")", ";", "throw", "ce", ";", "}" ]
Invoked when one of the CORS checks failed. The default implementation sets the response status to 403. @param translet the Translet instance @param ce the CORS Exception @throws CorsException if the request is denied
[ "Invoked", "when", "one", "of", "the", "CORS", "checks", "failed", ".", "The", "default", "implementation", "sets", "the", "response", "status", "to", "403", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/support/cors/DefaultCorsProcessor.java#L158-L166
142,729
aspectran/aspectran
web/src/main/java/com/aspectran/web/startup/servlet/SpecificIPAllowedWebActivityServlet.java
SpecificIPAllowedWebActivityServlet.isAllowedAddress
private boolean isAllowedAddress(String ipAddress) { if (allowedAddresses == null) { return false; } // IPv4 int offset = ipAddress.lastIndexOf('.'); if (offset == -1) { // IPv6 offset = ipAddress.lastIndexOf(':'); if (offset == -1) { return false; } } String ipAddressClass = ipAddress.substring(0, offset + 1) + '*'; return (allowedAddresses.contains(ipAddressClass) || allowedAddresses.contains(ipAddress)); }
java
private boolean isAllowedAddress(String ipAddress) { if (allowedAddresses == null) { return false; } // IPv4 int offset = ipAddress.lastIndexOf('.'); if (offset == -1) { // IPv6 offset = ipAddress.lastIndexOf(':'); if (offset == -1) { return false; } } String ipAddressClass = ipAddress.substring(0, offset + 1) + '*'; return (allowedAddresses.contains(ipAddressClass) || allowedAddresses.contains(ipAddress)); }
[ "private", "boolean", "isAllowedAddress", "(", "String", "ipAddress", ")", "{", "if", "(", "allowedAddresses", "==", "null", ")", "{", "return", "false", ";", "}", "// IPv4", "int", "offset", "=", "ipAddress", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "offset", "==", "-", "1", ")", "{", "// IPv6", "offset", "=", "ipAddress", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "offset", "==", "-", "1", ")", "{", "return", "false", ";", "}", "}", "String", "ipAddressClass", "=", "ipAddress", ".", "substring", "(", "0", ",", "offset", "+", "1", ")", "+", "'", "'", ";", "return", "(", "allowedAddresses", ".", "contains", "(", "ipAddressClass", ")", "||", "allowedAddresses", ".", "contains", "(", "ipAddress", ")", ")", ";", "}" ]
Returns whether IP address is valid. @param ipAddress the IP address @return true if IP address is a valid; false otherwise
[ "Returns", "whether", "IP", "address", "is", "valid", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/startup/servlet/SpecificIPAllowedWebActivityServlet.java#L85-L102
142,730
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/request/FileParameter.java
FileParameter.getBytes
public byte[] getBytes() throws IOException { InputStream input = getInputStream(); ByteArrayOutputStream output = new ByteArrayOutputStream(); final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; int len; try { while ((len = input.read(buffer)) != -1) { output.write(buffer, 0, len); } } finally { try { output.close(); } catch (IOException e) { // ignore } try { input.close(); } catch (IOException e) { // ignore } } return output.toByteArray(); }
java
public byte[] getBytes() throws IOException { InputStream input = getInputStream(); ByteArrayOutputStream output = new ByteArrayOutputStream(); final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; int len; try { while ((len = input.read(buffer)) != -1) { output.write(buffer, 0, len); } } finally { try { output.close(); } catch (IOException e) { // ignore } try { input.close(); } catch (IOException e) { // ignore } } return output.toByteArray(); }
[ "public", "byte", "[", "]", "getBytes", "(", ")", "throws", "IOException", "{", "InputStream", "input", "=", "getInputStream", "(", ")", ";", "ByteArrayOutputStream", "output", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "final", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "DEFAULT_BUFFER_SIZE", "]", ";", "int", "len", ";", "try", "{", "while", "(", "(", "len", "=", "input", ".", "read", "(", "buffer", ")", ")", "!=", "-", "1", ")", "{", "output", ".", "write", "(", "buffer", ",", "0", ",", "len", ")", ";", "}", "}", "finally", "{", "try", "{", "output", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// ignore", "}", "try", "{", "input", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// ignore", "}", "}", "return", "output", ".", "toByteArray", "(", ")", ";", "}" ]
Returns the contents of the file in a byte array. Can not use a large array of memory than the JVM Heap deal. @return a byte array @throws IOException if an I/O error has occurred
[ "Returns", "the", "contents", "of", "the", "file", "in", "a", "byte", "array", ".", "Can", "not", "use", "a", "large", "array", "of", "memory", "than", "the", "JVM", "Heap", "deal", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/request/FileParameter.java#L112-L137
142,731
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/request/FileParameter.java
FileParameter.saveAs
public File saveAs(File destFile, boolean overwrite) throws IOException { if (destFile == null) { throw new IllegalArgumentException("destFile can not be null"); } try { destFile = determineDestinationFile(destFile, overwrite); final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; int len; try (InputStream input = getInputStream(); OutputStream output = new FileOutputStream(destFile)) { while ((len = input.read(buffer)) != -1) { output.write(buffer, 0, len); } } } catch (Exception e) { throw new IOException("Could not save as file " + destFile, e); } setSavedFile(destFile); return destFile; }
java
public File saveAs(File destFile, boolean overwrite) throws IOException { if (destFile == null) { throw new IllegalArgumentException("destFile can not be null"); } try { destFile = determineDestinationFile(destFile, overwrite); final byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; int len; try (InputStream input = getInputStream(); OutputStream output = new FileOutputStream(destFile)) { while ((len = input.read(buffer)) != -1) { output.write(buffer, 0, len); } } } catch (Exception e) { throw new IOException("Could not save as file " + destFile, e); } setSavedFile(destFile); return destFile; }
[ "public", "File", "saveAs", "(", "File", "destFile", ",", "boolean", "overwrite", ")", "throws", "IOException", "{", "if", "(", "destFile", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"destFile can not be null\"", ")", ";", "}", "try", "{", "destFile", "=", "determineDestinationFile", "(", "destFile", ",", "overwrite", ")", ";", "final", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "DEFAULT_BUFFER_SIZE", "]", ";", "int", "len", ";", "try", "(", "InputStream", "input", "=", "getInputStream", "(", ")", ";", "OutputStream", "output", "=", "new", "FileOutputStream", "(", "destFile", ")", ")", "{", "while", "(", "(", "len", "=", "input", ".", "read", "(", "buffer", ")", ")", "!=", "-", "1", ")", "{", "output", ".", "write", "(", "buffer", ",", "0", ",", "len", ")", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IOException", "(", "\"Could not save as file \"", "+", "destFile", ",", "e", ")", ";", "}", "setSavedFile", "(", "destFile", ")", ";", "return", "destFile", ";", "}" ]
Save an file as a given destination file. @param destFile the destination file @param overwrite whether to overwrite if it already exists @return a saved file @throws IOException if an I/O error has occurred
[ "Save", "an", "file", "as", "a", "given", "destination", "file", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/request/FileParameter.java#L177-L198
142,732
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/request/FileParameter.java
FileParameter.release
public void release() { if (file != null) { file.setWritable(true); } if (savedFile != null) { savedFile.setWritable(true); } }
java
public void release() { if (file != null) { file.setWritable(true); } if (savedFile != null) { savedFile.setWritable(true); } }
[ "public", "void", "release", "(", ")", "{", "if", "(", "file", "!=", "null", ")", "{", "file", ".", "setWritable", "(", "true", ")", ";", "}", "if", "(", "savedFile", "!=", "null", ")", "{", "savedFile", ".", "setWritable", "(", "true", ")", ";", "}", "}" ]
Sets the access permission that allow write operations on the file associated with this FileParameter.
[ "Sets", "the", "access", "permission", "that", "allow", "write", "operations", "on", "the", "file", "associated", "with", "this", "FileParameter", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/request/FileParameter.java#L282-L289
142,733
aspectran/aspectran
web/src/main/java/com/aspectran/web/service/AspectranWebService.java
AspectranWebService.getActivityContext
public static ActivityContext getActivityContext(ServletContext servletContext) { ActivityContext activityContext = getActivityContext(servletContext, ROOT_WEB_SERVICE_ATTRIBUTE); if (activityContext == null) { throw new IllegalStateException("No Root AspectranWebService found; " + "No AspectranServiceListener registered?"); } return activityContext; }
java
public static ActivityContext getActivityContext(ServletContext servletContext) { ActivityContext activityContext = getActivityContext(servletContext, ROOT_WEB_SERVICE_ATTRIBUTE); if (activityContext == null) { throw new IllegalStateException("No Root AspectranWebService found; " + "No AspectranServiceListener registered?"); } return activityContext; }
[ "public", "static", "ActivityContext", "getActivityContext", "(", "ServletContext", "servletContext", ")", "{", "ActivityContext", "activityContext", "=", "getActivityContext", "(", "servletContext", ",", "ROOT_WEB_SERVICE_ATTRIBUTE", ")", ";", "if", "(", "activityContext", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"No Root AspectranWebService found; \"", "+", "\"No AspectranServiceListener registered?\"", ")", ";", "}", "return", "activityContext", ";", "}" ]
Find the root ActivityContext for this web aspectran service. @param servletContext ServletContext to find the web aspectran service for @return the ActivityContext for this web aspectran service
[ "Find", "the", "root", "ActivityContext", "for", "this", "web", "aspectran", "service", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/service/AspectranWebService.java#L372-L379
142,734
aspectran/aspectran
web/src/main/java/com/aspectran/web/service/AspectranWebService.java
AspectranWebService.getActivityContext
public static ActivityContext getActivityContext(HttpServlet servlet) { ServletContext servletContext = servlet.getServletContext(); String attrName = STANDALONE_WEB_SERVICE_ATTRIBUTE_PREFIX + servlet.getServletName(); ActivityContext activityContext = getActivityContext(servletContext, attrName); if (activityContext != null) { return activityContext; } else { return getActivityContext(servletContext); } }
java
public static ActivityContext getActivityContext(HttpServlet servlet) { ServletContext servletContext = servlet.getServletContext(); String attrName = STANDALONE_WEB_SERVICE_ATTRIBUTE_PREFIX + servlet.getServletName(); ActivityContext activityContext = getActivityContext(servletContext, attrName); if (activityContext != null) { return activityContext; } else { return getActivityContext(servletContext); } }
[ "public", "static", "ActivityContext", "getActivityContext", "(", "HttpServlet", "servlet", ")", "{", "ServletContext", "servletContext", "=", "servlet", ".", "getServletContext", "(", ")", ";", "String", "attrName", "=", "STANDALONE_WEB_SERVICE_ATTRIBUTE_PREFIX", "+", "servlet", ".", "getServletName", "(", ")", ";", "ActivityContext", "activityContext", "=", "getActivityContext", "(", "servletContext", ",", "attrName", ")", ";", "if", "(", "activityContext", "!=", "null", ")", "{", "return", "activityContext", ";", "}", "else", "{", "return", "getActivityContext", "(", "servletContext", ")", ";", "}", "}" ]
Find the standalone ActivityContext for this web aspectran service. @param servlet the servlet @return the ActivityContext for this web aspectran service
[ "Find", "the", "standalone", "ActivityContext", "for", "this", "web", "aspectran", "service", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/service/AspectranWebService.java#L387-L396
142,735
aspectran/aspectran
web/src/main/java/com/aspectran/web/service/AspectranWebService.java
AspectranWebService.getActivityContext
private static ActivityContext getActivityContext(ServletContext servletContext, String attrName) { Object attr = servletContext.getAttribute(attrName); if (attr == null) { return null; } if (!(attr instanceof AspectranWebService)) { throw new IllegalStateException("Context attribute [" + attr + "] is not of type [" + AspectranWebService.class.getName() + "]"); } return ((CoreService)attr).getActivityContext(); }
java
private static ActivityContext getActivityContext(ServletContext servletContext, String attrName) { Object attr = servletContext.getAttribute(attrName); if (attr == null) { return null; } if (!(attr instanceof AspectranWebService)) { throw new IllegalStateException("Context attribute [" + attr + "] is not of type [" + AspectranWebService.class.getName() + "]"); } return ((CoreService)attr).getActivityContext(); }
[ "private", "static", "ActivityContext", "getActivityContext", "(", "ServletContext", "servletContext", ",", "String", "attrName", ")", "{", "Object", "attr", "=", "servletContext", ".", "getAttribute", "(", "attrName", ")", ";", "if", "(", "attr", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "!", "(", "attr", "instanceof", "AspectranWebService", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Context attribute [\"", "+", "attr", "+", "\"] is not of type [\"", "+", "AspectranWebService", ".", "class", ".", "getName", "(", ")", "+", "\"]\"", ")", ";", "}", "return", "(", "(", "CoreService", ")", "attr", ")", ".", "getActivityContext", "(", ")", ";", "}" ]
Find the ActivityContext for this web aspectran service. @param servletContext ServletContext to find the web aspectran service for @param attrName the name of the ServletContext attribute to look for @return the ActivityContext for this web aspectran service
[ "Find", "the", "ActivityContext", "for", "this", "web", "aspectran", "service", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/service/AspectranWebService.java#L405-L415
142,736
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java
FileSessionDataStore.deleteFile
private boolean deleteFile(String filename) throws Exception { if (filename == null) { return false; } File file = new File(storeDir, filename); return Files.deleteIfExists(file.toPath()); }
java
private boolean deleteFile(String filename) throws Exception { if (filename == null) { return false; } File file = new File(storeDir, filename); return Files.deleteIfExists(file.toPath()); }
[ "private", "boolean", "deleteFile", "(", "String", "filename", ")", "throws", "Exception", "{", "if", "(", "filename", "==", "null", ")", "{", "return", "false", ";", "}", "File", "file", "=", "new", "File", "(", "storeDir", ",", "filename", ")", ";", "return", "Files", ".", "deleteIfExists", "(", "file", ".", "toPath", "(", ")", ")", ";", "}" ]
Delete the file associated with a session @param filename name of the file containing the session's information @return true if file was deleted, false otherwise @throws Exception if the file associated with the session fails to be deleted
[ "Delete", "the", "file", "associated", "with", "a", "session" ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java#L101-L107
142,737
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java
FileSessionDataStore.doGetExpired
@Override public Set<String> doGetExpired(final Set<String> candidates) { final long now = System.currentTimeMillis(); Set<String> expired = new HashSet<>(); // iterate over the files and work out which have expired for (String filename : sessionFileMap.values()) { try { long expiry = getExpiryFromFilename(filename); if (expiry > 0 && expiry < now) { expired.add(getIdFromFilename(filename)); } } catch (Exception e) { log.warn(e.getMessage(), e); } } // check candidates that were not found to be expired, perhaps // because they no longer exist and they should be expired for (String c : candidates) { if (!expired.contains(c)) { // if it doesn't have a file then the session doesn't exist String filename = sessionFileMap.get(c); if (filename == null) { expired.add(c); } } } // Infrequently iterate over all files in the store, and delete those // that expired a long time ago. // If the graceperiod is disabled, don't do the sweep! if (gracePeriodSec > 0 && (lastSweepTime == 0L || ((now - lastSweepTime) >= (5 * TimeUnit.SECONDS.toMillis(gracePeriodSec))))) { lastSweepTime = now; sweepDisk(); } return expired; }
java
@Override public Set<String> doGetExpired(final Set<String> candidates) { final long now = System.currentTimeMillis(); Set<String> expired = new HashSet<>(); // iterate over the files and work out which have expired for (String filename : sessionFileMap.values()) { try { long expiry = getExpiryFromFilename(filename); if (expiry > 0 && expiry < now) { expired.add(getIdFromFilename(filename)); } } catch (Exception e) { log.warn(e.getMessage(), e); } } // check candidates that were not found to be expired, perhaps // because they no longer exist and they should be expired for (String c : candidates) { if (!expired.contains(c)) { // if it doesn't have a file then the session doesn't exist String filename = sessionFileMap.get(c); if (filename == null) { expired.add(c); } } } // Infrequently iterate over all files in the store, and delete those // that expired a long time ago. // If the graceperiod is disabled, don't do the sweep! if (gracePeriodSec > 0 && (lastSweepTime == 0L || ((now - lastSweepTime) >= (5 * TimeUnit.SECONDS.toMillis(gracePeriodSec))))) { lastSweepTime = now; sweepDisk(); } return expired; }
[ "@", "Override", "public", "Set", "<", "String", ">", "doGetExpired", "(", "final", "Set", "<", "String", ">", "candidates", ")", "{", "final", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "Set", "<", "String", ">", "expired", "=", "new", "HashSet", "<>", "(", ")", ";", "// iterate over the files and work out which have expired\r", "for", "(", "String", "filename", ":", "sessionFileMap", ".", "values", "(", ")", ")", "{", "try", "{", "long", "expiry", "=", "getExpiryFromFilename", "(", "filename", ")", ";", "if", "(", "expiry", ">", "0", "&&", "expiry", "<", "now", ")", "{", "expired", ".", "add", "(", "getIdFromFilename", "(", "filename", ")", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "warn", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}", "// check candidates that were not found to be expired, perhaps\r", "// because they no longer exist and they should be expired\r", "for", "(", "String", "c", ":", "candidates", ")", "{", "if", "(", "!", "expired", ".", "contains", "(", "c", ")", ")", "{", "// if it doesn't have a file then the session doesn't exist\r", "String", "filename", "=", "sessionFileMap", ".", "get", "(", "c", ")", ";", "if", "(", "filename", "==", "null", ")", "{", "expired", ".", "add", "(", "c", ")", ";", "}", "}", "}", "// Infrequently iterate over all files in the store, and delete those\r", "// that expired a long time ago.\r", "// If the graceperiod is disabled, don't do the sweep!\r", "if", "(", "gracePeriodSec", ">", "0", "&&", "(", "lastSweepTime", "==", "0L", "||", "(", "(", "now", "-", "lastSweepTime", ")", ">=", "(", "5", "*", "TimeUnit", ".", "SECONDS", ".", "toMillis", "(", "gracePeriodSec", ")", ")", ")", ")", ")", "{", "lastSweepTime", "=", "now", ";", "sweepDisk", "(", ")", ";", "}", "return", "expired", ";", "}" ]
Check to see which sessions have expired. @param candidates the set of session ids that the SessionCache believes have expired @return the complete set of sessions that have expired, including those that are not currently loaded into the SessionCache
[ "Check", "to", "see", "which", "sessions", "have", "expired", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java#L117-L156
142,738
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java
FileSessionDataStore.getIdFromFilename
private String getIdFromFilename(String filename) { if (!StringUtils.hasText(filename) || filename.indexOf('_') < 0) { return null; } return filename.substring(0, filename.lastIndexOf('_')); }
java
private String getIdFromFilename(String filename) { if (!StringUtils.hasText(filename) || filename.indexOf('_') < 0) { return null; } return filename.substring(0, filename.lastIndexOf('_')); }
[ "private", "String", "getIdFromFilename", "(", "String", "filename", ")", "{", "if", "(", "!", "StringUtils", ".", "hasText", "(", "filename", ")", "||", "filename", ".", "indexOf", "(", "'", "'", ")", "<", "0", ")", "{", "return", "null", ";", "}", "return", "filename", ".", "substring", "(", "0", ",", "filename", ".", "lastIndexOf", "(", "'", "'", ")", ")", ";", "}" ]
Extract the session id from the filename. @param filename the name of the file to use @return the session id
[ "Extract", "the", "session", "id", "from", "the", "filename", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java#L257-L262
142,739
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java
FileSessionDataStore.isSessionFilename
private boolean isSessionFilename(String filename) { if (!StringUtils.hasText(filename)) { return false; } String[] parts = filename.split("_"); // Need at least 2 parts for a valid filename return (parts.length >= 2); }
java
private boolean isSessionFilename(String filename) { if (!StringUtils.hasText(filename)) { return false; } String[] parts = filename.split("_"); // Need at least 2 parts for a valid filename return (parts.length >= 2); }
[ "private", "boolean", "isSessionFilename", "(", "String", "filename", ")", "{", "if", "(", "!", "StringUtils", ".", "hasText", "(", "filename", ")", ")", "{", "return", "false", ";", "}", "String", "[", "]", "parts", "=", "filename", ".", "split", "(", "\"_\"", ")", ";", "// Need at least 2 parts for a valid filename\r", "return", "(", "parts", ".", "length", ">=", "2", ")", ";", "}" ]
Check if the filename matches our session pattern. @param filename the name of the file to checks @return true if pattern matches
[ "Check", "if", "the", "filename", "matches", "our", "session", "pattern", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java#L270-L277
142,740
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java
FileSessionDataStore.sweepFile
public void sweepFile(long now, Path p) throws Exception { if (p == null) { return; } long expiry = getExpiryFromFilename(p.getFileName().toString()); // files with 0 expiry never expire if (expiry > 0 && ((now - expiry) >= (5 * TimeUnit.SECONDS.toMillis(gracePeriodSec)))) { Files.deleteIfExists(p); if (log.isDebugEnabled()) { log.debug("Sweep deleted " + p.getFileName()); } } }
java
public void sweepFile(long now, Path p) throws Exception { if (p == null) { return; } long expiry = getExpiryFromFilename(p.getFileName().toString()); // files with 0 expiry never expire if (expiry > 0 && ((now - expiry) >= (5 * TimeUnit.SECONDS.toMillis(gracePeriodSec)))) { Files.deleteIfExists(p); if (log.isDebugEnabled()) { log.debug("Sweep deleted " + p.getFileName()); } } }
[ "public", "void", "sweepFile", "(", "long", "now", ",", "Path", "p", ")", "throws", "Exception", "{", "if", "(", "p", "==", "null", ")", "{", "return", ";", "}", "long", "expiry", "=", "getExpiryFromFilename", "(", "p", ".", "getFileName", "(", ")", ".", "toString", "(", ")", ")", ";", "// files with 0 expiry never expire\r", "if", "(", "expiry", ">", "0", "&&", "(", "(", "now", "-", "expiry", ")", ">=", "(", "5", "*", "TimeUnit", ".", "SECONDS", ".", "toMillis", "(", "gracePeriodSec", ")", ")", ")", ")", "{", "Files", ".", "deleteIfExists", "(", "p", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Sweep deleted \"", "+", "p", ".", "getFileName", "(", ")", ")", ";", "}", "}", "}" ]
Check to see if the expiry on the file is very old, and delete the file if so. "Old" means that it expired at least 5 gracePeriods ago. @param now the time now in msec @param p the file to check @throws Exception indicating error in sweep
[ "Check", "to", "see", "if", "the", "expiry", "on", "the", "file", "is", "very", "old", "and", "delete", "the", "file", "if", "so", ".", "Old", "means", "that", "it", "expired", "at", "least", "5", "gracePeriods", "ago", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java#L315-L327
142,741
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java
FileSessionDataStore.save
private void save(OutputStream os, String id, SessionData data) throws IOException { DataOutputStream out = new DataOutputStream(os); out.writeUTF(id); out.writeLong(data.getCreationTime()); out.writeLong(data.getAccessedTime()); out.writeLong(data.getLastAccessedTime()); out.writeLong(data.getExpiryTime()); out.writeLong(data.getMaxInactiveInterval()); List<String> keys = new ArrayList<>(data.getKeys()); out.writeInt(keys.size()); ObjectOutputStream oos = new ObjectOutputStream(out); for (String name : keys) { oos.writeUTF(name); oos.writeObject(data.getAttribute(name)); } }
java
private void save(OutputStream os, String id, SessionData data) throws IOException { DataOutputStream out = new DataOutputStream(os); out.writeUTF(id); out.writeLong(data.getCreationTime()); out.writeLong(data.getAccessedTime()); out.writeLong(data.getLastAccessedTime()); out.writeLong(data.getExpiryTime()); out.writeLong(data.getMaxInactiveInterval()); List<String> keys = new ArrayList<>(data.getKeys()); out.writeInt(keys.size()); ObjectOutputStream oos = new ObjectOutputStream(out); for (String name : keys) { oos.writeUTF(name); oos.writeObject(data.getAttribute(name)); } }
[ "private", "void", "save", "(", "OutputStream", "os", ",", "String", "id", ",", "SessionData", "data", ")", "throws", "IOException", "{", "DataOutputStream", "out", "=", "new", "DataOutputStream", "(", "os", ")", ";", "out", ".", "writeUTF", "(", "id", ")", ";", "out", ".", "writeLong", "(", "data", ".", "getCreationTime", "(", ")", ")", ";", "out", ".", "writeLong", "(", "data", ".", "getAccessedTime", "(", ")", ")", ";", "out", ".", "writeLong", "(", "data", ".", "getLastAccessedTime", "(", ")", ")", ";", "out", ".", "writeLong", "(", "data", ".", "getExpiryTime", "(", ")", ")", ";", "out", ".", "writeLong", "(", "data", ".", "getMaxInactiveInterval", "(", ")", ")", ";", "List", "<", "String", ">", "keys", "=", "new", "ArrayList", "<>", "(", "data", ".", "getKeys", "(", ")", ")", ";", "out", ".", "writeInt", "(", "keys", ".", "size", "(", ")", ")", ";", "ObjectOutputStream", "oos", "=", "new", "ObjectOutputStream", "(", "out", ")", ";", "for", "(", "String", "name", ":", "keys", ")", "{", "oos", ".", "writeUTF", "(", "name", ")", ";", "oos", ".", "writeObject", "(", "data", ".", "getAttribute", "(", "name", ")", ")", ";", "}", "}" ]
Save the session data. @param os the output stream to save to @param id identity of the session @param data the info of the session @throws IOException if an I/O error has occurred
[ "Save", "the", "session", "data", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java#L337-L353
142,742
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java
FileSessionDataStore.load
private SessionData load(InputStream is, String expectedId) throws Exception { try { DataInputStream di = new DataInputStream(is); String id = di.readUTF(); // the actual id from inside the file long created = di.readLong(); long accessed = di.readLong(); long lastAccessed = di.readLong(); long expiry = di.readLong(); long maxIdle = di.readLong(); SessionData data = newSessionData(id, created, accessed, lastAccessed, maxIdle); data.setExpiryTime(expiry); data.setMaxInactiveInterval(maxIdle); // Attributes restoreAttributes(di, di.readInt(), data); return data; } catch (Exception e) { throw new UnreadableSessionDataException(expectedId, e); } }
java
private SessionData load(InputStream is, String expectedId) throws Exception { try { DataInputStream di = new DataInputStream(is); String id = di.readUTF(); // the actual id from inside the file long created = di.readLong(); long accessed = di.readLong(); long lastAccessed = di.readLong(); long expiry = di.readLong(); long maxIdle = di.readLong(); SessionData data = newSessionData(id, created, accessed, lastAccessed, maxIdle); data.setExpiryTime(expiry); data.setMaxInactiveInterval(maxIdle); // Attributes restoreAttributes(di, di.readInt(), data); return data; } catch (Exception e) { throw new UnreadableSessionDataException(expectedId, e); } }
[ "private", "SessionData", "load", "(", "InputStream", "is", ",", "String", "expectedId", ")", "throws", "Exception", "{", "try", "{", "DataInputStream", "di", "=", "new", "DataInputStream", "(", "is", ")", ";", "String", "id", "=", "di", ".", "readUTF", "(", ")", ";", "// the actual id from inside the file\r", "long", "created", "=", "di", ".", "readLong", "(", ")", ";", "long", "accessed", "=", "di", ".", "readLong", "(", ")", ";", "long", "lastAccessed", "=", "di", ".", "readLong", "(", ")", ";", "long", "expiry", "=", "di", ".", "readLong", "(", ")", ";", "long", "maxIdle", "=", "di", ".", "readLong", "(", ")", ";", "SessionData", "data", "=", "newSessionData", "(", "id", ",", "created", ",", "accessed", ",", "lastAccessed", ",", "maxIdle", ")", ";", "data", ".", "setExpiryTime", "(", "expiry", ")", ";", "data", ".", "setMaxInactiveInterval", "(", "maxIdle", ")", ";", "// Attributes\r", "restoreAttributes", "(", "di", ",", "di", ".", "readInt", "(", ")", ",", "data", ")", ";", "return", "data", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "UnreadableSessionDataException", "(", "expectedId", ",", "e", ")", ";", "}", "}" ]
Load session data from an input stream that contains session data. @param is the input stream containing session data @param expectedId the id we've been told to load @return the session data @throws Exception if the session data could not be read from the file
[ "Load", "session", "data", "from", "an", "input", "stream", "that", "contains", "session", "data", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java#L363-L384
142,743
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java
FileSessionDataStore.restoreAttributes
private void restoreAttributes(InputStream is, int size, SessionData data) throws Exception { if (size > 0) { // input stream should not be closed here Map<String, Object> attributes = new HashMap<>(); ObjectInputStream ois = new CustomObjectInputStream(is); for (int i = 0; i < size; i++) { String key = ois.readUTF(); Object value = ois.readObject(); attributes.put(key, value); } data.putAllAttributes(attributes); } }
java
private void restoreAttributes(InputStream is, int size, SessionData data) throws Exception { if (size > 0) { // input stream should not be closed here Map<String, Object> attributes = new HashMap<>(); ObjectInputStream ois = new CustomObjectInputStream(is); for (int i = 0; i < size; i++) { String key = ois.readUTF(); Object value = ois.readObject(); attributes.put(key, value); } data.putAllAttributes(attributes); } }
[ "private", "void", "restoreAttributes", "(", "InputStream", "is", ",", "int", "size", ",", "SessionData", "data", ")", "throws", "Exception", "{", "if", "(", "size", ">", "0", ")", "{", "// input stream should not be closed here\r", "Map", "<", "String", ",", "Object", ">", "attributes", "=", "new", "HashMap", "<>", "(", ")", ";", "ObjectInputStream", "ois", "=", "new", "CustomObjectInputStream", "(", "is", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "String", "key", "=", "ois", ".", "readUTF", "(", ")", ";", "Object", "value", "=", "ois", ".", "readObject", "(", ")", ";", "attributes", ".", "put", "(", "key", ",", "value", ")", ";", "}", "data", ".", "putAllAttributes", "(", "attributes", ")", ";", "}", "}" ]
Load attributes from an input stream that contains session data. @param is the input stream containing session data @param size number of attributes @param data the data to restore to @throws Exception if the input stream is invalid or fails to read
[ "Load", "attributes", "from", "an", "input", "stream", "that", "contains", "session", "data", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/FileSessionDataStore.java#L394-L406
142,744
aspectran/aspectran
web/src/main/java/com/aspectran/web/support/multipart/inmemory/MemoryMultipartFormDataParser.java
MemoryMultipartFormDataParser.parseMultipartParameters
private void parseMultipartParameters(Map<String, List<FileItem>> fileItemListMap, RequestAdapter requestAdapter) { String encoding = requestAdapter.getEncoding(); MultiValueMap<String, String> parameterMap = new LinkedMultiValueMap<>(); MultiValueMap<String, FileParameter> fileParameterMap = new LinkedMultiValueMap<>(); for (Map.Entry<String, List<FileItem>> entry : fileItemListMap.entrySet()) { String fieldName = entry.getKey(); List<FileItem> fileItemList = entry.getValue(); if (fileItemList != null && !fileItemList.isEmpty()) { for (FileItem fileItem : fileItemList) { if (fileItem.isFormField()) { String value = getString(fileItem, encoding); parameterMap.add(fieldName, value); } else { String fileName = fileItem.getName(); // Skip file uploads that don't have a file name - meaning that // no file was selected. if (StringUtils.isEmpty(fileName)) { continue; } boolean valid = FilenameUtils.isValidFileExtension(fileName, allowedFileExtensions, deniedFileExtensions); if (!valid) { continue; } MemoryMultipartFileParameter fileParameter = new MemoryMultipartFileParameter(fileItem); fileParameterMap.add(fieldName, fileParameter); if (log.isDebugEnabled()) { log.debug("Found multipart file [" + fileParameter.getFileName() + "] of size " + fileParameter.getFileSize() + " bytes, stored " + fileParameter.getStorageDescription()); } } } } } if (!parameterMap.isEmpty()) { for (Map.Entry<String, List<String>> entry : parameterMap.entrySet()) { String name = entry.getKey(); List<String> list = entry.getValue(); String[] values = list.toArray(new String[0]); requestAdapter.setParameter(name, values); } } if (!fileParameterMap.isEmpty()) { for (Map.Entry<String, List<FileParameter>> entry : fileParameterMap.entrySet()) { String name = entry.getKey(); List<FileParameter> list = entry.getValue(); FileParameter[] values = list.toArray(new FileParameter[0]); requestAdapter.setFileParameter(name, values); } } }
java
private void parseMultipartParameters(Map<String, List<FileItem>> fileItemListMap, RequestAdapter requestAdapter) { String encoding = requestAdapter.getEncoding(); MultiValueMap<String, String> parameterMap = new LinkedMultiValueMap<>(); MultiValueMap<String, FileParameter> fileParameterMap = new LinkedMultiValueMap<>(); for (Map.Entry<String, List<FileItem>> entry : fileItemListMap.entrySet()) { String fieldName = entry.getKey(); List<FileItem> fileItemList = entry.getValue(); if (fileItemList != null && !fileItemList.isEmpty()) { for (FileItem fileItem : fileItemList) { if (fileItem.isFormField()) { String value = getString(fileItem, encoding); parameterMap.add(fieldName, value); } else { String fileName = fileItem.getName(); // Skip file uploads that don't have a file name - meaning that // no file was selected. if (StringUtils.isEmpty(fileName)) { continue; } boolean valid = FilenameUtils.isValidFileExtension(fileName, allowedFileExtensions, deniedFileExtensions); if (!valid) { continue; } MemoryMultipartFileParameter fileParameter = new MemoryMultipartFileParameter(fileItem); fileParameterMap.add(fieldName, fileParameter); if (log.isDebugEnabled()) { log.debug("Found multipart file [" + fileParameter.getFileName() + "] of size " + fileParameter.getFileSize() + " bytes, stored " + fileParameter.getStorageDescription()); } } } } } if (!parameterMap.isEmpty()) { for (Map.Entry<String, List<String>> entry : parameterMap.entrySet()) { String name = entry.getKey(); List<String> list = entry.getValue(); String[] values = list.toArray(new String[0]); requestAdapter.setParameter(name, values); } } if (!fileParameterMap.isEmpty()) { for (Map.Entry<String, List<FileParameter>> entry : fileParameterMap.entrySet()) { String name = entry.getKey(); List<FileParameter> list = entry.getValue(); FileParameter[] values = list.toArray(new FileParameter[0]); requestAdapter.setFileParameter(name, values); } } }
[ "private", "void", "parseMultipartParameters", "(", "Map", "<", "String", ",", "List", "<", "FileItem", ">", ">", "fileItemListMap", ",", "RequestAdapter", "requestAdapter", ")", "{", "String", "encoding", "=", "requestAdapter", ".", "getEncoding", "(", ")", ";", "MultiValueMap", "<", "String", ",", "String", ">", "parameterMap", "=", "new", "LinkedMultiValueMap", "<>", "(", ")", ";", "MultiValueMap", "<", "String", ",", "FileParameter", ">", "fileParameterMap", "=", "new", "LinkedMultiValueMap", "<>", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "List", "<", "FileItem", ">", ">", "entry", ":", "fileItemListMap", ".", "entrySet", "(", ")", ")", "{", "String", "fieldName", "=", "entry", ".", "getKey", "(", ")", ";", "List", "<", "FileItem", ">", "fileItemList", "=", "entry", ".", "getValue", "(", ")", ";", "if", "(", "fileItemList", "!=", "null", "&&", "!", "fileItemList", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "FileItem", "fileItem", ":", "fileItemList", ")", "{", "if", "(", "fileItem", ".", "isFormField", "(", ")", ")", "{", "String", "value", "=", "getString", "(", "fileItem", ",", "encoding", ")", ";", "parameterMap", ".", "add", "(", "fieldName", ",", "value", ")", ";", "}", "else", "{", "String", "fileName", "=", "fileItem", ".", "getName", "(", ")", ";", "// Skip file uploads that don't have a file name - meaning that", "// no file was selected.", "if", "(", "StringUtils", ".", "isEmpty", "(", "fileName", ")", ")", "{", "continue", ";", "}", "boolean", "valid", "=", "FilenameUtils", ".", "isValidFileExtension", "(", "fileName", ",", "allowedFileExtensions", ",", "deniedFileExtensions", ")", ";", "if", "(", "!", "valid", ")", "{", "continue", ";", "}", "MemoryMultipartFileParameter", "fileParameter", "=", "new", "MemoryMultipartFileParameter", "(", "fileItem", ")", ";", "fileParameterMap", ".", "add", "(", "fieldName", ",", "fileParameter", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Found multipart file [\"", "+", "fileParameter", ".", "getFileName", "(", ")", "+", "\"] of size \"", "+", "fileParameter", ".", "getFileSize", "(", ")", "+", "\" bytes, stored \"", "+", "fileParameter", ".", "getStorageDescription", "(", ")", ")", ";", "}", "}", "}", "}", "}", "if", "(", "!", "parameterMap", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "List", "<", "String", ">", ">", "entry", ":", "parameterMap", ".", "entrySet", "(", ")", ")", "{", "String", "name", "=", "entry", ".", "getKey", "(", ")", ";", "List", "<", "String", ">", "list", "=", "entry", ".", "getValue", "(", ")", ";", "String", "[", "]", "values", "=", "list", ".", "toArray", "(", "new", "String", "[", "0", "]", ")", ";", "requestAdapter", ".", "setParameter", "(", "name", ",", "values", ")", ";", "}", "}", "if", "(", "!", "fileParameterMap", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "List", "<", "FileParameter", ">", ">", "entry", ":", "fileParameterMap", ".", "entrySet", "(", ")", ")", "{", "String", "name", "=", "entry", ".", "getKey", "(", ")", ";", "List", "<", "FileParameter", ">", "list", "=", "entry", ".", "getValue", "(", ")", ";", "FileParameter", "[", "]", "values", "=", "list", ".", "toArray", "(", "new", "FileParameter", "[", "0", "]", ")", ";", "requestAdapter", ".", "setFileParameter", "(", "name", ",", "values", ")", ";", "}", "}", "}" ]
Parse form fields and file items. @param fileItemListMap the file item list map @param requestAdapter the request adapter
[ "Parse", "form", "fields", "and", "file", "items", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/web/src/main/java/com/aspectran/web/support/multipart/inmemory/MemoryMultipartFormDataParser.java#L151-L208
142,745
aspectran/aspectran
with-freemarker/src/main/java/com/aspectran/freemarker/FreeMarkerConfigurationFactory.java
FreeMarkerConfigurationFactory.createConfiguration
public Configuration createConfiguration() throws IOException, TemplateException { Configuration config = newConfiguration(); Properties props = new Properties(); // Merge local properties if specified. if (this.freemarkerSettings != null) { props.putAll(this.freemarkerSettings); } // FreeMarker will only accept known keys in its setSettings and // setAllSharedVariables methods. if (!props.isEmpty()) { config.setSettings(props); } if (this.freemarkerVariables != null && freemarkerVariables.size() > 0) { config.setAllSharedVariables(new SimpleHash(this.freemarkerVariables, config.getObjectWrapper())); } if (this.defaultEncoding != null) { config.setDefaultEncoding(this.defaultEncoding); } // determine FreeMarker TemplateLoader if (templateLoaders == null) { if (templateLoaderPaths != null && templateLoaderPaths.length > 0) { List<TemplateLoader> templateLoaderList = new ArrayList<>(); for (String path : templateLoaderPaths) { templateLoaderList.add(getTemplateLoaderForPath(path)); } setTemplateLoader(templateLoaderList); } } TemplateLoader templateLoader = getAggregateTemplateLoader(templateLoaders); if (templateLoader != null) { config.setTemplateLoader(templateLoader); } // determine CustomTrimDirectives if (trimDirectives != null && trimDirectives.length > 0) { TrimDirectiveGroup group = new TrimDirectiveGroup(trimDirectives); for (Map.Entry<String, Map<String, TrimDirective>> directives : group.entrySet()) { config.setSharedVariable(directives.getKey(), directives.getValue()); } } return config; }
java
public Configuration createConfiguration() throws IOException, TemplateException { Configuration config = newConfiguration(); Properties props = new Properties(); // Merge local properties if specified. if (this.freemarkerSettings != null) { props.putAll(this.freemarkerSettings); } // FreeMarker will only accept known keys in its setSettings and // setAllSharedVariables methods. if (!props.isEmpty()) { config.setSettings(props); } if (this.freemarkerVariables != null && freemarkerVariables.size() > 0) { config.setAllSharedVariables(new SimpleHash(this.freemarkerVariables, config.getObjectWrapper())); } if (this.defaultEncoding != null) { config.setDefaultEncoding(this.defaultEncoding); } // determine FreeMarker TemplateLoader if (templateLoaders == null) { if (templateLoaderPaths != null && templateLoaderPaths.length > 0) { List<TemplateLoader> templateLoaderList = new ArrayList<>(); for (String path : templateLoaderPaths) { templateLoaderList.add(getTemplateLoaderForPath(path)); } setTemplateLoader(templateLoaderList); } } TemplateLoader templateLoader = getAggregateTemplateLoader(templateLoaders); if (templateLoader != null) { config.setTemplateLoader(templateLoader); } // determine CustomTrimDirectives if (trimDirectives != null && trimDirectives.length > 0) { TrimDirectiveGroup group = new TrimDirectiveGroup(trimDirectives); for (Map.Entry<String, Map<String, TrimDirective>> directives : group.entrySet()) { config.setSharedVariable(directives.getKey(), directives.getValue()); } } return config; }
[ "public", "Configuration", "createConfiguration", "(", ")", "throws", "IOException", ",", "TemplateException", "{", "Configuration", "config", "=", "newConfiguration", "(", ")", ";", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "// Merge local properties if specified.", "if", "(", "this", ".", "freemarkerSettings", "!=", "null", ")", "{", "props", ".", "putAll", "(", "this", ".", "freemarkerSettings", ")", ";", "}", "// FreeMarker will only accept known keys in its setSettings and", "// setAllSharedVariables methods.", "if", "(", "!", "props", ".", "isEmpty", "(", ")", ")", "{", "config", ".", "setSettings", "(", "props", ")", ";", "}", "if", "(", "this", ".", "freemarkerVariables", "!=", "null", "&&", "freemarkerVariables", ".", "size", "(", ")", ">", "0", ")", "{", "config", ".", "setAllSharedVariables", "(", "new", "SimpleHash", "(", "this", ".", "freemarkerVariables", ",", "config", ".", "getObjectWrapper", "(", ")", ")", ")", ";", "}", "if", "(", "this", ".", "defaultEncoding", "!=", "null", ")", "{", "config", ".", "setDefaultEncoding", "(", "this", ".", "defaultEncoding", ")", ";", "}", "// determine FreeMarker TemplateLoader", "if", "(", "templateLoaders", "==", "null", ")", "{", "if", "(", "templateLoaderPaths", "!=", "null", "&&", "templateLoaderPaths", ".", "length", ">", "0", ")", "{", "List", "<", "TemplateLoader", ">", "templateLoaderList", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "path", ":", "templateLoaderPaths", ")", "{", "templateLoaderList", ".", "add", "(", "getTemplateLoaderForPath", "(", "path", ")", ")", ";", "}", "setTemplateLoader", "(", "templateLoaderList", ")", ";", "}", "}", "TemplateLoader", "templateLoader", "=", "getAggregateTemplateLoader", "(", "templateLoaders", ")", ";", "if", "(", "templateLoader", "!=", "null", ")", "{", "config", ".", "setTemplateLoader", "(", "templateLoader", ")", ";", "}", "// determine CustomTrimDirectives", "if", "(", "trimDirectives", "!=", "null", "&&", "trimDirectives", ".", "length", ">", "0", ")", "{", "TrimDirectiveGroup", "group", "=", "new", "TrimDirectiveGroup", "(", "trimDirectives", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Map", "<", "String", ",", "TrimDirective", ">", ">", "directives", ":", "group", ".", "entrySet", "(", ")", ")", "{", "config", ".", "setSharedVariable", "(", "directives", ".", "getKey", "(", ")", ",", "directives", ".", "getValue", "(", ")", ")", ";", "}", "}", "return", "config", ";", "}" ]
Prepare the FreeMarker Configuration and return it. @return the FreeMarker Configuration object @throws IOException if the config file wasn't found @throws TemplateException on FreeMarker initialization failure
[ "Prepare", "the", "FreeMarker", "Configuration", "and", "return", "it", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/with-freemarker/src/main/java/com/aspectran/freemarker/FreeMarkerConfigurationFactory.java#L219-L267
142,746
aspectran/aspectran
with-freemarker/src/main/java/com/aspectran/freemarker/FreeMarkerConfigurationFactory.java
FreeMarkerConfigurationFactory.getAggregateTemplateLoader
protected TemplateLoader getAggregateTemplateLoader(TemplateLoader[] templateLoaders) { int loaderCount = (templateLoaders != null ? templateLoaders.length : 0); switch (loaderCount) { case 0: if (log.isDebugEnabled()) { log.debug("No FreeMarker TemplateLoaders specified; Can be used only inner template source"); } return null; case 1: if (log.isDebugEnabled()) { log.debug("One FreeMarker TemplateLoader registered: " + templateLoaders[0]); } return templateLoaders[0]; default: TemplateLoader loader = new MultiTemplateLoader(templateLoaders); if (log.isDebugEnabled()) { log.debug("Multiple FreeMarker TemplateLoader registered: " + loader); } return loader; } }
java
protected TemplateLoader getAggregateTemplateLoader(TemplateLoader[] templateLoaders) { int loaderCount = (templateLoaders != null ? templateLoaders.length : 0); switch (loaderCount) { case 0: if (log.isDebugEnabled()) { log.debug("No FreeMarker TemplateLoaders specified; Can be used only inner template source"); } return null; case 1: if (log.isDebugEnabled()) { log.debug("One FreeMarker TemplateLoader registered: " + templateLoaders[0]); } return templateLoaders[0]; default: TemplateLoader loader = new MultiTemplateLoader(templateLoaders); if (log.isDebugEnabled()) { log.debug("Multiple FreeMarker TemplateLoader registered: " + loader); } return loader; } }
[ "protected", "TemplateLoader", "getAggregateTemplateLoader", "(", "TemplateLoader", "[", "]", "templateLoaders", ")", "{", "int", "loaderCount", "=", "(", "templateLoaders", "!=", "null", "?", "templateLoaders", ".", "length", ":", "0", ")", ";", "switch", "(", "loaderCount", ")", "{", "case", "0", ":", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"No FreeMarker TemplateLoaders specified; Can be used only inner template source\"", ")", ";", "}", "return", "null", ";", "case", "1", ":", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"One FreeMarker TemplateLoader registered: \"", "+", "templateLoaders", "[", "0", "]", ")", ";", "}", "return", "templateLoaders", "[", "0", "]", ";", "default", ":", "TemplateLoader", "loader", "=", "new", "MultiTemplateLoader", "(", "templateLoaders", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Multiple FreeMarker TemplateLoader registered: \"", "+", "loader", ")", ";", "}", "return", "loader", ";", "}", "}" ]
Return a TemplateLoader based on the given TemplateLoader list. If more than one TemplateLoader has been registered, a FreeMarker MultiTemplateLoader needs to be created. @param templateLoaders the final List of TemplateLoader instances @return the aggregate TemplateLoader
[ "Return", "a", "TemplateLoader", "based", "on", "the", "given", "TemplateLoader", "list", ".", "If", "more", "than", "one", "TemplateLoader", "has", "been", "registered", "a", "FreeMarker", "MultiTemplateLoader", "needs", "to", "be", "created", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/with-freemarker/src/main/java/com/aspectran/freemarker/FreeMarkerConfigurationFactory.java#L289-L309
142,747
aspectran/aspectran
with-freemarker/src/main/java/com/aspectran/freemarker/FreeMarkerConfigurationFactory.java
FreeMarkerConfigurationFactory.getTemplateLoaderForPath
protected TemplateLoader getTemplateLoaderForPath(String templateLoaderPath) throws IOException { if (templateLoaderPath.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) { String basePackagePath = templateLoaderPath.substring(ResourceUtils.CLASSPATH_URL_PREFIX.length()); if (log.isDebugEnabled()) { log.debug("Template loader path [" + templateLoaderPath + "] resolved to class path [" + basePackagePath + "]"); } return new ClassTemplateLoader(environment.getClassLoader(), basePackagePath); } else if (templateLoaderPath.startsWith(ResourceUtils.FILE_URL_PREFIX)) { File file = new File(templateLoaderPath.substring(ResourceUtils.FILE_URL_PREFIX.length())); if (log.isDebugEnabled()) { log.debug("Template loader path [" + templateLoaderPath + "] resolved to file path [" + file.getAbsolutePath() + "]"); } return new FileTemplateLoader(file); } else { File file = new File(environment.getBasePath(), templateLoaderPath); if (log.isDebugEnabled()) { log.debug("Template loader path [" + templateLoaderPath + "] resolved to file path [" + file.getAbsolutePath() + "]"); } return new FileTemplateLoader(file); } }
java
protected TemplateLoader getTemplateLoaderForPath(String templateLoaderPath) throws IOException { if (templateLoaderPath.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) { String basePackagePath = templateLoaderPath.substring(ResourceUtils.CLASSPATH_URL_PREFIX.length()); if (log.isDebugEnabled()) { log.debug("Template loader path [" + templateLoaderPath + "] resolved to class path [" + basePackagePath + "]"); } return new ClassTemplateLoader(environment.getClassLoader(), basePackagePath); } else if (templateLoaderPath.startsWith(ResourceUtils.FILE_URL_PREFIX)) { File file = new File(templateLoaderPath.substring(ResourceUtils.FILE_URL_PREFIX.length())); if (log.isDebugEnabled()) { log.debug("Template loader path [" + templateLoaderPath + "] resolved to file path [" + file.getAbsolutePath() + "]"); } return new FileTemplateLoader(file); } else { File file = new File(environment.getBasePath(), templateLoaderPath); if (log.isDebugEnabled()) { log.debug("Template loader path [" + templateLoaderPath + "] resolved to file path [" + file.getAbsolutePath() + "]"); } return new FileTemplateLoader(file); } }
[ "protected", "TemplateLoader", "getTemplateLoaderForPath", "(", "String", "templateLoaderPath", ")", "throws", "IOException", "{", "if", "(", "templateLoaderPath", ".", "startsWith", "(", "ResourceUtils", ".", "CLASSPATH_URL_PREFIX", ")", ")", "{", "String", "basePackagePath", "=", "templateLoaderPath", ".", "substring", "(", "ResourceUtils", ".", "CLASSPATH_URL_PREFIX", ".", "length", "(", ")", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Template loader path [\"", "+", "templateLoaderPath", "+", "\"] resolved to class path [\"", "+", "basePackagePath", "+", "\"]\"", ")", ";", "}", "return", "new", "ClassTemplateLoader", "(", "environment", ".", "getClassLoader", "(", ")", ",", "basePackagePath", ")", ";", "}", "else", "if", "(", "templateLoaderPath", ".", "startsWith", "(", "ResourceUtils", ".", "FILE_URL_PREFIX", ")", ")", "{", "File", "file", "=", "new", "File", "(", "templateLoaderPath", ".", "substring", "(", "ResourceUtils", ".", "FILE_URL_PREFIX", ".", "length", "(", ")", ")", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Template loader path [\"", "+", "templateLoaderPath", "+", "\"] resolved to file path [\"", "+", "file", ".", "getAbsolutePath", "(", ")", "+", "\"]\"", ")", ";", "}", "return", "new", "FileTemplateLoader", "(", "file", ")", ";", "}", "else", "{", "File", "file", "=", "new", "File", "(", "environment", ".", "getBasePath", "(", ")", ",", "templateLoaderPath", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Template loader path [\"", "+", "templateLoaderPath", "+", "\"] resolved to file path [\"", "+", "file", ".", "getAbsolutePath", "(", ")", "+", "\"]\"", ")", ";", "}", "return", "new", "FileTemplateLoader", "(", "file", ")", ";", "}", "}" ]
Determine a FreeMarker TemplateLoader for the given path. @param templateLoaderPath the path to load templates from @return an appropriate TemplateLoader @throws IOException if an I/O error has occurred @see freemarker.cache.FileTemplateLoader
[ "Determine", "a", "FreeMarker", "TemplateLoader", "for", "the", "given", "path", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/with-freemarker/src/main/java/com/aspectran/freemarker/FreeMarkerConfigurationFactory.java#L319-L342
142,748
aspectran/aspectran
shell/src/main/java/com/aspectran/shell/command/option/Options.java
Options.addOption
public Options addOption(Option opt) { String key = opt.getKey(); // add it to the long option list if (opt.hasLongName()) { longOpts.put(opt.getLongName(), opt); } // if the option is required add it to the required list if (opt.isRequired()) { if (requiredOpts.contains(key)) { requiredOpts.remove(requiredOpts.indexOf(key)); } requiredOpts.add(key); } shortOpts.put(key, opt); return this; }
java
public Options addOption(Option opt) { String key = opt.getKey(); // add it to the long option list if (opt.hasLongName()) { longOpts.put(opt.getLongName(), opt); } // if the option is required add it to the required list if (opt.isRequired()) { if (requiredOpts.contains(key)) { requiredOpts.remove(requiredOpts.indexOf(key)); } requiredOpts.add(key); } shortOpts.put(key, opt); return this; }
[ "public", "Options", "addOption", "(", "Option", "opt", ")", "{", "String", "key", "=", "opt", ".", "getKey", "(", ")", ";", "// add it to the long option list", "if", "(", "opt", ".", "hasLongName", "(", ")", ")", "{", "longOpts", ".", "put", "(", "opt", ".", "getLongName", "(", ")", ",", "opt", ")", ";", "}", "// if the option is required add it to the required list", "if", "(", "opt", ".", "isRequired", "(", ")", ")", "{", "if", "(", "requiredOpts", ".", "contains", "(", "key", ")", ")", "{", "requiredOpts", ".", "remove", "(", "requiredOpts", ".", "indexOf", "(", "key", ")", ")", ";", "}", "requiredOpts", ".", "add", "(", "key", ")", ";", "}", "shortOpts", ".", "put", "(", "key", ",", "opt", ")", ";", "return", "this", ";", "}" ]
Adds an option instance. @param opt the option that is to be added @return the resulting Options instance
[ "Adds", "an", "option", "instance", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/shell/src/main/java/com/aspectran/shell/command/option/Options.java#L120-L138
142,749
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/HeaderActionRule.java
HeaderActionRule.newHeaderItemRule
public ItemRule newHeaderItemRule(String headerName) { ItemRule itemRule = new ItemRule(); itemRule.setName(headerName); addHeaderItemRule(itemRule); return itemRule; }
java
public ItemRule newHeaderItemRule(String headerName) { ItemRule itemRule = new ItemRule(); itemRule.setName(headerName); addHeaderItemRule(itemRule); return itemRule; }
[ "public", "ItemRule", "newHeaderItemRule", "(", "String", "headerName", ")", "{", "ItemRule", "itemRule", "=", "new", "ItemRule", "(", ")", ";", "itemRule", ".", "setName", "(", "headerName", ")", ";", "addHeaderItemRule", "(", "itemRule", ")", ";", "return", "itemRule", ";", "}" ]
Adds a new header rule with the specified name and returns it. @param headerName the header name @return the header item rule
[ "Adds", "a", "new", "header", "rule", "with", "the", "specified", "name", "and", "returns", "it", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/HeaderActionRule.java#L78-L83
142,750
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/HeaderActionRule.java
HeaderActionRule.addHeaderItemRule
public void addHeaderItemRule(ItemRule headerItemRule) { if (headerItemRuleMap == null) { headerItemRuleMap = new ItemRuleMap(); } headerItemRuleMap.putItemRule(headerItemRule); }
java
public void addHeaderItemRule(ItemRule headerItemRule) { if (headerItemRuleMap == null) { headerItemRuleMap = new ItemRuleMap(); } headerItemRuleMap.putItemRule(headerItemRule); }
[ "public", "void", "addHeaderItemRule", "(", "ItemRule", "headerItemRule", ")", "{", "if", "(", "headerItemRuleMap", "==", "null", ")", "{", "headerItemRuleMap", "=", "new", "ItemRuleMap", "(", ")", ";", "}", "headerItemRuleMap", ".", "putItemRule", "(", "headerItemRule", ")", ";", "}" ]
Adds the header item rule. @param headerItemRule the header item rule
[ "Adds", "the", "header", "item", "rule", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/HeaderActionRule.java#L90-L95
142,751
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/HeaderActionRule.java
HeaderActionRule.newInstance
public static HeaderActionRule newInstance(String id, Boolean hidden) { HeaderActionRule headerActionRule = new HeaderActionRule(); headerActionRule.setActionId(id); headerActionRule.setHidden(hidden); return headerActionRule; }
java
public static HeaderActionRule newInstance(String id, Boolean hidden) { HeaderActionRule headerActionRule = new HeaderActionRule(); headerActionRule.setActionId(id); headerActionRule.setHidden(hidden); return headerActionRule; }
[ "public", "static", "HeaderActionRule", "newInstance", "(", "String", "id", ",", "Boolean", "hidden", ")", "{", "HeaderActionRule", "headerActionRule", "=", "new", "HeaderActionRule", "(", ")", ";", "headerActionRule", ".", "setActionId", "(", "id", ")", ";", "headerActionRule", ".", "setHidden", "(", "hidden", ")", ";", "return", "headerActionRule", ";", "}" ]
Returns a new derived instance of HeaderActionRule. @param id the action id @param hidden whether to hide result of the action @return the header action rule
[ "Returns", "a", "new", "derived", "instance", "of", "HeaderActionRule", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/HeaderActionRule.java#L142-L147
142,752
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/expr/TokenExpression.java
TokenExpression.getBean
protected Object getBean(Token token) { Object value; if (token.getAlternativeValue() != null) { if (token.getDirectiveType() == TokenDirectiveType.FIELD) { Field field = (Field)token.getAlternativeValue(); if (Modifier.isStatic(field.getModifiers())) { value = ReflectionUtils.getField(field, null); } else { Class<?> cls = field.getDeclaringClass(); Object target = activity.getBean(cls); value = ReflectionUtils.getField(field, target); } } else if (token.getDirectiveType() == TokenDirectiveType.METHOD) { Method method = (Method)token.getAlternativeValue(); if (Modifier.isStatic(method.getModifiers())) { value = ReflectionUtils.invokeMethod(method, null); } else { Class<?> cls = method.getDeclaringClass(); Object target = activity.getBean(cls); value = ReflectionUtils.invokeMethod(method, target); } } else { Class<?> cls = (Class<?>)token.getAlternativeValue(); try { value = activity.getBean(cls); } catch (RequiredTypeBeanNotFoundException | NoUniqueBeanException e) { if (token.getGetterName() != null) { try { value = BeanUtils.getProperty(cls, token.getGetterName()); if (value == null) { value = token.getDefaultValue(); } return value; } catch (InvocationTargetException e2) { // ignore } } throw e; } if (value != null && token.getGetterName() != null) { value = getBeanProperty(value, token.getGetterName()); } } } else { value = activity.getBean(token.getName()); if (value != null && token.getGetterName() != null) { value = getBeanProperty(value, token.getGetterName()); } } if (value == null) { value = token.getDefaultValue(); } return value; }
java
protected Object getBean(Token token) { Object value; if (token.getAlternativeValue() != null) { if (token.getDirectiveType() == TokenDirectiveType.FIELD) { Field field = (Field)token.getAlternativeValue(); if (Modifier.isStatic(field.getModifiers())) { value = ReflectionUtils.getField(field, null); } else { Class<?> cls = field.getDeclaringClass(); Object target = activity.getBean(cls); value = ReflectionUtils.getField(field, target); } } else if (token.getDirectiveType() == TokenDirectiveType.METHOD) { Method method = (Method)token.getAlternativeValue(); if (Modifier.isStatic(method.getModifiers())) { value = ReflectionUtils.invokeMethod(method, null); } else { Class<?> cls = method.getDeclaringClass(); Object target = activity.getBean(cls); value = ReflectionUtils.invokeMethod(method, target); } } else { Class<?> cls = (Class<?>)token.getAlternativeValue(); try { value = activity.getBean(cls); } catch (RequiredTypeBeanNotFoundException | NoUniqueBeanException e) { if (token.getGetterName() != null) { try { value = BeanUtils.getProperty(cls, token.getGetterName()); if (value == null) { value = token.getDefaultValue(); } return value; } catch (InvocationTargetException e2) { // ignore } } throw e; } if (value != null && token.getGetterName() != null) { value = getBeanProperty(value, token.getGetterName()); } } } else { value = activity.getBean(token.getName()); if (value != null && token.getGetterName() != null) { value = getBeanProperty(value, token.getGetterName()); } } if (value == null) { value = token.getDefaultValue(); } return value; }
[ "protected", "Object", "getBean", "(", "Token", "token", ")", "{", "Object", "value", ";", "if", "(", "token", ".", "getAlternativeValue", "(", ")", "!=", "null", ")", "{", "if", "(", "token", ".", "getDirectiveType", "(", ")", "==", "TokenDirectiveType", ".", "FIELD", ")", "{", "Field", "field", "=", "(", "Field", ")", "token", ".", "getAlternativeValue", "(", ")", ";", "if", "(", "Modifier", ".", "isStatic", "(", "field", ".", "getModifiers", "(", ")", ")", ")", "{", "value", "=", "ReflectionUtils", ".", "getField", "(", "field", ",", "null", ")", ";", "}", "else", "{", "Class", "<", "?", ">", "cls", "=", "field", ".", "getDeclaringClass", "(", ")", ";", "Object", "target", "=", "activity", ".", "getBean", "(", "cls", ")", ";", "value", "=", "ReflectionUtils", ".", "getField", "(", "field", ",", "target", ")", ";", "}", "}", "else", "if", "(", "token", ".", "getDirectiveType", "(", ")", "==", "TokenDirectiveType", ".", "METHOD", ")", "{", "Method", "method", "=", "(", "Method", ")", "token", ".", "getAlternativeValue", "(", ")", ";", "if", "(", "Modifier", ".", "isStatic", "(", "method", ".", "getModifiers", "(", ")", ")", ")", "{", "value", "=", "ReflectionUtils", ".", "invokeMethod", "(", "method", ",", "null", ")", ";", "}", "else", "{", "Class", "<", "?", ">", "cls", "=", "method", ".", "getDeclaringClass", "(", ")", ";", "Object", "target", "=", "activity", ".", "getBean", "(", "cls", ")", ";", "value", "=", "ReflectionUtils", ".", "invokeMethod", "(", "method", ",", "target", ")", ";", "}", "}", "else", "{", "Class", "<", "?", ">", "cls", "=", "(", "Class", "<", "?", ">", ")", "token", ".", "getAlternativeValue", "(", ")", ";", "try", "{", "value", "=", "activity", ".", "getBean", "(", "cls", ")", ";", "}", "catch", "(", "RequiredTypeBeanNotFoundException", "|", "NoUniqueBeanException", "e", ")", "{", "if", "(", "token", ".", "getGetterName", "(", ")", "!=", "null", ")", "{", "try", "{", "value", "=", "BeanUtils", ".", "getProperty", "(", "cls", ",", "token", ".", "getGetterName", "(", ")", ")", ";", "if", "(", "value", "==", "null", ")", "{", "value", "=", "token", ".", "getDefaultValue", "(", ")", ";", "}", "return", "value", ";", "}", "catch", "(", "InvocationTargetException", "e2", ")", "{", "// ignore", "}", "}", "throw", "e", ";", "}", "if", "(", "value", "!=", "null", "&&", "token", ".", "getGetterName", "(", ")", "!=", "null", ")", "{", "value", "=", "getBeanProperty", "(", "value", ",", "token", ".", "getGetterName", "(", ")", ")", ";", "}", "}", "}", "else", "{", "value", "=", "activity", ".", "getBean", "(", "token", ".", "getName", "(", ")", ")", ";", "if", "(", "value", "!=", "null", "&&", "token", ".", "getGetterName", "(", ")", "!=", "null", ")", "{", "value", "=", "getBeanProperty", "(", "value", ",", "token", ".", "getGetterName", "(", ")", ")", ";", "}", "}", "if", "(", "value", "==", "null", ")", "{", "value", "=", "token", ".", "getDefaultValue", "(", ")", ";", "}", "return", "value", ";", "}" ]
Returns the bean instance that matches the given token. @param token the token @return an instance of the bean
[ "Returns", "the", "bean", "instance", "that", "matches", "the", "given", "token", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/expr/TokenExpression.java#L363-L416
142,753
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/expr/TokenExpression.java
TokenExpression.getBeanProperty
protected Object getBeanProperty(final Object object, String propertyName) { Object value; try { value = BeanUtils.getProperty(object, propertyName); } catch (InvocationTargetException e) { // ignore value = null; } return value; }
java
protected Object getBeanProperty(final Object object, String propertyName) { Object value; try { value = BeanUtils.getProperty(object, propertyName); } catch (InvocationTargetException e) { // ignore value = null; } return value; }
[ "protected", "Object", "getBeanProperty", "(", "final", "Object", "object", ",", "String", "propertyName", ")", "{", "Object", "value", ";", "try", "{", "value", "=", "BeanUtils", ".", "getProperty", "(", "object", ",", "propertyName", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "// ignore", "value", "=", "null", ";", "}", "return", "value", ";", "}" ]
Invoke bean's property. @param object the object @param propertyName the property name @return the object
[ "Invoke", "bean", "s", "property", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/expr/TokenExpression.java#L425-L434
142,754
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/expr/TokenExpression.java
TokenExpression.getProperty
protected Object getProperty(Token token) throws IOException { if (token.getDirectiveType() == TokenDirectiveType.CLASSPATH) { Properties props = PropertiesLoaderUtils.loadProperties(token.getValue(), activity.getEnvironment().getClassLoader()); Object value = (token.getGetterName() != null ? props.get(token.getGetterName()) : props); return (value != null ? value : token.getDefaultValue()); } else { Object value = activity.getActivityContext().getEnvironment().getProperty(token.getName(), activity); if (value != null && token.getGetterName() != null) { value = getBeanProperty(value, token.getGetterName()); } return (value != null ? value : token.getDefaultValue()); } }
java
protected Object getProperty(Token token) throws IOException { if (token.getDirectiveType() == TokenDirectiveType.CLASSPATH) { Properties props = PropertiesLoaderUtils.loadProperties(token.getValue(), activity.getEnvironment().getClassLoader()); Object value = (token.getGetterName() != null ? props.get(token.getGetterName()) : props); return (value != null ? value : token.getDefaultValue()); } else { Object value = activity.getActivityContext().getEnvironment().getProperty(token.getName(), activity); if (value != null && token.getGetterName() != null) { value = getBeanProperty(value, token.getGetterName()); } return (value != null ? value : token.getDefaultValue()); } }
[ "protected", "Object", "getProperty", "(", "Token", "token", ")", "throws", "IOException", "{", "if", "(", "token", ".", "getDirectiveType", "(", ")", "==", "TokenDirectiveType", ".", "CLASSPATH", ")", "{", "Properties", "props", "=", "PropertiesLoaderUtils", ".", "loadProperties", "(", "token", ".", "getValue", "(", ")", ",", "activity", ".", "getEnvironment", "(", ")", ".", "getClassLoader", "(", ")", ")", ";", "Object", "value", "=", "(", "token", ".", "getGetterName", "(", ")", "!=", "null", "?", "props", ".", "get", "(", "token", ".", "getGetterName", "(", ")", ")", ":", "props", ")", ";", "return", "(", "value", "!=", "null", "?", "value", ":", "token", ".", "getDefaultValue", "(", ")", ")", ";", "}", "else", "{", "Object", "value", "=", "activity", ".", "getActivityContext", "(", ")", ".", "getEnvironment", "(", ")", ".", "getProperty", "(", "token", ".", "getName", "(", ")", ",", "activity", ")", ";", "if", "(", "value", "!=", "null", "&&", "token", ".", "getGetterName", "(", ")", "!=", "null", ")", "{", "value", "=", "getBeanProperty", "(", "value", ",", "token", ".", "getGetterName", "(", ")", ")", ";", "}", "return", "(", "value", "!=", "null", "?", "value", ":", "token", ".", "getDefaultValue", "(", ")", ")", ";", "}", "}" ]
Returns an Environment variable that matches the given token. <pre> %{classpath:/com/aspectran/sample.properties} %{classpath:/com/aspectran/sample.properties^propertyName:defaultValue} </pre> @param token the token @return an environment variable @throws IOException if an I/O error has occurred
[ "Returns", "an", "Environment", "variable", "that", "matches", "the", "given", "token", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/expr/TokenExpression.java#L448-L460
142,755
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/expr/TokenExpression.java
TokenExpression.getTemplate
protected String getTemplate(Token token) { TemplateRenderer templateRenderer = activity.getActivityContext().getTemplateRenderer(); StringWriter writer = new StringWriter(); templateRenderer.render(token.getName(), activity, writer); String result = writer.toString(); return (result != null ? result : token.getDefaultValue()); }
java
protected String getTemplate(Token token) { TemplateRenderer templateRenderer = activity.getActivityContext().getTemplateRenderer(); StringWriter writer = new StringWriter(); templateRenderer.render(token.getName(), activity, writer); String result = writer.toString(); return (result != null ? result : token.getDefaultValue()); }
[ "protected", "String", "getTemplate", "(", "Token", "token", ")", "{", "TemplateRenderer", "templateRenderer", "=", "activity", ".", "getActivityContext", "(", ")", ".", "getTemplateRenderer", "(", ")", ";", "StringWriter", "writer", "=", "new", "StringWriter", "(", ")", ";", "templateRenderer", ".", "render", "(", "token", ".", "getName", "(", ")", ",", "activity", ",", "writer", ")", ";", "String", "result", "=", "writer", ".", "toString", "(", ")", ";", "return", "(", "result", "!=", "null", "?", "result", ":", "token", ".", "getDefaultValue", "(", ")", ")", ";", "}" ]
Executes template, returns the generated output. @param token the token @return the generated output as {@code String}
[ "Executes", "template", "returns", "the", "generated", "output", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/expr/TokenExpression.java#L468-L476
142,756
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/expr/token/Token.java
Token.stringify
public String stringify() { if (type == TokenType.TEXT) { return defaultValue; } StringBuilder sb = new StringBuilder(); if (type == TokenType.BEAN) { sb.append(BEAN_SYMBOL); sb.append(START_BRACKET); if (name != null) { sb.append(name); } if (value != null) { sb.append(VALUE_SEPARATOR); sb.append(value); } if (getterName != null) { sb.append(GETTER_SEPARATOR); sb.append(getterName); } } else if (type == TokenType.TEMPLATE) { sb.append(TEMPLATE_SYMBOL); sb.append(START_BRACKET); if (name != null) { sb.append(name); } } else if (type == TokenType.PARAMETER) { sb.append(PARAMETER_SYMBOL); sb.append(START_BRACKET); if (name != null) { sb.append(name); } } else if (type == TokenType.ATTRIBUTE) { sb.append(ATTRIBUTE_SYMBOL); sb.append(START_BRACKET); if (name != null) { sb.append(name); } if (getterName != null) { sb.append(GETTER_SEPARATOR); sb.append(getterName); } } else if (type == TokenType.PROPERTY) { sb.append(PROPERTY_SYMBOL); sb.append(START_BRACKET); if (name != null) { sb.append(name); } if (value != null) { sb.append(VALUE_SEPARATOR); sb.append(value); } if (getterName != null) { sb.append(GETTER_SEPARATOR); sb.append(getterName); } } else { throw new InvalidTokenException("Unknown token type: " + type, this); } if (defaultValue != null) { sb.append(VALUE_SEPARATOR); sb.append(defaultValue); } sb.append(END_BRACKET); return sb.toString(); }
java
public String stringify() { if (type == TokenType.TEXT) { return defaultValue; } StringBuilder sb = new StringBuilder(); if (type == TokenType.BEAN) { sb.append(BEAN_SYMBOL); sb.append(START_BRACKET); if (name != null) { sb.append(name); } if (value != null) { sb.append(VALUE_SEPARATOR); sb.append(value); } if (getterName != null) { sb.append(GETTER_SEPARATOR); sb.append(getterName); } } else if (type == TokenType.TEMPLATE) { sb.append(TEMPLATE_SYMBOL); sb.append(START_BRACKET); if (name != null) { sb.append(name); } } else if (type == TokenType.PARAMETER) { sb.append(PARAMETER_SYMBOL); sb.append(START_BRACKET); if (name != null) { sb.append(name); } } else if (type == TokenType.ATTRIBUTE) { sb.append(ATTRIBUTE_SYMBOL); sb.append(START_BRACKET); if (name != null) { sb.append(name); } if (getterName != null) { sb.append(GETTER_SEPARATOR); sb.append(getterName); } } else if (type == TokenType.PROPERTY) { sb.append(PROPERTY_SYMBOL); sb.append(START_BRACKET); if (name != null) { sb.append(name); } if (value != null) { sb.append(VALUE_SEPARATOR); sb.append(value); } if (getterName != null) { sb.append(GETTER_SEPARATOR); sb.append(getterName); } } else { throw new InvalidTokenException("Unknown token type: " + type, this); } if (defaultValue != null) { sb.append(VALUE_SEPARATOR); sb.append(defaultValue); } sb.append(END_BRACKET); return sb.toString(); }
[ "public", "String", "stringify", "(", ")", "{", "if", "(", "type", "==", "TokenType", ".", "TEXT", ")", "{", "return", "defaultValue", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "type", "==", "TokenType", ".", "BEAN", ")", "{", "sb", ".", "append", "(", "BEAN_SYMBOL", ")", ";", "sb", ".", "append", "(", "START_BRACKET", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "sb", ".", "append", "(", "name", ")", ";", "}", "if", "(", "value", "!=", "null", ")", "{", "sb", ".", "append", "(", "VALUE_SEPARATOR", ")", ";", "sb", ".", "append", "(", "value", ")", ";", "}", "if", "(", "getterName", "!=", "null", ")", "{", "sb", ".", "append", "(", "GETTER_SEPARATOR", ")", ";", "sb", ".", "append", "(", "getterName", ")", ";", "}", "}", "else", "if", "(", "type", "==", "TokenType", ".", "TEMPLATE", ")", "{", "sb", ".", "append", "(", "TEMPLATE_SYMBOL", ")", ";", "sb", ".", "append", "(", "START_BRACKET", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "sb", ".", "append", "(", "name", ")", ";", "}", "}", "else", "if", "(", "type", "==", "TokenType", ".", "PARAMETER", ")", "{", "sb", ".", "append", "(", "PARAMETER_SYMBOL", ")", ";", "sb", ".", "append", "(", "START_BRACKET", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "sb", ".", "append", "(", "name", ")", ";", "}", "}", "else", "if", "(", "type", "==", "TokenType", ".", "ATTRIBUTE", ")", "{", "sb", ".", "append", "(", "ATTRIBUTE_SYMBOL", ")", ";", "sb", ".", "append", "(", "START_BRACKET", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "sb", ".", "append", "(", "name", ")", ";", "}", "if", "(", "getterName", "!=", "null", ")", "{", "sb", ".", "append", "(", "GETTER_SEPARATOR", ")", ";", "sb", ".", "append", "(", "getterName", ")", ";", "}", "}", "else", "if", "(", "type", "==", "TokenType", ".", "PROPERTY", ")", "{", "sb", ".", "append", "(", "PROPERTY_SYMBOL", ")", ";", "sb", ".", "append", "(", "START_BRACKET", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "sb", ".", "append", "(", "name", ")", ";", "}", "if", "(", "value", "!=", "null", ")", "{", "sb", ".", "append", "(", "VALUE_SEPARATOR", ")", ";", "sb", ".", "append", "(", "value", ")", ";", "}", "if", "(", "getterName", "!=", "null", ")", "{", "sb", ".", "append", "(", "GETTER_SEPARATOR", ")", ";", "sb", ".", "append", "(", "getterName", ")", ";", "}", "}", "else", "{", "throw", "new", "InvalidTokenException", "(", "\"Unknown token type: \"", "+", "type", ",", "this", ")", ";", "}", "if", "(", "defaultValue", "!=", "null", ")", "{", "sb", ".", "append", "(", "VALUE_SEPARATOR", ")", ";", "sb", ".", "append", "(", "defaultValue", ")", ";", "}", "sb", ".", "append", "(", "END_BRACKET", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Convert a Token object into a string. @return a string representation of the token
[ "Convert", "a", "Token", "object", "into", "a", "string", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/expr/token/Token.java#L299-L363
142,757
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/expr/token/Token.java
Token.isTokenSymbol
public static boolean isTokenSymbol(char c) { return (c == BEAN_SYMBOL || c == TEMPLATE_SYMBOL || c == PARAMETER_SYMBOL || c == ATTRIBUTE_SYMBOL || c == PROPERTY_SYMBOL); }
java
public static boolean isTokenSymbol(char c) { return (c == BEAN_SYMBOL || c == TEMPLATE_SYMBOL || c == PARAMETER_SYMBOL || c == ATTRIBUTE_SYMBOL || c == PROPERTY_SYMBOL); }
[ "public", "static", "boolean", "isTokenSymbol", "(", "char", "c", ")", "{", "return", "(", "c", "==", "BEAN_SYMBOL", "||", "c", "==", "TEMPLATE_SYMBOL", "||", "c", "==", "PARAMETER_SYMBOL", "||", "c", "==", "ATTRIBUTE_SYMBOL", "||", "c", "==", "PROPERTY_SYMBOL", ")", ";", "}" ]
Returns whether a specified character is the token symbol. @param c a character @return true, if a specified character is one of the token symbols
[ "Returns", "whether", "a", "specified", "character", "is", "the", "token", "symbol", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/expr/token/Token.java#L454-L460
142,758
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/expr/token/Token.java
Token.resolveTypeAsSymbol
public static TokenType resolveTypeAsSymbol(char symbol) { TokenType type; if (symbol == Token.BEAN_SYMBOL) { type = TokenType.BEAN; } else if (symbol == Token.TEMPLATE_SYMBOL) { type = TokenType.TEMPLATE; } else if (symbol == Token.PARAMETER_SYMBOL) { type = TokenType.PARAMETER; } else if (symbol == Token.ATTRIBUTE_SYMBOL) { type = TokenType.ATTRIBUTE; } else if (symbol == Token.PROPERTY_SYMBOL) { type = TokenType.PROPERTY; } else { throw new IllegalArgumentException("Unknown token symbol: " + symbol); } return type; }
java
public static TokenType resolveTypeAsSymbol(char symbol) { TokenType type; if (symbol == Token.BEAN_SYMBOL) { type = TokenType.BEAN; } else if (symbol == Token.TEMPLATE_SYMBOL) { type = TokenType.TEMPLATE; } else if (symbol == Token.PARAMETER_SYMBOL) { type = TokenType.PARAMETER; } else if (symbol == Token.ATTRIBUTE_SYMBOL) { type = TokenType.ATTRIBUTE; } else if (symbol == Token.PROPERTY_SYMBOL) { type = TokenType.PROPERTY; } else { throw new IllegalArgumentException("Unknown token symbol: " + symbol); } return type; }
[ "public", "static", "TokenType", "resolveTypeAsSymbol", "(", "char", "symbol", ")", "{", "TokenType", "type", ";", "if", "(", "symbol", "==", "Token", ".", "BEAN_SYMBOL", ")", "{", "type", "=", "TokenType", ".", "BEAN", ";", "}", "else", "if", "(", "symbol", "==", "Token", ".", "TEMPLATE_SYMBOL", ")", "{", "type", "=", "TokenType", ".", "TEMPLATE", ";", "}", "else", "if", "(", "symbol", "==", "Token", ".", "PARAMETER_SYMBOL", ")", "{", "type", "=", "TokenType", ".", "PARAMETER", ";", "}", "else", "if", "(", "symbol", "==", "Token", ".", "ATTRIBUTE_SYMBOL", ")", "{", "type", "=", "TokenType", ".", "ATTRIBUTE", ";", "}", "else", "if", "(", "symbol", "==", "Token", ".", "PROPERTY_SYMBOL", ")", "{", "type", "=", "TokenType", ".", "PROPERTY", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unknown token symbol: \"", "+", "symbol", ")", ";", "}", "return", "type", ";", "}" ]
Returns the token type for the specified character. @param symbol the token symbol character @return the token type
[ "Returns", "the", "token", "type", "for", "the", "specified", "character", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/expr/token/Token.java#L482-L498
142,759
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/TransformRule.java
TransformRule.setTransformType
public void setTransformType(TransformType transformType) { this.transformType = transformType; if (contentType == null && transformType != null) { if (transformType == TransformType.TEXT) { contentType = ContentType.TEXT_PLAIN.toString(); } else if (transformType == TransformType.JSON) { contentType = ContentType.TEXT_JSON.toString(); } else if (transformType == TransformType.XML) { contentType = ContentType.TEXT_XML.toString(); } } }
java
public void setTransformType(TransformType transformType) { this.transformType = transformType; if (contentType == null && transformType != null) { if (transformType == TransformType.TEXT) { contentType = ContentType.TEXT_PLAIN.toString(); } else if (transformType == TransformType.JSON) { contentType = ContentType.TEXT_JSON.toString(); } else if (transformType == TransformType.XML) { contentType = ContentType.TEXT_XML.toString(); } } }
[ "public", "void", "setTransformType", "(", "TransformType", "transformType", ")", "{", "this", ".", "transformType", "=", "transformType", ";", "if", "(", "contentType", "==", "null", "&&", "transformType", "!=", "null", ")", "{", "if", "(", "transformType", "==", "TransformType", ".", "TEXT", ")", "{", "contentType", "=", "ContentType", ".", "TEXT_PLAIN", ".", "toString", "(", ")", ";", "}", "else", "if", "(", "transformType", "==", "TransformType", ".", "JSON", ")", "{", "contentType", "=", "ContentType", ".", "TEXT_JSON", ".", "toString", "(", ")", ";", "}", "else", "if", "(", "transformType", "==", "TransformType", ".", "XML", ")", "{", "contentType", "=", "ContentType", ".", "TEXT_XML", ".", "toString", "(", ")", ";", "}", "}", "}" ]
Sets the transform type. @param transformType the transformType to set
[ "Sets", "the", "transform", "type", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/TransformRule.java#L66-L78
142,760
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/TransformRule.java
TransformRule.setTemplateRule
public void setTemplateRule(TemplateRule templateRule) { this.templateRule = templateRule; if (templateRule != null) { if (this.transformType == null) { setTransformType(TransformType.TEXT); } if (templateRule.getEncoding() != null && this.encoding == null) { this.encoding = templateRule.getEncoding(); } } }
java
public void setTemplateRule(TemplateRule templateRule) { this.templateRule = templateRule; if (templateRule != null) { if (this.transformType == null) { setTransformType(TransformType.TEXT); } if (templateRule.getEncoding() != null && this.encoding == null) { this.encoding = templateRule.getEncoding(); } } }
[ "public", "void", "setTemplateRule", "(", "TemplateRule", "templateRule", ")", "{", "this", ".", "templateRule", "=", "templateRule", ";", "if", "(", "templateRule", "!=", "null", ")", "{", "if", "(", "this", ".", "transformType", "==", "null", ")", "{", "setTransformType", "(", "TransformType", ".", "TEXT", ")", ";", "}", "if", "(", "templateRule", ".", "getEncoding", "(", ")", "!=", "null", "&&", "this", ".", "encoding", "==", "null", ")", "{", "this", ".", "encoding", "=", "templateRule", ".", "getEncoding", "(", ")", ";", "}", "}", "}" ]
Sets the template rule. @param templateRule the template rule
[ "Sets", "the", "template", "rule", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/TransformRule.java#L181-L191
142,761
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/process/result/ActionResult.java
ActionResult.setResultValue
public void setResultValue(String actionId, Object resultValue) { if (actionId == null || !actionId.contains(ActivityContext.ID_SEPARATOR)) { this.actionId = actionId; this.resultValue = resultValue; } else { String[] ids = StringUtils.tokenize(actionId, ActivityContext.ID_SEPARATOR, true); if (ids.length == 1) { this.actionId = null; this.resultValue = resultValue; } else if (ids.length == 2) { ResultValueMap resultValueMap = new ResultValueMap(); resultValueMap.put(ids[1], resultValue); this.actionId = ids[0]; this.resultValue = resultValueMap; } else { ResultValueMap resultValueMap = new ResultValueMap(); for (int i = 1; i < ids.length - 1; i++) { ResultValueMap resultValueMap2 = new ResultValueMap(); resultValueMap.put(ids[i], resultValueMap2); resultValueMap = resultValueMap2; } resultValueMap.put(ids[ids.length - 1], resultValue); this.actionId = actionId; this.resultValue = resultValueMap; } } }
java
public void setResultValue(String actionId, Object resultValue) { if (actionId == null || !actionId.contains(ActivityContext.ID_SEPARATOR)) { this.actionId = actionId; this.resultValue = resultValue; } else { String[] ids = StringUtils.tokenize(actionId, ActivityContext.ID_SEPARATOR, true); if (ids.length == 1) { this.actionId = null; this.resultValue = resultValue; } else if (ids.length == 2) { ResultValueMap resultValueMap = new ResultValueMap(); resultValueMap.put(ids[1], resultValue); this.actionId = ids[0]; this.resultValue = resultValueMap; } else { ResultValueMap resultValueMap = new ResultValueMap(); for (int i = 1; i < ids.length - 1; i++) { ResultValueMap resultValueMap2 = new ResultValueMap(); resultValueMap.put(ids[i], resultValueMap2); resultValueMap = resultValueMap2; } resultValueMap.put(ids[ids.length - 1], resultValue); this.actionId = actionId; this.resultValue = resultValueMap; } } }
[ "public", "void", "setResultValue", "(", "String", "actionId", ",", "Object", "resultValue", ")", "{", "if", "(", "actionId", "==", "null", "||", "!", "actionId", ".", "contains", "(", "ActivityContext", ".", "ID_SEPARATOR", ")", ")", "{", "this", ".", "actionId", "=", "actionId", ";", "this", ".", "resultValue", "=", "resultValue", ";", "}", "else", "{", "String", "[", "]", "ids", "=", "StringUtils", ".", "tokenize", "(", "actionId", ",", "ActivityContext", ".", "ID_SEPARATOR", ",", "true", ")", ";", "if", "(", "ids", ".", "length", "==", "1", ")", "{", "this", ".", "actionId", "=", "null", ";", "this", ".", "resultValue", "=", "resultValue", ";", "}", "else", "if", "(", "ids", ".", "length", "==", "2", ")", "{", "ResultValueMap", "resultValueMap", "=", "new", "ResultValueMap", "(", ")", ";", "resultValueMap", ".", "put", "(", "ids", "[", "1", "]", ",", "resultValue", ")", ";", "this", ".", "actionId", "=", "ids", "[", "0", "]", ";", "this", ".", "resultValue", "=", "resultValueMap", ";", "}", "else", "{", "ResultValueMap", "resultValueMap", "=", "new", "ResultValueMap", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "ids", ".", "length", "-", "1", ";", "i", "++", ")", "{", "ResultValueMap", "resultValueMap2", "=", "new", "ResultValueMap", "(", ")", ";", "resultValueMap", ".", "put", "(", "ids", "[", "i", "]", ",", "resultValueMap2", ")", ";", "resultValueMap", "=", "resultValueMap2", ";", "}", "resultValueMap", ".", "put", "(", "ids", "[", "ids", ".", "length", "-", "1", "]", ",", "resultValue", ")", ";", "this", ".", "actionId", "=", "actionId", ";", "this", ".", "resultValue", "=", "resultValueMap", ";", "}", "}", "}" ]
Sets the result value of the action. @param actionId the new action id @param resultValue the new result value of the action
[ "Sets", "the", "result", "value", "of", "the", "action", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/process/result/ActionResult.java#L59-L85
142,762
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/ResourceUtils.java
ResourceUtils.getResource
public static URL getResource(String resource, ClassLoader classLoader) throws IOException { URL url = null; if (classLoader != null) { url = classLoader.getResource(resource); } if (url == null) { url = ClassLoader.getSystemResource(resource); } if (url == null) { throw new IOException("Could not find resource '" + resource + "'"); } return url; }
java
public static URL getResource(String resource, ClassLoader classLoader) throws IOException { URL url = null; if (classLoader != null) { url = classLoader.getResource(resource); } if (url == null) { url = ClassLoader.getSystemResource(resource); } if (url == null) { throw new IOException("Could not find resource '" + resource + "'"); } return url; }
[ "public", "static", "URL", "getResource", "(", "String", "resource", ",", "ClassLoader", "classLoader", ")", "throws", "IOException", "{", "URL", "url", "=", "null", ";", "if", "(", "classLoader", "!=", "null", ")", "{", "url", "=", "classLoader", ".", "getResource", "(", "resource", ")", ";", "}", "if", "(", "url", "==", "null", ")", "{", "url", "=", "ClassLoader", ".", "getSystemResource", "(", "resource", ")", ";", "}", "if", "(", "url", "==", "null", ")", "{", "throw", "new", "IOException", "(", "\"Could not find resource '\"", "+", "resource", "+", "\"'\"", ")", ";", "}", "return", "url", ";", "}" ]
Returns the URL of the resource on the classpath. @param classLoader the class loader used to load the resource @param resource the resource to find @return {@code URL} object for reading the resource; {@code null} if the resource could not be found @throws IOException if the resource cannot be found or read
[ "Returns", "the", "URL", "of", "the", "resource", "on", "the", "classpath", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/ResourceUtils.java#L229-L241
142,763
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/ResourceUtils.java
ResourceUtils.getReader
public static Reader getReader(final File file, String encoding) throws IOException { InputStream stream; try { stream = AccessController.doPrivileged( new PrivilegedExceptionAction<InputStream>() { @Override public InputStream run() throws IOException { return new FileInputStream(file); } } ); } catch (PrivilegedActionException e) { throw (IOException)e.getException(); } Reader reader; if (encoding != null) { reader = new InputStreamReader(stream, encoding); } else { reader = new InputStreamReader(stream); } return reader; }
java
public static Reader getReader(final File file, String encoding) throws IOException { InputStream stream; try { stream = AccessController.doPrivileged( new PrivilegedExceptionAction<InputStream>() { @Override public InputStream run() throws IOException { return new FileInputStream(file); } } ); } catch (PrivilegedActionException e) { throw (IOException)e.getException(); } Reader reader; if (encoding != null) { reader = new InputStreamReader(stream, encoding); } else { reader = new InputStreamReader(stream); } return reader; }
[ "public", "static", "Reader", "getReader", "(", "final", "File", "file", ",", "String", "encoding", ")", "throws", "IOException", "{", "InputStream", "stream", ";", "try", "{", "stream", "=", "AccessController", ".", "doPrivileged", "(", "new", "PrivilegedExceptionAction", "<", "InputStream", ">", "(", ")", "{", "@", "Override", "public", "InputStream", "run", "(", ")", "throws", "IOException", "{", "return", "new", "FileInputStream", "(", "file", ")", ";", "}", "}", ")", ";", "}", "catch", "(", "PrivilegedActionException", "e", ")", "{", "throw", "(", "IOException", ")", "e", ".", "getException", "(", ")", ";", "}", "Reader", "reader", ";", "if", "(", "encoding", "!=", "null", ")", "{", "reader", "=", "new", "InputStreamReader", "(", "stream", ",", "encoding", ")", ";", "}", "else", "{", "reader", "=", "new", "InputStreamReader", "(", "stream", ")", ";", "}", "return", "reader", ";", "}" ]
Returns a Reader for reading the specified file. @param file the file @param encoding the encoding @return the reader instance @throws IOException if an error occurred when reading resources using any I/O operations
[ "Returns", "a", "Reader", "for", "reading", "the", "specified", "file", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/ResourceUtils.java#L294-L316
142,764
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/ResourceUtils.java
ResourceUtils.getReader
public static Reader getReader(final URL url, String encoding) throws IOException { InputStream stream; try { stream = AccessController.doPrivileged( new PrivilegedExceptionAction<InputStream>() { @Override public InputStream run() throws IOException { InputStream is = null; if (url != null) { URLConnection connection = url.openConnection(); if (connection != null) { // Disable caches to get fresh data for reloading. connection.setUseCaches(false); is = connection.getInputStream(); } } return is; } } ); } catch (PrivilegedActionException e) { throw (IOException)e.getException(); } Reader reader; if (encoding != null) { reader = new InputStreamReader(stream, encoding); } else { reader = new InputStreamReader(stream); } return reader; }
java
public static Reader getReader(final URL url, String encoding) throws IOException { InputStream stream; try { stream = AccessController.doPrivileged( new PrivilegedExceptionAction<InputStream>() { @Override public InputStream run() throws IOException { InputStream is = null; if (url != null) { URLConnection connection = url.openConnection(); if (connection != null) { // Disable caches to get fresh data for reloading. connection.setUseCaches(false); is = connection.getInputStream(); } } return is; } } ); } catch (PrivilegedActionException e) { throw (IOException)e.getException(); } Reader reader; if (encoding != null) { reader = new InputStreamReader(stream, encoding); } else { reader = new InputStreamReader(stream); } return reader; }
[ "public", "static", "Reader", "getReader", "(", "final", "URL", "url", ",", "String", "encoding", ")", "throws", "IOException", "{", "InputStream", "stream", ";", "try", "{", "stream", "=", "AccessController", ".", "doPrivileged", "(", "new", "PrivilegedExceptionAction", "<", "InputStream", ">", "(", ")", "{", "@", "Override", "public", "InputStream", "run", "(", ")", "throws", "IOException", "{", "InputStream", "is", "=", "null", ";", "if", "(", "url", "!=", "null", ")", "{", "URLConnection", "connection", "=", "url", ".", "openConnection", "(", ")", ";", "if", "(", "connection", "!=", "null", ")", "{", "// Disable caches to get fresh data for reloading.", "connection", ".", "setUseCaches", "(", "false", ")", ";", "is", "=", "connection", ".", "getInputStream", "(", ")", ";", "}", "}", "return", "is", ";", "}", "}", ")", ";", "}", "catch", "(", "PrivilegedActionException", "e", ")", "{", "throw", "(", "IOException", ")", "e", ".", "getException", "(", ")", ";", "}", "Reader", "reader", ";", "if", "(", "encoding", "!=", "null", ")", "{", "reader", "=", "new", "InputStreamReader", "(", "stream", ",", "encoding", ")", ";", "}", "else", "{", "reader", "=", "new", "InputStreamReader", "(", "stream", ")", ";", "}", "return", "reader", ";", "}" ]
Returns a Reader for reading the specified url. @param url the url @param encoding the encoding @return the reader instance @throws IOException if an error occurred when reading resources using any I/O operations
[ "Returns", "a", "Reader", "for", "reading", "the", "specified", "url", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/ResourceUtils.java#L326-L357
142,765
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/ResourceUtils.java
ResourceUtils.read
public static String read(File file, String encoding) throws IOException { Reader reader = getReader(file, encoding); String source; try { source = read(reader); } finally { reader.close(); } return source; }
java
public static String read(File file, String encoding) throws IOException { Reader reader = getReader(file, encoding); String source; try { source = read(reader); } finally { reader.close(); } return source; }
[ "public", "static", "String", "read", "(", "File", "file", ",", "String", "encoding", ")", "throws", "IOException", "{", "Reader", "reader", "=", "getReader", "(", "file", ",", "encoding", ")", ";", "String", "source", ";", "try", "{", "source", "=", "read", "(", "reader", ")", ";", "}", "finally", "{", "reader", ".", "close", "(", ")", ";", "}", "return", "source", ";", "}" ]
Returns a string from the specified file. @param file the file @param encoding the encoding @return the reader instance @throws IOException if an error occurred when reading resources using any I/O operations
[ "Returns", "a", "string", "from", "the", "specified", "file", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/ResourceUtils.java#L367-L376
142,766
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/ResourceUtils.java
ResourceUtils.read
public static String read(URL url, String encoding) throws IOException { Reader reader = getReader(url, encoding); String source; try { source = read(reader); } finally { reader.close(); } return source; }
java
public static String read(URL url, String encoding) throws IOException { Reader reader = getReader(url, encoding); String source; try { source = read(reader); } finally { reader.close(); } return source; }
[ "public", "static", "String", "read", "(", "URL", "url", ",", "String", "encoding", ")", "throws", "IOException", "{", "Reader", "reader", "=", "getReader", "(", "url", ",", "encoding", ")", ";", "String", "source", ";", "try", "{", "source", "=", "read", "(", "reader", ")", ";", "}", "finally", "{", "reader", ".", "close", "(", ")", ";", "}", "return", "source", ";", "}" ]
Returns a string from the specified url. @param url the url @param encoding the encoding @return the string @throws IOException if an error occurred when reading resources using any I/O operations
[ "Returns", "a", "string", "from", "the", "specified", "url", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/ResourceUtils.java#L386-L395
142,767
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/ResourceUtils.java
ResourceUtils.read
public static String read(Reader reader) throws IOException { final char[] buffer = new char[1024]; StringBuilder sb = new StringBuilder(); int len; while ((len = reader.read(buffer)) != -1) { sb.append(buffer, 0, len); } return sb.toString(); }
java
public static String read(Reader reader) throws IOException { final char[] buffer = new char[1024]; StringBuilder sb = new StringBuilder(); int len; while ((len = reader.read(buffer)) != -1) { sb.append(buffer, 0, len); } return sb.toString(); }
[ "public", "static", "String", "read", "(", "Reader", "reader", ")", "throws", "IOException", "{", "final", "char", "[", "]", "buffer", "=", "new", "char", "[", "1024", "]", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "int", "len", ";", "while", "(", "(", "len", "=", "reader", ".", "read", "(", "buffer", ")", ")", "!=", "-", "1", ")", "{", "sb", ".", "append", "(", "buffer", ",", "0", ",", "len", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Returns a string from the specified Reader object. @param reader the reader @return the string @throws IOException if an error occurred when reading resources using any I/O operations
[ "Returns", "a", "string", "from", "the", "specified", "Reader", "object", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/ResourceUtils.java#L404-L412
142,768
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/response/dispatch/DispatchResponse.java
DispatchResponse.getViewDispatcher
private ViewDispatcher getViewDispatcher(Activity activity) throws ViewDispatcherException { if (dispatchRule.getViewDispatcher() != null) { return dispatchRule.getViewDispatcher(); } try { String dispatcherName; if (dispatchRule.getDispatcherName() != null) { dispatcherName = dispatchRule.getDispatcherName(); } else { dispatcherName = activity.getSetting(ViewDispatcher.VIEW_DISPATCHER_SETTING_NAME); if (dispatcherName == null) { throw new IllegalArgumentException("The settings name '" + ViewDispatcher.VIEW_DISPATCHER_SETTING_NAME + "' has not been specified in the default response rule"); } } ViewDispatcher viewDispatcher = cache.get(dispatcherName); if (viewDispatcher == null) { if (dispatcherName.startsWith(BeanRule.CLASS_DIRECTIVE_PREFIX)) { String dispatcherClassName = dispatcherName.substring(BeanRule.CLASS_DIRECTIVE_PREFIX.length()); Class<?> dispatcherClass = activity.getEnvironment().getClassLoader().loadClass(dispatcherClassName); viewDispatcher = (ViewDispatcher)activity.getBean(dispatcherClass); } else { viewDispatcher = activity.getBean(dispatcherName); } if (viewDispatcher == null) { throw new IllegalArgumentException("No bean named '" + dispatcherName + "' is defined"); } if (viewDispatcher.isSingleton()) { ViewDispatcher existing = cache.putIfAbsent(dispatcherName, viewDispatcher); if (existing != null) { viewDispatcher = existing; } else { if (log.isDebugEnabled()) { log.debug("Caching " + viewDispatcher); } } } } return viewDispatcher; } catch(Exception e) { throw new ViewDispatcherException("Unable to determine ViewDispatcher", e); } }
java
private ViewDispatcher getViewDispatcher(Activity activity) throws ViewDispatcherException { if (dispatchRule.getViewDispatcher() != null) { return dispatchRule.getViewDispatcher(); } try { String dispatcherName; if (dispatchRule.getDispatcherName() != null) { dispatcherName = dispatchRule.getDispatcherName(); } else { dispatcherName = activity.getSetting(ViewDispatcher.VIEW_DISPATCHER_SETTING_NAME); if (dispatcherName == null) { throw new IllegalArgumentException("The settings name '" + ViewDispatcher.VIEW_DISPATCHER_SETTING_NAME + "' has not been specified in the default response rule"); } } ViewDispatcher viewDispatcher = cache.get(dispatcherName); if (viewDispatcher == null) { if (dispatcherName.startsWith(BeanRule.CLASS_DIRECTIVE_PREFIX)) { String dispatcherClassName = dispatcherName.substring(BeanRule.CLASS_DIRECTIVE_PREFIX.length()); Class<?> dispatcherClass = activity.getEnvironment().getClassLoader().loadClass(dispatcherClassName); viewDispatcher = (ViewDispatcher)activity.getBean(dispatcherClass); } else { viewDispatcher = activity.getBean(dispatcherName); } if (viewDispatcher == null) { throw new IllegalArgumentException("No bean named '" + dispatcherName + "' is defined"); } if (viewDispatcher.isSingleton()) { ViewDispatcher existing = cache.putIfAbsent(dispatcherName, viewDispatcher); if (existing != null) { viewDispatcher = existing; } else { if (log.isDebugEnabled()) { log.debug("Caching " + viewDispatcher); } } } } return viewDispatcher; } catch(Exception e) { throw new ViewDispatcherException("Unable to determine ViewDispatcher", e); } }
[ "private", "ViewDispatcher", "getViewDispatcher", "(", "Activity", "activity", ")", "throws", "ViewDispatcherException", "{", "if", "(", "dispatchRule", ".", "getViewDispatcher", "(", ")", "!=", "null", ")", "{", "return", "dispatchRule", ".", "getViewDispatcher", "(", ")", ";", "}", "try", "{", "String", "dispatcherName", ";", "if", "(", "dispatchRule", ".", "getDispatcherName", "(", ")", "!=", "null", ")", "{", "dispatcherName", "=", "dispatchRule", ".", "getDispatcherName", "(", ")", ";", "}", "else", "{", "dispatcherName", "=", "activity", ".", "getSetting", "(", "ViewDispatcher", ".", "VIEW_DISPATCHER_SETTING_NAME", ")", ";", "if", "(", "dispatcherName", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The settings name '\"", "+", "ViewDispatcher", ".", "VIEW_DISPATCHER_SETTING_NAME", "+", "\"' has not been specified in the default response rule\"", ")", ";", "}", "}", "ViewDispatcher", "viewDispatcher", "=", "cache", ".", "get", "(", "dispatcherName", ")", ";", "if", "(", "viewDispatcher", "==", "null", ")", "{", "if", "(", "dispatcherName", ".", "startsWith", "(", "BeanRule", ".", "CLASS_DIRECTIVE_PREFIX", ")", ")", "{", "String", "dispatcherClassName", "=", "dispatcherName", ".", "substring", "(", "BeanRule", ".", "CLASS_DIRECTIVE_PREFIX", ".", "length", "(", ")", ")", ";", "Class", "<", "?", ">", "dispatcherClass", "=", "activity", ".", "getEnvironment", "(", ")", ".", "getClassLoader", "(", ")", ".", "loadClass", "(", "dispatcherClassName", ")", ";", "viewDispatcher", "=", "(", "ViewDispatcher", ")", "activity", ".", "getBean", "(", "dispatcherClass", ")", ";", "}", "else", "{", "viewDispatcher", "=", "activity", ".", "getBean", "(", "dispatcherName", ")", ";", "}", "if", "(", "viewDispatcher", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"No bean named '\"", "+", "dispatcherName", "+", "\"' is defined\"", ")", ";", "}", "if", "(", "viewDispatcher", ".", "isSingleton", "(", ")", ")", "{", "ViewDispatcher", "existing", "=", "cache", ".", "putIfAbsent", "(", "dispatcherName", ",", "viewDispatcher", ")", ";", "if", "(", "existing", "!=", "null", ")", "{", "viewDispatcher", "=", "existing", ";", "}", "else", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Caching \"", "+", "viewDispatcher", ")", ";", "}", "}", "}", "}", "return", "viewDispatcher", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ViewDispatcherException", "(", "\"Unable to determine ViewDispatcher\"", ",", "e", ")", ";", "}", "}" ]
Determine the view dispatcher. @param activity the current Activity @throws ViewDispatcherException if ViewDispatcher can not be determined
[ "Determine", "the", "view", "dispatcher", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/response/dispatch/DispatchResponse.java#L119-L163
142,769
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/response/dispatch/DispatchResponse.java
DispatchResponse.fetchAttributes
public static void fetchAttributes(RequestAdapter requestAdapter, ProcessResult processResult) { if (processResult != null) { for (ContentResult contentResult : processResult) { for (ActionResult actionResult : contentResult) { Object actionResultValue = actionResult.getResultValue(); if (actionResultValue instanceof ProcessResult) { fetchAttributes(requestAdapter, (ProcessResult)actionResultValue); } else { String actionId = actionResult.getActionId(); if (actionId != null) { requestAdapter.setAttribute(actionId, actionResultValue); } } } } } }
java
public static void fetchAttributes(RequestAdapter requestAdapter, ProcessResult processResult) { if (processResult != null) { for (ContentResult contentResult : processResult) { for (ActionResult actionResult : contentResult) { Object actionResultValue = actionResult.getResultValue(); if (actionResultValue instanceof ProcessResult) { fetchAttributes(requestAdapter, (ProcessResult)actionResultValue); } else { String actionId = actionResult.getActionId(); if (actionId != null) { requestAdapter.setAttribute(actionId, actionResultValue); } } } } } }
[ "public", "static", "void", "fetchAttributes", "(", "RequestAdapter", "requestAdapter", ",", "ProcessResult", "processResult", ")", "{", "if", "(", "processResult", "!=", "null", ")", "{", "for", "(", "ContentResult", "contentResult", ":", "processResult", ")", "{", "for", "(", "ActionResult", "actionResult", ":", "contentResult", ")", "{", "Object", "actionResultValue", "=", "actionResult", ".", "getResultValue", "(", ")", ";", "if", "(", "actionResultValue", "instanceof", "ProcessResult", ")", "{", "fetchAttributes", "(", "requestAdapter", ",", "(", "ProcessResult", ")", "actionResultValue", ")", ";", "}", "else", "{", "String", "actionId", "=", "actionResult", ".", "getActionId", "(", ")", ";", "if", "(", "actionId", "!=", "null", ")", "{", "requestAdapter", ".", "setAttribute", "(", "actionId", ",", "actionResultValue", ")", ";", "}", "}", "}", "}", "}", "}" ]
Stores an attribute in request. @param requestAdapter the request adapter @param processResult the process result
[ "Stores", "an", "attribute", "in", "request", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/response/dispatch/DispatchResponse.java#L176-L192
142,770
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/resource/AspectranClassLoader.java
AspectranClassLoader.excludePackage
public void excludePackage(String... packageNames) { if (packageNames == null) { excludePackageNames = null; } else { for (String packageName : packageNames) { if (excludePackageNames == null) { excludePackageNames = new HashSet<>(); } excludePackageNames.add(packageName + PACKAGE_SEPARATOR_CHAR); } } }
java
public void excludePackage(String... packageNames) { if (packageNames == null) { excludePackageNames = null; } else { for (String packageName : packageNames) { if (excludePackageNames == null) { excludePackageNames = new HashSet<>(); } excludePackageNames.add(packageName + PACKAGE_SEPARATOR_CHAR); } } }
[ "public", "void", "excludePackage", "(", "String", "...", "packageNames", ")", "{", "if", "(", "packageNames", "==", "null", ")", "{", "excludePackageNames", "=", "null", ";", "}", "else", "{", "for", "(", "String", "packageName", ":", "packageNames", ")", "{", "if", "(", "excludePackageNames", "==", "null", ")", "{", "excludePackageNames", "=", "new", "HashSet", "<>", "(", ")", ";", "}", "excludePackageNames", ".", "add", "(", "packageName", "+", "PACKAGE_SEPARATOR_CHAR", ")", ";", "}", "}", "}" ]
Adds packages that this ClassLoader should not handle. Any class whose fully-qualified name starts with the name registered here will be handled by the parent ClassLoader in the usual fashion. @param packageNames package names that we be compared against fully qualified package names to exclude
[ "Adds", "packages", "that", "this", "ClassLoader", "should", "not", "handle", ".", "Any", "class", "whose", "fully", "-", "qualified", "name", "starts", "with", "the", "name", "registered", "here", "will", "be", "handled", "by", "the", "parent", "ClassLoader", "in", "the", "usual", "fashion", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/resource/AspectranClassLoader.java#L179-L190
142,771
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/resource/AspectranClassLoader.java
AspectranClassLoader.excludeClass
public void excludeClass(String... classNames) { if (classNames == null) { excludeClassNames = null; } else { for (String className : classNames) { if (!isExcludePackage(className)) { if (excludeClassNames == null) { excludeClassNames = new HashSet<>(); } excludeClassNames.add(className); } } } }
java
public void excludeClass(String... classNames) { if (classNames == null) { excludeClassNames = null; } else { for (String className : classNames) { if (!isExcludePackage(className)) { if (excludeClassNames == null) { excludeClassNames = new HashSet<>(); } excludeClassNames.add(className); } } } }
[ "public", "void", "excludeClass", "(", "String", "...", "classNames", ")", "{", "if", "(", "classNames", "==", "null", ")", "{", "excludeClassNames", "=", "null", ";", "}", "else", "{", "for", "(", "String", "className", ":", "classNames", ")", "{", "if", "(", "!", "isExcludePackage", "(", "className", ")", ")", "{", "if", "(", "excludeClassNames", "==", "null", ")", "{", "excludeClassNames", "=", "new", "HashSet", "<>", "(", ")", ";", "}", "excludeClassNames", ".", "add", "(", "className", ")", ";", "}", "}", "}", "}" ]
Adds classes that this ClassLoader should not handle. Any class whose fully-qualified name starts with the name registered here will be handled by the parent ClassLoader in the usual fashion. @param classNames class names that we be compared against fully qualified class names to exclude
[ "Adds", "classes", "that", "this", "ClassLoader", "should", "not", "handle", ".", "Any", "class", "whose", "fully", "-", "qualified", "name", "starts", "with", "the", "name", "registered", "here", "will", "be", "handled", "by", "the", "parent", "ClassLoader", "in", "the", "usual", "fashion", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/resource/AspectranClassLoader.java#L199-L212
142,772
aspectran/aspectran
with-mybatis/src/main/java/com/aspectran/mybatis/SqlSessionTxAdvice.java
SqlSessionTxAdvice.open
public void open() { if(sqlSession == null) { if (executorType == null) { executorType = ExecutorType.SIMPLE; } sqlSession = sqlSessionFactory.openSession(executorType, autoCommit); if (log.isDebugEnabled()) { ToStringBuilder tsb = new ToStringBuilder(String.format("%s %s@%x", (arbitrarilyClosed ? "Reopened" : "Opened"), sqlSession.getClass().getSimpleName(), sqlSession.hashCode())); tsb.append("executorType", executorType); tsb.append("autoCommit", autoCommit); log.debug(tsb.toString()); } arbitrarilyClosed = false; } }
java
public void open() { if(sqlSession == null) { if (executorType == null) { executorType = ExecutorType.SIMPLE; } sqlSession = sqlSessionFactory.openSession(executorType, autoCommit); if (log.isDebugEnabled()) { ToStringBuilder tsb = new ToStringBuilder(String.format("%s %s@%x", (arbitrarilyClosed ? "Reopened" : "Opened"), sqlSession.getClass().getSimpleName(), sqlSession.hashCode())); tsb.append("executorType", executorType); tsb.append("autoCommit", autoCommit); log.debug(tsb.toString()); } arbitrarilyClosed = false; } }
[ "public", "void", "open", "(", ")", "{", "if", "(", "sqlSession", "==", "null", ")", "{", "if", "(", "executorType", "==", "null", ")", "{", "executorType", "=", "ExecutorType", ".", "SIMPLE", ";", "}", "sqlSession", "=", "sqlSessionFactory", ".", "openSession", "(", "executorType", ",", "autoCommit", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "ToStringBuilder", "tsb", "=", "new", "ToStringBuilder", "(", "String", ".", "format", "(", "\"%s %s@%x\"", ",", "(", "arbitrarilyClosed", "?", "\"Reopened\"", ":", "\"Opened\"", ")", ",", "sqlSession", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ",", "sqlSession", ".", "hashCode", "(", ")", ")", ")", ";", "tsb", ".", "append", "(", "\"executorType\"", ",", "executorType", ")", ";", "tsb", ".", "append", "(", "\"autoCommit\"", ",", "autoCommit", ")", ";", "log", ".", "debug", "(", "tsb", ".", "toString", "(", ")", ")", ";", "}", "arbitrarilyClosed", "=", "false", ";", "}", "}" ]
Opens a new SqlSession and store its instance inside. Therefore, whenever there is a request for a SqlSessionTxAdvice bean, a new bean instance of the object must be created.
[ "Opens", "a", "new", "SqlSession", "and", "store", "its", "instance", "inside", ".", "Therefore", "whenever", "there", "is", "a", "request", "for", "a", "SqlSessionTxAdvice", "bean", "a", "new", "bean", "instance", "of", "the", "object", "must", "be", "created", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/with-mybatis/src/main/java/com/aspectran/mybatis/SqlSessionTxAdvice.java#L72-L92
142,773
aspectran/aspectran
with-mybatis/src/main/java/com/aspectran/mybatis/SqlSessionTxAdvice.java
SqlSessionTxAdvice.commit
public void commit(boolean force) { if (checkSession()) { return; } if (log.isDebugEnabled()) { ToStringBuilder tsb = new ToStringBuilder(String.format("Committing transactional %s@%x", sqlSession.getClass().getSimpleName(),sqlSession.hashCode())); tsb.append("force", force); log.debug(tsb.toString()); } sqlSession.commit(force); }
java
public void commit(boolean force) { if (checkSession()) { return; } if (log.isDebugEnabled()) { ToStringBuilder tsb = new ToStringBuilder(String.format("Committing transactional %s@%x", sqlSession.getClass().getSimpleName(),sqlSession.hashCode())); tsb.append("force", force); log.debug(tsb.toString()); } sqlSession.commit(force); }
[ "public", "void", "commit", "(", "boolean", "force", ")", "{", "if", "(", "checkSession", "(", ")", ")", "{", "return", ";", "}", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "ToStringBuilder", "tsb", "=", "new", "ToStringBuilder", "(", "String", ".", "format", "(", "\"Committing transactional %s@%x\"", ",", "sqlSession", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ",", "sqlSession", ".", "hashCode", "(", ")", ")", ")", ";", "tsb", ".", "append", "(", "\"force\"", ",", "force", ")", ";", "log", ".", "debug", "(", "tsb", ".", "toString", "(", ")", ")", ";", "}", "sqlSession", ".", "commit", "(", "force", ")", ";", "}" ]
Flushes batch statements and commits database connection. @param force forces connection commit
[ "Flushes", "batch", "statements", "and", "commits", "database", "connection", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/with-mybatis/src/main/java/com/aspectran/mybatis/SqlSessionTxAdvice.java#L134-L147
142,774
aspectran/aspectran
with-mybatis/src/main/java/com/aspectran/mybatis/SqlSessionTxAdvice.java
SqlSessionTxAdvice.close
public void close(boolean arbitrarily) { if (checkSession()) { return; } arbitrarilyClosed = arbitrarily; sqlSession.close(); if (log.isDebugEnabled()) { log.debug(String.format("Closed %s@%x", sqlSession.getClass().getSimpleName(), sqlSession.hashCode())); } sqlSession = null; }
java
public void close(boolean arbitrarily) { if (checkSession()) { return; } arbitrarilyClosed = arbitrarily; sqlSession.close(); if (log.isDebugEnabled()) { log.debug(String.format("Closed %s@%x", sqlSession.getClass().getSimpleName(), sqlSession.hashCode())); } sqlSession = null; }
[ "public", "void", "close", "(", "boolean", "arbitrarily", ")", "{", "if", "(", "checkSession", "(", ")", ")", "{", "return", ";", "}", "arbitrarilyClosed", "=", "arbitrarily", ";", "sqlSession", ".", "close", "(", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "String", ".", "format", "(", "\"Closed %s@%x\"", ",", "sqlSession", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ",", "sqlSession", ".", "hashCode", "(", ")", ")", ")", ";", "}", "sqlSession", "=", "null", ";", "}" ]
Closes the session arbitrarily. If the transaction advice does not finally close the session, the session will automatically reopen whenever necessary. @param arbitrarily true if the session is closed arbitrarily; otherwise false
[ "Closes", "the", "session", "arbitrarily", ".", "If", "the", "transaction", "advice", "does", "not", "finally", "close", "the", "session", "the", "session", "will", "automatically", "reopen", "whenever", "necessary", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/with-mybatis/src/main/java/com/aspectran/mybatis/SqlSessionTxAdvice.java#L202-L217
142,775
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/MultiException.java
MultiException.ifExceptionThrow
public void ifExceptionThrow() throws Exception { if(nested == null || nested.isEmpty()) { return; } if (nested.size() == 1) { Throwable th = nested.get(0); if (th instanceof Error) { throw (Error)th; } if (th instanceof Exception) { throw (Exception)th; } } throw this; }
java
public void ifExceptionThrow() throws Exception { if(nested == null || nested.isEmpty()) { return; } if (nested.size() == 1) { Throwable th = nested.get(0); if (th instanceof Error) { throw (Error)th; } if (th instanceof Exception) { throw (Exception)th; } } throw this; }
[ "public", "void", "ifExceptionThrow", "(", ")", "throws", "Exception", "{", "if", "(", "nested", "==", "null", "||", "nested", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "if", "(", "nested", ".", "size", "(", ")", "==", "1", ")", "{", "Throwable", "th", "=", "nested", ".", "get", "(", "0", ")", ";", "if", "(", "th", "instanceof", "Error", ")", "{", "throw", "(", "Error", ")", "th", ";", "}", "if", "(", "th", "instanceof", "Exception", ")", "{", "throw", "(", "Exception", ")", "th", ";", "}", "}", "throw", "this", ";", "}" ]
Throw a MultiException. If this multi exception is empty then no action is taken. If it contains a single exception that is thrown, otherwise the this multi exception is thrown. @exception Exception the Error or Exception if nested is 1, or the MultiException itself if nested is more than 1.
[ "Throw", "a", "MultiException", ".", "If", "this", "multi", "exception", "is", "empty", "then", "no", "action", "is", "taken", ".", "If", "it", "contains", "a", "single", "exception", "that", "is", "thrown", "otherwise", "the", "this", "multi", "exception", "is", "thrown", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/MultiException.java#L80-L94
142,776
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/MultiException.java
MultiException.ifExceptionThrowRuntime
public void ifExceptionThrowRuntime() throws Error { if(nested == null || nested.isEmpty()) { return; } if (nested.size() == 1) { Throwable th = nested.get(0); if (th instanceof Error) { throw (Error)th; } else if (th instanceof RuntimeException) { throw (RuntimeException)th; } else { throw new RuntimeException(th); } } throw new RuntimeException(this); }
java
public void ifExceptionThrowRuntime() throws Error { if(nested == null || nested.isEmpty()) { return; } if (nested.size() == 1) { Throwable th = nested.get(0); if (th instanceof Error) { throw (Error)th; } else if (th instanceof RuntimeException) { throw (RuntimeException)th; } else { throw new RuntimeException(th); } } throw new RuntimeException(this); }
[ "public", "void", "ifExceptionThrowRuntime", "(", ")", "throws", "Error", "{", "if", "(", "nested", "==", "null", "||", "nested", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "if", "(", "nested", ".", "size", "(", ")", "==", "1", ")", "{", "Throwable", "th", "=", "nested", ".", "get", "(", "0", ")", ";", "if", "(", "th", "instanceof", "Error", ")", "{", "throw", "(", "Error", ")", "th", ";", "}", "else", "if", "(", "th", "instanceof", "RuntimeException", ")", "{", "throw", "(", "RuntimeException", ")", "th", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "th", ")", ";", "}", "}", "throw", "new", "RuntimeException", "(", "this", ")", ";", "}" ]
Throw a Runtime exception. If this multi exception is empty then no action is taken. If it contains a single error or runtime exception that is thrown, otherwise the this multi exception is thrown, wrapped in a runtime exception. @exception Error if this exception contains exactly 1 {@link Error} @exception RuntimeException if this exception contains 1 {@link Throwable} but it is not an error, or it contains more than 1 {@link Throwable} of any type
[ "Throw", "a", "Runtime", "exception", ".", "If", "this", "multi", "exception", "is", "empty", "then", "no", "action", "is", "taken", ".", "If", "it", "contains", "a", "single", "error", "or", "runtime", "exception", "that", "is", "thrown", "otherwise", "the", "this", "multi", "exception", "is", "thrown", "wrapped", "in", "a", "runtime", "exception", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/MultiException.java#L106-L121
142,777
aspectran/aspectran
shell/src/main/java/com/aspectran/shell/command/option/HelpFormatter.java
HelpFormatter.printHelp
public void printHelp(Command command) { if (command.getDescriptor().getUsage() != null) { printUsage(command.getDescriptor().getUsage()); } else { printUsage(command); } int leftWidth = printOptions(command.getOptions()); printArguments(command.getArgumentsList(), leftWidth); }
java
public void printHelp(Command command) { if (command.getDescriptor().getUsage() != null) { printUsage(command.getDescriptor().getUsage()); } else { printUsage(command); } int leftWidth = printOptions(command.getOptions()); printArguments(command.getArgumentsList(), leftWidth); }
[ "public", "void", "printHelp", "(", "Command", "command", ")", "{", "if", "(", "command", ".", "getDescriptor", "(", ")", ".", "getUsage", "(", ")", "!=", "null", ")", "{", "printUsage", "(", "command", ".", "getDescriptor", "(", ")", ".", "getUsage", "(", ")", ")", ";", "}", "else", "{", "printUsage", "(", "command", ")", ";", "}", "int", "leftWidth", "=", "printOptions", "(", "command", ".", "getOptions", "(", ")", ")", ";", "printArguments", "(", "command", ".", "getArgumentsList", "(", ")", ",", "leftWidth", ")", ";", "}" ]
Print the help with the given Command object. @param command the Command instance
[ "Print", "the", "help", "with", "the", "given", "Command", "object", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/shell/src/main/java/com/aspectran/shell/command/option/HelpFormatter.java#L180-L188
142,778
aspectran/aspectran
shell/src/main/java/com/aspectran/shell/command/option/HelpFormatter.java
HelpFormatter.printUsage
public void printUsage(Command command) { String commandName = command.getDescriptor().getName(); StringBuilder sb = new StringBuilder(getSyntaxPrefix()).append(commandName).append(" "); // create a list for processed option groups Collection<OptionGroup> processedGroups = new ArrayList<>(); Collection<Option> optList = command.getOptions().getAllOptions(); if (optList.size() > 1 && getOptionComparator() != null) { List<Option> optList2 = new ArrayList<>(optList); optList2.sort(getOptionComparator()); optList = optList2; } for (Iterator<Option> it = optList.iterator(); it.hasNext();) { // get the next Option Option option = it.next(); // check if the option is part of an OptionGroup OptionGroup group = command.getOptions().getOptionGroup(option); if (group != null) { // if the group has not already been processed if (!processedGroups.contains(group)) { // add the group to the processed list processedGroups.add(group); // add the usage clause appendOptionGroup(sb, group); } // otherwise the option was displayed in the group // previously so ignore it. } // if the Option is not part of an OptionGroup else { appendOption(sb, option, option.isRequired()); } if (it.hasNext()) { sb.append(" "); } } for (Arguments arguments : command.getArgumentsList()) { sb.append(" "); appendArguments(sb, arguments); } printWrapped(getSyntaxPrefix().length() + commandName.length() + 1, sb.toString()); }
java
public void printUsage(Command command) { String commandName = command.getDescriptor().getName(); StringBuilder sb = new StringBuilder(getSyntaxPrefix()).append(commandName).append(" "); // create a list for processed option groups Collection<OptionGroup> processedGroups = new ArrayList<>(); Collection<Option> optList = command.getOptions().getAllOptions(); if (optList.size() > 1 && getOptionComparator() != null) { List<Option> optList2 = new ArrayList<>(optList); optList2.sort(getOptionComparator()); optList = optList2; } for (Iterator<Option> it = optList.iterator(); it.hasNext();) { // get the next Option Option option = it.next(); // check if the option is part of an OptionGroup OptionGroup group = command.getOptions().getOptionGroup(option); if (group != null) { // if the group has not already been processed if (!processedGroups.contains(group)) { // add the group to the processed list processedGroups.add(group); // add the usage clause appendOptionGroup(sb, group); } // otherwise the option was displayed in the group // previously so ignore it. } // if the Option is not part of an OptionGroup else { appendOption(sb, option, option.isRequired()); } if (it.hasNext()) { sb.append(" "); } } for (Arguments arguments : command.getArgumentsList()) { sb.append(" "); appendArguments(sb, arguments); } printWrapped(getSyntaxPrefix().length() + commandName.length() + 1, sb.toString()); }
[ "public", "void", "printUsage", "(", "Command", "command", ")", "{", "String", "commandName", "=", "command", ".", "getDescriptor", "(", ")", ".", "getName", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "getSyntaxPrefix", "(", ")", ")", ".", "append", "(", "commandName", ")", ".", "append", "(", "\" \"", ")", ";", "// create a list for processed option groups", "Collection", "<", "OptionGroup", ">", "processedGroups", "=", "new", "ArrayList", "<>", "(", ")", ";", "Collection", "<", "Option", ">", "optList", "=", "command", ".", "getOptions", "(", ")", ".", "getAllOptions", "(", ")", ";", "if", "(", "optList", ".", "size", "(", ")", ">", "1", "&&", "getOptionComparator", "(", ")", "!=", "null", ")", "{", "List", "<", "Option", ">", "optList2", "=", "new", "ArrayList", "<>", "(", "optList", ")", ";", "optList2", ".", "sort", "(", "getOptionComparator", "(", ")", ")", ";", "optList", "=", "optList2", ";", "}", "for", "(", "Iterator", "<", "Option", ">", "it", "=", "optList", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "// get the next Option", "Option", "option", "=", "it", ".", "next", "(", ")", ";", "// check if the option is part of an OptionGroup", "OptionGroup", "group", "=", "command", ".", "getOptions", "(", ")", ".", "getOptionGroup", "(", "option", ")", ";", "if", "(", "group", "!=", "null", ")", "{", "// if the group has not already been processed", "if", "(", "!", "processedGroups", ".", "contains", "(", "group", ")", ")", "{", "// add the group to the processed list", "processedGroups", ".", "add", "(", "group", ")", ";", "// add the usage clause", "appendOptionGroup", "(", "sb", ",", "group", ")", ";", "}", "// otherwise the option was displayed in the group", "// previously so ignore it.", "}", "// if the Option is not part of an OptionGroup", "else", "{", "appendOption", "(", "sb", ",", "option", ",", "option", ".", "isRequired", "(", ")", ")", ";", "}", "if", "(", "it", ".", "hasNext", "(", ")", ")", "{", "sb", ".", "append", "(", "\" \"", ")", ";", "}", "}", "for", "(", "Arguments", "arguments", ":", "command", ".", "getArgumentsList", "(", ")", ")", "{", "sb", ".", "append", "(", "\" \"", ")", ";", "appendArguments", "(", "sb", ",", "arguments", ")", ";", "}", "printWrapped", "(", "getSyntaxPrefix", "(", ")", ".", "length", "(", ")", "+", "commandName", ".", "length", "(", ")", "+", "1", ",", "sb", ".", "toString", "(", ")", ")", ";", "}" ]
Prints the usage statement for the specified command. @param command the Command instance
[ "Prints", "the", "usage", "statement", "for", "the", "specified", "command", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/shell/src/main/java/com/aspectran/shell/command/option/HelpFormatter.java#L206-L251
142,779
aspectran/aspectran
shell/src/main/java/com/aspectran/shell/command/option/HelpFormatter.java
HelpFormatter.appendOptionGroup
private void appendOptionGroup(StringBuilder sb, OptionGroup group) { if (!group.isRequired()) { sb.append(OPTIONAL_BRACKET_OPEN); } List<Option> optList = new ArrayList<>(group.getOptions()); if (optList.size() > 1 && getOptionComparator() != null) { optList.sort(getOptionComparator()); } // for each option in the OptionGroup for (Iterator<Option> it = optList.iterator(); it.hasNext();) { // whether the option is required or not is handled at group level appendOption(sb, it.next(), true); if (it.hasNext()) { sb.append(" | "); } } if (!group.isRequired()) { sb.append(OPTIONAL_BRACKET_CLOSE); } }
java
private void appendOptionGroup(StringBuilder sb, OptionGroup group) { if (!group.isRequired()) { sb.append(OPTIONAL_BRACKET_OPEN); } List<Option> optList = new ArrayList<>(group.getOptions()); if (optList.size() > 1 && getOptionComparator() != null) { optList.sort(getOptionComparator()); } // for each option in the OptionGroup for (Iterator<Option> it = optList.iterator(); it.hasNext();) { // whether the option is required or not is handled at group level appendOption(sb, it.next(), true); if (it.hasNext()) { sb.append(" | "); } } if (!group.isRequired()) { sb.append(OPTIONAL_BRACKET_CLOSE); } }
[ "private", "void", "appendOptionGroup", "(", "StringBuilder", "sb", ",", "OptionGroup", "group", ")", "{", "if", "(", "!", "group", ".", "isRequired", "(", ")", ")", "{", "sb", ".", "append", "(", "OPTIONAL_BRACKET_OPEN", ")", ";", "}", "List", "<", "Option", ">", "optList", "=", "new", "ArrayList", "<>", "(", "group", ".", "getOptions", "(", ")", ")", ";", "if", "(", "optList", ".", "size", "(", ")", ">", "1", "&&", "getOptionComparator", "(", ")", "!=", "null", ")", "{", "optList", ".", "sort", "(", "getOptionComparator", "(", ")", ")", ";", "}", "// for each option in the OptionGroup", "for", "(", "Iterator", "<", "Option", ">", "it", "=", "optList", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "// whether the option is required or not is handled at group level", "appendOption", "(", "sb", ",", "it", ".", "next", "(", ")", ",", "true", ")", ";", "if", "(", "it", ".", "hasNext", "(", ")", ")", "{", "sb", ".", "append", "(", "\" | \"", ")", ";", "}", "}", "if", "(", "!", "group", ".", "isRequired", "(", ")", ")", "{", "sb", ".", "append", "(", "OPTIONAL_BRACKET_CLOSE", ")", ";", "}", "}" ]
Appends the usage clause for an OptionGroup to a StringBuilder. The clause is wrapped in square brackets if the group is required. The display of the options is handled by appendOption. @param sb the StringBuilder to append to @param group the group to append
[ "Appends", "the", "usage", "clause", "for", "an", "OptionGroup", "to", "a", "StringBuilder", ".", "The", "clause", "is", "wrapped", "in", "square", "brackets", "if", "the", "group", "is", "required", ".", "The", "display", "of", "the", "options", "is", "handled", "by", "appendOption", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/shell/src/main/java/com/aspectran/shell/command/option/HelpFormatter.java#L261-L280
142,780
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/BeanMethodActionRule.java
BeanMethodActionRule.newArgumentItemRule
public ItemRule newArgumentItemRule(String argumentName) { ItemRule itemRule = new ItemRule(); itemRule.setName(argumentName); addArgumentItemRule(itemRule); return itemRule; }
java
public ItemRule newArgumentItemRule(String argumentName) { ItemRule itemRule = new ItemRule(); itemRule.setName(argumentName); addArgumentItemRule(itemRule); return itemRule; }
[ "public", "ItemRule", "newArgumentItemRule", "(", "String", "argumentName", ")", "{", "ItemRule", "itemRule", "=", "new", "ItemRule", "(", ")", ";", "itemRule", ".", "setName", "(", "argumentName", ")", ";", "addArgumentItemRule", "(", "itemRule", ")", ";", "return", "itemRule", ";", "}" ]
Adds a new argument rule with the specified name and returns it. @param argumentName the argument name @return the argument item rule
[ "Adds", "a", "new", "argument", "rule", "with", "the", "specified", "name", "and", "returns", "it", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/BeanMethodActionRule.java#L181-L186
142,781
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/BeanMethodActionRule.java
BeanMethodActionRule.addArgumentItemRule
public void addArgumentItemRule(ItemRule argumentItemRule) { if (argumentItemRuleMap == null) { argumentItemRuleMap = new ItemRuleMap(); } argumentItemRuleMap.putItemRule(argumentItemRule); }
java
public void addArgumentItemRule(ItemRule argumentItemRule) { if (argumentItemRuleMap == null) { argumentItemRuleMap = new ItemRuleMap(); } argumentItemRuleMap.putItemRule(argumentItemRule); }
[ "public", "void", "addArgumentItemRule", "(", "ItemRule", "argumentItemRule", ")", "{", "if", "(", "argumentItemRuleMap", "==", "null", ")", "{", "argumentItemRuleMap", "=", "new", "ItemRuleMap", "(", ")", ";", "}", "argumentItemRuleMap", ".", "putItemRule", "(", "argumentItemRule", ")", ";", "}" ]
Adds the argument item rule. @param argumentItemRule the new argument item rule
[ "Adds", "the", "argument", "item", "rule", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/BeanMethodActionRule.java#L193-L198
142,782
aspectran/aspectran
core/src/main/java/com/aspectran/core/context/rule/BeanMethodActionRule.java
BeanMethodActionRule.newInstance
public static BeanMethodActionRule newInstance(String id, String beanId, String methodName, Boolean hidden) throws IllegalRuleException { if (methodName == null) { throw new IllegalRuleException("The 'action' element requires an 'method' attribute"); } BeanMethodActionRule beanMethodActionRule = new BeanMethodActionRule(); beanMethodActionRule.setActionId(id); beanMethodActionRule.setBeanId(beanId); beanMethodActionRule.setMethodName(methodName); beanMethodActionRule.setHidden(hidden); return beanMethodActionRule; }
java
public static BeanMethodActionRule newInstance(String id, String beanId, String methodName, Boolean hidden) throws IllegalRuleException { if (methodName == null) { throw new IllegalRuleException("The 'action' element requires an 'method' attribute"); } BeanMethodActionRule beanMethodActionRule = new BeanMethodActionRule(); beanMethodActionRule.setActionId(id); beanMethodActionRule.setBeanId(beanId); beanMethodActionRule.setMethodName(methodName); beanMethodActionRule.setHidden(hidden); return beanMethodActionRule; }
[ "public", "static", "BeanMethodActionRule", "newInstance", "(", "String", "id", ",", "String", "beanId", ",", "String", "methodName", ",", "Boolean", "hidden", ")", "throws", "IllegalRuleException", "{", "if", "(", "methodName", "==", "null", ")", "{", "throw", "new", "IllegalRuleException", "(", "\"The 'action' element requires an 'method' attribute\"", ")", ";", "}", "BeanMethodActionRule", "beanMethodActionRule", "=", "new", "BeanMethodActionRule", "(", ")", ";", "beanMethodActionRule", ".", "setActionId", "(", "id", ")", ";", "beanMethodActionRule", ".", "setBeanId", "(", "beanId", ")", ";", "beanMethodActionRule", ".", "setMethodName", "(", "methodName", ")", ";", "beanMethodActionRule", ".", "setHidden", "(", "hidden", ")", ";", "return", "beanMethodActionRule", ";", "}" ]
Returns a new instance of BeanActionRule. @param id the action id @param beanId the bean id @param methodName the method name @param hidden true if hiding the result of the action; false otherwise @return the bean method action rule @throws IllegalRuleException if an illegal rule is found
[ "Returns", "a", "new", "instance", "of", "BeanActionRule", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/context/rule/BeanMethodActionRule.java#L274-L286
142,783
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/request/ParameterMap.java
ParameterMap.setAll
public void setAll(Map<String, String> params) { for (Map.Entry<String, String> entry : params.entrySet()) { setParameter(entry.getKey(), entry.getValue()); } }
java
public void setAll(Map<String, String> params) { for (Map.Entry<String, String> entry : params.entrySet()) { setParameter(entry.getKey(), entry.getValue()); } }
[ "public", "void", "setAll", "(", "Map", "<", "String", ",", "String", ">", "params", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ":", "params", ".", "entrySet", "(", ")", ")", "{", "setParameter", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}" ]
Set the given parameters under. @param params the other parameter map
[ "Set", "the", "given", "parameters", "under", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/request/ParameterMap.java#L125-L129
142,784
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/ActivityDataMap.java
ActivityDataMap.getParameterWithoutCache
public Object getParameterWithoutCache(String name) { if (activity.getRequestAdapter() != null) { String[] values = activity.getRequestAdapter().getParameterValues(name); if (values != null) { if (values.length == 1) { return values[0]; } else { return values; } } } return null; }
java
public Object getParameterWithoutCache(String name) { if (activity.getRequestAdapter() != null) { String[] values = activity.getRequestAdapter().getParameterValues(name); if (values != null) { if (values.length == 1) { return values[0]; } else { return values; } } } return null; }
[ "public", "Object", "getParameterWithoutCache", "(", "String", "name", ")", "{", "if", "(", "activity", ".", "getRequestAdapter", "(", ")", "!=", "null", ")", "{", "String", "[", "]", "values", "=", "activity", ".", "getRequestAdapter", "(", ")", ".", "getParameterValues", "(", "name", ")", ";", "if", "(", "values", "!=", "null", ")", "{", "if", "(", "values", ".", "length", "==", "1", ")", "{", "return", "values", "[", "0", "]", ";", "}", "else", "{", "return", "values", ";", "}", "}", "}", "return", "null", ";", "}" ]
Returns the value of the request parameter from the request adapter without storing it in the cache. If the parameter does not exist, returns null. @param name a {@code String} specifying the name of the parameter @return an {@code Object} containing the value of the parameter, or {@code null} if the parameter does not exist @see RequestAdapter#setParameter
[ "Returns", "the", "value", "of", "the", "request", "parameter", "from", "the", "request", "adapter", "without", "storing", "it", "in", "the", "cache", ".", "If", "the", "parameter", "does", "not", "exist", "returns", "null", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/ActivityDataMap.java#L141-L153
142,785
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/ActivityDataMap.java
ActivityDataMap.getAttributeWithoutCache
public Object getAttributeWithoutCache(String name) { if (activity.getRequestAdapter() != null) { return activity.getRequestAdapter().getAttribute(name); } else { return null; } }
java
public Object getAttributeWithoutCache(String name) { if (activity.getRequestAdapter() != null) { return activity.getRequestAdapter().getAttribute(name); } else { return null; } }
[ "public", "Object", "getAttributeWithoutCache", "(", "String", "name", ")", "{", "if", "(", "activity", ".", "getRequestAdapter", "(", ")", "!=", "null", ")", "{", "return", "activity", ".", "getRequestAdapter", "(", ")", ".", "getAttribute", "(", "name", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns the value of the named attribute from the request adapter without storing it in the cache. If no attribute of the given name exists, returns null. @param name a {@code String} specifying the name of the attribute @return an {@code Object} containing the value of the attribute, or {@code null} if the attribute does not exist @see RequestAdapter#getAttribute
[ "Returns", "the", "value", "of", "the", "named", "attribute", "from", "the", "request", "adapter", "without", "storing", "it", "in", "the", "cache", ".", "If", "no", "attribute", "of", "the", "given", "name", "exists", "returns", "null", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/ActivityDataMap.java#L165-L171
142,786
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/ActivityDataMap.java
ActivityDataMap.getActionResultWithoutCache
public Object getActionResultWithoutCache(String name) { if (activity.getProcessResult() != null) { return activity.getProcessResult().getResultValue(name); } else { return null; } }
java
public Object getActionResultWithoutCache(String name) { if (activity.getProcessResult() != null) { return activity.getProcessResult().getResultValue(name); } else { return null; } }
[ "public", "Object", "getActionResultWithoutCache", "(", "String", "name", ")", "{", "if", "(", "activity", ".", "getProcessResult", "(", ")", "!=", "null", ")", "{", "return", "activity", ".", "getProcessResult", "(", ")", ".", "getResultValue", "(", "name", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns the value of the named action's process result without storing it in the cache. If no process result of the given name exists, returns null. @param name a {@code String} specifying the name of the action @return an {@code Object} containing the value of the action result, or {@code null} if the action result does not exist
[ "Returns", "the", "value", "of", "the", "named", "action", "s", "process", "result", "without", "storing", "it", "in", "the", "cache", ".", "If", "no", "process", "result", "of", "the", "given", "name", "exists", "returns", "null", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/ActivityDataMap.java#L182-L188
142,787
aspectran/aspectran
core/src/main/java/com/aspectran/core/activity/ActivityDataMap.java
ActivityDataMap.getSessionAttributeWithoutCache
public Object getSessionAttributeWithoutCache(String name) { if (activity.getSessionAdapter() != null) { return activity.getSessionAdapter().getAttribute(name); } else { return null; } }
java
public Object getSessionAttributeWithoutCache(String name) { if (activity.getSessionAdapter() != null) { return activity.getSessionAdapter().getAttribute(name); } else { return null; } }
[ "public", "Object", "getSessionAttributeWithoutCache", "(", "String", "name", ")", "{", "if", "(", "activity", ".", "getSessionAdapter", "(", ")", "!=", "null", ")", "{", "return", "activity", ".", "getSessionAdapter", "(", ")", ".", "getAttribute", "(", "name", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns the value of the named attribute from the session adapter without storing it in the cache. If no attribute of the given name exists, returns null. @param name a {@code String} specifying the name of the attribute @return an {@code Object} containing the value of the attribute, or {@code null} if the attribute does not exist @see SessionAdapter#getAttribute
[ "Returns", "the", "value", "of", "the", "named", "attribute", "from", "the", "session", "adapter", "without", "storing", "it", "in", "the", "cache", ".", "If", "no", "attribute", "of", "the", "given", "name", "exists", "returns", "null", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/activity/ActivityDataMap.java#L200-L206
142,788
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/AbstractSessionCache.java
AbstractSessionCache.get
@Override public Session get(String id) throws Exception { Session session; Exception ex = null; while (true) { session = doGet(id); if (sessionDataStore == null) { break; // can't load any session data so just return null or the session object } if (session == null) { if (log.isDebugEnabled()) { log.debug("Session " + id + " not found locally, attempting to load"); } // didn't get a session, try and create one and put in a placeholder for it PlaceHolderSession phs = new PlaceHolderSession (new SessionData(id, 0, 0, 0, 0)); Lock phsLock = phs.lock(); Session s = doPutIfAbsent(id, phs); if (s == null) { // My placeholder won, go ahead and load the full session data try { session = loadSession(id); if (session == null) { // session does not exist, remove the placeholder doDelete(id); phsLock.close(); break; } try (Lock ignored = session.lock()) { // swap it in instead of the placeholder boolean success = doReplace(id, phs, session); if (!success) { // something has gone wrong, it should have been our placeholder doDelete(id); session = null; log.warn("Replacement of placeholder for session " + id + " failed"); phsLock.close(); break; } else { // successfully swapped in the session session.setResident(true); session.updateInactivityTimer(); phsLock.close(); break; } } } catch (Exception e) { ex = e; // remember a problem happened loading the session doDelete(id); // remove the placeholder phsLock.close(); session = null; break; } } else { // my placeholder didn't win, check the session returned phsLock.close(); try (Lock ignored = s.lock()) { // is it a placeholder? or is a non-resident session? In both cases, chuck it away and start again if (!s.isResident() || s instanceof PlaceHolderSession) { continue; } session = s; break; } } } else { // check the session returned try (Lock ignored = session.lock()) { // is it a placeholder? or is it passivated? In both cases, chuck it away and start again if (!session.isResident() || session instanceof PlaceHolderSession) { continue; } // got the session break; } } } if (ex != null) { throw ex; } return session; }
java
@Override public Session get(String id) throws Exception { Session session; Exception ex = null; while (true) { session = doGet(id); if (sessionDataStore == null) { break; // can't load any session data so just return null or the session object } if (session == null) { if (log.isDebugEnabled()) { log.debug("Session " + id + " not found locally, attempting to load"); } // didn't get a session, try and create one and put in a placeholder for it PlaceHolderSession phs = new PlaceHolderSession (new SessionData(id, 0, 0, 0, 0)); Lock phsLock = phs.lock(); Session s = doPutIfAbsent(id, phs); if (s == null) { // My placeholder won, go ahead and load the full session data try { session = loadSession(id); if (session == null) { // session does not exist, remove the placeholder doDelete(id); phsLock.close(); break; } try (Lock ignored = session.lock()) { // swap it in instead of the placeholder boolean success = doReplace(id, phs, session); if (!success) { // something has gone wrong, it should have been our placeholder doDelete(id); session = null; log.warn("Replacement of placeholder for session " + id + " failed"); phsLock.close(); break; } else { // successfully swapped in the session session.setResident(true); session.updateInactivityTimer(); phsLock.close(); break; } } } catch (Exception e) { ex = e; // remember a problem happened loading the session doDelete(id); // remove the placeholder phsLock.close(); session = null; break; } } else { // my placeholder didn't win, check the session returned phsLock.close(); try (Lock ignored = s.lock()) { // is it a placeholder? or is a non-resident session? In both cases, chuck it away and start again if (!s.isResident() || s instanceof PlaceHolderSession) { continue; } session = s; break; } } } else { // check the session returned try (Lock ignored = session.lock()) { // is it a placeholder? or is it passivated? In both cases, chuck it away and start again if (!session.isResident() || session instanceof PlaceHolderSession) { continue; } // got the session break; } } } if (ex != null) { throw ex; } return session; }
[ "@", "Override", "public", "Session", "get", "(", "String", "id", ")", "throws", "Exception", "{", "Session", "session", ";", "Exception", "ex", "=", "null", ";", "while", "(", "true", ")", "{", "session", "=", "doGet", "(", "id", ")", ";", "if", "(", "sessionDataStore", "==", "null", ")", "{", "break", ";", "// can't load any session data so just return null or the session object", "}", "if", "(", "session", "==", "null", ")", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Session \"", "+", "id", "+", "\" not found locally, attempting to load\"", ")", ";", "}", "// didn't get a session, try and create one and put in a placeholder for it", "PlaceHolderSession", "phs", "=", "new", "PlaceHolderSession", "(", "new", "SessionData", "(", "id", ",", "0", ",", "0", ",", "0", ",", "0", ")", ")", ";", "Lock", "phsLock", "=", "phs", ".", "lock", "(", ")", ";", "Session", "s", "=", "doPutIfAbsent", "(", "id", ",", "phs", ")", ";", "if", "(", "s", "==", "null", ")", "{", "// My placeholder won, go ahead and load the full session data", "try", "{", "session", "=", "loadSession", "(", "id", ")", ";", "if", "(", "session", "==", "null", ")", "{", "// session does not exist, remove the placeholder", "doDelete", "(", "id", ")", ";", "phsLock", ".", "close", "(", ")", ";", "break", ";", "}", "try", "(", "Lock", "ignored", "=", "session", ".", "lock", "(", ")", ")", "{", "// swap it in instead of the placeholder", "boolean", "success", "=", "doReplace", "(", "id", ",", "phs", ",", "session", ")", ";", "if", "(", "!", "success", ")", "{", "// something has gone wrong, it should have been our placeholder", "doDelete", "(", "id", ")", ";", "session", "=", "null", ";", "log", ".", "warn", "(", "\"Replacement of placeholder for session \"", "+", "id", "+", "\" failed\"", ")", ";", "phsLock", ".", "close", "(", ")", ";", "break", ";", "}", "else", "{", "// successfully swapped in the session", "session", ".", "setResident", "(", "true", ")", ";", "session", ".", "updateInactivityTimer", "(", ")", ";", "phsLock", ".", "close", "(", ")", ";", "break", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "ex", "=", "e", ";", "// remember a problem happened loading the session", "doDelete", "(", "id", ")", ";", "// remove the placeholder", "phsLock", ".", "close", "(", ")", ";", "session", "=", "null", ";", "break", ";", "}", "}", "else", "{", "// my placeholder didn't win, check the session returned", "phsLock", ".", "close", "(", ")", ";", "try", "(", "Lock", "ignored", "=", "s", ".", "lock", "(", ")", ")", "{", "// is it a placeholder? or is a non-resident session? In both cases, chuck it away and start again", "if", "(", "!", "s", ".", "isResident", "(", ")", "||", "s", "instanceof", "PlaceHolderSession", ")", "{", "continue", ";", "}", "session", "=", "s", ";", "break", ";", "}", "}", "}", "else", "{", "// check the session returned", "try", "(", "Lock", "ignored", "=", "session", ".", "lock", "(", ")", ")", "{", "// is it a placeholder? or is it passivated? In both cases, chuck it away and start again", "if", "(", "!", "session", ".", "isResident", "(", ")", "||", "session", "instanceof", "PlaceHolderSession", ")", "{", "continue", ";", "}", "// got the session", "break", ";", "}", "}", "}", "if", "(", "ex", "!=", "null", ")", "{", "throw", "ex", ";", "}", "return", "session", ";", "}" ]
Get a session object. If the session object is not in this session store, try getting the data for it from a SessionDataStore associated with the session manager. @param id the session id
[ "Get", "a", "session", "object", ".", "If", "the", "session", "object", "is", "not", "in", "this", "session", "store", "try", "getting", "the", "data", "for", "it", "from", "a", "SessionDataStore", "associated", "with", "the", "session", "manager", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/AbstractSessionCache.java#L147-L235
142,789
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/AbstractSessionCache.java
AbstractSessionCache.loadSession
private Session loadSession(String id) throws Exception { if (sessionDataStore == null) { return null; // can't load it } try { SessionData data = sessionDataStore.load(id); if (data == null) { // session doesn't exist return null; } return newSession(data); } catch (UnreadableSessionDataException e) { // can't load the session, delete it if (isRemoveUnloadableSessions()) { sessionDataStore.delete(id); } throw e; } }
java
private Session loadSession(String id) throws Exception { if (sessionDataStore == null) { return null; // can't load it } try { SessionData data = sessionDataStore.load(id); if (data == null) { // session doesn't exist return null; } return newSession(data); } catch (UnreadableSessionDataException e) { // can't load the session, delete it if (isRemoveUnloadableSessions()) { sessionDataStore.delete(id); } throw e; } }
[ "private", "Session", "loadSession", "(", "String", "id", ")", "throws", "Exception", "{", "if", "(", "sessionDataStore", "==", "null", ")", "{", "return", "null", ";", "// can't load it", "}", "try", "{", "SessionData", "data", "=", "sessionDataStore", ".", "load", "(", "id", ")", ";", "if", "(", "data", "==", "null", ")", "{", "// session doesn't exist", "return", "null", ";", "}", "return", "newSession", "(", "data", ")", ";", "}", "catch", "(", "UnreadableSessionDataException", "e", ")", "{", "// can't load the session, delete it", "if", "(", "isRemoveUnloadableSessions", "(", ")", ")", "{", "sessionDataStore", ".", "delete", "(", "id", ")", ";", "}", "throw", "e", ";", "}", "}" ]
Load the info for the session from the session data store. @param id the session id @return a Session object filled with data or null if the session doesn't exist @throws Exception if the session can not be loaded
[ "Load", "the", "info", "for", "the", "session", "from", "the", "session", "data", "store", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/AbstractSessionCache.java#L244-L261
142,790
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/AbstractSessionCache.java
AbstractSessionCache.put
@Override public void put(String id, Session session) throws Exception { if (id == null || session == null) { throw new IllegalArgumentException("Put key=" + id + " session=" + (session == null ? "null" : session.getId())); } try (Lock ignored = session.lock()) { if (!session.isValid()) { return; } if (sessionDataStore == null) { if (log.isDebugEnabled()) { log.debug("No SessionDataStore, putting into SessionCache only id=" + id); } session.setResident(true); if (doPutIfAbsent(id, session) == null) { // ensure it is in our map session.updateInactivityTimer(); } return; } // don't do anything with the session until the last request for it has finished if ((session.getRequests() <= 0)) { // save the session if (!sessionDataStore.isPassivating()) { // if our backing datastore isn't the passivating kind, just save the session sessionDataStore.store(id, session.getSessionData()); // if we evict on session exit, boot it from the cache if (getEvictionPolicy() == EVICT_ON_SESSION_EXIT) { if (log.isDebugEnabled()) { log.debug("Eviction on request exit id=" + id); } doDelete(session.getId()); session.setResident(false); } else { session.setResident(true); if (doPutIfAbsent(id,session) == null) { // ensure it is in our map session.updateInactivityTimer(); } if (log.isDebugEnabled()) { log.debug("Non passivating SessionDataStore, session in SessionCache only id=" + id); } } } else { // backing store supports passivation, call the listeners sessionHandler.willPassivate(session); if (log.isDebugEnabled()) { log.debug("Session passivating id=" + id); } sessionDataStore.store(id, session.getSessionData()); if (getEvictionPolicy() == EVICT_ON_SESSION_EXIT) { // throw out the passivated session object from the map doDelete(id); session.setResident(false); if (log.isDebugEnabled()) { log.debug("Evicted on request exit id=" + id); } } else { // reactivate the session sessionHandler.didActivate(session); session.setResident(true); if (doPutIfAbsent(id,session) == null) // ensure it is in our map session.updateInactivityTimer(); if (log.isDebugEnabled()) { log.debug("Session reactivated id=" + id); } } } } else { if (log.isDebugEnabled()) { log.debug("Req count=" + session.getRequests() + " for id=" + id); } session.setResident(true); if (doPutIfAbsent(id, session) == null) { // ensure it is the map, but don't save it to the backing store until the last request exists session.updateInactivityTimer(); } } } }
java
@Override public void put(String id, Session session) throws Exception { if (id == null || session == null) { throw new IllegalArgumentException("Put key=" + id + " session=" + (session == null ? "null" : session.getId())); } try (Lock ignored = session.lock()) { if (!session.isValid()) { return; } if (sessionDataStore == null) { if (log.isDebugEnabled()) { log.debug("No SessionDataStore, putting into SessionCache only id=" + id); } session.setResident(true); if (doPutIfAbsent(id, session) == null) { // ensure it is in our map session.updateInactivityTimer(); } return; } // don't do anything with the session until the last request for it has finished if ((session.getRequests() <= 0)) { // save the session if (!sessionDataStore.isPassivating()) { // if our backing datastore isn't the passivating kind, just save the session sessionDataStore.store(id, session.getSessionData()); // if we evict on session exit, boot it from the cache if (getEvictionPolicy() == EVICT_ON_SESSION_EXIT) { if (log.isDebugEnabled()) { log.debug("Eviction on request exit id=" + id); } doDelete(session.getId()); session.setResident(false); } else { session.setResident(true); if (doPutIfAbsent(id,session) == null) { // ensure it is in our map session.updateInactivityTimer(); } if (log.isDebugEnabled()) { log.debug("Non passivating SessionDataStore, session in SessionCache only id=" + id); } } } else { // backing store supports passivation, call the listeners sessionHandler.willPassivate(session); if (log.isDebugEnabled()) { log.debug("Session passivating id=" + id); } sessionDataStore.store(id, session.getSessionData()); if (getEvictionPolicy() == EVICT_ON_SESSION_EXIT) { // throw out the passivated session object from the map doDelete(id); session.setResident(false); if (log.isDebugEnabled()) { log.debug("Evicted on request exit id=" + id); } } else { // reactivate the session sessionHandler.didActivate(session); session.setResident(true); if (doPutIfAbsent(id,session) == null) // ensure it is in our map session.updateInactivityTimer(); if (log.isDebugEnabled()) { log.debug("Session reactivated id=" + id); } } } } else { if (log.isDebugEnabled()) { log.debug("Req count=" + session.getRequests() + " for id=" + id); } session.setResident(true); if (doPutIfAbsent(id, session) == null) { // ensure it is the map, but don't save it to the backing store until the last request exists session.updateInactivityTimer(); } } } }
[ "@", "Override", "public", "void", "put", "(", "String", "id", ",", "Session", "session", ")", "throws", "Exception", "{", "if", "(", "id", "==", "null", "||", "session", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Put key=\"", "+", "id", "+", "\" session=\"", "+", "(", "session", "==", "null", "?", "\"null\"", ":", "session", ".", "getId", "(", ")", ")", ")", ";", "}", "try", "(", "Lock", "ignored", "=", "session", ".", "lock", "(", ")", ")", "{", "if", "(", "!", "session", ".", "isValid", "(", ")", ")", "{", "return", ";", "}", "if", "(", "sessionDataStore", "==", "null", ")", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"No SessionDataStore, putting into SessionCache only id=\"", "+", "id", ")", ";", "}", "session", ".", "setResident", "(", "true", ")", ";", "if", "(", "doPutIfAbsent", "(", "id", ",", "session", ")", "==", "null", ")", "{", "// ensure it is in our map", "session", ".", "updateInactivityTimer", "(", ")", ";", "}", "return", ";", "}", "// don't do anything with the session until the last request for it has finished", "if", "(", "(", "session", ".", "getRequests", "(", ")", "<=", "0", ")", ")", "{", "// save the session", "if", "(", "!", "sessionDataStore", ".", "isPassivating", "(", ")", ")", "{", "// if our backing datastore isn't the passivating kind, just save the session", "sessionDataStore", ".", "store", "(", "id", ",", "session", ".", "getSessionData", "(", ")", ")", ";", "// if we evict on session exit, boot it from the cache", "if", "(", "getEvictionPolicy", "(", ")", "==", "EVICT_ON_SESSION_EXIT", ")", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Eviction on request exit id=\"", "+", "id", ")", ";", "}", "doDelete", "(", "session", ".", "getId", "(", ")", ")", ";", "session", ".", "setResident", "(", "false", ")", ";", "}", "else", "{", "session", ".", "setResident", "(", "true", ")", ";", "if", "(", "doPutIfAbsent", "(", "id", ",", "session", ")", "==", "null", ")", "{", "// ensure it is in our map", "session", ".", "updateInactivityTimer", "(", ")", ";", "}", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Non passivating SessionDataStore, session in SessionCache only id=\"", "+", "id", ")", ";", "}", "}", "}", "else", "{", "// backing store supports passivation, call the listeners", "sessionHandler", ".", "willPassivate", "(", "session", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Session passivating id=\"", "+", "id", ")", ";", "}", "sessionDataStore", ".", "store", "(", "id", ",", "session", ".", "getSessionData", "(", ")", ")", ";", "if", "(", "getEvictionPolicy", "(", ")", "==", "EVICT_ON_SESSION_EXIT", ")", "{", "// throw out the passivated session object from the map", "doDelete", "(", "id", ")", ";", "session", ".", "setResident", "(", "false", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Evicted on request exit id=\"", "+", "id", ")", ";", "}", "}", "else", "{", "// reactivate the session", "sessionHandler", ".", "didActivate", "(", "session", ")", ";", "session", ".", "setResident", "(", "true", ")", ";", "if", "(", "doPutIfAbsent", "(", "id", ",", "session", ")", "==", "null", ")", "// ensure it is in our map", "session", ".", "updateInactivityTimer", "(", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Session reactivated id=\"", "+", "id", ")", ";", "}", "}", "}", "}", "else", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Req count=\"", "+", "session", ".", "getRequests", "(", ")", "+", "\" for id=\"", "+", "id", ")", ";", "}", "session", ".", "setResident", "(", "true", ")", ";", "if", "(", "doPutIfAbsent", "(", "id", ",", "session", ")", "==", "null", ")", "{", "// ensure it is the map, but don't save it to the backing store until the last request exists", "session", ".", "updateInactivityTimer", "(", ")", ";", "}", "}", "}", "}" ]
Put the Session object back into the session store. <p>This should be called when a request exists the session. Only when the last simultaneous request exists the session will any action be taken.</p> <p>If there is a SessionDataStore write the session data through to it.</p> <p>If the SessionDataStore supports passivation, call the passivate/active listeners.</p> <p>If the evictionPolicy == SessionCache.EVICT_ON_SESSION_EXIT then after we have saved the session, we evict it from the cache.</p>
[ "Put", "the", "Session", "object", "back", "into", "the", "session", "store", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/AbstractSessionCache.java#L276-L357
142,791
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/AbstractSessionCache.java
AbstractSessionCache.exists
@Override public boolean exists(String id) throws Exception { // try the object store first Session s = doGet(id); if (s != null) { try (Lock ignored = s.lock()) { // wait for the lock and check the validity of the session return s.isValid(); } } // not there, so find out if session data exists for it return (sessionDataStore != null && sessionDataStore.exists(id)); }
java
@Override public boolean exists(String id) throws Exception { // try the object store first Session s = doGet(id); if (s != null) { try (Lock ignored = s.lock()) { // wait for the lock and check the validity of the session return s.isValid(); } } // not there, so find out if session data exists for it return (sessionDataStore != null && sessionDataStore.exists(id)); }
[ "@", "Override", "public", "boolean", "exists", "(", "String", "id", ")", "throws", "Exception", "{", "// try the object store first", "Session", "s", "=", "doGet", "(", "id", ")", ";", "if", "(", "s", "!=", "null", ")", "{", "try", "(", "Lock", "ignored", "=", "s", ".", "lock", "(", ")", ")", "{", "// wait for the lock and check the validity of the session", "return", "s", ".", "isValid", "(", ")", ";", "}", "}", "// not there, so find out if session data exists for it", "return", "(", "sessionDataStore", "!=", "null", "&&", "sessionDataStore", ".", "exists", "(", "id", ")", ")", ";", "}" ]
Check to see if a session corresponding to the id exists. This method will first check with the object store. If it doesn't exist in the object store (might be passivated etc), it will check with the data store. @throws Exception the Exception
[ "Check", "to", "see", "if", "a", "session", "corresponding", "to", "the", "id", "exists", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/AbstractSessionCache.java#L368-L380
142,792
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/AbstractSessionCache.java
AbstractSessionCache.delete
@Override public Session delete(String id) throws Exception { // get the session, if its not in memory, this will load it Session session = get(id); // Always delete it from the backing data store if (sessionDataStore != null) { boolean deleted = sessionDataStore.delete(id); if (log.isDebugEnabled()) { log.debug("Session " + id + " deleted in db: " + deleted); } } // delete it from the session object store if (session != null) { session.stopInactivityTimer(); session.setResident(false); } return doDelete(id); }
java
@Override public Session delete(String id) throws Exception { // get the session, if its not in memory, this will load it Session session = get(id); // Always delete it from the backing data store if (sessionDataStore != null) { boolean deleted = sessionDataStore.delete(id); if (log.isDebugEnabled()) { log.debug("Session " + id + " deleted in db: " + deleted); } } // delete it from the session object store if (session != null) { session.stopInactivityTimer(); session.setResident(false); } return doDelete(id); }
[ "@", "Override", "public", "Session", "delete", "(", "String", "id", ")", "throws", "Exception", "{", "// get the session, if its not in memory, this will load it", "Session", "session", "=", "get", "(", "id", ")", ";", "// Always delete it from the backing data store", "if", "(", "sessionDataStore", "!=", "null", ")", "{", "boolean", "deleted", "=", "sessionDataStore", ".", "delete", "(", "id", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Session \"", "+", "id", "+", "\" deleted in db: \"", "+", "deleted", ")", ";", "}", "}", "// delete it from the session object store", "if", "(", "session", "!=", "null", ")", "{", "session", ".", "stopInactivityTimer", "(", ")", ";", "session", ".", "setResident", "(", "false", ")", ";", "}", "return", "doDelete", "(", "id", ")", ";", "}" ]
Remove a session object from this store and from any backing store.
[ "Remove", "a", "session", "object", "from", "this", "store", "and", "from", "any", "backing", "store", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/AbstractSessionCache.java#L395-L415
142,793
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/AbstractSessionCache.java
AbstractSessionCache.checkInactiveSession
public void checkInactiveSession(Session session) { if (session == null) { return; } if (log.isDebugEnabled()) { log.debug("Checking for idle " + session.getId()); } try (Lock ignored = session.lock()) { if (getEvictionPolicy() > 0 && session.isIdleLongerThan(getEvictionPolicy()) && session.isValid() && session.isResident() && session.getRequests() <= 0) { // Be careful with saveOnInactiveEviction - you may be able to re-animate a session that was // being managed on another node and has expired. try { if (log.isDebugEnabled()) { log.debug("Evicting idle session " + session.getId()); } // save before evicting if (isSaveOnInactiveEviction() && sessionDataStore != null) { if (sessionDataStore.isPassivating()) { sessionHandler.willPassivate(session); } sessionDataStore.store(session.getId(), session.getSessionData()); } doDelete(session.getId()); // detach from this cache session.setResident(false); } catch (Exception e) { log.warn("Passivation of idle session" + session.getId() + " failed", e); session.updateInactivityTimer(); } } } }
java
public void checkInactiveSession(Session session) { if (session == null) { return; } if (log.isDebugEnabled()) { log.debug("Checking for idle " + session.getId()); } try (Lock ignored = session.lock()) { if (getEvictionPolicy() > 0 && session.isIdleLongerThan(getEvictionPolicy()) && session.isValid() && session.isResident() && session.getRequests() <= 0) { // Be careful with saveOnInactiveEviction - you may be able to re-animate a session that was // being managed on another node and has expired. try { if (log.isDebugEnabled()) { log.debug("Evicting idle session " + session.getId()); } // save before evicting if (isSaveOnInactiveEviction() && sessionDataStore != null) { if (sessionDataStore.isPassivating()) { sessionHandler.willPassivate(session); } sessionDataStore.store(session.getId(), session.getSessionData()); } doDelete(session.getId()); // detach from this cache session.setResident(false); } catch (Exception e) { log.warn("Passivation of idle session" + session.getId() + " failed", e); session.updateInactivityTimer(); } } } }
[ "public", "void", "checkInactiveSession", "(", "Session", "session", ")", "{", "if", "(", "session", "==", "null", ")", "{", "return", ";", "}", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Checking for idle \"", "+", "session", ".", "getId", "(", ")", ")", ";", "}", "try", "(", "Lock", "ignored", "=", "session", ".", "lock", "(", ")", ")", "{", "if", "(", "getEvictionPolicy", "(", ")", ">", "0", "&&", "session", ".", "isIdleLongerThan", "(", "getEvictionPolicy", "(", ")", ")", "&&", "session", ".", "isValid", "(", ")", "&&", "session", ".", "isResident", "(", ")", "&&", "session", ".", "getRequests", "(", ")", "<=", "0", ")", "{", "// Be careful with saveOnInactiveEviction - you may be able to re-animate a session that was", "// being managed on another node and has expired.", "try", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Evicting idle session \"", "+", "session", ".", "getId", "(", ")", ")", ";", "}", "// save before evicting", "if", "(", "isSaveOnInactiveEviction", "(", ")", "&&", "sessionDataStore", "!=", "null", ")", "{", "if", "(", "sessionDataStore", ".", "isPassivating", "(", ")", ")", "{", "sessionHandler", ".", "willPassivate", "(", "session", ")", ";", "}", "sessionDataStore", ".", "store", "(", "session", ".", "getId", "(", ")", ",", "session", ".", "getSessionData", "(", ")", ")", ";", "}", "doDelete", "(", "session", ".", "getId", "(", ")", ")", ";", "// detach from this cache", "session", ".", "setResident", "(", "false", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "warn", "(", "\"Passivation of idle session\"", "+", "session", ".", "getId", "(", ")", "+", "\" failed\"", ",", "e", ")", ";", "session", ".", "updateInactivityTimer", "(", ")", ";", "}", "}", "}", "}" ]
Check a session for being inactive and thus being able to be evicted, if eviction is enabled. @param session session to check
[ "Check", "a", "session", "for", "being", "inactive", "and", "thus", "being", "able", "to", "be", "evicted", "if", "eviction", "is", "enabled", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/AbstractSessionCache.java#L453-L486
142,794
aspectran/aspectran
with-pebble/src/main/java/com/aspectran/pebble/PebbleEngineFactory.java
PebbleEngineFactory.createPebbleEngine
public PebbleEngine createPebbleEngine() { PebbleEngine.Builder builder = new PebbleEngine.Builder(); builder.strictVariables(strictVariables); if (defaultLocale != null) { builder.defaultLocale(defaultLocale); } if (templateLoaders == null) { if (templateLoaderPaths != null && templateLoaderPaths.length > 0) { List<Loader<?>> templateLoaderList = new ArrayList<>(); for (String path : templateLoaderPaths) { templateLoaderList.add(getTemplateLoaderForPath(path)); } setTemplateLoader(templateLoaderList); } } Loader<?> templateLoader = getAggregateTemplateLoader(templateLoaders); builder.loader(templateLoader); return builder.build(); }
java
public PebbleEngine createPebbleEngine() { PebbleEngine.Builder builder = new PebbleEngine.Builder(); builder.strictVariables(strictVariables); if (defaultLocale != null) { builder.defaultLocale(defaultLocale); } if (templateLoaders == null) { if (templateLoaderPaths != null && templateLoaderPaths.length > 0) { List<Loader<?>> templateLoaderList = new ArrayList<>(); for (String path : templateLoaderPaths) { templateLoaderList.add(getTemplateLoaderForPath(path)); } setTemplateLoader(templateLoaderList); } } Loader<?> templateLoader = getAggregateTemplateLoader(templateLoaders); builder.loader(templateLoader); return builder.build(); }
[ "public", "PebbleEngine", "createPebbleEngine", "(", ")", "{", "PebbleEngine", ".", "Builder", "builder", "=", "new", "PebbleEngine", ".", "Builder", "(", ")", ";", "builder", ".", "strictVariables", "(", "strictVariables", ")", ";", "if", "(", "defaultLocale", "!=", "null", ")", "{", "builder", ".", "defaultLocale", "(", "defaultLocale", ")", ";", "}", "if", "(", "templateLoaders", "==", "null", ")", "{", "if", "(", "templateLoaderPaths", "!=", "null", "&&", "templateLoaderPaths", ".", "length", ">", "0", ")", "{", "List", "<", "Loader", "<", "?", ">", ">", "templateLoaderList", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "path", ":", "templateLoaderPaths", ")", "{", "templateLoaderList", ".", "add", "(", "getTemplateLoaderForPath", "(", "path", ")", ")", ";", "}", "setTemplateLoader", "(", "templateLoaderList", ")", ";", "}", "}", "Loader", "<", "?", ">", "templateLoader", "=", "getAggregateTemplateLoader", "(", "templateLoaders", ")", ";", "builder", ".", "loader", "(", "templateLoader", ")", ";", "return", "builder", ".", "build", "(", ")", ";", "}" ]
Creates a PebbleEngine instance. @return a PebbleEngine object that can be used to create PebbleTemplate objects
[ "Creates", "a", "PebbleEngine", "instance", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/with-pebble/src/main/java/com/aspectran/pebble/PebbleEngineFactory.java#L98-L116
142,795
aspectran/aspectran
with-pebble/src/main/java/com/aspectran/pebble/PebbleEngineFactory.java
PebbleEngineFactory.getAggregateTemplateLoader
protected Loader<?> getAggregateTemplateLoader(Loader<?>[] templateLoaders) { int loaderCount = (templateLoaders == null) ? 0 : templateLoaders.length; switch (loaderCount) { case 0: // Register default template loaders. Loader<?> stringLoader = new StringLoader(); if (log.isDebugEnabled()) { log.debug("Pebble Engine Template Loader not specified. Default Template Loader registered: " + stringLoader); } return stringLoader; case 1: if (log.isDebugEnabled()) { log.debug("One Pebble Engine Template Loader registered: " + templateLoaders[0]); } return templateLoaders[0]; default: List<Loader<?>> defaultLoadingStrategies = new ArrayList<>(); Collections.addAll(defaultLoadingStrategies, templateLoaders); Loader<?> delegatingLoader = new DelegatingLoader(defaultLoadingStrategies); if (log.isDebugEnabled()) { log.debug("Multiple Pebble Engine Template Loader registered: " + delegatingLoader); } return delegatingLoader; } }
java
protected Loader<?> getAggregateTemplateLoader(Loader<?>[] templateLoaders) { int loaderCount = (templateLoaders == null) ? 0 : templateLoaders.length; switch (loaderCount) { case 0: // Register default template loaders. Loader<?> stringLoader = new StringLoader(); if (log.isDebugEnabled()) { log.debug("Pebble Engine Template Loader not specified. Default Template Loader registered: " + stringLoader); } return stringLoader; case 1: if (log.isDebugEnabled()) { log.debug("One Pebble Engine Template Loader registered: " + templateLoaders[0]); } return templateLoaders[0]; default: List<Loader<?>> defaultLoadingStrategies = new ArrayList<>(); Collections.addAll(defaultLoadingStrategies, templateLoaders); Loader<?> delegatingLoader = new DelegatingLoader(defaultLoadingStrategies); if (log.isDebugEnabled()) { log.debug("Multiple Pebble Engine Template Loader registered: " + delegatingLoader); } return delegatingLoader; } }
[ "protected", "Loader", "<", "?", ">", "getAggregateTemplateLoader", "(", "Loader", "<", "?", ">", "[", "]", "templateLoaders", ")", "{", "int", "loaderCount", "=", "(", "templateLoaders", "==", "null", ")", "?", "0", ":", "templateLoaders", ".", "length", ";", "switch", "(", "loaderCount", ")", "{", "case", "0", ":", "// Register default template loaders.", "Loader", "<", "?", ">", "stringLoader", "=", "new", "StringLoader", "(", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Pebble Engine Template Loader not specified. Default Template Loader registered: \"", "+", "stringLoader", ")", ";", "}", "return", "stringLoader", ";", "case", "1", ":", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"One Pebble Engine Template Loader registered: \"", "+", "templateLoaders", "[", "0", "]", ")", ";", "}", "return", "templateLoaders", "[", "0", "]", ";", "default", ":", "List", "<", "Loader", "<", "?", ">", ">", "defaultLoadingStrategies", "=", "new", "ArrayList", "<>", "(", ")", ";", "Collections", ".", "addAll", "(", "defaultLoadingStrategies", ",", "templateLoaders", ")", ";", "Loader", "<", "?", ">", "delegatingLoader", "=", "new", "DelegatingLoader", "(", "defaultLoadingStrategies", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Multiple Pebble Engine Template Loader registered: \"", "+", "delegatingLoader", ")", ";", "}", "return", "delegatingLoader", ";", "}", "}" ]
Return a Template Loader based on the given Template Loader list. If more than one Template Loader has been registered, a DelegatingLoader needs to be created. @param templateLoaders the final List of TemplateLoader instances @return the aggregate TemplateLoader
[ "Return", "a", "Template", "Loader", "based", "on", "the", "given", "Template", "Loader", "list", ".", "If", "more", "than", "one", "Template", "Loader", "has", "been", "registered", "a", "DelegatingLoader", "needs", "to", "be", "created", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/with-pebble/src/main/java/com/aspectran/pebble/PebbleEngineFactory.java#L125-L149
142,796
aspectran/aspectran
with-pebble/src/main/java/com/aspectran/pebble/PebbleEngineFactory.java
PebbleEngineFactory.getTemplateLoaderForPath
protected Loader<?> getTemplateLoaderForPath(String templateLoaderPath) { if (templateLoaderPath.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) { String basePackagePath = templateLoaderPath.substring(ResourceUtils.CLASSPATH_URL_PREFIX.length()); if (log.isDebugEnabled()) { log.debug("Template loader path [" + templateLoaderPath + "] resolved to class path [" + basePackagePath + "]"); } ClasspathLoader loader = new ClasspathLoader(environment.getClassLoader()); loader.setPrefix(basePackagePath); return loader; } else if (templateLoaderPath.startsWith(ResourceUtils.FILE_URL_PREFIX)) { File file = new File(templateLoaderPath.substring(ResourceUtils.FILE_URL_PREFIX.length())); String prefix = file.getAbsolutePath(); if (log.isDebugEnabled()) { log.debug("Template loader path [" + templateLoaderPath + "] resolved to file path [" + prefix + "]"); } FileLoader loader = new FileLoader(); loader.setPrefix(prefix); return loader; } else { File file = new File(environment.getBasePath(), templateLoaderPath); String prefix = file.getAbsolutePath(); if (log.isDebugEnabled()) { log.debug("Template loader path [" + templateLoaderPath + "] resolved to file path [" + prefix + "]"); } FileLoader loader = new FileLoader(); loader.setPrefix(prefix); return loader; } }
java
protected Loader<?> getTemplateLoaderForPath(String templateLoaderPath) { if (templateLoaderPath.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)) { String basePackagePath = templateLoaderPath.substring(ResourceUtils.CLASSPATH_URL_PREFIX.length()); if (log.isDebugEnabled()) { log.debug("Template loader path [" + templateLoaderPath + "] resolved to class path [" + basePackagePath + "]"); } ClasspathLoader loader = new ClasspathLoader(environment.getClassLoader()); loader.setPrefix(basePackagePath); return loader; } else if (templateLoaderPath.startsWith(ResourceUtils.FILE_URL_PREFIX)) { File file = new File(templateLoaderPath.substring(ResourceUtils.FILE_URL_PREFIX.length())); String prefix = file.getAbsolutePath(); if (log.isDebugEnabled()) { log.debug("Template loader path [" + templateLoaderPath + "] resolved to file path [" + prefix + "]"); } FileLoader loader = new FileLoader(); loader.setPrefix(prefix); return loader; } else { File file = new File(environment.getBasePath(), templateLoaderPath); String prefix = file.getAbsolutePath(); if (log.isDebugEnabled()) { log.debug("Template loader path [" + templateLoaderPath + "] resolved to file path [" + prefix + "]"); } FileLoader loader = new FileLoader(); loader.setPrefix(prefix); return loader; } }
[ "protected", "Loader", "<", "?", ">", "getTemplateLoaderForPath", "(", "String", "templateLoaderPath", ")", "{", "if", "(", "templateLoaderPath", ".", "startsWith", "(", "ResourceUtils", ".", "CLASSPATH_URL_PREFIX", ")", ")", "{", "String", "basePackagePath", "=", "templateLoaderPath", ".", "substring", "(", "ResourceUtils", ".", "CLASSPATH_URL_PREFIX", ".", "length", "(", ")", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Template loader path [\"", "+", "templateLoaderPath", "+", "\"] resolved to class path [\"", "+", "basePackagePath", "+", "\"]\"", ")", ";", "}", "ClasspathLoader", "loader", "=", "new", "ClasspathLoader", "(", "environment", ".", "getClassLoader", "(", ")", ")", ";", "loader", ".", "setPrefix", "(", "basePackagePath", ")", ";", "return", "loader", ";", "}", "else", "if", "(", "templateLoaderPath", ".", "startsWith", "(", "ResourceUtils", ".", "FILE_URL_PREFIX", ")", ")", "{", "File", "file", "=", "new", "File", "(", "templateLoaderPath", ".", "substring", "(", "ResourceUtils", ".", "FILE_URL_PREFIX", ".", "length", "(", ")", ")", ")", ";", "String", "prefix", "=", "file", ".", "getAbsolutePath", "(", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Template loader path [\"", "+", "templateLoaderPath", "+", "\"] resolved to file path [\"", "+", "prefix", "+", "\"]\"", ")", ";", "}", "FileLoader", "loader", "=", "new", "FileLoader", "(", ")", ";", "loader", ".", "setPrefix", "(", "prefix", ")", ";", "return", "loader", ";", "}", "else", "{", "File", "file", "=", "new", "File", "(", "environment", ".", "getBasePath", "(", ")", ",", "templateLoaderPath", ")", ";", "String", "prefix", "=", "file", ".", "getAbsolutePath", "(", ")", ";", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Template loader path [\"", "+", "templateLoaderPath", "+", "\"] resolved to file path [\"", "+", "prefix", "+", "\"]\"", ")", ";", "}", "FileLoader", "loader", "=", "new", "FileLoader", "(", ")", ";", "loader", ".", "setPrefix", "(", "prefix", ")", ";", "return", "loader", ";", "}", "}" ]
Determine a Pebble Engine Template Loader for the given path. @param templateLoaderPath the path to load templates from @return an appropriate Template Loader
[ "Determine", "a", "Pebble", "Engine", "Template", "Loader", "for", "the", "given", "path", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/with-pebble/src/main/java/com/aspectran/pebble/PebbleEngineFactory.java#L157-L185
142,797
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/SessionIdGenerator.java
SessionIdGenerator.newSessionId
public String newSessionId(long seedTerm) { synchronized (random) { long r0; if (weakRandom) { r0 = hashCode() ^ Runtime.getRuntime().freeMemory() ^ random.nextInt() ^ (seedTerm << 32); } else { r0 = random.nextLong(); } if (r0 < 0) { r0 = -r0; } long r1; if (weakRandom) { r1 = hashCode() ^ Runtime.getRuntime().freeMemory() ^ random.nextInt() ^ (seedTerm << 32); } else { r1 = random.nextLong(); } if (r1 < 0) { r1 = -r1; } StringBuilder id = new StringBuilder(); if (!StringUtils.isEmpty(groupName)) { id.append(groupName); } id.append(Long.toString(r0,36)); id.append(Long.toString(r1,36)); id.append(counter.getAndIncrement()); return id.toString(); } }
java
public String newSessionId(long seedTerm) { synchronized (random) { long r0; if (weakRandom) { r0 = hashCode() ^ Runtime.getRuntime().freeMemory() ^ random.nextInt() ^ (seedTerm << 32); } else { r0 = random.nextLong(); } if (r0 < 0) { r0 = -r0; } long r1; if (weakRandom) { r1 = hashCode() ^ Runtime.getRuntime().freeMemory() ^ random.nextInt() ^ (seedTerm << 32); } else { r1 = random.nextLong(); } if (r1 < 0) { r1 = -r1; } StringBuilder id = new StringBuilder(); if (!StringUtils.isEmpty(groupName)) { id.append(groupName); } id.append(Long.toString(r0,36)); id.append(Long.toString(r1,36)); id.append(counter.getAndIncrement()); return id.toString(); } }
[ "public", "String", "newSessionId", "(", "long", "seedTerm", ")", "{", "synchronized", "(", "random", ")", "{", "long", "r0", ";", "if", "(", "weakRandom", ")", "{", "r0", "=", "hashCode", "(", ")", "^", "Runtime", ".", "getRuntime", "(", ")", ".", "freeMemory", "(", ")", "^", "random", ".", "nextInt", "(", ")", "^", "(", "seedTerm", "<<", "32", ")", ";", "}", "else", "{", "r0", "=", "random", ".", "nextLong", "(", ")", ";", "}", "if", "(", "r0", "<", "0", ")", "{", "r0", "=", "-", "r0", ";", "}", "long", "r1", ";", "if", "(", "weakRandom", ")", "{", "r1", "=", "hashCode", "(", ")", "^", "Runtime", ".", "getRuntime", "(", ")", ".", "freeMemory", "(", ")", "^", "random", ".", "nextInt", "(", ")", "^", "(", "seedTerm", "<<", "32", ")", ";", "}", "else", "{", "r1", "=", "random", ".", "nextLong", "(", ")", ";", "}", "if", "(", "r1", "<", "0", ")", "{", "r1", "=", "-", "r1", ";", "}", "StringBuilder", "id", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "!", "StringUtils", ".", "isEmpty", "(", "groupName", ")", ")", "{", "id", ".", "append", "(", "groupName", ")", ";", "}", "id", ".", "append", "(", "Long", ".", "toString", "(", "r0", ",", "36", ")", ")", ";", "id", ".", "append", "(", "Long", ".", "toString", "(", "r1", ",", "36", ")", ")", ";", "id", ".", "append", "(", "counter", ".", "getAndIncrement", "(", ")", ")", ";", "return", "id", ".", "toString", "(", ")", ";", "}", "}" ]
Returns a new unique session id. @param seedTerm the seed for RNG @return a new unique session id
[ "Returns", "a", "new", "unique", "session", "id", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/SessionIdGenerator.java#L54-L85
142,798
aspectran/aspectran
core/src/main/java/com/aspectran/core/component/session/SessionIdGenerator.java
SessionIdGenerator.initRandom
private void initRandom() { try { random = new SecureRandom(); } catch (Exception e) { log.warn("Could not generate SecureRandom for session-id randomness", e); random = new Random(); weakRandom = true; } }
java
private void initRandom() { try { random = new SecureRandom(); } catch (Exception e) { log.warn("Could not generate SecureRandom for session-id randomness", e); random = new Random(); weakRandom = true; } }
[ "private", "void", "initRandom", "(", ")", "{", "try", "{", "random", "=", "new", "SecureRandom", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "warn", "(", "\"Could not generate SecureRandom for session-id randomness\"", ",", "e", ")", ";", "random", "=", "new", "Random", "(", ")", ";", "weakRandom", "=", "true", ";", "}", "}" ]
Set up a random number generator for the sessionids. By preference, use a SecureRandom but allow to be injected.
[ "Set", "up", "a", "random", "number", "generator", "for", "the", "sessionids", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/component/session/SessionIdGenerator.java#L92-L100
142,799
aspectran/aspectran
core/src/main/java/com/aspectran/core/util/apon/AponWriter.java
AponWriter.write
public void write(Parameters parameters) throws IOException { if (parameters != null) { for (Parameter pv : parameters.getParameterValueMap().values()) { if (pv.isAssigned()) { write(pv); } } } }
java
public void write(Parameters parameters) throws IOException { if (parameters != null) { for (Parameter pv : parameters.getParameterValueMap().values()) { if (pv.isAssigned()) { write(pv); } } } }
[ "public", "void", "write", "(", "Parameters", "parameters", ")", "throws", "IOException", "{", "if", "(", "parameters", "!=", "null", ")", "{", "for", "(", "Parameter", "pv", ":", "parameters", ".", "getParameterValueMap", "(", ")", ".", "values", "(", ")", ")", "{", "if", "(", "pv", ".", "isAssigned", "(", ")", ")", "{", "write", "(", "pv", ")", ";", "}", "}", "}", "}" ]
Write a Parameters object to the character-output stream. @param parameters the Parameters object to be converted @throws IOException if an I/O error occurs
[ "Write", "a", "Parameters", "object", "to", "the", "character", "-", "output", "stream", "." ]
2d758a2a28b71ee85b42823c12dc44674d7f2c70
https://github.com/aspectran/aspectran/blob/2d758a2a28b71ee85b42823c12dc44674d7f2c70/core/src/main/java/com/aspectran/core/util/apon/AponWriter.java#L98-L106