001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.servicemix.jbi.deployment;
018
019 import java.util.Arrays;
020 import java.util.List;
021
022 /**
023 * @version $Revision: 564374 $
024 */
025 public class ClassPath {
026
027 private String[] pathElements = new String[] {};
028
029 public ClassPath() {
030 }
031
032 public ClassPath(String[] pathElements) {
033 this.pathElements = pathElements;
034 }
035
036 public String[] getPathElements() {
037 return pathElements;
038 }
039
040 public void setPathElements(String[] pathElements) {
041 this.pathElements = pathElements;
042 }
043
044 public boolean equals(Object o) {
045 if (this == o) {
046 return true;
047 }
048 if (!(o instanceof ClassPath)) {
049 return false;
050 }
051
052 final ClassPath classPath = (ClassPath) o;
053
054 if (!Arrays.equals(pathElements, classPath.pathElements)) {
055 return false;
056 }
057
058 return true;
059 }
060
061 //SM-199: Hashcode method added
062 public int hashCode() {
063 if (pathElements == null) {
064 return 0;
065 }
066 int result = 1;
067 for (int i = 0; i < pathElements.length; i++) {
068 result = 31 * result + (pathElements[i] == null ? 0 : pathElements[i].hashCode());
069 }
070 return result;
071 }
072
073
074 public String toString() {
075 StringBuffer buffer = new StringBuffer("ClassPath[");
076 for (int i = 0; i < pathElements.length; i++) {
077 String pathElement = pathElements[i];
078 if (i > 0) {
079 buffer.append(", ");
080 }
081 buffer.append(pathElement);
082 }
083 return buffer.toString();
084 }
085
086 public List getPathList() {
087 return Arrays.asList(pathElements);
088 }
089
090 public void setPathList(List list) {
091 pathElements = new String[list.size()];
092 list.toArray(pathElements);
093 }
094 }