Source Code Cross Referenced for IWrapperIndexedParam.java in  » J2EE » Pustefix » de » schlund » pfixcore » generator » 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 » J2EE » Pustefix » de.schlund.pfixcore.generator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of PFIXCORE.
003:         *
004:         * PFIXCORE is free software; you can redistribute it and/or modify
005:         * it under the terms of the GNU Lesser General Public License as published by
006:         * the Free Software Foundation; either version 2 of the License, or
007:         * (at your option) any later version.
008:         *
009:         * PFIXCORE is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:         * GNU Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public License
015:         * along with PFIXCORE; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         *
018:         */
019:
020:        package de.schlund.pfixcore.generator;
021:
022:        import java.util.ArrayList;
023:        import java.util.HashMap;
024:        import java.util.Iterator;
025:
026:        import org.apache.log4j.Logger;
027:
028:        import de.schlund.util.statuscodes.StatusCode;
029:
030:        /**
031:         * IWrapperIndexedParam.java
032:         *
033:         *
034:         * Created: Mon Aug 20 18:45:30 2001
035:         *
036:         * @author <a href="mailto:jtl@schlund.de">Jens Lautenbacher</a>
037:         *
038:         *
039:         */
040:
041:        public class IWrapperIndexedParam implements  IWrapperParamDefinition,
042:                Comparable<IWrapperParamDefinition> {
043:
044:            private static final String TYPE_INDEXED = "indexed";
045:            private static final String TYPE_MULTIPLE = "multiple";
046:            private static final String TYPE_SINGLE = "single";
047:            private String name;
048:            private String type;
049:            private boolean trim;
050:            private boolean multiple;
051:            private IWrapperParamCaster caster;
052:            private ArrayList<IWrapperParamPreCheck> precheck = new ArrayList<IWrapperParamPreCheck>();
053:            private ArrayList<IWrapperParamPostCheck> postcheck = new ArrayList<IWrapperParamPostCheck>();
054:            private HashMap<String, IWrapperParam> params = new HashMap<String, IWrapperParam>();
055:            private HashMap<String, IWrapperParam> errors = new HashMap<String, IWrapperParam>();
056:            // private String              prefix;
057:            private Logger LOG = Logger.getLogger(this .getClass());
058:
059:            public IWrapperIndexedParam(String name, boolean multiple,
060:                    String type, boolean trim) {
061:                this .type = type;
062:                this .name = name;
063:                this .caster = null;
064:                this .multiple = multiple;
065:                this .trim = trim;
066:            }
067:
068:            @Deprecated
069:            public IWrapperIndexedParam(String name, boolean multiple,
070:                    String type) {
071:                this (name, multiple, type, true);
072:            }
073:
074:            public String getOccurance() {
075:                return TYPE_INDEXED;
076:            }
077:
078:            public String getFrequency() {
079:                return multiple ? TYPE_MULTIPLE : TYPE_SINGLE;
080:            }
081:
082:            public IWrapperParamCaster getCaster() {
083:                return caster;
084:            }
085:
086:            public IWrapperParamPreCheck[] getPreChecks() {
087:                return (IWrapperParamPreCheck[]) precheck
088:                        .toArray(new IWrapperParamPreCheck[] {});
089:            }
090:
091:            public IWrapperParamPostCheck[] getPostChecks() {
092:                return (IWrapperParamPostCheck[]) postcheck
093:                        .toArray(new IWrapperParamPostCheck[] {});
094:            }
095:
096:            protected void initValueFromRequest(String prefix, RequestData req) {
097:                String wholename = prefix + "." + name;
098:                for (Iterator<String> i = req.getParameterNames(); i.hasNext();) {
099:                    String pname = i.next();
100:                    if (pname.startsWith(wholename + ".")) {
101:                        // Now initialize the IWrapperParams
102:                        String idx = pname.substring(wholename.length() + 1);
103:                        LOG.debug("~~~ Found index: " + idx
104:                                + " for IndexedParam " + name);
105:                        IWrapperParam pinfo = new IWrapperParam(name + "."
106:                                + idx, multiple, true, null, type, trim);
107:                        pinfo.setParamCaster(caster);
108:                        synchronized (params) {
109:                            params.put(pinfo.getName(), pinfo);
110:                        }
111:                        for (Iterator<IWrapperParamPreCheck> j = precheck
112:                                .iterator(); j.hasNext();) {
113:                            pinfo.addPreChecker(j.next());
114:                        }
115:                        for (Iterator<IWrapperParamPostCheck> j = postcheck
116:                                .iterator(); j.hasNext();) {
117:                            pinfo.addPostChecker(j.next());
118:                        }
119:                        pinfo.initValueFromRequest(prefix, req);
120:                        if (pinfo.errorHappened()) {
121:                            LOG.debug("*** ERROR happened for Param: "
122:                                    + pinfo.getName());
123:                            synchronized (errors) {
124:                                errors.put(pinfo.getName(), pinfo);
125:                            }
126:                        }
127:                    }
128:                }
129:            }
130:
131:            protected void initFromStringValue() {
132:                Iterator<?> it = params.values().iterator();
133:                while (it.hasNext()) {
134:                    IWrapperParam pinfo = (IWrapperParam) it.next();
135:                    pinfo.initFromStringValue();
136:                }
137:            }
138:
139:            public String getType() {
140:                return type;
141:            }
142:
143:            public String getName() {
144:                return name;
145:            }
146:
147:            public void setParamCaster(IWrapperParamCaster caster) {
148:                this .caster = caster;
149:            }
150:
151:            public void addPreChecker(IWrapperParamPreCheck check) {
152:                precheck.add(check);
153:            }
154:
155:            public void addPostChecker(IWrapperParamPostCheck check) {
156:                postcheck.add(check);
157:            }
158:
159:            public boolean errorHappened() {
160:                return !errors.isEmpty();
161:            }
162:
163:            public IWrapperParam[] getAllParamsWithErrors() {
164:                synchronized (errors) {
165:                    return (IWrapperParam[]) errors.values().toArray(
166:                            new IWrapperParam[] {});
167:                }
168:            }
169:
170:            public IWrapperParam[] getAllParams() {
171:                synchronized (params) {
172:                    return (IWrapperParam[]) params.values().toArray(
173:                            new IWrapperParam[] {});
174:                }
175:            }
176:
177:            public IWrapperParam getParamForIndex(String idx) {
178:                String key = name + "." + idx;
179:                synchronized (params) {
180:                    IWrapperParam pinfo = (IWrapperParam) params.get(key);
181:                    if (pinfo == null) {
182:                        pinfo = new IWrapperParam(key, multiple, true, null,
183:                                type, trim);
184:                        params.put(pinfo.getName(), pinfo);
185:                    }
186:                    return pinfo;
187:                }
188:            }
189:
190:            public void addSCode(StatusCode scode, String[] args, String level,
191:                    String idx) {
192:                IWrapperParam pinfo = getParamForIndex(idx);
193:                pinfo.addSCode(scode, args, level);
194:                synchronized (errors) {
195:                    errors.put(pinfo.getName(), pinfo);
196:                }
197:            }
198:
199:            public String[] getKeys() {
200:                String[] keys;
201:                synchronized (params) {
202:                    keys = new String[params.size()];
203:                    int j = 0;
204:                    for (Iterator<String> i = params.keySet().iterator(); i
205:                            .hasNext();) {
206:                        keys[j] = i.next().substring(getName().length() + 1);
207:                        j++;
208:                    }
209:                }
210:                return keys;
211:            }
212:
213:            public int compareTo(IWrapperParamDefinition in) {
214:                return name.compareTo(in.getName());
215:            }
216:        }// IWrapperIndexedParam
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.