Reformat the class MessageFilter
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/8a5de9c4 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/8a5de9c4 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/8a5de9c4 Branch: refs/heads/master Commit: 8a5de9c4a9a72fcab366ffada4d765edf37e58d2 Parents: 2b77329 Author: gayan <[email protected]> Authored: Fri Nov 28 17:33:37 2014 +0530 Committer: gayan <[email protected]> Committed: Fri Nov 28 18:29:26 2014 +0530 ---------------------------------------------------------------------- .../messaging/message/filter/MessageFilter.java | 151 ++++++++++--------- 1 file changed, 76 insertions(+), 75 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/8a5de9c4/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/filter/MessageFilter.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/filter/MessageFilter.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/filter/MessageFilter.java index 748209e..0035c62 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/filter/MessageFilter.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/filter/MessageFilter.java @@ -34,92 +34,93 @@ import java.util.*; */ public class MessageFilter { - private static final Log log = LogFactory.getLog(TopologyServiceFilter.class); + private static final Log log = LogFactory.getLog(TopologyServiceFilter.class); public static final String FILTER_VALUE_ASSIGN_OPERATOR = "="; public static final String FILTER_KEY_VALUE_PAIR_SEPARATOR = "|"; - private String filterName; - private Map<String, Map<String, Boolean>> filterMap; + private String filterName; + private Map<String, Map<String, Boolean>> filterMap; - public MessageFilter(String filterName) { - this.filterName = filterName; - this.filterMap = new HashMap<String, Map<String, Boolean>>(); - init(); - } + public MessageFilter(String filterName) { + this.filterName = filterName; + this.filterMap = new HashMap<String, Map<String, Boolean>>(); + init(); + } - private Map<String, String> splitToMap(String filter) { - HashMap<String, String> keyValuePairMap = new HashMap<String, String>(); - List<String> keyValuePairList = splitUsingTokenizer(filter,FILTER_KEY_VALUE_PAIR_SEPARATOR); - for (String keyValuePair : keyValuePairList) { - List<String> keyValueList = splitUsingTokenizer(keyValuePair, FILTER_VALUE_ASSIGN_OPERATOR); - if (keyValueList.size() == 2) { - keyValuePairMap.put(keyValueList.get(0).trim(), keyValueList.get(1).trim()); - } else { - throw new RuntimeException(String.format("Invalid key-value pair: %s", keyValuePair)); - } - } - return keyValuePairMap; - } + private Map<String, String> splitToMap(String filter) { + HashMap<String, String> keyValuePairMap = new HashMap<String, String>(); + List<String> keyValuePairList = splitUsingTokenizer(filter, FILTER_KEY_VALUE_PAIR_SEPARATOR); + for (String keyValuePair : keyValuePairList) { + List<String> keyValueList = splitUsingTokenizer(keyValuePair, FILTER_VALUE_ASSIGN_OPERATOR); + if (keyValueList.size() == 2) { + keyValuePairMap.put(keyValueList.get(0).trim(), keyValueList.get(1).trim()); + } else { + throw new RuntimeException(String.format("Invalid key-value pair: %s", keyValuePair)); + } + } + return keyValuePairMap; + } - public static List<String> splitUsingTokenizer(String string, String delimiter) { - StringTokenizer tokenizer = new StringTokenizer(string, delimiter); - List<String> list = new ArrayList<String>(string.length()); - while (tokenizer.hasMoreTokens()) { - list.add(tokenizer.nextToken()); - } - return list; - } + public static List<String> splitUsingTokenizer(String string, String delimiter) { + StringTokenizer tokenizer = new StringTokenizer(string, delimiter); + List<String> list = new ArrayList<String>(string.length()); + while (tokenizer.hasMoreTokens()) { + list.add(tokenizer.nextToken()); + } + return list; + } - /** - * Initialize message filter using system property. - */ - public void init() { - String filter = System.getProperty(filterName); - if (StringUtils.isNotBlank(filter)) { - if (log.isDebugEnabled()) { - log.debug(String.format("Initializing filter: %s", filterName)); - } + /** + * Initialize message filter using system property. + */ + public void init() { + String filter = System.getProperty(filterName); + if (StringUtils.isNotBlank(filter)) { + if (log.isDebugEnabled()) { + log.debug(String.format("Initializing filter: %s", filterName)); + } - String propertyValue; - Map<String, Boolean> propertyValueMap; - String[] propertyValueArray; - Map<String, String> keyValuePairMap = splitToMap(filter); + String propertyValue; + Map<String, Boolean> propertyValueMap; + String[] propertyValueArray; + Map<String, String> keyValuePairMap = splitToMap(filter); - for (String propertyName : keyValuePairMap.keySet()) { - propertyValue = keyValuePairMap.get(propertyName); - propertyValueMap = new HashMap<String, Boolean>(); - propertyValueArray = propertyValue.split(StratosConstants.FILTER_VALUE_SEPARATOR); - for (String value : propertyValueArray) { - propertyValueMap.put(value, true); - if (log.isDebugEnabled()) { - log.debug(String.format("Filter property value found: [property] %s [value] %s", propertyName, value)); - } - } - filterMap.put(propertyName, propertyValueMap); - } - } - } + for (String propertyName : keyValuePairMap.keySet()) { + propertyValue = keyValuePairMap.get(propertyName); + propertyValueMap = new HashMap<String, Boolean>(); + propertyValueArray = propertyValue.split(StratosConstants.FILTER_VALUE_SEPARATOR); + for (String value : propertyValueArray) { + propertyValueMap.put(value, true); + if (log.isDebugEnabled()) { + log.debug(String.format("Filter property value found: [property] %s [value] %s", propertyName, + value)); + } + } + filterMap.put(propertyName, propertyValueMap); + } + } + } - public boolean isActive() { - return filterMap.size() > 0; - } + public boolean isActive() { + return filterMap.size() > 0; + } - public boolean included(String propertyName, String propertyValue) { - if (filterMap.containsKey(propertyName)) { - Map<String, Boolean> propertyValueMap = filterMap.get(propertyName); - return propertyValueMap.containsKey(propertyValue); - } - return false; - } + public boolean included(String propertyName, String propertyValue) { + if (filterMap.containsKey(propertyName)) { + Map<String, Boolean> propertyValueMap = filterMap.get(propertyName); + return propertyValueMap.containsKey(propertyValue); + } + return false; + } - public boolean excluded(String propertyName, String propertyValue) { - return !included(propertyName, propertyValue); - } + public boolean excluded(String propertyName, String propertyValue) { + return !included(propertyName, propertyValue); + } - public Collection<String> getIncludedPropertyValues(String propertyName) { - if (filterMap.containsKey(propertyName)) { - return filterMap.get(propertyName).keySet(); - } - return CollectionUtils.EMPTY_COLLECTION; - } + public Collection<String> getIncludedPropertyValues(String propertyName) { + if (filterMap.containsKey(propertyName)) { + return filterMap.get(propertyName).keySet(); + } + return CollectionUtils.EMPTY_COLLECTION; + } }
