KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > core > ExtendedSite


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
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  * IBM - Initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.update.internal.core;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.List JavaDoc;
15
16 import org.eclipse.update.core.IURLEntry;
17 import org.eclipse.update.core.VersionedIdentifier;
18 import org.eclipse.update.internal.model.SiteWithTimestamp;
19
20 public class ExtendedSite extends SiteWithTimestamp /*Site*/ {
21     
22     private boolean digestExist;
23     private String JavaDoc[] availableLocals;
24     private String JavaDoc digestURL;
25     private LiteFeature[] liteFeatures;
26     private LiteFeature[] allLiteFeatures;
27     private IURLEntry[] associateSites;
28     private boolean pack200 = false;
29     private IURLEntry selectedMirror;
30     
31     
32     public String JavaDoc getDigestURL() {
33         return digestURL;
34     }
35     public void setDigestURL(String JavaDoc digestURL) {
36         this.digestURL = digestURL;
37     }
38
39     public String JavaDoc[] getAvailableLocals() {
40         return availableLocals;
41     }
42     public void setAvailableLocals(String JavaDoc[] availableLocals) {
43         this.availableLocals = availableLocals;
44     }
45     public boolean isDigestExist() {
46         return digestExist;
47     }
48     public void setDigestExist(boolean digestExist) {
49         this.digestExist = digestExist;
50     }
51     public LiteFeature[] getLiteFeatures() {
52         if (getCurrentConfiguredSite()!=null)
53             return filterFeatures(getNonFilteredLiteFeatures());
54         else
55             return getNonFilteredLiteFeatures();
56     }
57     public void setLiteFeatures(LiteFeature[] liteFeatures) {
58         
59         if ((liteFeatures == null) || (liteFeatures.length == 0))
60             return;
61         this.allLiteFeatures = liteFeatures;
62         List JavaDoc temp = new ArrayList JavaDoc();
63         for(int i = 0; i < allLiteFeatures.length ; i++) {
64             if (getFeatureReference(allLiteFeatures[i]) != null) {
65                 temp.add(allLiteFeatures[i]);
66             }
67         }
68         if (!temp.isEmpty()) {
69             this.liteFeatures = (LiteFeature[])temp.toArray( new LiteFeature[temp.size()]);
70         }
71     }
72     
73     public LiteFeature getLiteFeature(VersionedIdentifier vid) {
74         if (allLiteFeatures == null)
75             return null;
76         
77         for(int i = 0; i < allLiteFeatures.length ; i++) {
78             if (vid.equals(allLiteFeatures[i].getVersionedIdentifier())) {
79                 return allLiteFeatures[i];
80             }
81         }
82         return null;
83     }
84     
85     public LiteFeature[] getNonFilteredLiteFeatures() {
86         return liteFeatures;
87     }
88     public void setNonFilteredLiteFeatures(LiteFeature[] liteFeatures) {
89         this.liteFeatures = liteFeatures;
90     }
91     
92     
93     /**
94      * Get whether or not this site may contain jars packed with pack200.
95      * The packed version of foo.jar, is expected to be foo.jar.pack.gz
96      * @return
97      */

98     public boolean supportsPack200() {
99         return pack200;
100     }
101     
102     /**
103      * Set whether or not this site may contain jars packed with pack200
104      * The packed version of foo.jar is expected to be foo.jar.pack.gz
105      * @param pack
106      */

107     public void setSupportsPack200(boolean pack){
108         pack200 = pack;
109     }
110     
111     /*
112      * Method filterFeatures.
113      * Also implemented in Feature
114      *
115      * @param list
116      * @return List
117      */

118     private LiteFeature[] filterFeatures(LiteFeature[] allIncluded) {
119         List JavaDoc list = new ArrayList JavaDoc();
120         if (allIncluded!=null){
121             for (int i = 0; i < allIncluded.length; i++) {
122                 LiteFeature included = allIncluded[i];
123                 if (UpdateManagerUtils.isValidEnvironment(included))
124                     list.add(included);
125                 else{
126                     if (UpdateCore.DEBUG && UpdateCore.DEBUG_SHOW_WARNINGS){
127                         UpdateCore.warn("Filtered out feature reference:"+included); //$NON-NLS-1$
128
}
129                 }
130             }
131         }
132         
133         LiteFeature[] result = new LiteFeature[list.size()];
134         if (!list.isEmpty()){
135             list.toArray(result);
136         }
137         
138         return result;
139     }
140     public IURLEntry[] getAssociateSites() {
141         return associateSites;
142     }
143     public void setAssociateSites(IURLEntry[] associateSites) {
144         this.associateSites = associateSites;
145     }
146     
147     public IURLEntry getSelectedMirror() {
148         return selectedMirror;
149     }
150     
151     public void setSelectedMirror(IURLEntry selectedMirror) {
152         this.selectedMirror = selectedMirror;
153     }
154
155 }
156
Popular Tags