1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Cache.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 package com
.sun
.star
.filter
.config
.tools
.utils
;
32 //_______________________________________________
38 //_______________________________________________
41 * It implements a container for all possible entries which are part of the type
42 * and filter mechanism of an office - means all items of the configuration file
43 * "TypeDetection". How these entries will be readed or written can be switch
44 * in different modes. That would make it possible to edit an xml directly or
45 * to contact a running office instance.
51 //___________________________________________
54 /** identifies a file type item of this cache. */
55 public static final int E_TYPE
= 0;
57 /** identifies a filter item of this cache. */
58 public static final int E_FILTER
= 1;
60 /** identifies a detect service item of this cache. */
61 public static final int E_DETECTSERVICE
= 2;
63 /** identifies a frame loader item of this cache. */
64 public static final int E_FRAMELOADER
= 3;
66 /** identifies a content handler item of this cache. */
67 public static final int E_CONTENTHANDLER
= 4;
69 /** indicates an unsupported xml format => error! */
70 public static final int FORMAT_UNSUPPORTED
= -1;
72 /** identify the configuration format of an office 6.0.
73 * The own formated data string is used. */
74 public static final int FORMAT_60
= 0;
76 /** identify the configuration format of an office 6.y.
77 * Properties are realy xml tags again. */
78 public static final int FORMAT_6Y
= 1;
80 /** identify the configuration format which is used inside
81 * this tooling project. */
82 public static final int FORMAT_INTERNAL
= 2;
84 /** right value for a command line parameter to define a 6.0 version. */
85 public static final java
.lang
.String CMDVAL_FORMAT_60
= "6.0";
87 /** right value for a command line parameter to define a 6.Y version. */
88 public static final java
.lang
.String CMDVAL_FORMAT_6Y
= "6.Y";
90 /** right value for a command line parameter to define an internal xml version! */
91 public static final java
.lang
.String CMDVAL_FORMAT_INTERNAL
= "internal";
94 public static final java
.lang
.String PROPNAME_DATA
= "Data";
95 public static final java
.lang
.String PROPNAME_NAME
= "Name";
96 public static final java
.lang
.String PROPNAME_UINAME
= "UIName";
97 public static final java
.lang
.String PROPNAME_UINAMES
= "UINames";
100 public static final java
.lang
.String PROPNAME_MEDIATYPE
= "MediaType";
101 public static final java
.lang
.String PROPNAME_PREFERRED
= "Preferred";
102 public static final java
.lang
.String PROPNAME_CLIPBOARDFORMAT
= "ClipboardFormat";
103 public static final java
.lang
.String PROPNAME_DOCUMENTICONID
= "DocumentIconID";
104 public static final java
.lang
.String PROPNAME_URLPATTERN
= "URLPattern";
105 public static final java
.lang
.String PROPNAME_EXTENSIONS
= "Extensions";
107 public static final java
.lang
.String PROPNAME_UIORDER
= "UIOrder";
108 public static final java
.lang
.String PROPNAME_PREFERREDFILTER
= "PreferredFilter";
109 public static final java
.lang
.String PROPNAME_DETECTSERVICE
= "DetectService";
110 public static final java
.lang
.String PROPNAME_FRAMELOADER
= "FrameLoader";
111 public static final java
.lang
.String PROPNAME_CONTENTHANDLER
= "ContentHandler";
114 public static final java
.lang
.String PROPNAME_DOCUMENTSERVICE
= "DocumentService";
115 public static final java
.lang
.String PROPNAME_FILEFORMATVERSION
= "FileFormatVersion";
116 public static final java
.lang
.String PROPNAME_FILTERSERVICE
= "FilterService";
117 public static final java
.lang
.String PROPNAME_FLAGS
= "Flags";
118 public static final java
.lang
.String PROPNAME_ORDER
= "Order"; // -6.y
119 public static final java
.lang
.String PROPNAME_TEMPLATENAME
= "TemplateName";
120 public static final java
.lang
.String PROPNAME_TYPE
= "Type";
121 public static final java
.lang
.String PROPNAME_UICOMPONENT
= "UIComponent";
122 public static final java
.lang
.String PROPNAME_USERDATA
= "UserData";
124 // frame loader / detect services / content handler
125 public static final java
.lang
.String PROPNAME_TYPES
= "Types";
127 //___________________________________________
130 private static final java
.lang
.String FILTERSERVICE_NATIVEWARPPER
= "com.sun.star.filter.NativeFilterWrapper";
131 private static final java
.lang
.String GENERIC_DETECTSERVICE
= "com.sun.star.comp.office.FrameLoader";
133 /** its the name of the cfg set, which contains all types. */
134 private static final java
.lang
.String CFGNODE_TYPES
= "Types";
136 /** its the name of the cfg set, which contains all filters. */
137 private static final java
.lang
.String CFGNODE_FILTERS
= "Filters";
139 /** its the name of the cfg set, which contains all detect services. */
140 private static final java
.lang
.String CFGNODE_DETECTSERVICES
= "DetectServices";
142 /** its the name of the cfg set, which contains all frame loaders. */
143 private static final java
.lang
.String CFGNODE_FRAMELOADERS
= "FrameLoaders";
145 /** its the name of the cfg set, which contains all content handlers. */
146 private static final java
.lang
.String CFGNODE_CONTENTHANDLERS
= "ContentHandlers";
148 // names for filter flags
149 private static final java
.lang
.String FLAGNAME_3RDPARTYFILTER
= "3RDPARTYFILTER";
150 private static final java
.lang
.String FLAGNAME_ALIEN
= "ALIEN";
151 private static final java
.lang
.String FLAGNAME_ASYNCHRON
= "ASYNCHRON";
152 private static final java
.lang
.String FLAGNAME_BROWSERPREFERRED
= "BROWSERPREFERRED";
153 private static final java
.lang
.String FLAGNAME_CONSULTSERVICE
= "CONSULTSERVICE";
154 private static final java
.lang
.String FLAGNAME_DEFAULT
= "DEFAULT";
155 private static final java
.lang
.String FLAGNAME_EXPORT
= "EXPORT";
156 private static final java
.lang
.String FLAGNAME_IMPORT
= "IMPORT";
157 private static final java
.lang
.String FLAGNAME_INTERNAL
= "INTERNAL";
158 private static final java
.lang
.String FLAGNAME_NOTINCHOOSER
= "NOTINCHOOSER";
159 private static final java
.lang
.String FLAGNAME_NOTINFILEDIALOG
= "NOTINFILEDIALOG";
160 private static final java
.lang
.String FLAGNAME_NOTINSTALLED
= "NOTINSTALLED";
161 private static final java
.lang
.String FLAGNAME_OWN
= "OWN";
162 private static final java
.lang
.String FLAGNAME_PACKED
= "PACKED";
163 private static final java
.lang
.String FLAGNAME_PREFERRED
= "PREFERRED";
164 private static final java
.lang
.String FLAGNAME_READONLY
= "READONLY";
165 private static final java
.lang
.String FLAGNAME_SILENTEXPORT
= "SILENTEXPORT";
166 private static final java
.lang
.String FLAGNAME_TEMPLATE
= "TEMPLATE";
167 private static final java
.lang
.String FLAGNAME_TEMPLATEPATH
= "TEMPLATEPATH";
168 private static final java
.lang
.String FLAGNAME_USESOPTIONS
= "USESOPTIONS";
170 private static final java
.lang
.String FLAGNAME_COMBINED
= "COMBINED";
171 private static final java
.lang
.String FLAGNAME_SUPPORTSSELECTION
= "SUPPORTSSELECTION";
173 // values for filter flags
174 private static final int FLAGVAL_3RDPARTYFILTER
= 0x00080000; // 524288
175 private static final int FLAGVAL_ALIEN
= 0x00000040; // 64
176 private static final int FLAGVAL_ALL
= 0xffffffff; // 4294967295
177 private static final int FLAGVAL_ASYNCHRON
= 0x00004000; // 16384
178 private static final int FLAGVAL_BROWSERPREFERRED
= 0x00400000; // 4194304
179 private static final int FLAGVAL_CONSULTSERVICE
= 0x00040000; // 262144
180 private static final int FLAGVAL_DEFAULT
= 0x00000100; // 256
181 private static final int FLAGVAL_EXPORT
= 0x00000002; // 2
182 private static final int FLAGVAL_IMPORT
= 0x00000001; // 1
183 private static final int FLAGVAL_INTERNAL
= 0x00000008; // 8
184 private static final int FLAGVAL_NOTINCHOOSER
= 0x00002000; // 8192
185 private static final int FLAGVAL_NOTINFILEDIALOG
= 0x00001000; // 4096
186 private static final int FLAGVAL_NOTINSTALLED
= 0x00020000; // 131072
187 private static final int FLAGVAL_OWN
= 0x00000020; // 32
188 private static final int FLAGVAL_PACKED
= 0x00100000; // 1048576
189 private static final int FLAGVAL_PREFERRED
= 0x10000000; // 268435456
190 private static final int FLAGVAL_READONLY
= 0x00010000; // 65536
191 private static final int FLAGVAL_SILENTEXPORT
= 0x00200000; // 2097152
192 private static final int FLAGVAL_TEMPLATE
= 0x00000004; // 4
193 private static final int FLAGVAL_TEMPLATEPATH
= 0x00000010; // 16
194 private static final int FLAGVAL_USESOPTIONS
= 0x00000080; // 128
196 private static final int FLAGVAL_COMBINED
= 0x00800000; // ...
197 private static final int FLAGVAL_SUPPORTSSELECTION
= 0x00000400; // 1024
199 //___________________________________________
202 /** list of all located types.
203 * Format: [string,HashMap]
205 private java
.util
.HashMap m_lTypes
;
207 /** list of all located filters.
208 * Format: [string,HashMap]
210 private java
.util
.HashMap m_lFilters
;
212 /** list of all located detect services.
213 * Format: [string,HashMap]
215 private java
.util
.HashMap m_lDetectServices
;
217 /** list of all located frame loader.
218 * Format: [string,HashMap]
220 private java
.util
.HashMap m_lFrameLoaders
;
222 /** list of all located content handler.
223 * Format: [string,HashMap]
225 private java
.util
.HashMap m_lContentHandlers
;
227 /** contains all analyzed relations between
228 * filters and types. The key is an internal
229 * type name (can be used as reference into the
230 * list m_lTypes) and the value is a Vector of all
231 * internal filter names, which are registered for
233 * Format: [string, Vector]
235 private java
.util
.HashMap m_lFilterToTypeRegistrations
;
237 private int m_nDoubleRegisteredFilters
;
238 private int m_nTypesForFilters
;
239 private int m_nTypesForDetectServices
;
240 private int m_nTypesForFrameLoaders
;
241 private int m_nTypesForContentHandlers
;
243 /** can be used to log different informations. */
244 private Logger m_aDebug
;
246 //___________________________________________
251 * Initialize an empty cache instance. You have to use
252 * on of the fromXXX() methods to fill it from different
253 * sources with content.
255 public Cache(Logger aDebug
)
261 //___________________________________________
263 /** free memory and set default values on all members.
265 public synchronized void reset()
267 m_lTypes
= new java
.util
.HashMap();
268 m_lFilters
= new java
.util
.HashMap();
269 m_lFrameLoaders
= new java
.util
.HashMap();
270 m_lDetectServices
= new java
.util
.HashMap();
271 m_lContentHandlers
= new java
.util
.HashMap();
272 m_lFilterToTypeRegistrations
= new java
.util
.HashMap();
273 m_aDebug
= new Logger();
274 m_nDoubleRegisteredFilters
= 0;
275 m_nTypesForFilters
= 0;
276 m_nTypesForDetectServices
= 0;
277 m_nTypesForFrameLoaders
= 0;
278 m_nTypesForContentHandlers
= 0;
281 //___________________________________________
283 /** converts a string representation of an xml format
284 * to its int value, which must be used at some interface
285 * methods of this cache.
287 * If the given string does not match to any well known format,
288 * the return value will be FORMAT_UNSUPPORTED. The calli have to
289 * check that. Otherwhise a called interface method at this cache
290 * instance will be rejected by an exception!
293 * the string representation
294 * Must be one of our public const values from type CMDVAL_FORMAT_xxx.
297 * the int representation.
298 * Will be one of our public const values from type FORMAT_xxx.
300 public static int mapFormatString2Format(java
.lang
.String sFormat
)
302 int nFormat
= FORMAT_UNSUPPORTED
;
303 if (sFormat
.equalsIgnoreCase(CMDVAL_FORMAT_60
))
306 if (sFormat
.equalsIgnoreCase(CMDVAL_FORMAT_6Y
))
309 if (sFormat
.equalsIgnoreCase(CMDVAL_FORMAT_INTERNAL
))
310 nFormat
= FORMAT_INTERNAL
;
314 //___________________________________________
316 /** return some statistic values.
318 * Such values can be: - count of container items,
321 * @return [java.lang.String]
322 * a formated string, which contains al statistic data.
324 public synchronized java
.lang
.String
getStatistics()
326 java
.lang
.StringBuffer sBuffer
= new java
.lang
.StringBuffer(256);
328 sBuffer
.append("types = "+m_lTypes
.size() +"\n");
329 sBuffer
.append("filters = "+m_lFilters
.size() +"\n");
330 sBuffer
.append("detect services = "+m_lDetectServices
.size() +"\n");
331 sBuffer
.append("frame loaders = "+m_lFrameLoaders
.size() +"\n");
332 sBuffer
.append("content handler = "+m_lContentHandlers
.size() +"\n");
333 sBuffer
.append("double registered filters = "+m_nDoubleRegisteredFilters
+"\n");
334 sBuffer
.append("types used by filters = "+m_nTypesForFilters
+"\n");
335 sBuffer
.append("types used by detect services = "+m_nTypesForDetectServices
+"\n");
336 sBuffer
.append("types used by frame loaders = "+m_nTypesForFrameLoaders
+"\n");
337 sBuffer
.append("types used by content handlers = "+m_nTypesForContentHandlers
+"\n");
339 return sBuffer
.toString();
342 //___________________________________________
344 /** reset this cache and fill it with new values using the given XML file.
347 * must be a system file of a suitable XML file, which
348 * include all neccessary type/filter items.
351 * identifies the format of the specified xml file,
352 * which must be interpreted.
354 public synchronized void fromXML(java
.io
.File aXML
,
356 throws java
.lang
.Exception
362 javax
.xml
.parsers
.DocumentBuilderFactory aFactory
= javax
.xml
.parsers
.DocumentBuilderFactory
.newInstance();
364 * This call is important. It force right handling of entities during parsing and(!)
365 * writing. It let all possible signs for entities or it's quoted representations
366 * untouched. So this class don't change the original signs of the original file.
369 * <li>(') => (')</li>
370 * <li>(") => (")</li>
371 * <li>(>) => (>)</li>
372 * <li>(<) => (<)</li>
373 * <li>(>) => (>)</li>
374 * <li>(&) => (&)</li>
379 System
.out
.println("TODO: must be adapted to java 1.3 :-(");
381 //TODO_JAVA aFactory.setExpandEntityReferences(false);
383 javax
.xml
.parsers
.DocumentBuilder aBuilder
= aFactory
.newDocumentBuilder();
384 org
.w3c
.dom
.Document aDOM
= aBuilder
.parse(aXML
);
385 org
.w3c
.dom
.Element aRoot
= aDOM
.getDocumentElement();
387 // step over all sets
388 java
.util
.Vector lSetNodes
= XMLHelper
.extractChildNodesByTagName(aRoot
, XMLHelper
.XMLTAG_NODE
);
389 java
.util
.Enumeration it1
= lSetNodes
.elements();
390 while (it1
.hasMoreElements())
392 // try to find out, which set should be read
393 org
.w3c
.dom
.Node aSetNode
= (org
.w3c
.dom
.Node
)it1
.nextElement();
394 java
.lang
.String sSetName
= XMLHelper
.extractNodeAttribByName(aSetNode
, XMLHelper
.XMLATTRIB_OOR_NAME
);
395 if (sSetName
== null)
396 throw new java
.io
.IOException("unsupported format: could not extract set name on node ...\n"+aSetNode
);
398 // map some generic interfaces to the right members!
400 java
.util
.HashMap rMap
= null;
402 if (sSetName
.equals(CFGNODE_TYPES
))
408 if (sSetName
.equals(CFGNODE_FILTERS
))
414 if (sSetName
.equals(CFGNODE_FRAMELOADERS
))
416 eType
= E_FRAMELOADER
;
417 rMap
= m_lFrameLoaders
;
420 if (sSetName
.equals(CFGNODE_DETECTSERVICES
))
422 eType
= E_DETECTSERVICE
;
423 rMap
= m_lDetectServices
;
426 if (sSetName
.equals(CFGNODE_CONTENTHANDLERS
))
428 eType
= E_CONTENTHANDLER
;
429 rMap
= m_lContentHandlers
;
432 throw new java
.io
.IOException("unsupported format: unknown set name [\""+sSetName
+"\"] detected on node ...\n"+aSetNode
);
434 // load all set entries
435 java
.util
.Vector lChildNodes
= XMLHelper
.extractChildNodesByTagName(aSetNode
, XMLHelper
.XMLTAG_NODE
);
436 java
.util
.Enumeration it2
= lChildNodes
.elements();
437 while (it2
.hasMoreElements())
439 org
.w3c
.dom
.Node aChildNode
= (org
.w3c
.dom
.Node
)it2
.nextElement();
440 java
.lang
.String sChildName
= XMLHelper
.extractNodeAttribByName(aChildNode
, XMLHelper
.XMLATTRIB_OOR_NAME
);
441 if (sChildName
== null)
442 throw new java
.io
.IOException("unsupported format: could not extract child node name on node ...\n"+aChildNode
);
443 java
.util
.HashMap aPropSet
= null;
445 // Note: Our internal format is different from the source format!
446 java
.util
.HashMap aTempSet
= XMLHelper
.convertNodeToPropSet(aChildNode
);
451 aPropSet
= Cache
.convertTypePropsToInternal(aTempSet
, nFormat
);
452 m_aDebug
.setDetailedInfo("type [\""+sChildName
+"\"] converted to internal format");
458 aPropSet
= Cache
.convertFilterPropsToInternal(aTempSet
, nFormat
);
459 m_aDebug
.setDetailedInfo("filter [\""+sChildName
+"\"] converted to internal format");
463 case E_DETECTSERVICE
:
465 aPropSet
= Cache
.convertDetectServicePropsToInternal(aTempSet
, nFormat
);
466 m_aDebug
.setDetailedInfo("detect service [\""+sChildName
+"\"] converted to internal format");
472 aPropSet
= Cache
.convertFrameLoaderPropsToInternal(aTempSet
, nFormat
);
473 m_aDebug
.setDetailedInfo("frame loader [\""+sChildName
+"\"] converted to internal format");
477 case E_CONTENTHANDLER
:
479 aPropSet
= Cache
.convertContentHandlerPropsToInternal(aTempSet
, nFormat
);
480 m_aDebug
.setDetailedInfo("content handler [\""+sChildName
+"\"] converted to internal format");
484 m_aDebug
.setDetailedInfo("props = "+aTempSet
);
485 rMap
.put(sChildName
, aPropSet
);
490 //___________________________________________
492 /** create some hml views of the current content of this cache.
494 * The given directory is used to create different html files
495 * there. Every of them show another aspect of this cache.
496 * E.g.: - all type/filter properties
497 * - relation ships between types/filters/loaders etc.
500 * points to a system directory, which
501 * can be used completely(!) to generate
505 * specify in which context the cache items should be
508 public synchronized void toHTML(java
.io
.File aDirectory
,
510 java
.lang
.String sEncoding
)
511 throws java
.lang
.Exception
513 if (nFormat
!= FORMAT_6Y
)
514 throw new java
.lang
.Exception("HTML views are supported for the new 6.y format only yet.");
516 java
.lang
.StringBuffer sRelationView
= new java
.lang
.StringBuffer(1000);
517 sRelationView
.append("<html><header><title>Relation View</title></header><body>");
518 sRelationView
.append("<table border=1>");
519 sRelationView
.append("<tr><td><b>type</b></td><td><b>detect service</b></td><td><b>preferred filter</b></td><td><b>frame loader</b></td><td><b>content handler</b></td></tr>");
521 java
.util
.Iterator aIt
= m_lTypes
.keySet().iterator();
522 while (aIt
.hasNext())
524 java
.lang
.String sType
= (java
.lang
.String
)aIt
.next();
525 java
.util
.HashMap aType
= (java
.util
.HashMap
)m_lTypes
.get(sType
);
527 sRelationView
.append("<tr>");
528 sRelationView
.append("<td>"+sType
+"</td>");
530 java
.lang
.String sVal
= (java
.lang
.String
)aType
.get(PROPNAME_DETECTSERVICE
);
531 if (sVal
== null || sVal
.length()<1)
532 sRelationView
.append("<td> - </td>");
534 sRelationView
.append("<td>"+sVal
+"</td>");
536 sVal
= (java
.lang
.String
)aType
.get(PROPNAME_PREFERREDFILTER
);
537 if (sVal
== null || sVal
.length()<1)
538 sRelationView
.append("<td> - </td>");
540 sRelationView
.append("<td>"+sVal
+"</td>");
542 sVal
= (java
.lang
.String
)aType
.get(PROPNAME_FRAMELOADER
);
543 if (sVal
== null || sVal
.length()<1)
544 sRelationView
.append("<td> - </td>");
546 sRelationView
.append("<td>"+sVal
+"</td>");
548 sVal
= (java
.lang
.String
)aType
.get(PROPNAME_CONTENTHANDLER
);
549 if (sVal
== null || sVal
.length()<1)
550 sRelationView
.append("<td> - </td>");
552 sRelationView
.append("<td>"+sVal
+"</td>");
554 sRelationView
.append("</tr>");
557 sRelationView
.append("</table>");
558 sRelationView
.append("</body>");
560 FileHelper
.writeEncodedBufferToFile(new java
.io
.File(aDirectory
, "relation_view.html"), sEncoding
, false, sRelationView
);
562 java
.util
.HashMap lFilters2TypeRegistration
= new java
.util
.HashMap();
563 aIt
= m_lFilters
.keySet().iterator();
564 while (aIt
.hasNext())
566 java
.lang
.String sFilter
= (java
.lang
.String
)aIt
.next();
567 java
.util
.HashMap aFilter
= (java
.util
.HashMap
)m_lFilters
.get(sFilter
);
568 java
.lang
.String sType
= (java
.lang
.String
)aFilter
.get(PROPNAME_TYPE
);
570 java
.util
.Vector lFilters
= (java
.util
.Vector
)lFilters2TypeRegistration
.get(sType
);
571 if (lFilters
== null)
572 lFilters
= new java
.util
.Vector();
573 lFilters
.add(sFilter
);
574 lFilters2TypeRegistration
.put(sType
, lFilters
);
577 java
.lang
.StringBuffer sType2FiltersView
= new java
.lang
.StringBuffer(1000);
578 sType2FiltersView
.append("<html><header><title>Type2Filters View</title></header><body>");
579 sType2FiltersView
.append("<table border=1>");
580 sType2FiltersView
.append("<tr><td><b>type</b></td><td><b>filters</b></td></tr>");
582 aIt
= lFilters2TypeRegistration
.keySet().iterator();
583 while (aIt
.hasNext())
585 java
.lang
.String sType
= (java
.lang
.String
)aIt
.next();
586 java
.util
.Vector lFilters
= (java
.util
.Vector
)lFilters2TypeRegistration
.get(sType
);
588 sType2FiltersView
.append("<tr><td>"+sType
+"</td><td>");
589 java
.util
.Enumeration aEn
= lFilters
.elements();
590 while(aEn
.hasMoreElements())
591 sType2FiltersView
.append(aEn
.nextElement()+"<br>");
592 sType2FiltersView
.append("</td></tr>");
595 sType2FiltersView
.append("</table>");
596 sType2FiltersView
.append("</body>");
598 FileHelper
.writeEncodedBufferToFile(new java
.io
.File(aDirectory
, "type2filters_view.html"), sEncoding
, false, sType2FiltersView
);
601 //___________________________________________
603 /** converts all items of this cache to its xml representation
604 * and write it to the given file.
607 * the target file for output.
610 * the requested xml format.
611 * see const values FORMAT_xxx too.
614 * specify the file encoding for the generated xml file.
616 * @throws [java.lang.Exception]
617 * if something fail during convertion.
619 public synchronized void toXML(java
.io
.File aXML
,
621 java
.lang
.String sEncoding
)
622 throws java
.lang
.Exception
624 java
.lang
.StringBuffer sXML
= new java
.lang
.StringBuffer(500000);
626 for (int i
=0; i
<5; ++i
)
628 // define right sub container
629 java
.lang
.String sSetName
= null;
630 java
.util
.HashMap rMap
= null;
637 sSetName
= CFGNODE_TYPES
;
645 sSetName
= CFGNODE_FILTERS
;
653 sSetName
= CFGNODE_DETECTSERVICES
;
654 rMap
= m_lDetectServices
;
655 eType
= E_DETECTSERVICE
;
661 sSetName
= CFGNODE_FRAMELOADERS
;
662 rMap
= m_lFrameLoaders
;
663 eType
= E_FRAMELOADER
;
669 sSetName
= CFGNODE_CONTENTHANDLERS
;
670 rMap
= m_lContentHandlers
;
671 eType
= E_CONTENTHANDLER
;
677 sXML
.append("<node oor:name=\""+sSetName
+"\" oor:op=\"replace\">\n");
678 java
.util
.Iterator it
= rMap
.keySet().iterator();
681 java
.lang
.String sItem
= (java
.lang
.String
)it
.next();
682 sXML
.append("<node oor:name=\""+sItem
+"\" oor:op=\"replace\">\n");
683 sXML
.append(getItemAsXML(eType
, sItem
, nFormat
));
684 sXML
.append("</node>\n");
686 sXML
.append("</node>\n");
689 java
.io
.FileOutputStream aStream
= new java
.io
.FileOutputStream(aXML
.getAbsolutePath(), false);
690 java
.io
.OutputStreamWriter aWriter
= new java
.io
.OutputStreamWriter(aStream
, sEncoding
);
691 java
.lang
.String sOut
= sXML
.toString();
692 aWriter
.write(sOut
, 0, sOut
.length());
697 //___________________________________________
699 /** converts a type property set from internal format
700 * to an external one.
703 * points to the item, which should be converted.
706 * specify the requested output format.
708 * @return [java.util.HashMap]
709 * contains the properties in the requested format.
711 * @throws [java.lang.Exception
712 * if something fail during convertion.
714 private static java
.util
.HashMap
convertTypePropsToExternal(java
.util
.HashMap aMap
,
716 throws java
.lang
.Exception
718 java
.util
.HashMap aResultMap
= new java
.util
.HashMap();
719 // copy Name property ... if it exists!
720 if (aMap
.containsKey(PROPNAME_NAME
))
721 aResultMap
.put(PROPNAME_NAME
, aMap
.get(PROPNAME_NAME
));
724 //-----------------------------------
727 // copy UIName property unchanged
728 aResultMap
.put(PROPNAME_UINAME
, aMap
.get(PROPNAME_UINAME
));
730 // ignore properties "UIOrder", "PreferredFilter", "DetectService"
731 // They are not supported for 6.0 types.
733 // pack all other properties to one "Data" string value
734 java
.lang
.StringBuffer sData
= new java
.lang
.StringBuffer(256);
736 sData
.append(aMap
.get(PROPNAME_PREFERRED
));
738 sData
.append(aMap
.get(PROPNAME_MEDIATYPE
));
740 sData
.append(aMap
.get(PROPNAME_CLIPBOARDFORMAT
));
743 java
.util
.Vector lList
= (java
.util
.Vector
)aMap
.get(PROPNAME_URLPATTERN
);
744 int c
= lList
.size();
748 sData
.append(lList
.elementAt(i
));
753 lList
= (java
.util
.Vector
)aMap
.get(PROPNAME_EXTENSIONS
);
757 sData
.append(lList
.elementAt(i
));
763 sData
.append(aMap
.get(PROPNAME_DOCUMENTICONID
));
766 aResultMap
.put(PROPNAME_DATA
, sData
.toString());
770 //-----------------------------------
773 // copy all supported properties directly
774 aResultMap
.put(PROPNAME_PREFERRED
, aMap
.get(PROPNAME_PREFERRED
));
775 aResultMap
.put(PROPNAME_MEDIATYPE
, aMap
.get(PROPNAME_MEDIATYPE
));
776 aResultMap
.put(PROPNAME_URLPATTERN
, aMap
.get(PROPNAME_URLPATTERN
));
777 aResultMap
.put(PROPNAME_EXTENSIONS
, aMap
.get(PROPNAME_EXTENSIONS
));
778 aResultMap
.put(PROPNAME_UINAME
, aMap
.get(PROPNAME_UINAME
));
779 aResultMap
.put(PROPNAME_PREFERREDFILTER
, aMap
.get(PROPNAME_PREFERREDFILTER
));
780 aResultMap
.put(PROPNAME_DETECTSERVICE
, aMap
.get(PROPNAME_DETECTSERVICE
));
781 aResultMap
.put(PROPNAME_CLIPBOARDFORMAT
, aMap
.get(PROPNAME_CLIPBOARDFORMAT
));
782 aResultMap
.put(PROPNAME_UIORDER
, aMap
.get(PROPNAME_UIORDER
));
784 aResultMap.put(PROPNAME_DOCUMENTICONID , aMap.get(PROPNAME_DOCUMENTICONID ));
789 //-----------------------------------
791 throw new java
.lang
.Exception("unknown format");
797 //___________________________________________
799 /** converts a filter property set from internal format
800 * to an external one.
803 * points to the item, which should be converted.
806 * specify the requested output format.
808 * @return [java.util.HashMap]
809 * contains the properties in the requested format.
811 * @throws [java.lang.Exception
812 * if something fail during convertion.
814 private static java
.util
.HashMap
convertFilterPropsToExternal(java
.util
.HashMap aMap
,
816 throws java
.lang
.Exception
818 java
.util
.HashMap aResultMap
= new java
.util
.HashMap();
819 // copy Name property ... if it exists!
820 if (aMap
.containsKey(PROPNAME_NAME
))
821 aResultMap
.put(PROPNAME_NAME
, aMap
.get(PROPNAME_NAME
));
824 //-----------------------------------
827 // copy UIName property unchanged!
828 aResultMap
.put(PROPNAME_UINAME
, aMap
.get(PROPNAME_UINAME
));
830 // but pack all other properties
831 java
.lang
.StringBuffer sData
= new java
.lang
.StringBuffer(256);
833 sData
.append(aMap
.get(PROPNAME_ORDER
));
835 sData
.append(aMap
.get(PROPNAME_TYPE
));
837 sData
.append(aMap
.get(PROPNAME_DOCUMENTSERVICE
));
839 sData
.append(aMap
.get(PROPNAME_FILTERSERVICE
));
841 sData
.append(aMap
.get(PROPNAME_FLAGS
));
843 java
.util
.Vector lList
= (java
.util
.Vector
)aMap
.get(PROPNAME_USERDATA
);
844 int c
= lList
.size();
848 sData
.append(lList
.elementAt(i
));
853 sData
.append(aMap
.get(PROPNAME_FILEFORMATVERSION
));
855 sData
.append(aMap
.get(PROPNAME_TEMPLATENAME
));
857 sData
.append(aMap
.get(PROPNAME_UICOMPONENT
));
860 aResultMap
.put(PROPNAME_DATA
, sData
.toString());
864 //-----------------------------------
867 // supress "Order" property.
868 // Will be moved to type entries in 6.y version!
870 // supress "UIName" property.
871 // Only type entries will be localized in 6.y version!
872 /* TODO make it configurable :-) */
873 aResultMap
.put(PROPNAME_UINAME
, aMap
.get(PROPNAME_UINAME
));
875 // copy all supported properties directly
876 aResultMap
.put(PROPNAME_TYPE
, aMap
.get(PROPNAME_TYPE
));
877 aResultMap
.put(PROPNAME_DOCUMENTSERVICE
, aMap
.get(PROPNAME_DOCUMENTSERVICE
));
878 aResultMap
.put(PROPNAME_FILTERSERVICE
, aMap
.get(PROPNAME_FILTERSERVICE
));
879 aResultMap
.put(PROPNAME_USERDATA
, aMap
.get(PROPNAME_USERDATA
));
880 aResultMap
.put(PROPNAME_FILEFORMATVERSION
, aMap
.get(PROPNAME_FILEFORMATVERSION
));
881 aResultMap
.put(PROPNAME_TEMPLATENAME
, aMap
.get(PROPNAME_TEMPLATENAME
));
882 aResultMap
.put(PROPNAME_UICOMPONENT
, aMap
.get(PROPNAME_UICOMPONENT
));
884 // "Flags" will be converted from internal format [int] to
885 // the 6.y format [string-list]!
886 java
.lang
.Integer nFlags
= (java
.lang
.Integer
)aMap
.get(PROPNAME_FLAGS
);
887 java
.util
.Vector lFlags
= Cache
.convertFilterFlagValues2Names(nFlags
);
888 aResultMap
.put(PROPNAME_FLAGS
, lFlags
);
892 //-----------------------------------
894 throw new java
.lang
.Exception("unknown format");
900 //___________________________________________
902 /** converts a detect service property set from internal format
903 * to an external one.
906 * points to the item, which should be converted.
909 * specify the requested output format.
911 * @return [java.util.HashMap]
912 * contains the properties in the requested format.
914 * @throws [java.lang.Exception
915 * if something fail during convertion.
917 private static java
.util
.HashMap
convertDetectServicePropsToExternal(java
.util
.HashMap aMap
,
919 throws java
.lang
.Exception
921 java
.util
.HashMap aResultMap
= null;
925 //-----------------------------------
933 //-----------------------------------
936 // remove localized name
938 aResultMap
.remove(PROPNAME_UINAME
);
942 //-----------------------------------
944 throw new java
.lang
.Exception("unknown format");
950 private static java
.util
.HashMap
convertFrameLoaderPropsToExternal(java
.util
.HashMap aMap
,
952 throws java
.lang
.Exception
954 java
.util
.HashMap aResultMap
= null;
958 //-----------------------------------
966 //-----------------------------------
969 // remove localized name
971 aResultMap
.remove(PROPNAME_UINAME
);
975 //-----------------------------------
977 throw new java
.lang
.Exception("unknown format");
983 private static java
.util
.HashMap
convertContentHandlerPropsToExternal(java
.util
.HashMap aMap
,
985 throws java
.lang
.Exception
987 java
.util
.HashMap aResultMap
= null;
991 //-----------------------------------
999 //-----------------------------------
1002 // remove localized name
1004 aResultMap
.remove(PROPNAME_UINAME
);
1008 //-----------------------------------
1010 throw new java
.lang
.Exception("unknown format");
1016 //___________________________________________
1018 /** converts a type property set (using an external format) to
1019 * our internal cache format.
1021 * Especialy the data format string will be expanded
1022 * to its real properties.
1025 * aMap["UIName"] => aExpandedMap["UIName"]
1026 * aMap["Data" ] => aExpandedMap["Preferred" ], aExpandedMap["MediaType"] etc. ...
1029 * points to the item, which should be converted.
1032 * specify the external format.
1034 * @return [java.util.HashMap]
1035 * The new map in internal format.
1037 private static java
.util
.HashMap
convertTypePropsToInternal(java
.util
.HashMap aMap
,
1039 throws java
.lang
.Exception
1041 java
.util
.HashMap aResultMap
= new java
.util
.HashMap();
1042 // copy Name property ... if it exists!
1043 if (aMap
.containsKey(PROPNAME_NAME
))
1044 aResultMap
.put(PROPNAME_NAME
, aMap
.get(PROPNAME_NAME
));
1047 //-----------------------------------
1050 // copy UIName property unchanged!
1051 aResultMap
.put(PROPNAME_UINAME
, aMap
.get(PROPNAME_UINAME
));
1053 // generate new property "UIOrder"
1054 // Its the moved property "Order" of filters for versions >= 6.y!
1055 aResultMap
.put(PROPNAME_UIORDER
, new java
.lang
.Integer(0));
1057 // generate new property "PreferredFilter"
1058 // Its a the moved filter flag "Preferred" for versions >= 6.y!
1059 aResultMap
.put(PROPNAME_PREFERREDFILTER
, new java
.lang
.String());
1061 // generate new property "DetectService"
1062 // Every type know its detector diretcly from now. No search
1063 // will be neccessary any longer.
1064 aResultMap
.put(PROPNAME_DETECTSERVICE
, new java
.lang
.String());
1066 // analyze the Data property of the original map
1067 // and copy its results (means all expanded properties)
1068 // to the result map.
1069 java
.lang
.String sDataVal
= (java
.lang
.String
)aMap
.get(PROPNAME_DATA
);
1070 java
.util
.Vector lTokens
= Cache
.splitTokenString(sDataVal
, ",");
1073 java
.util
.Enumeration it
= lTokens
.elements();
1074 while (it
.hasMoreElements())
1076 java
.lang
.String sToken
= (java
.lang
.String
)it
.nextElement();
1080 aResultMap
.put(PROPNAME_PREFERRED
, new java
.lang
.Boolean(sToken
));
1083 aResultMap
.put(PROPNAME_MEDIATYPE
, sToken
);
1087 /*HACK ersetze %20 mit " " ...*/
1088 int ni
= sToken
.indexOf("%20");
1091 java
.lang
.String sPatch
= sToken
.substring(0,ni
) + " " + sToken
.substring(ni
+3);
1094 aResultMap
.put(PROPNAME_CLIPBOARDFORMAT
, sToken
);
1098 aResultMap
.put(PROPNAME_URLPATTERN
, Cache
.splitTokenString(sToken
, ";"));
1101 aResultMap
.put(PROPNAME_EXTENSIONS
, Cache
.splitTokenString(sToken
, ";"));
1104 aResultMap
.put(PROPNAME_DOCUMENTICONID
, new java
.lang
.Integer(sToken
));
1107 throw new java
.lang
.Exception("unsupported format for data value of a type \""+aMap
.get(PROPNAME_NAME
)+"\" detected.");
1114 //-----------------------------------
1117 // copy all supported properties directly
1118 aResultMap
.put(PROPNAME_PREFERRED
, aMap
.get(PROPNAME_PREFERRED
));
1119 aResultMap
.put(PROPNAME_MEDIATYPE
, aMap
.get(PROPNAME_MEDIATYPE
));
1120 aResultMap
.put(PROPNAME_CLIPBOARDFORMAT
, aMap
.get(PROPNAME_CLIPBOARDFORMAT
));
1121 aResultMap
.put(PROPNAME_URLPATTERN
, aMap
.get(PROPNAME_URLPATTERN
));
1122 aResultMap
.put(PROPNAME_EXTENSIONS
, aMap
.get(PROPNAME_EXTENSIONS
));
1123 aResultMap
.put(PROPNAME_DOCUMENTICONID
, aMap
.get(PROPNAME_DOCUMENTICONID
));
1124 aResultMap
.put(PROPNAME_UINAME
, aMap
.get(PROPNAME_UINAME
));
1125 aResultMap
.put(PROPNAME_UIORDER
, aMap
.get(PROPNAME_UIORDER
));
1126 aResultMap
.put(PROPNAME_PREFERREDFILTER
, aMap
.get(PROPNAME_PREFERREDFILTER
));
1127 aResultMap
.put(PROPNAME_DETECTSERVICE
, aMap
.get(PROPNAME_DETECTSERVICE
));
1131 //-----------------------------------
1133 throw new java
.lang
.Exception("unknown format");
1139 //___________________________________________
1141 /** converts a filter property set (using an external format) to
1142 * our internal cache format.
1144 * Especialy the data format string will be expanded
1145 * to its real properties.
1148 * aMap["UIName"] => aExpandedMap["UIName"]
1149 * aMap["Data" ] => aExpandedMap["Order" ], aExpandedMap["Flags"] etc. ...
1152 * points to the item, which should be converted.
1155 * specify the external format.
1157 * @return [java.util.HashMap]
1158 * The new map in internal format.
1160 private static java
.util
.HashMap
convertFilterPropsToInternal(java
.util
.HashMap aMap
,
1162 throws java
.lang
.Exception
1164 java
.util
.HashMap aResultMap
= new java
.util
.HashMap();
1165 // copy Name property ... if it exists!
1166 if (aMap
.containsKey(PROPNAME_NAME
))
1167 aResultMap
.put(PROPNAME_NAME
, aMap
.get(PROPNAME_NAME
));
1170 //-----------------------------------
1173 // copy UIName property
1174 aResultMap
.put(PROPNAME_UINAME
, aMap
.get(PROPNAME_UINAME
));
1176 // analyze the Data property of the original map
1177 // and copy its results (means all expanded properties)
1178 // to the result map.
1179 java
.lang
.String sDataVal
= (java
.lang
.String
)aMap
.get(PROPNAME_DATA
);
1180 java
.util
.Vector lTokens
= Cache
.splitTokenString(sDataVal
, ",");
1183 java
.util
.Enumeration it
= lTokens
.elements();
1184 while (it
.hasMoreElements())
1186 java
.lang
.String sToken
= (java
.lang
.String
)it
.nextElement();
1190 aResultMap
.put(PROPNAME_ORDER
, new java
.lang
.Integer(sToken
));
1193 aResultMap
.put(PROPNAME_TYPE
, sToken
);
1196 aResultMap
.put(PROPNAME_DOCUMENTSERVICE
, sToken
);
1199 aResultMap
.put(PROPNAME_FILTERSERVICE
, sToken
);
1202 aResultMap
.put(PROPNAME_FLAGS
, new java
.lang
.Integer(sToken
));
1205 aResultMap
.put(PROPNAME_USERDATA
, Cache
.splitTokenString(sToken
, ";"));
1208 aResultMap
.put(PROPNAME_FILEFORMATVERSION
, new java
.lang
.Integer(sToken
));
1211 aResultMap
.put(PROPNAME_TEMPLATENAME
, sToken
);
1214 aResultMap
.put(PROPNAME_UICOMPONENT
, sToken
);
1217 throw new java
.lang
.Exception("unsupported format for data value of a filter detected.");
1222 // its an optional property :-)
1223 if (!aResultMap
.containsKey(PROPNAME_TEMPLATENAME
))
1224 aResultMap
.put(PROPNAME_TEMPLATENAME
, new java
.lang
.String(""));
1226 // its an optional property :-)
1227 if (!aResultMap
.containsKey(PROPNAME_UICOMPONENT
))
1228 aResultMap
.put(PROPNAME_UICOMPONENT
, new java
.lang
.String(""));
1232 //-----------------------------------
1235 // "Order" does not exist for 6.y versions! Use default.
1236 aResultMap
.put(PROPNAME_ORDER
, new java
.lang
.Integer(0));
1238 // "UIName" property does not exist for 6.y versions! use default.
1239 /* TODO make it configurable :-) */
1240 aResultMap
.put(PROPNAME_UINAME
, aMap
.get(PROPNAME_UINAME
));
1241 //aResultMap.put(PROPNAME_UINAME, new java.util.HashMap());
1243 // "Flags" must be converted from names to its values
1244 java
.util
.Vector lFlags
= (java
.util
.Vector
)aMap
.get(PROPNAME_FLAGS
);
1245 java
.lang
.Integer nFlags
= Cache
.convertFilterFlagNames2Values(lFlags
);
1246 aResultMap
.put(PROPNAME_FLAGS
, nFlags
);
1248 // copy all direct supported properties
1249 aResultMap
.put(PROPNAME_TYPE
, aMap
.get(PROPNAME_TYPE
));
1250 aResultMap
.put(PROPNAME_DOCUMENTSERVICE
, aMap
.get(PROPNAME_DOCUMENTSERVICE
));
1251 aResultMap
.put(PROPNAME_FILTERSERVICE
, aMap
.get(PROPNAME_ORDER
));
1252 aResultMap
.put(PROPNAME_USERDATA
, aMap
.get(PROPNAME_USERDATA
));
1253 aResultMap
.put(PROPNAME_FILEFORMATVERSION
, aMap
.get(PROPNAME_FILEFORMATVERSION
));
1254 aResultMap
.put(PROPNAME_TEMPLATENAME
, aMap
.get(PROPNAME_TEMPLATENAME
));
1255 aResultMap
.put(PROPNAME_UICOMPONENT
, aMap
.get(PROPNAME_UICOMPONENT
));
1259 //-----------------------------------
1261 throw new java
.lang
.Exception("unknown format");
1267 private static java
.util
.HashMap
convertDetectServicePropsToInternal(java
.util
.HashMap aMap
,
1269 throws java
.lang
.Exception
1272 java
.util
.HashMap aResultMap
= aMap
;
1276 private static java
.util
.HashMap
convertFrameLoaderPropsToInternal(java
.util
.HashMap aMap
,
1278 throws java
.lang
.Exception
1281 java
.util
.HashMap aResultMap
= aMap
;
1285 private static java
.util
.HashMap
convertContentHandlerPropsToInternal(java
.util
.HashMap aMap
,
1287 throws java
.lang
.Exception
1290 java
.util
.HashMap aResultMap
= aMap
;
1294 //___________________________________________
1296 /** converts filter flag names to its int representation.
1299 * a list of flag names.
1301 * @return [java.lang.Integer]
1302 * an integer field of all set flags.
1304 * @throws [java.lang.Exception]
1305 * for unsupported flags or empty flag fields!
1307 private static java
.lang
.Integer
convertFilterFlagNames2Values(java
.util
.Vector lFlags
)
1308 throws java
.lang
.Exception
1311 java
.util
.Enumeration it
= lFlags
.elements();
1312 while(it
.hasMoreElements())
1314 java
.lang
.String sFlagName
= (java
.lang
.String
)it
.nextElement();
1316 if (sFlagName
.equals(FLAGNAME_3RDPARTYFILTER
))
1317 nFlags
|= FLAGVAL_3RDPARTYFILTER
;
1319 if (sFlagName
.equals(FLAGNAME_ALIEN
))
1320 nFlags
|= FLAGVAL_ALIEN
;
1322 if (sFlagName
.equals(FLAGNAME_ASYNCHRON
))
1323 nFlags
|= FLAGVAL_ASYNCHRON
;
1325 if (sFlagName
.equals(FLAGNAME_BROWSERPREFERRED
))
1326 nFlags
|= FLAGVAL_BROWSERPREFERRED
;
1328 if (sFlagName
.equals(FLAGNAME_CONSULTSERVICE
))
1329 nFlags
|= FLAGVAL_CONSULTSERVICE
;
1331 if (sFlagName
.equals(FLAGNAME_DEFAULT
))
1332 nFlags
|= FLAGVAL_DEFAULT
;
1334 if (sFlagName
.equals(FLAGNAME_EXPORT
))
1335 nFlags
|= FLAGVAL_EXPORT
;
1337 if (sFlagName
.equals(FLAGNAME_IMPORT
))
1338 nFlags
|= FLAGVAL_IMPORT
;
1340 if (sFlagName
.equals(FLAGNAME_INTERNAL
))
1341 nFlags
|= FLAGVAL_INTERNAL
;
1343 if (sFlagName
.equals(FLAGNAME_NOTINCHOOSER
))
1344 nFlags
|= FLAGVAL_NOTINCHOOSER
;
1346 if (sFlagName
.equals(FLAGNAME_NOTINFILEDIALOG
))
1347 nFlags
|= FLAGVAL_NOTINFILEDIALOG
;
1349 if (sFlagName
.equals(FLAGNAME_NOTINSTALLED
))
1350 nFlags
|= FLAGVAL_NOTINSTALLED
;
1352 if (sFlagName
.equals(FLAGNAME_OWN
))
1353 nFlags
|= FLAGVAL_OWN
;
1355 if (sFlagName
.equals(FLAGNAME_PACKED
))
1356 nFlags
|= FLAGVAL_PACKED
;
1358 if (sFlagName
.equals(FLAGNAME_PREFERRED
))
1359 nFlags
|= FLAGVAL_PREFERRED
;
1361 if (sFlagName
.equals(FLAGNAME_READONLY
))
1362 nFlags
|= FLAGVAL_READONLY
;
1364 if (sFlagName
.equals(FLAGNAME_SILENTEXPORT
))
1365 nFlags
|= FLAGVAL_SILENTEXPORT
;
1367 if (sFlagName
.equals(FLAGNAME_TEMPLATE
))
1368 nFlags
|= FLAGVAL_TEMPLATE
;
1370 if (sFlagName
.equals(FLAGNAME_TEMPLATEPATH
))
1371 nFlags
|= FLAGVAL_TEMPLATEPATH
;
1373 if (sFlagName
.equals(FLAGNAME_USESOPTIONS
))
1374 nFlags
|= FLAGVAL_USESOPTIONS
;
1376 if (sFlagName
.equals(FLAGNAME_COMBINED
))
1377 nFlags
|= FLAGVAL_COMBINED
;
1379 throw new java
.lang
.Exception("unsupported filter flag detected: \""+sFlagName
+"\"");
1383 throw new java
.lang
.Exception("no filter flags?");
1385 return new java
.lang
.Integer(nFlags
);
1388 //___________________________________________
1390 /** converts filter flag values to its string representation.
1393 * the flag field as int value.
1395 * @return [java.util.Vector]
1396 * a list of flag names.
1398 * @throws [java.lang.Exception]
1399 * for unsupported flags or empty flag fields!
1401 private static java
.util
.Vector
convertFilterFlagValues2Names(java
.lang
.Integer nFlags
)
1402 throws java
.lang
.Exception
1404 java
.util
.Vector lFlags
= new java
.util
.Vector();
1405 int field
= nFlags
.intValue();
1408 throw new java
.lang
.Exception("no filter flags?");
1410 if((field
& FLAGVAL_IMPORT
) == FLAGVAL_IMPORT
)
1411 lFlags
.add(FLAGNAME_IMPORT
);
1413 if((field
& FLAGVAL_EXPORT
) == FLAGVAL_EXPORT
)
1414 lFlags
.add(FLAGNAME_EXPORT
);
1416 if((field
& FLAGVAL_TEMPLATE
) == FLAGVAL_TEMPLATE
)
1417 lFlags
.add(FLAGNAME_TEMPLATE
);
1419 if((field
& FLAGVAL_INTERNAL
) == FLAGVAL_INTERNAL
)
1420 lFlags
.add(FLAGNAME_INTERNAL
);
1422 if((field
& FLAGVAL_TEMPLATEPATH
) == FLAGVAL_TEMPLATEPATH
)
1423 lFlags
.add(FLAGNAME_TEMPLATEPATH
);
1425 if((field
& FLAGVAL_OWN
) == FLAGVAL_OWN
)
1426 lFlags
.add(FLAGNAME_OWN
);
1428 if((field
& FLAGVAL_ALIEN
) == FLAGVAL_ALIEN
)
1429 lFlags
.add(FLAGNAME_ALIEN
);
1431 if((field
& FLAGVAL_USESOPTIONS
) == FLAGVAL_USESOPTIONS
)
1432 lFlags
.add(FLAGNAME_USESOPTIONS
);
1434 if((field
& FLAGVAL_DEFAULT
) == FLAGVAL_DEFAULT
)
1435 lFlags
.add(FLAGNAME_DEFAULT
);
1437 if((field
& FLAGVAL_NOTINFILEDIALOG
) == FLAGVAL_NOTINFILEDIALOG
)
1438 lFlags
.add(FLAGNAME_NOTINFILEDIALOG
);
1440 if((field
& FLAGVAL_NOTINCHOOSER
) == FLAGVAL_NOTINCHOOSER
)
1441 lFlags
.add(FLAGNAME_NOTINCHOOSER
);
1443 if((field
& FLAGVAL_ASYNCHRON
) == FLAGVAL_ASYNCHRON
)
1444 lFlags
.add(FLAGNAME_ASYNCHRON
);
1446 if((field
& FLAGVAL_READONLY
) == FLAGVAL_READONLY
)
1447 lFlags
.add(FLAGNAME_READONLY
);
1449 if((field
& FLAGVAL_NOTINSTALLED
) == FLAGVAL_NOTINSTALLED
)
1450 lFlags
.add(FLAGNAME_NOTINSTALLED
);
1452 if((field
& FLAGVAL_CONSULTSERVICE
) == FLAGVAL_CONSULTSERVICE
)
1453 lFlags
.add(FLAGNAME_CONSULTSERVICE
);
1455 if((field
& FLAGVAL_3RDPARTYFILTER
) == FLAGVAL_3RDPARTYFILTER
)
1456 lFlags
.add(FLAGNAME_3RDPARTYFILTER
);
1458 if((field
& FLAGVAL_PACKED
) == FLAGVAL_PACKED
)
1459 lFlags
.add(FLAGNAME_PACKED
);
1461 if((field
& FLAGVAL_SILENTEXPORT
) == FLAGVAL_SILENTEXPORT
)
1462 lFlags
.add(FLAGNAME_SILENTEXPORT
);
1464 if((field
& FLAGVAL_BROWSERPREFERRED
) == FLAGVAL_BROWSERPREFERRED
)
1465 lFlags
.add(FLAGNAME_BROWSERPREFERRED
);
1467 if((field
& FLAGVAL_PREFERRED
) == FLAGVAL_PREFERRED
)
1468 lFlags
.add(FLAGNAME_PREFERRED
);
1470 if((field
& FLAGVAL_COMBINED
) == FLAGVAL_COMBINED
)
1471 lFlags
.add(FLAGNAME_COMBINED
);
1473 if((field
& FLAGVAL_COMBINED
) == FLAGVAL_SUPPORTSSELECTION
)
1474 lFlags
.add(FLAGNAME_SUPPORTSSELECTION
);
1479 //___________________________________________
1481 /** return a reference to one of our member
1482 * lists for types/filters etc ...
1485 * specify, which item map is required.
1487 * @return [java.util.HashMap]
1488 * a reference(!) to the right member.
1490 * @throws [java.lang.Exception]
1491 * if the specified map does not exist.
1493 private java
.util
.HashMap
getItemMap(int eItemType
)
1494 throws java
.lang
.Exception
1496 java
.util
.HashMap rMap
= null;
1507 case E_DETECTSERVICE
:
1508 rMap
= m_lDetectServices
;
1511 case E_FRAMELOADER
:
1512 rMap
= m_lFrameLoaders
;
1515 case E_CONTENTHANDLER
:
1516 rMap
= m_lContentHandlers
;
1520 throw new java
.lang
.Exception("Invalid item map specified.");
1525 //___________________________________________
1527 /** return the count of items inside a sub container
1531 * specify, which item map is required.
1533 * @throws [java.lang.Exception]
1534 * if the specified map does not exist.
1536 public synchronized int getItemCount(int eItemType
)
1537 throws java
.lang
.Exception
1539 java
.util
.HashMap rMap
= getItemMap(eItemType
);
1543 //___________________________________________
1545 /** get a list of all item names of the specified
1549 * specify, which item map is required.
1551 * @throws [java.lang.Exception]
1552 * if the specified map does not exist.
1554 public synchronized java
.util
.Vector
getItemNames(int eItemType
)
1555 throws java
.lang
.Exception
1557 java
.util
.Vector lNames
= new java
.util
.Vector();
1558 java
.util
.HashMap rMap
= getItemMap(eItemType
);
1559 java
.util
.Iterator it
= rMap
.keySet().iterator();
1561 lNames
.add(it
.next());
1565 //___________________________________________
1567 /** get a list of all item names of the specified
1568 * sub coontainer, where items match to given property set.
1570 * Note: The given property set must exist at all
1571 * returned items as minimum and every checked property
1572 * value must be equals! Using of reg expressions or
1573 * similar mechanism will not be supported here.
1576 * specify, which item map is required.
1579 * the set of properties, which must
1580 * exist at the returned item as minimum.
1582 * @throws [java.lang.Exception]
1583 * if the specified map does not exist.
1585 public synchronized java
.util
.Vector
getMatchedItemNames(int eItemType
,
1586 java
.util
.HashMap aPropSet
)
1587 throws java
.lang
.Exception
1589 java
.util
.Vector lNames
= new java
.util
.Vector();
1590 java
.util
.HashMap rMap
= getItemMap(eItemType
);
1591 java
.util
.Iterator it
= rMap
.keySet().iterator();
1594 java
.lang
.String sItemName
= (java
.lang
.String
)it
.next();
1595 java
.util
.HashMap rItemProps
= (java
.util
.HashMap
)rMap
.get(sItemName
);
1597 boolean bMatch
= Cache
.matchPropSet(rItemProps
, aPropSet
);
1599 lNames
.add(sItemName
);
1602 java
.lang
.StringBuffer sBuffer
= new java
.lang
.StringBuffer(1000);
1603 sBuffer
.append("entry ["+eItemType
+"] \""+sItemName
+"\" does not match.\n");
1604 sBuffer
.append("\torg items = {"+rItemProps
+"}\n");
1605 sBuffer
.append("\treq items = {"+aPropSet
+"}\n");
1607 m_aDebug
.setDetailedInfo(sBuffer
.toString());
1613 //___________________________________________
1615 /** check if two property sets are equals in its
1616 * shared properties.
1618 * Note: Only set properties of the match set will be searched
1619 * inside the original set. And its values must be equals.
1620 * Using of reg expressions or similar mechanism will not
1621 * be supported here.
1624 * the original property set, which should be checked.
1626 * @param rMatchProps
1627 * contains the properties, which must be searched
1630 * @return TRUE if all properties of rMatchProps could be located
1633 private static boolean matchPropSet(java
.util
.HashMap rOrgProps
,
1634 java
.util
.HashMap rMatchProps
)
1636 java
.util
.Iterator it
= rMatchProps
.keySet().iterator();
1639 java
.lang
.String sMatchName
= (java
.lang
.String
)it
.next();
1640 java
.lang
.Object aMatchValue
= rMatchProps
.get(sMatchName
);
1643 (!rOrgProps
.containsKey(sMatchName
) ) ||
1644 (!rOrgProps
.get(sMatchName
).equals(aMatchValue
))
1653 //___________________________________________
1655 /** return a property set for the queried container item.
1658 * specify, which item map is required.
1661 * must be a valid item name of the specified item map.
1663 * @return [java.util.HashMap]
1664 * the property set of the queried item.
1665 * Always different from null!
1667 * @throws [java.lang.Exception]
1668 * if the specified item does not exists or
1669 * seems to be invalid in general (means null!).
1671 public synchronized java
.util
.HashMap
getItem(int eItemType
,
1672 java
.lang
.String sItemName
)
1673 throws java
.lang
.Exception
1675 java
.util
.HashMap rMap
= getItemMap(eItemType
);
1676 java
.util
.HashMap rItem
= (java
.util
.HashMap
)rMap
.get(sItemName
);
1678 throw new java
.lang
.Exception("Queried item \""+sItemName
+"\" does not exist inside this cache.");
1682 //___________________________________________
1684 /** return a requested item in XML format.
1687 * identify the right sub set of this cache
1688 * inside which the requested item should exist.
1689 * e.g. E_TYPE, E_FILTER, ...
1692 * the name of the request item
1695 * means the format of the generated xml source.
1697 * @return [java.lang.String]
1698 * a xml formated string, which contains all properties
1699 * for this container item.
1701 public synchronized java
.lang
.String
getItemAsXML(int eItemType
,
1702 java
.lang
.String sItemName
,
1704 throws java
.lang
.Exception
1706 // Note: Our internal format must be converted to the target format!
1707 java
.util
.HashMap rItem
= getItem(eItemType
, sItemName
);
1708 java
.util
.HashMap rFormatedItem
= null;
1713 rFormatedItem
= Cache
.convertTypePropsToExternal(rItem
, nXMLFormat
);
1714 m_aDebug
.setGlobalInfo("type to external \""+sItemName
+"\"");
1720 rFormatedItem
= Cache
.convertFilterPropsToExternal(rItem
, nXMLFormat
);
1721 m_aDebug
.setGlobalInfo("filter to external \""+sItemName
+"\"");
1725 case E_DETECTSERVICE
:
1727 rFormatedItem
= Cache
.convertDetectServicePropsToExternal(rItem
, nXMLFormat
);
1728 m_aDebug
.setGlobalInfo("detect service to external \""+sItemName
+"\"");
1732 case E_FRAMELOADER
:
1734 rFormatedItem
= Cache
.convertFrameLoaderPropsToExternal(rItem
, nXMLFormat
);
1735 m_aDebug
.setGlobalInfo("frame loader to external \""+sItemName
+"\"");
1739 case E_CONTENTHANDLER
:
1741 rFormatedItem
= Cache
.convertContentHandlerPropsToExternal(rItem
, nXMLFormat
);
1742 m_aDebug
.setGlobalInfo("content handler to external \""+sItemName
+"\"");
1747 java
.lang
.StringBuffer sXML
= new java
.lang
.StringBuffer(1000);
1748 int nPrettyTabs
= 1;
1749 for (int t
=0; t
<nPrettyTabs
; ++t
)
1751 sXML
.append("<"+XMLHelper
.XMLTAG_NODE
+" "+XMLHelper
.XMLATTRIB_OOR_NAME
+"=\""+XMLHelper
.encodeHTMLSigns(sItemName
)+"\" "+XMLHelper
.XMLATTRIB_OOR_OP
+"=\""+XMLHelper
.XMLATTRIB_OP_REPLACE
+"\">\n");
1752 sXML
.append(XMLHelper
.convertPropSetToXML(rFormatedItem
, nPrettyTabs
+1));
1753 for (int t
=0; t
<nPrettyTabs
; ++t
)
1755 sXML
.append("</"+XMLHelper
.XMLTAG_NODE
+">\n");
1757 return sXML
.toString();
1760 //___________________________________________
1762 /** split the given string (using the specified delimiter)
1763 * and return alist of found string tokens.
1765 * Note: Against the normal behaviour of the StringTokenizer class
1766 * this method returns empty tokens too.
1767 * E.g: "0,,1" will return "0" - "" - "1"
1769 * @param sTokenString
1770 * the string value, which should be analyzed.
1773 * the delimiter, which will be used to differe between tokens.
1775 * @return [java.util.Vector]
1776 * a list of string tokens. Can be empty - but not null!
1778 private static java
.util
.Vector
splitTokenString(java
.lang
.String sTokenString
,
1779 java
.lang
.String sDelim
)
1781 java
.util
.Vector lTokens
= new java
.util
.Vector();
1782 java
.util
.StringTokenizer aTokenizer
= new java
.util
.StringTokenizer(sTokenString
, sDelim
, true);
1783 boolean bLastWasDelim
= false;
1785 while (aTokenizer
.hasMoreTokens())
1787 java
.lang
.String sToken
= aTokenizer
.nextToken();
1788 if (sToken
.equals(sDelim
))
1792 // last token was a delimiter - new one too
1793 // => an empty token must be placed between these
1794 // two delimiters! Add this empty value to the return list.
1799 // last token was not a delimiter - new one is such delim
1800 // => ignore this delimiter - but save the information, that
1802 bLastWasDelim
= true;
1807 // new token is no delim
1808 // => Add it to the return list.
1809 lTokens
.add(sToken
);
1810 // Dont forget to reset this information - so next loop
1811 // will do the right things!
1812 bLastWasDelim
= false;
1819 //___________________________________________
1823 public synchronized void analyze()
1825 m_nDoubleRegisteredFilters
= 0;
1826 m_nTypesForFilters
= 0;
1827 m_nTypesForDetectServices
= 0;
1828 m_nTypesForFrameLoaders
= 0;
1829 m_nTypesForContentHandlers
= 0;
1831 // create table of types and all registered filters for such types
1832 // By the way: count all double registrations, where a filter
1833 // uses the same type then another filter.
1834 m_lFilterToTypeRegistrations
= new java
.util
.HashMap();
1835 java
.util
.Iterator aIt1
= m_lFilters
.keySet().iterator();
1836 while (aIt1
.hasNext())
1838 java
.lang
.String sFilter
= (java
.lang
.String
)aIt1
.next();
1839 java
.util
.HashMap aFilter
= (java
.util
.HashMap
)m_lFilters
.get(sFilter
);
1840 java
.lang
.String sType
= (java
.lang
.String
)aFilter
.get(PROPNAME_TYPE
);
1842 java
.util
.Vector lFilters
= (java
.util
.Vector
)m_lFilterToTypeRegistrations
.get(sType
);
1843 if (lFilters
== null)
1844 lFilters
= new java
.util
.Vector();
1846 ++m_nDoubleRegisteredFilters
;
1847 lFilters
.add(sFilter
);
1848 m_lFilterToTypeRegistrations
.put(sType
, lFilters
);
1851 // count, how many types are used by filters, frame loaders or content handlers
1852 aIt1
= m_lTypes
.keySet().iterator();
1853 while (aIt1
.hasNext())
1855 java
.lang
.String sType
= (java
.lang
.String
)aIt1
.next();
1857 java
.util
.Iterator aIt2
= m_lFilters
.keySet().iterator();
1858 while (aIt2
.hasNext())
1860 java
.lang
.String sItem
= (java
.lang
.String
)aIt2
.next();
1861 java
.util
.HashMap aItem
= (java
.util
.HashMap
)m_lFilters
.get(sItem
);
1862 java
.lang
.String sTypeReg
= (java
.lang
.String
)aItem
.get(PROPNAME_TYPE
);
1864 if (sTypeReg
.equals(sType
))
1866 ++m_nTypesForFilters
;
1871 aIt2
= m_lDetectServices
.keySet().iterator();
1872 while (aIt2
.hasNext())
1874 java
.lang
.String sItem
= (java
.lang
.String
)aIt2
.next();
1875 java
.util
.HashMap aItem
= (java
.util
.HashMap
)m_lDetectServices
.get(sItem
);
1876 java
.util
.Vector lTypeReg
= (java
.util
.Vector
)aItem
.get(PROPNAME_TYPES
);
1878 if (lTypeReg
.contains(sType
))
1880 ++m_nTypesForDetectServices
;
1885 aIt2
= m_lFrameLoaders
.keySet().iterator();
1886 while (aIt2
.hasNext())
1888 java
.lang
.String sItem
= (java
.lang
.String
)aIt2
.next();
1889 java
.util
.HashMap aItem
= (java
.util
.HashMap
)m_lFrameLoaders
.get(sItem
);
1890 java
.util
.Vector lTypeReg
= (java
.util
.Vector
)aItem
.get(PROPNAME_TYPES
);
1892 if (lTypeReg
.contains(sType
))
1894 ++m_nTypesForFrameLoaders
;
1899 aIt2
= m_lContentHandlers
.keySet().iterator();
1900 while (aIt2
.hasNext())
1902 java
.lang
.String sItem
= (java
.lang
.String
)aIt2
.next();
1903 java
.util
.HashMap aItem
= (java
.util
.HashMap
)m_lContentHandlers
.get(sItem
);
1904 java
.util
.Vector lTypeReg
= (java
.util
.Vector
)aItem
.get(PROPNAME_TYPES
);
1906 if (lTypeReg
.contains(sType
))
1908 ++m_nTypesForContentHandlers
;
1915 //___________________________________________
1917 /** validate all cache entries.
1919 * It checks if all made registrations are valid;
1920 * try to repair some simple problems;
1921 * create missing informations on demand ...
1924 * specify, which configuration format
1927 * @throws [java.lang.Exception]
1928 * if an unrecoverable problem occure.
1930 public synchronized void validate(int nFormat
)
1931 throws java
.lang
.Exception
1933 validateTypes(nFormat
);
1934 validateFilters(nFormat
);
1937 //___________________________________________
1939 /** validate all type entries of this cache.
1942 * specify, which configuration format
1945 * @throws [java.lang.Exception]
1946 * if an unrecoverable problem occure.
1948 private void validateTypes(int nFormat
)
1949 throws java
.lang
.Exception
1951 java
.util
.Iterator aIt1
= m_lTypes
.keySet().iterator();
1952 while(aIt1
.hasNext())
1954 java
.lang
.String sType
= (java
.lang
.String
)aIt1
.next();
1955 java
.util
.HashMap aType
= (java
.util
.HashMap
)m_lTypes
.get(sType
);
1957 throw new java
.lang
.Exception("type ["+sType
+"] dos not exist realy?!");
1960 (!aType
.containsKey(PROPNAME_MEDIATYPE
)) ||
1961 (!aType
.containsKey(PROPNAME_PREFERRED
)) ||
1962 (!aType
.containsKey(PROPNAME_CLIPBOARDFORMAT
)) ||
1963 (!aType
.containsKey(PROPNAME_DOCUMENTICONID
)) ||
1964 (!aType
.containsKey(PROPNAME_URLPATTERN
)) ||
1965 (!aType
.containsKey(PROPNAME_EXTENSIONS
)) ||
1966 (!aType
.containsKey(PROPNAME_UINAME
))
1969 throw new java
.lang
.Exception("Type \""+sType
+"\" does not contain all neccessary properties for a 6.0/6.Y format.");
1973 (((java
.util
.Vector
)aType
.get(PROPNAME_EXTENSIONS
)).isEmpty()) &&
1974 (((java
.util
.Vector
)aType
.get(PROPNAME_URLPATTERN
)).isEmpty())
1977 throw new java
.lang
.Exception("Type \""+sType
+"\" does not contain any extension nor an url pattern.");
1980 if (((java
.util
.HashMap
)aType
.get(PROPNAME_UINAME
)).isEmpty())
1981 throw new java
.lang
.Exception("Type \""+sType
+"\" is not localized.");
1983 if (nFormat
== FORMAT_6Y
)
1986 (!aType
.containsKey(PROPNAME_UIORDER
)) ||
1987 (!aType
.containsKey(PROPNAME_PREFERREDFILTER
)) ||
1988 (!aType
.containsKey(PROPNAME_DETECTSERVICE
))
1991 throw new java
.lang
.Exception("Type \""+sType
+"\" does not contain all neccessary properties for a 6.Y format.");
1994 if (((java
.lang
.Integer
)aType
.get(PROPNAME_UIORDER
)).intValue() < 0)
1995 throw new java
.lang
.Exception("Type \""+sType
+"\" has invalid value for prop UIOrder.");
1997 if (((java
.lang
.String
)aType
.get(PROPNAME_DETECTSERVICE
)).length() < 1)
1998 m_aDebug
.setWarning("Type \""+sType
+"\" has no detect service registered.");
2000 java
.lang
.String sPreferredReg
= (java
.lang
.String
)aType
.get(PROPNAME_PREFERREDFILTER
);
2002 (sPreferredReg
== null) ||
2003 (sPreferredReg
.length() < 1 )
2006 m_aDebug
.setWarning("Type \""+sType
+"\" has no preferred filter ...");
2008 * OK - not every type has a filter registered .. but the
2009 * a frame loader MUST(!) exist! Check it.
2014 if (!m_lFilters
.containsKey(sPreferredReg
))
2015 throw new java
.lang
.Exception("Type \""+sType
+"\" has no valid preferred filter registration [\""+sPreferredReg
+"\"].");
2021 //___________________________________________
2023 /** validate all filter entries of this cache.
2026 * specify, which configuration format
2029 * @throws [java.lang.Exception]
2030 * if an unrecoverable problem occure.
2032 public synchronized void validateFilters(int nFormat
)
2033 throws java
.lang
.Exception
2035 java
.util
.Iterator aIt1
= m_lFilters
.keySet().iterator();
2036 while(aIt1
.hasNext())
2038 java
.lang
.String sFilter
= (java
.lang
.String
)aIt1
.next();
2039 java
.util
.HashMap aFilter
= (java
.util
.HashMap
)m_lFilters
.get(sFilter
);
2040 if (aFilter
== null)
2041 throw new java
.lang
.Exception("filter ["+sFilter
+"] dos not exist realy?!");
2044 (!aFilter
.containsKey(PROPNAME_DOCUMENTSERVICE
)) ||
2045 (!aFilter
.containsKey(PROPNAME_FILEFORMATVERSION
)) ||
2046 (!aFilter
.containsKey(PROPNAME_FILTERSERVICE
)) ||
2047 (!aFilter
.containsKey(PROPNAME_FLAGS
)) ||
2048 (!aFilter
.containsKey(PROPNAME_TEMPLATENAME
)) ||
2049 (!aFilter
.containsKey(PROPNAME_TYPE
)) ||
2050 (!aFilter
.containsKey(PROPNAME_UICOMPONENT
)) ||
2051 (!aFilter
.containsKey(PROPNAME_USERDATA
))
2054 throw new java
.lang
.Exception("Filter \""+sFilter
+"\" does not contain all neccessary properties for a 6.0/6.Y format.");
2057 if (((java
.lang
.Integer
)aFilter
.get(PROPNAME_FLAGS
)).intValue() < 1)
2058 throw new java
.lang
.Exception("Filter \""+sFilter
+"\" does not have a valid flag field.");
2060 if (!m_lTypes
.containsKey(aFilter
.get(PROPNAME_TYPE
)))
2061 throw new java
.lang
.Exception("Filter \""+sFilter
+"\" is not registered for a well known type.");
2063 if (nFormat
== FORMAT_60
)
2066 (!aFilter
.containsKey(PROPNAME_ORDER
)) ||
2067 (!aFilter
.containsKey(PROPNAME_UINAME
))
2070 throw new java
.lang
.Exception("Filter \""+sFilter
+"\" does not contain all neccessary properties for a 6.0 format.");
2073 if (((java
.lang
.Integer
)aFilter
.get(PROPNAME_ORDER
)).intValue() < 0)
2074 throw new java
.lang
.Exception("Filter \""+sFilter
+"\" does not have a valid Order value.");
2076 if (((java
.util
.HashMap
)aFilter
.get(PROPNAME_UINAME
)).isEmpty())
2077 throw new java
.lang
.Exception("Filter \""+sFilter
+"\" is not localized.");
2080 depends from the configuration item "remove_filter_flag_preferred" ...
2082 if (nFormat == FORMAT_6Y)
2084 int flags = ((java.lang.Integer)aFilter.get(PROPNAME_FLAGS)).intValue();
2085 if ((flags & FLAGVAL_PREFERRED) == FLAGVAL_PREFERRED)
2086 throw new java.lang.Exception("Filter \""+sFilter+"\" has superflous Preferred flag set. Please remove this flag. ["+flags+"]");
2093 * - remove graphic filters!
2094 * - move detect services to types
2097 public synchronized void transform60to6Y(boolean bCreateCombineFilterFlag
,
2098 boolean bRemoveFilterFlagBrowserPreferred
,
2099 boolean bRemoveFilterFlagPreferred
,
2100 boolean bRemoveFilterFlag3rdparty
,
2101 boolean bRemoveFilterUINames
,
2102 boolean bRemoveGraphicFilters
,
2103 boolean bSetDefaultDetector
)
2104 throws java
.lang
.Exception
2106 // remove some superflous cache entries ...
2107 // everything related to "load macros"
2108 // Macros should be dispatched instead of loaded!
2109 if (m_lTypes
.containsKey("macro"))
2111 m_lTypes
.remove("macro");
2112 m_aDebug
.setDetailedInfo("superflous type \"macro\" was removed");
2114 if (m_lFrameLoaders
.containsKey("com.sun.star.comp.sfx2.SfxMacroLoader"))
2116 m_lFrameLoaders
.remove("com.sun.star.comp.sfx2.SfxMacroLoader");
2117 m_aDebug
.setDetailedInfo("superflous frame loader \"com.sun.star.comp.sfx2.SfxMacroLoader\" was removed");
2120 // step over all filters and check her properties and references
2121 java
.util
.Vector lPreferredFilters
= new java
.util
.Vector();
2122 java
.util
.Vector lNoRealFilters
= new java
.util
.Vector();
2123 java
.util
.Iterator aIt1
= m_lFilters
.keySet().iterator();
2124 while(aIt1
.hasNext())
2126 java
.lang
.String sFilter
= (java
.lang
.String
)aIt1
.next();
2127 java
.util
.HashMap aFilter
= (java
.util
.HashMap
)m_lFilters
.get(sFilter
);
2129 // remove the "graphic helper filters" used by draw and impress
2130 // They dont have any valid document service name set and cant be handled
2131 // by our generic FrameLoader!
2132 // They must be moved to her own configuration ...
2135 (bRemoveGraphicFilters
) &&
2136 (((java
.lang
.String
)aFilter
.get(PROPNAME_DOCUMENTSERVICE
)).length() < 1)
2139 lNoRealFilters
.add(sFilter
);
2143 java
.lang
.String sTypeReg
= (java
.lang
.String
)aFilter
.get(PROPNAME_TYPE
);
2144 java
.util
.HashMap aType
= (java
.util
.HashMap
)m_lTypes
.get(sTypeReg
);
2146 // move UINames of filters to types
2147 java
.util
.HashMap lFilterUINames
= (java
.util
.HashMap
)aFilter
.get(PROPNAME_UINAME
);
2148 java
.util
.HashMap lTypeUINames
= (java
.util
.HashMap
)aType
.get(PROPNAME_UINAME
);
2149 java
.util
.HashMap lPatchUINames
= new java
.util
.HashMap();
2151 java
.util
.Iterator pUINames
= lTypeUINames
.keySet().iterator();
2152 while(pUINames
.hasNext())
2154 java
.lang
.String sLocale
= (java
.lang
.String
)pUINames
.next();
2155 java
.lang
.String sValue
= (java
.lang
.String
)lTypeUINames
.get(sLocale
);
2156 lPatchUINames
.put(sLocale
, sValue
);
2159 pUINames
= lFilterUINames
.keySet().iterator();
2160 while(pUINames
.hasNext())
2162 java
.lang
.String sLocale
= (java
.lang
.String
)pUINames
.next();
2163 java
.lang
.String sValue
= (java
.lang
.String
)lFilterUINames
.get(sLocale
);
2164 lPatchUINames
.put(sFilter
+":"+sLocale
, sValue
);
2166 aType
.put(PROPNAME_UINAME
, lPatchUINames
);
2168 // set generic filter service wrapper for our own native filters!
2169 // By the way: The format types of such filters can be detected by our
2170 // generic detector too.
2172 (bSetDefaultDetector
) &&
2173 (((java
.lang
.String
)aFilter
.get(PROPNAME_FILTERSERVICE
)).length() < 1)
2176 /*ME_THINKING aFilter.put(PROPNAME_FILTERSERVICE, FILTERSERVICE_NATIVEWARPPER);*/
2177 aType
.put(PROPNAME_DETECTSERVICE
, GENERIC_DETECTSERVICE
);
2180 // move the preferred filter information to any type
2181 // Set the filter name to the type for which the filter is registered.
2182 // If this type already have a set PreferredFilter value, check if the current filter
2183 // has the preferred flag set. If not ignore it - otherwhise overwrite the
2184 // current information at the type. But look for multiple preferred filter relations ...
2185 // means: look if more the one filter has set the preferred flag for the same type!
2189 * Dont remove the preferred flag from any filter! ... not here.
2190 * Otherwhise next loop can't detect ambigous preferred registrations!
2191 * Add filter to a temp. list, which can be used later to remove the preferred
2195 int flags1
= ((java
.lang
.Integer
)aFilter
.get(PROPNAME_FLAGS
)).intValue();
2196 java
.lang
.String sDocSrv
= (java
.lang
.String
)aFilter
.get(PROPNAME_DOCUMENTSERVICE
);
2197 if (sDocSrv
.length()>0)// without a doc service its not a real filter - its a graphic filter!
2199 boolean preferred1
= ((flags1
& FLAGVAL_PREFERRED
) == FLAGVAL_PREFERRED
);
2201 lPreferredFilters
.add(aFilter
);
2203 java
.lang
.String sAlreadyRegisteredFilter
= (java
.lang
.String
)aType
.get(PROPNAME_PREFERREDFILTER
);
2204 // no registration => set this filter as "any possible one"!
2205 if (sAlreadyRegisteredFilter
.length() < 1)
2206 aType
.put(PROPNAME_PREFERREDFILTER
, sFilter
);
2209 java
.util
.HashMap aAlreadyRegisteredFilter
= (java
.util
.HashMap
)m_lFilters
.get(sAlreadyRegisteredFilter
);
2210 int flags2
= ((java
.lang
.Integer
)aAlreadyRegisteredFilter
.get(PROPNAME_FLAGS
)).intValue();
2211 boolean preferred2
= ((flags2
& FLAGVAL_PREFERRED
) == FLAGVAL_PREFERRED
);
2213 // two preferred filters for the same type! => error
2214 if (preferred1
&& preferred2
)
2216 java
.lang
.StringBuffer sMsg
= new java
.lang
.StringBuffer(256);
2217 sMsg
.append("More the one preferred filter detected for the same type.\n");
2218 sMsg
.append("\ttype = \""+sTypeReg
+"\"\n");
2219 sMsg
.append("\tfilter[1] = \""+sAlreadyRegisteredFilter
+"\"\n");
2220 sMsg
.append("\tfilter[2] = \""+sFilter
+"\"\n");
2221 throw new java
.lang
.Exception(sMsg
.toString());
2224 // overwrite the "any possible" filter with a real preferred one
2225 if (preferred1
&& !preferred2
)
2226 aType
.put(PROPNAME_PREFERREDFILTER
, sFilter
);
2230 // create the new combined filter flag if required
2231 if (bCreateCombineFilterFlag
)
2234 ((flags1
& FLAGVAL_IMPORT
) == FLAGVAL_IMPORT
) &&
2235 ((flags1
& FLAGVAL_EXPORT
) == FLAGVAL_EXPORT
)
2238 flags1
|= FLAGVAL_COMBINED
;
2239 flags1
&= ~FLAGVAL_IMPORT
;
2240 flags1
&= ~FLAGVAL_EXPORT
;
2241 aFilter
.put(PROPNAME_FLAGS
, new java
.lang
.Integer(flags1
));
2245 // remove some obsolete filter flags
2246 if (bRemoveFilterFlagBrowserPreferred
)
2248 flags1
&= ~FLAGVAL_BROWSERPREFERRED
;
2249 aFilter
.put(PROPNAME_FLAGS
, new java
.lang
.Integer(flags1
));
2252 if (bRemoveFilterFlag3rdparty
)
2254 flags1
&= ~FLAGVAL_3RDPARTYFILTER
;
2255 aFilter
.put(PROPNAME_FLAGS
, new java
.lang
.Integer(flags1
));
2258 // if its a filter with an UI order ...
2259 // move this information to the registered type.
2260 // Note: Because more then one filter can be registered for the same type.
2261 // Handle it as an error ... till we find a better transformation!
2262 java
.lang
.Integer nOrder
= (java
.lang
.Integer
)aFilter
.get(PROPNAME_ORDER
);
2263 java
.lang
.Integer nUIOrder
= (java
.lang
.Integer
)aType
.get(PROPNAME_UIORDER
);
2264 int order
= nOrder
.intValue();
2265 int uiorder
= nUIOrder
.intValue();
2274 aType
.put(PROPNAME_UIORDER
, nOrder
);
2275 m_aDebug
.setDetailedInfo("moved order value "+nOrder
+" from filter \""+sFilter
+"\" to type \""+sTypeReg
+"\"");
2278 m_aDebug
.setDetailedInfo("ignore order value [order="+nOrder
+",uiorder="+nUIOrder
+"] for filter \""+sFilter
+"\" and type \""+sTypeReg
+"\"");
2282 // NOW ... remove the preferred flags from every filter, which it has set.
2283 java
.util
.Enumeration aIt2
= null;
2284 if (bRemoveFilterFlagPreferred
)
2286 aIt2
= lPreferredFilters
.elements();
2287 while (aIt2
.hasMoreElements())
2289 java
.util
.HashMap aFilter
= (java
.util
.HashMap
)aIt2
.nextElement();
2290 int flags
= ((java
.lang
.Integer
)aFilter
.get(PROPNAME_FLAGS
)).intValue();
2291 flags
&= ~FLAGVAL_PREFERRED
;
2292 aFilter
.put(PROPNAME_FLAGS
, new java
.lang
.Integer(flags
));
2296 // NOW ... remove all "no real filters" like the graphich helper filters of
2297 // draw and impress!
2298 aIt2
= lNoRealFilters
.elements();
2299 while (aIt2
.hasMoreElements())
2300 m_lFilters
.remove(aIt2
.nextElement());
2302 // step over all detect services and move this information directly to
2303 // the corresponding types
2304 // Overwrite possibel default registrations with a real existing one!
2305 aIt1
= m_lDetectServices
.keySet().iterator();
2306 while(aIt1
.hasNext())
2308 java
.lang
.String sDetector
= (java
.lang
.String
)aIt1
.next();
2309 java
.util
.HashMap aDetector
= (java
.util
.HashMap
)m_lDetectServices
.get(sDetector
);
2310 java
.util
.Vector lTypeReg
= (java
.util
.Vector
)aDetector
.get(PROPNAME_TYPES
);
2311 aIt2
= lTypeReg
.elements();
2312 while(aIt2
.hasMoreElements())
2314 java
.lang
.String sTypeReg
= (java
.lang
.String
)aIt2
.nextElement();
2315 java
.util
.HashMap aType
= (java
.util
.HashMap
)m_lTypes
.get(sTypeReg
);
2319 m_aDebug
.setWarning("Detector \""+sDetector
+"\" seem to be registered for unknown type \""+sTypeReg
+"\"");
2323 java
.lang
.Object aAlreadyRegisteredDetector
= aType
.get(PROPNAME_DETECTSERVICE
);
2324 if (aAlreadyRegisteredDetector
!= null && ((java
.lang
.String
)aAlreadyRegisteredDetector
).length() > 0)
2326 java
.lang
.StringBuffer sMsg
= new java
.lang
.StringBuffer(256);
2327 sMsg
.append("type \""+sTypeReg
+"\" has ambigous registrations of a detect service\n");
2328 sMsg
.append("\tdetect service[1] = \""+(java
.lang
.String
)aAlreadyRegisteredDetector
+"\"\n");
2329 sMsg
.append("\tdetect service[2] = \""+sDetector
+"\"\n");
2330 m_aDebug
.setWarning(sMsg
.toString());
2332 aType
.put(PROPNAME_DETECTSERVICE
, sDetector
);
2333 m_aDebug
.setGlobalInfo("move detector \""+sDetector
+"\" to type \""+sTypeReg
+"\"");
2337 // because all detect service was registered as type properties directly ...
2338 // remove all detect service objects of this cache!
2339 m_lDetectServices
.clear();
2341 // step over all frame loader and move this information directly to
2342 // the corresponding types
2343 // Overwrite possibel default registrations with a real existing one!
2344 aIt1
= m_lFrameLoaders
.keySet().iterator();
2345 while(aIt1
.hasNext())
2347 java
.lang
.String sLoader
= (java
.lang
.String
)aIt1
.next();
2348 java
.util
.HashMap aLoader
= (java
.util
.HashMap
)m_lFrameLoaders
.get(sLoader
);
2349 java
.util
.Vector lTypeReg
= (java
.util
.Vector
)aLoader
.get(PROPNAME_TYPES
);
2350 aIt2
= lTypeReg
.elements();
2351 while(aIt2
.hasMoreElements())
2353 java
.lang
.String sTypeReg
= (java
.lang
.String
)aIt2
.nextElement();
2354 java
.util
.HashMap aType
= (java
.util
.HashMap
)m_lTypes
.get(sTypeReg
);
2355 java
.lang
.String sAlreadyRegisteredLoader
= (java
.lang
.String
)aType
.get(PROPNAME_FRAMELOADER
);
2356 if (sAlreadyRegisteredLoader
!= null && sAlreadyRegisteredLoader
.length() > 0)
2358 java
.lang
.StringBuffer sMsg
= new java
.lang
.StringBuffer(256);
2359 sMsg
.append("type \""+sTypeReg
+"\" has ambigous registrations of a frame loader\n");
2360 sMsg
.append("\tframe loader[1] = \""+sAlreadyRegisteredLoader
+"\"\n");
2361 sMsg
.append("\tframe loader[2] = \""+sLoader
+"\"\n");
2362 m_aDebug
.setWarning(sMsg
.toString());
2364 aType
.put(PROPNAME_FRAMELOADER
, sLoader
);
2365 System
.out
.println("move loader \""+sLoader
+"\" to type \""+sTypeReg
+"\"");
2369 m_lFrameLoaders
.clear();
2371 // step over all content handler and move this information directly to
2372 // the corresponding types
2373 // Overwrite possibel default registrations with a real existing one!
2374 aIt1
= m_lContentHandlers
.keySet().iterator();
2375 while(aIt1
.hasNext())
2377 java
.lang
.String sHandler
= (java
.lang
.String
)aIt1
.next();
2378 java
.util
.HashMap aHandler
= (java
.util
.HashMap
)m_lContentHandlers
.get(sHandler
);
2379 java
.util
.Vector lTypeReg
= (java
.util
.Vector
)aHandler
.get(PROPNAME_TYPES
);
2380 aIt2
= lTypeReg
.elements();
2381 while(aIt2
.hasMoreElements())
2383 java
.lang
.String sTypeReg
= (java
.lang
.String
)aIt2
.nextElement();
2384 java
.util
.HashMap aType
= (java
.util
.HashMap
)m_lTypes
.get(sTypeReg
);
2385 java
.lang
.String sAlreadyRegisteredHandler
= (java
.lang
.String
)aType
.get(PROPNAME_CONTENTHANDLER
);
2386 if (sAlreadyRegisteredHandler
!= null && sAlreadyRegisteredHandler
.length() > 0)
2388 java
.lang
.StringBuffer sMsg
= new java
.lang
.StringBuffer(256);
2389 sMsg
.append("type \""+sTypeReg
+"\" has ambigous registrations of a content handler\n");
2390 sMsg
.append("\tcontent handler[1] = \""+sAlreadyRegisteredHandler
+"\"\n");
2391 sMsg
.append("\tcontent handler[2] = \""+sHandler
+"\"\n");
2392 m_aDebug
.setWarning(sMsg
.toString());
2394 aType
.put(PROPNAME_CONTENTHANDLER
, sHandler
);
2395 System
.out
.println("move handler \""+sHandler
+"\" to type \""+sTypeReg
+"\"");
2399 m_lContentHandlers
.clear();
2402 int c = m_lTypes.size();
2403 java.lang.String[] lT1 = new java.lang.String[c];
2404 java.lang.String[] lT2 = new java.lang.String[c];
2408 aIt1 = m_lTypes.keySet().iterator();
2409 while(aIt1.hasNext())
2411 lT1[i] = (java.lang.String)aIt1.next();
2416 for (int i1=0; i1<c; ++i1)
2418 java.lang.String sT1 = lT1[i1];
2419 java.util.HashMap aT1 = (java.util.HashMap)m_lTypes.get(sT1);
2421 for (int i2=i1; i2<c; ++i2)
2423 java.lang.String sT2 = lT1[i2];
2424 java.util.HashMap aT2 = (java.util.HashMap)m_lTypes.get(sT2);
2426 if (!sT1.equals(sT2))
2429 aT1.get(PROPNAME_MEDIATYPE).equals(aT2.get(PROPNAME_MEDIATYPE)) &&
2430 aT1.get(PROPNAME_CLIPBOARDFORMAT).equals(aT2.get(PROPNAME_CLIPBOARDFORMAT)) &&
2431 aT1.get(PROPNAME_URLPATTERN).equals(aT2.get(PROPNAME_URLPATTERN)) &&
2432 aT1.get(PROPNAME_EXTENSIONS).equals(aT2.get(PROPNAME_EXTENSIONS))
2435 System.err.println("UUPPSS----------------------------------------------------------------------------");
2436 System.err.println("[1]\""+sT1+"\" equals [2]\""+sT2+"\"");
2437 System.err.println("\tprops 1: "+aT1);
2438 System.err.println("\tprops 2: "+aT2);
2439 System.err.println("----------------------------------------------------------------------------------\n");
2441 // throw new java.lang.Exception("UUPPS :-)");
2446 System.err.println("count of UPS = "+nUPS);