diff options
author | adrianocrestani <adrianocrestani@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-17 06:24:15 +0000 |
---|---|---|
committer | adrianocrestani <adrianocrestani@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-17 06:24:15 +0000 |
commit | 53c043ac18ca8dd9d7f823bf7a399058c305003d (patch) | |
tree | 5b8184792065accca1e5a68092d0960db455cda6 /branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ParentField.java | |
parent | a4f020f2df42181bf54587acddb3b748ff5f698f (diff) |
committing domain-search changes from patch tuscany_2552_phillipe_ramalho_08_16_2009.patch
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@804871 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ParentField.java | 346 |
1 files changed, 173 insertions, 173 deletions
diff --git a/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ParentField.java b/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ParentField.java index cf4e3ca70d..862db63b2c 100644 --- a/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ParentField.java +++ b/branches/sca-java-1.x/modules/domain-search/src/main/java/org/apache/tuscany/sca/domain/search/impl/ParentField.java @@ -29,178 +29,178 @@ import java.util.List; */ public class ParentField implements Serializable { - private static final long serialVersionUID = -2090538050273088026L; - - final private List<ParentFieldElement> elements; - - public ParentField(String parentFieldValue) { - int length = parentFieldValue.length(); - - if (length == 0) { - this.elements = Collections.emptyList(); - - return; - - } - - this.elements = new ArrayList<ParentFieldElement>(); - - ParentFieldElement element = null; - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < length ; i++) { - char c = parentFieldValue.charAt(i); - - if (c == DomainPathAnalyzer.PATH_SEPARATOR || c == DomainPathAnalyzer.PATH_START) { - - if (sb.length() > 0 || element != null) { - - if (element == null) { - element = new ParentFieldElement(); - } - - if (element.type == null) { - element.type = ""; - } - - if (element.uri == null) { - element.uri = element.name = sb.toString(); - - } else { - element.name = sb.toString(); - } - - sb.setLength(0); - this.elements.add(element); - element = null; - - } - - } else if (c == DomainPathAnalyzer.TYPE_SEPARATOR) { - - if (element == null) { - element = new ParentFieldElement(); - } - - element.type = sb.toString(); - - sb.setLength(0); - - } else if (c == DomainPathAnalyzer.URI_SEPARATOR) { - - if (element == null) { - element = new ParentFieldElement(); - } - - element.uri = sb.toString(); - - sb.setLength(0); - - } else { - sb.append(c); - } - - } - - if (sb.length() > 0 || element != null) { - - if (element == null) { - element = new ParentFieldElement(); - } - - if (element.type == null) { - element.type = ""; - } - - if (element.uri == null) { - element.uri = element.name = sb.toString(); - - } else { - element.name = sb.toString(); - } - - sb.setLength(0); - this.elements.add(element); - element = null; - - } - - } - - public static String getURIPath(ParentField parentField) { - return getURIPath(parentField, System.getProperty("file.separator")); - } - - public static String getURIPath(ParentField parentField, String pathSeparator) { - StringBuilder sb = new StringBuilder(); - sb.append(pathSeparator); - int elementsCount = parentField.getElementsCount(); - - for (int i = 0 ; i < elementsCount ; i++) { - sb.append(parentField.getElementName(i)); - sb.append(pathSeparator); - - } - - if (sb.length() > pathSeparator.length()) { - sb.setLength(sb.length() - pathSeparator.length()); - } - - return sb.toString(); - - } - - public static int getParentElementsCount(String parent) { - int length = parent.length(); - - if (length == 0) { - return 0; - } - - boolean pathSeparatorBefore = true; - int count = 1; - - for (int i = 0; i < length - 1; i++) { - char c = parent.charAt(i); - - if (c == DomainPathAnalyzer.PATH_SEPARATOR && !pathSeparatorBefore) { - pathSeparatorBefore = true; - count++; - - } else { - pathSeparatorBefore = false; - } - - } - - return count; - - } - - public int getElementsCount() { - return this.elements.size(); - } - - public String getElementType(int index) { - return this.elements.get(index).type; - } - - public String getElementURI(int index) { - return this.elements.get(index).uri; - } - - public String getElementName(int index) { - return this.elements.get(index).name; - } - - final private static class ParentFieldElement { - - String type; - - String uri; - - String name; - - } + private static final long serialVersionUID = -2090538050273088026L; + + final private List<ParentFieldElement> elements; + + public ParentField(String parentFieldValue) { + int length = parentFieldValue.length(); + + if (length == 0) { + this.elements = Collections.emptyList(); + + return; + + } + + this.elements = new ArrayList<ParentFieldElement>(); + + ParentFieldElement element = null; + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < length; i++) { + char c = parentFieldValue.charAt(i); + + if (c == DomainPathAnalyzer.PATH_SEPARATOR || c == DomainPathAnalyzer.PATH_START) { + + if (sb.length() > 0 || element != null) { + + if (element == null) { + element = new ParentFieldElement(); + } + + if (element.type == null) { + element.type = ""; + } + + if (element.uri == null) { + element.uri = element.name = sb.toString(); + + } else { + element.name = sb.toString(); + } + + sb.setLength(0); + this.elements.add(element); + element = null; + + } + + } else if (c == DomainPathAnalyzer.TYPE_SEPARATOR) { + + if (element == null) { + element = new ParentFieldElement(); + } + + element.type = sb.toString(); + + sb.setLength(0); + + } else if (c == DomainPathAnalyzer.URI_SEPARATOR) { + + if (element == null) { + element = new ParentFieldElement(); + } + + element.uri = sb.toString(); + + sb.setLength(0); + + } else { + sb.append(c); + } + + } + + if (sb.length() > 0 || element != null) { + + if (element == null) { + element = new ParentFieldElement(); + } + + if (element.type == null) { + element.type = ""; + } + + if (element.uri == null) { + element.uri = element.name = sb.toString(); + + } else { + element.name = sb.toString(); + } + + sb.setLength(0); + this.elements.add(element); + element = null; + + } + + } + + public static String getURIPath(ParentField parentField) { + return getURIPath(parentField, System.getProperty("file.separator")); + } + + public static String getURIPath(ParentField parentField, String pathSeparator) { + StringBuilder sb = new StringBuilder(); + sb.append(pathSeparator); + int elementsCount = parentField.getElementsCount(); + + for (int i = 0; i < elementsCount; i++) { + sb.append(parentField.getElementName(i)); + sb.append(pathSeparator); + + } + + if (sb.length() > pathSeparator.length()) { + sb.setLength(sb.length() - pathSeparator.length()); + } + + return sb.toString(); + + } + + public static int getParentElementsCount(String parent) { + int length = parent.length(); + + if (length == 0) { + return 0; + } + + boolean pathSeparatorBefore = true; + int count = 1; + + for (int i = 0; i < length - 1; i++) { + char c = parent.charAt(i); + + if (c == DomainPathAnalyzer.PATH_SEPARATOR && !pathSeparatorBefore) { + pathSeparatorBefore = true; + count++; + + } else { + pathSeparatorBefore = false; + } + + } + + return count; + + } + + public int getElementsCount() { + return this.elements.size(); + } + + public String getElementType(int index) { + return this.elements.get(index).type; + } + + public String getElementURI(int index) { + return this.elements.get(index).uri; + } + + public String getElementName(int index) { + return this.elements.get(index).name; + } + + final private static class ParentFieldElement { + + String type; + + String uri; + + String name; + + } } |