View Javadoc

1   /*
2    * Copyright (c) 2007 Creative Sphere Limited.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *
10   *   Creative Sphere - initial API and implementation
11   *
12   */
13  package org.abstracthorizon.extend.repository.maven.pom;
14  
15  
16  public class Dependency extends Artifact {
17  
18      protected String scope;
19      
20      protected Exclusions exclusions;
21      
22      protected String optional;
23      
24      public Dependency() {
25      }
26  
27      public Exclusions getExclusions() {
28          return exclusions;
29      }
30      
31      public Exclusions addExclusions() {
32          exclusions = new Exclusions();
33          return exclusions;
34      }
35  
36      public String getScope() {
37          return scope;
38      }
39  
40      public void setScope(String scope) {
41          this.scope = scope;
42      }
43  
44      public String getOptional() {
45          return optional;
46      }
47  
48      public void setOptional(String optional) {
49          this.optional = optional;
50      }
51  
52  //    public List<Dependency> filterDependencies() {
53  //        ArrayList<Dependency> result = new ArrayList<Dependency>();
54  //        result.addAll(getDependencies());
55  //        if (exclusions != null) {
56  //            Iterator<Dependency> it = result.iterator();
57  //            while (it.hasNext()) {
58  //                Dependency d = it.next();
59  //                if (exclusions.contains(d)) {
60  //                    it.remove();
61  //                }
62  //            }
63  //        }
64  //        
65  //        return result;
66  //    }
67      
68      public String toString(int indent) {
69          StringBuffer res = new StringBuffer();
70          ToStringHelper.openTag("dependency", res, indent);
71          res.append(super.toString(indent + 2));
72          if (scope != null) {
73              ToStringHelper.valueTag("scope", scope, res, indent + 2);
74          }
75          if (optional != null) {
76              ToStringHelper.valueTag("optional", optional, res, indent + 2);
77          }
78          if (exclusions != null) {
79              res.append(exclusions.toString(indent + 2));
80          }
81          ToStringHelper.closeTag("dependency", res, indent);
82          return res.toString();
83      }
84      
85      public String toString() {
86          return toString(0);
87      }
88  }