Source Code Cross Referenced for StatusManager.java in  » Code-Analyzer » apache-ivy » org » apache » ivy » core » module » status » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » apache ivy » org.apache.ivy.core.module.status 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         */
018:        package org.apache.ivy.core.module.status;
019:
020:        import java.util.ArrayList;
021:        import java.util.Arrays;
022:        import java.util.HashMap;
023:        import java.util.Iterator;
024:        import java.util.List;
025:        import java.util.ListIterator;
026:        import java.util.Map;
027:
028:        import org.apache.ivy.core.IvyContext;
029:        import org.apache.ivy.util.Message;
030:
031:        /**
032:         * Note: update methods (such as addStatus) should only be called BEFORE any call to accessor
033:         * methods
034:         */
035:        public class StatusManager {
036:            public static StatusManager newDefaultInstance() {
037:                return new StatusManager(new Status[] {
038:                        new Status("release", false),
039:                        new Status("milestone", false),
040:                        new Status("integration", true) }, "integration");
041:            }
042:
043:            public static StatusManager getCurrent() {
044:                return IvyContext.getContext().getSettings().getStatusManager();
045:            }
046:
047:            private List status = new ArrayList();
048:
049:            private String defaultStatus;
050:
051:            // for easier querying only
052:            private Map statusPriorityMap;
053:
054:            private Map statusIntegrationMap;
055:
056:            private String deliveryStatusListString;
057:
058:            public StatusManager(Status[] status, String defaultStatus) {
059:                this .status.addAll(Arrays.asList(status));
060:                this .defaultStatus = defaultStatus;
061:
062:                computeMaps();
063:            }
064:
065:            public StatusManager() {
066:            }
067:
068:            public void addStatus(Status status) {
069:                this .status.add(status);
070:            }
071:
072:            public void setDefaultStatus(String defaultStatus) {
073:                this .defaultStatus = defaultStatus;
074:            }
075:
076:            public List getStatuses() {
077:                return status;
078:            }
079:
080:            private void computeMaps() {
081:                if (status.isEmpty()) {
082:                    throw new IllegalStateException(
083:                            "badly configured statuses: no status found");
084:                }
085:                statusPriorityMap = new HashMap();
086:                for (ListIterator iter = status.listIterator(); iter.hasNext();) {
087:                    Status status = (Status) iter.next();
088:                    statusPriorityMap.put(status.getName(), new Integer(iter
089:                            .previousIndex()));
090:                }
091:                statusIntegrationMap = new HashMap();
092:                for (Iterator iter = status.iterator(); iter.hasNext();) {
093:                    Status status = (Status) iter.next();
094:                    statusIntegrationMap.put(status.getName(), Boolean
095:                            .valueOf(status.isIntegration()));
096:                }
097:            }
098:
099:            public boolean isStatus(String status) {
100:                if (statusPriorityMap == null) {
101:                    computeMaps();
102:                }
103:                return statusPriorityMap.containsKey(status);
104:            }
105:
106:            public int getPriority(String status) {
107:                if (statusPriorityMap == null) {
108:                    computeMaps();
109:                }
110:                Integer priority = (Integer) statusPriorityMap.get(status);
111:                if (priority == null) {
112:                    Message.debug("unknown status " + status
113:                            + ": assuming lowest priority");
114:                    return Integer.MAX_VALUE;
115:                }
116:                return priority.intValue();
117:            }
118:
119:            public boolean isIntegration(String status) {
120:                if (statusIntegrationMap == null) {
121:                    computeMaps();
122:                }
123:                Boolean isIntegration = (Boolean) statusIntegrationMap
124:                        .get(status);
125:                if (isIntegration == null) {
126:                    Message.debug("unknown status " + status
127:                            + ": assuming integration");
128:                    return true;
129:                }
130:                return isIntegration.booleanValue();
131:            }
132:
133:            public String getDeliveryStatusListString() {
134:                if (deliveryStatusListString == null) {
135:                    StringBuffer ret = new StringBuffer();
136:                    for (Iterator iter = status.iterator(); iter.hasNext();) {
137:                        Status status = (Status) iter.next();
138:                        if (!status.isIntegration()) {
139:                            ret.append(status.getName()).append(",");
140:                        }
141:                    }
142:                    if (ret.length() > 0) {
143:                        ret.deleteCharAt(ret.length() - 1);
144:                    }
145:                    deliveryStatusListString = ret.toString();
146:                }
147:                return deliveryStatusListString;
148:            }
149:
150:            public String getDefaultStatus() {
151:                if (defaultStatus == null) {
152:                    if (status.isEmpty()) {
153:                        throw new IllegalStateException(
154:                                "badly configured statuses: no status found");
155:                    }
156:                    defaultStatus = ((Status) status.get(status.size() - 1))
157:                            .getName();
158:                }
159:                return defaultStatus;
160:            }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.