Revision 37599 branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/DefaultDependencies.java

View differences:

DefaultDependencies.java
5 5

  
6 6
import org.gvsig.installer.lib.api.Dependencies;
7 7
import org.gvsig.installer.lib.api.Dependency;
8
import org.gvsig.installer.lib.api.PackageInfo;
9 8
import org.gvsig.installer.lib.api.Version;
10 9

  
11
public class DefaultDependencies extends ArrayList<Dependency> implements Dependencies {
10
public class DefaultDependencies extends ArrayList<Dependency> implements
11
		Dependencies {
12 12

  
13 13
	/**
14 14
	 * 
......
16 16
	private static final long serialVersionUID = -6743931124069465522L;
17 17

  
18 18
	private Dependency createDependency() {
19
//		InstallerManager manager = InstallerLocator.getInstallerManager();
20
//		return manager.createDependency();
19
		// InstallerManager manager = InstallerLocator.getInstallerManager();
20
		// return manager.createDependency();
21 21
		return new DefaultDependency();
22 22
	}
23
	
23

  
24 24
	public Dependencies parse(String dependecies) {
25
		if( dependecies == null ) {
25
		if (dependecies == null) {
26 26
			this.clear();
27 27
			return this;
28 28
		}
29 29
		dependecies = dependecies.trim();
30
		if( dependecies.equals("") ) {
30
		if (dependecies.equals("")) {
31 31
			this.clear();
32 32
			return this;
33 33
		}
34
		
34

  
35 35
		String[] x = dependecies.split(",");
36
		for( int i=0; i<x.length ; i++ ) {
37
			this.add( createDependency().parse(x[i]) );
36
		for (int i = 0; i < x.length; i++) {
37
			this.add(createDependency().parse(x[i]));
38 38
		}
39 39
		return this;
40 40
	}
41 41

  
42
	@Override
42 43
	public String toString() {
43 44
		StringBuffer s = null;
44 45
		Iterator<Dependency> it = this.iterator();
45
		while( it.hasNext() ) {
46
			if( s == null ) {
46
		while (it.hasNext()) {
47
			if (s == null) {
47 48
				s = new StringBuffer();
48 49
			} else {
49 50
				s.append(", ");
50 51
			}
51
			s.append( it.next().toString() );
52
			s.append(it.next().toString());
52 53
		}
53
		if( s == null ) {
54
		if (s == null) {
54 55
			return "";
55 56
		}
56 57
		return s.toString();
57 58
	}
58
	
59

  
60
	@Override
59 61
	public boolean contains(Object o) {
60
		if( !(o instanceof Dependency) ) {
62
		if (!(o instanceof Dependency)) {
61 63
			return false;
62 64
		}
63 65
		Iterator<Dependency> it = this.iterator();
64
		while( it.hasNext() ) {
66
		while (it.hasNext()) {
65 67
			Dependency dep = it.next();
66
			if( dep.equals((Dependency)o) ) {
68
			if (dep.equals(o)) {
67 69
				return true;
68 70
			}
69 71
		}
70 72
		return false;
71 73
	}
72
	
74

  
73 75
	public boolean match(String type, String code, Version version) {
74 76
		Iterator<Dependency> it = this.iterator();
75
		while( it.hasNext() ) {
77
		while (it.hasNext()) {
76 78
			Dependency dependency = it.next();
77
			if( dependency.match(type, code, version)) {
79
			if (dependency.match(type, code, version)) {
78 80
				return true;
79 81
			}
80 82
		}
......
83 85

  
84 86
	public Dependency find(String type, String code, Version version) {
85 87
		Iterator<Dependency> it = this.iterator();
86
		while( it.hasNext() ) {
88
		while (it.hasNext()) {
87 89
			Dependency dependency = it.next();
88
			if( dependency.match(type, code, version)) {
90
			if (dependency.match(type, code, version)) {
89 91
				return dependency;
90 92
			}
91 93
		}

Also available in: Unified diff