Source Code Cross Referenced for TKMarkupDefinition.java in  » Content-Management-System » webman » com » teamkonzept » publishing » markups » 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 » Content Management System » webman » com.teamkonzept.publishing.markups 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/publishing/markups/TKMarkupDefinition.java,v 1.8 2001/06/11 09:14:10 alex Exp $
003:         *
004:         */
005:        package com.teamkonzept.publishing.markups;
006:
007:        import java.sql.*;
008:        import java.util.*;
009:
010:        import com.teamkonzept.db.*;
011:        import com.teamkonzept.lib.*;
012:        import com.teamkonzept.publishing.markups.db.*;
013:        import com.teamkonzept.publishing.markups.db.queries.*;
014:        import org.apache.log4j.Category;
015:
016:        public class TKMarkupDefinition implements  TKSortable {
017:            private static final Category cat = Category
018:                    .getInstance(TKMarkupDefinition.class);
019:
020:            public int id;
021:            public String name;
022:            public TKMarkupParamCall idPar;
023:            public String info;
024:            public boolean isAtom;
025:
026:            public int idParId = -1;
027:
028:            // Bitte nicht ˆffentlich machen !
029:            private TKHashtable params;
030:            private TKMarkupStatics statics = TKMarkupStatics.setup();
031:
032:            public TKMarkupDefinition(int id, String name,
033:                    TKMarkupParamCall idPar, boolean isAtom, String info,
034:                    TKHashtable params) {
035:
036:                this .id = id;
037:                this .name = name.toUpperCase();
038:                this .idPar = idPar;
039:                this .isAtom = isAtom;
040:                this .info = info;
041:                this .params = params;
042:            }
043:
044:            public TKMarkupDefinition(int id, String name, int idParId,
045:                    boolean isAtom, String info) {
046:
047:                this .id = id;
048:                this .name = name.toUpperCase();
049:                this .idPar = null;
050:                this .isAtom = isAtom;
051:                this .info = info;
052:                this .params = null;
053:
054:                this .idParId = idParId;
055:            }
056:
057:            public TKMarkupDefinition(TKMarkupDefinition definition,
058:                    Enumeration params) throws Error {
059:
060:                if (definition == null)
061:                    throw new Error("Markup-Definition fehlt");
062:
063:                this .id = definition.id;
064:                this .name = definition.name.toUpperCase();
065:                this .idPar = definition.idPar;
066:                this .isAtom = definition.isAtom;
067:                this .info = definition.info;
068:
069:                this .params = null;
070:                if (params == null)
071:                    return;
072:
073:                while ((params != null) && (params.hasMoreElements())) {
074:
075:                    TKMarkupParamCall paramDef = (TKMarkupParamCall) params
076:                            .nextElement();
077:                    if ((paramDef != null) && (paramDef.name != null))
078:                        defineParam(paramDef);
079:                }
080:            }
081:
082:            public void setIdPar(TKMarkupParamCall idPar) {
083:
084:                if (idPar != null)
085:                    this .idPar = idPar;
086:            }
087:
088:            public void unSetIdPar() {
089:
090:                this .idPar = null;
091:            }
092:
093:            public Enumeration allParams() {
094:
095:                return params == null ? null : params.elements();
096:            }
097:
098:            public TKMarkupParamCall lookupParam(String name) {
099:
100:                return params == null ? null : name == null ? null
101:                        : (TKMarkupParamCall) params.get(name);
102:            }
103:
104:            public void defineParam(TKMarkupParamCall param) {
105:
106:                if ((param == null) || (param.name == null)
107:                        || (param.name.length() == 0))
108:                    return;
109:
110:                if (params == null)
111:                    this .params = new TKHashtable();
112:                params.put(param.name, param);
113:
114:                if ((idParId >= 0) && (idParId == param.param.id))
115:                    idPar = param;
116:            }
117:
118:            public static Enumeration allMarkups() {
119:
120:                return TKMarkupStatics.setup().markupNames.elements();
121:            }
122:
123:            public static Enumeration allMarkups(TKMarkupStatics statics) {
124:
125:                return statics.markupNames.elements();
126:            }
127:
128:            public static Enumeration allAtomMarkups() {
129:
130:                TKVector vec = new TKVector();
131:
132:                Enumeration e = TKMarkupStatics.setup().markupNames.elements();
133:                while ((e != null) && e.hasMoreElements()) {
134:
135:                    TKMarkupDefinition definition = (TKMarkupDefinition) e
136:                            .nextElement();
137:
138:                    if ((definition != null) && definition.isAtom)
139:                        vec.addElement(definition);
140:                }
141:
142:                return vec.elements();
143:            }
144:
145:            public static Enumeration allCompoundMarkups() {
146:
147:                TKVector vec = new TKVector();
148:
149:                Enumeration e = TKMarkupStatics.setup().markupNames.elements();
150:                while ((e != null) && e.hasMoreElements()) {
151:
152:                    TKMarkupDefinition definition = (TKMarkupDefinition) e
153:                            .nextElement();
154:
155:                    if ((definition != null) && !definition.isAtom)
156:                        vec.addElement(definition);
157:                }
158:
159:                return vec.elements();
160:            }
161:
162:            public static void define(TKMarkupStatics statics,
163:                    TKMarkupDefinition definition) {
164:
165:                if ((definition == null) || (definition.id < 0))
166:                    return;
167:
168:                statics.markupIds.put(new Integer(definition.id), definition);
169:                statics.markupNames.put(definition.name.toUpperCase(),
170:                        definition);
171:            }
172:
173:            public static synchronized void define(TKMarkupDefinition definition) {
174:
175:                define(TKMarkupStatics.setup(), definition);
176:            }
177:
178:            public static synchronized void unDefine(String name) {
179:
180:                if (name == null)
181:                    return;
182:
183:                TKMarkupStatics statics = TKMarkupStatics.setup();
184:                TKMarkupDefinition definition = lookup(statics, name);
185:
186:                if (definition != null)
187:                    statics.markupIds.remove(new Integer(definition.id));
188:                if (name != null)
189:                    statics.markupNames.remove(name.toUpperCase());
190:            }
191:
192:            public static synchronized void unDefine(int id) {
193:
194:                if (id < 0)
195:                    return;
196:
197:                TKMarkupStatics statics = TKMarkupStatics.setup();
198:                TKMarkupDefinition definition = lookup(id);
199:
200:                if ((definition != null) && (definition.name != null))
201:                    statics.markupNames.remove(definition.name.toUpperCase());
202:
203:                statics.markupIds.remove(new Integer(id));
204:            }
205:
206:            public static synchronized TKMarkupDefinition lookup(
207:                    TKMarkupStatics statics, String name) {
208:
209:                return name == null ? null
210:                        : (TKMarkupDefinition) statics.markupNames.get(name
211:                                .toUpperCase());
212:            }
213:
214:            public static synchronized TKMarkupDefinition lookup(
215:                    TKMarkupStatics statics, int id) {
216:
217:                return id < 0 ? null : (TKMarkupDefinition) statics.markupIds
218:                        .get(new Integer(id));
219:            }
220:
221:            public static TKMarkupDefinition lookup(String name) {
222:
223:                return lookup(TKMarkupStatics.setup(), name);
224:            }
225:
226:            public static TKMarkupDefinition lookup(int id) {
227:
228:                return lookup(TKMarkupStatics.setup(), id);
229:            }
230:
231:            public static void defineParam(TKHashtable params,
232:                    TKMarkupParamCall paramCall) {
233:
234:                if ((paramCall == null) || (paramCall.name == null))
235:                    return;
236:
237:                params.put(paramCall.name.toUpperCase(), paramCall);
238:            }
239:
240:            public static void defineParam(TKMarkupStatics statics, int id,
241:                    TKMarkupParamCall paramCall) throws Exception {
242:
243:                if ((paramCall == null) || (paramCall.param == null)
244:                        || (paramCall.param.id < 0))
245:                    return;
246:
247:                TKMarkupDefinition definition = lookup(statics, id);
248:                if (definition == null)
249:                    throw new Exception(
250:                            "TKMarkupDefinition.defineParam(): markup-id " + id
251:                                    + " undefined in DB");
252:
253:                definition.defineParam(paramCall);
254:
255:                if (definition.idParId == paramCall.param.id)
256:                    definition.idPar = paramCall;
257:            }
258:
259:            public String toString() {
260:
261:                StringBuffer buf = new StringBuffer();
262:
263:                buf.append("name=").append(name).append(" id=").append(id)
264:                        .append(" idPar=[").append(idPar).append(']').append(
265:                                " info=").append(info).append(" isAtom=")
266:                        .append(isAtom);
267:
268:                Enumeration e = allParams();
269:                while ((e != null) && e.hasMoreElements()) {
270:
271:                    TKMarkupParamCall param = (TKMarkupParamCall) e
272:                            .nextElement();
273:                    if (param != null)
274:                        buf.append(" param=[").append(param).append(']');
275:                }
276:
277:                return new String(buf);
278:            }
279:
280:            public int cmp(TKSortable other) {
281:
282:                if (!(other instanceof  TKMarkupDefinition))
283:                    return toString().compareTo(other.toString());
284:
285:                TKMarkupDefinition otherMarkup = (TKMarkupDefinition) other;
286:
287:                if ((name == null) && (otherMarkup.name != null))
288:                    return -1;
289:                else if ((name != null) && (otherMarkup.name == null))
290:                    return 1;
291:                else if ((name == null) && (otherMarkup.name == null))
292:                    return 0;
293:                else
294:                    return name.compareTo(otherMarkup.name);
295:            };
296:
297:            public static boolean doCrConversion(TKMarkupStatics statics) {
298:
299:                return statics.doCrConversion;
300:
301:            }
302:
303:            public static String crMarkup(TKMarkupStatics statics) {
304:
305:                return statics.crMarkup;
306:
307:            }
308:
309:            public static String crcrMarkup(TKMarkupStatics statics) {
310:
311:                return statics.crcrMarkup;
312:
313:            }
314:
315:            public static void doCrConversion(TKMarkupStatics statics,
316:                    boolean doCrConversion) {
317:
318:                statics.doCrConversion = doCrConversion;
319:            }
320:
321:            public static void crMarkup(TKMarkupStatics statics, String crMarkup) {
322:
323:                if ((crMarkup != null) && (crMarkup.trim().length() == 0))
324:                    crMarkup = null;
325:                statics.crMarkup = crMarkup;
326:            }
327:
328:            public static void crcrMarkup(TKMarkupStatics statics,
329:                    String crcrMarkup) {
330:
331:                if ((crcrMarkup != null) && (crcrMarkup.trim().length() == 0))
332:                    crcrMarkup = null;
333:                statics.crcrMarkup = crcrMarkup;
334:            }
335:
336:            public static boolean doCrConversion() {
337:
338:                return doCrConversion(TKMarkupStatics.setup());
339:
340:            }
341:
342:            public static String crMarkup() {
343:
344:                return crMarkup(TKMarkupStatics.setup());
345:
346:            }
347:
348:            public static String crcrMarkup() {
349:
350:                return crcrMarkup(TKMarkupStatics.setup());
351:
352:            }
353:
354:            public static void doCrConversion(boolean doCrConversion) {
355:
356:                doCrConversion(TKMarkupStatics.setup(), doCrConversion);
357:            }
358:
359:            public static void crMarkup(String crMarkup) {
360:
361:                crMarkup(TKMarkupStatics.setup(), crMarkup);
362:            }
363:
364:            public static void crcrMarkup(String crcrMarkup) {
365:
366:                crcrMarkup(TKMarkupStatics.setup(), crcrMarkup);
367:            }
368:
369:            public static void getDefinitions() throws SQLException {
370:
371:                TKMarkupStatics statics = TKMarkupStatics.setup();
372:
373:                statics.markupNames = new TKHashtable();
374:                statics.markupIds = new TKHashtable();
375:
376:                TKQuery q = TKDBManager.newQuery(TKMarkupGetDefinitions.class);
377:                q.execute();
378:                ResultSet rs = q.fetchResultSet();
379:
380:                while (rs.next()) {
381:
382:                    TKMarkupDefinition markup = TKMarkupDefinitionDBData
383:                            .newMarkupFromResultSet(rs);
384:                    if (markup != null)
385:                        define(statics, markup);
386:                }
387:
388:                rs = q.fetchResultSet();
389:
390:                while (rs.next()) {
391:
392:                    try {
393:                        TKMarkupParamCallTableData param = new TKMarkupParamCallTableData(
394:                                rs);
395:
396:                        if (param != null)
397:                            defineParam(statics, param.markupId, param.param);
398:
399:                    } catch (Exception ex) {
400:                        cat.error(
401:                                "TKMarkupParamCall.getDefinitions() failed: ",
402:                                ex);
403:                    }
404:                }
405:
406:                String doConversionStr = null;
407:                String crMarkup = null;
408:                String crcrMarkup = null;
409:
410:                q = TKDBManager.newQuery(TKMarkupPropGet.class);
411:                q.execute();
412:                rs = q.fetchResultSet();
413:
414:                while (rs.next()) {
415:
416:                    String name = rs.getString("NAME");
417:                    String value = rs.getString("VALUE");
418:
419:                    if (name == null)
420:                        ;
421:                    else if (name.trim().equalsIgnoreCase("CR_CONTROL"))
422:                        doConversionStr = value;
423:                    else if (name.trim().equalsIgnoreCase("CR_MARKUP"))
424:                        crMarkup = value;
425:                    else if (name.trim().equalsIgnoreCase("CR_CR_MARKUP"))
426:                        crcrMarkup = value;
427:                }
428:
429:                boolean doConversion = doConversionStr != null
430:                        && !doConversionStr.trim().equals("0");
431:
432:                TKMarkupDefinition.doCrConversion(statics, doConversion);
433:                TKMarkupDefinition.crMarkup(statics, crMarkup);
434:                TKMarkupDefinition.crcrMarkup(statics, crcrMarkup);
435:            }
436:
437:            public static synchronized void setup() {
438:
439:                try {
440:                    getDefinitions();
441:                } catch (Exception ex) {
442:                    cat.error("TKMarkupDefinition.setup() failed: ", ex);
443:                } catch (TKSQLError er) {
444:                    cat.error("TKMarkupDefinition.setup() failed: ", er);
445:                }
446:            }
447:
448:            public static void putCrControl(boolean doCrConversion,
449:                    String crMarkup, String crcrMarkup) throws SQLException,
450:                    Exception {
451:
452:                StringBuffer diagnostics = new StringBuffer();
453:
454:                TKQuery q = TKDBManager.newQuery(TKMarkupPropPut.class);
455:                q.setQueryParams("CR_CONTROL", String
456:                        .valueOf(doCrConversion ? 1 : 0));
457:                q.setQueryParams("CR_MARKUP", crMarkup == null ? "" : crMarkup);
458:                q.setQueryParams("CR_CR_MARKUP", crcrMarkup == null ? ""
459:                        : crcrMarkup);
460:                q.execute();
461:
462:                TKMarkupStatics statics = TKMarkupStatics.setup();
463:
464:                TKMarkupDefinition.doCrConversion(statics, doCrConversion);
465:                TKMarkupDefinition.crMarkup(statics, crMarkup);
466:                TKMarkupDefinition.crcrMarkup(statics, crcrMarkup);
467:            }
468:
469:            public static synchronized void saveCrControl(
470:                    boolean doCrConversion, String crMarkup, String crcrMarkup) {
471:
472:                try {
473:                    putCrControl(doCrConversion, crMarkup, crcrMarkup);
474:                } catch (Throwable ex) {
475:                    cat
476:                            .error(
477:                                    "TKMarkupDefinition.saveCrControl() failed: ",
478:                                    ex);
479:                }
480:            }
481:
482:            public static void putDefinition(TKMarkupDefinition definition)
483:                    throws SQLException, Exception {
484:                if (definition == null)
485:                    return;
486:
487:                StringBuffer diagnostics = new StringBuffer();
488:                TKMarkupDefinitionDBData dbData = new TKMarkupDefinitionDBData(
489:                        definition, diagnostics);
490:
491:                if (definition.id < 0)
492:                    TKMarkupDefinitionDBInterface.New(dbData);
493:
494:                TKMarkupDefinitionDBInterface.Put(dbData);
495:
496:                if (diagnostics.length() != 0)
497:                    throw new Exception(diagnostics.toString());
498:
499:                unDefine(definition.id);
500:                definition.id = dbData.markup.id;
501:                define(dbData.markup);
502:            }
503:
504:            public synchronized void save() throws Exception {
505:
506:                try {
507:                    putDefinition(this );
508:                } catch (Exception ex) {
509:                    cat.error("TKMarkupDefinition.save() failed:  definition="
510:                            + this , ex);
511:                    throw new Exception("save failed: " + ex);
512:
513:                } catch (TKSQLError er) {
514:                    cat.error("TKMarkupDefinition.save() failed: definition="
515:                            + this , er);
516:                    throw new Exception("save failed: " + er);
517:                }
518:            }
519:
520:            public static void deleteDefinition(TKMarkupDefinition definition)
521:                    throws SQLException, Exception {
522:
523:                if (definition == null)
524:                    return;
525:
526:                StringBuffer diagnostics = new StringBuffer();
527:                TKMarkupDefinitionDBData dbData = new TKMarkupDefinitionDBData(
528:                        definition, diagnostics);
529:
530:                TKMarkupDefinitionDBInterface.Del(dbData);
531:
532:                if (diagnostics.length() != 0)
533:                    throw new Exception(diagnostics.toString());
534:
535:                unDefine(dbData.markup.id);
536:            }
537:
538:            public synchronized void delete() throws Exception {
539:
540:                try {
541:                    deleteDefinition(this );
542:                } catch (Exception ex) {
543:                    cat.error("TKMarkupDefinition.delete() failed: definition="
544:                            + this , ex);
545:                    throw new Exception("delete failed: " + ex);
546:
547:                } catch (TKSQLError er) {
548:                    cat.error("TKMarkupDefinition.delete() failed: definition="
549:                            + this , er);
550:                    throw new Exception("delete failed:  definition='" + this 
551:                            + "'");
552:                }
553:            }
554:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.