1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 package com.sun.star.filter.config.tools.utils; 24 25 //_______________________________________________ 26 27 import java.lang.*; 28 import java.util.*; 29 import java.io.*; 30 31 //_______________________________________________ 32 33 /** 34 * It implements a container for all possible entries which are part of the type 35 * and filter mechanism of an office - means all items of the configuration file 36 * "TypeDetection". How these entries will be readed or written can be switch 37 * in different modes. That would make it possible to edit an xml directly or 38 * to contact a running office instance. 39 * 40 * 41 */ 42 public class Cache 43 { 44 //___________________________________________ 45 // public const 46 47 /** identifies a file type item of this cache. */ 48 public static final int E_TYPE = 0; 49 50 /** identifies a filter item of this cache. */ 51 public static final int E_FILTER = 1; 52 53 /** identifies a detect service item of this cache. */ 54 public static final int E_DETECTSERVICE = 2; 55 56 /** identifies a frame loader item of this cache. */ 57 public static final int E_FRAMELOADER = 3; 58 59 /** identifies a content handler item of this cache. */ 60 public static final int E_CONTENTHANDLER = 4; 61 62 /** indicates an unsupported xml format => error! */ 63 public static final int FORMAT_UNSUPPORTED = -1; 64 65 /** identify the configuration format of an office 6.0. 66 * The own formated data string is used. */ 67 public static final int FORMAT_60 = 0; 68 69 /** identify the configuration format of an office 6.y. 70 * Properties are realy xml tags again. */ 71 public static final int FORMAT_6Y = 1; 72 73 /** identify the configuration format which is used inside 74 * this tooling project. */ 75 public static final int FORMAT_INTERNAL = 2; 76 77 /** right value for a command line parameter to define a 6.0 version. */ 78 public static final java.lang.String CMDVAL_FORMAT_60 = "6.0"; 79 80 /** right value for a command line parameter to define a 6.Y version. */ 81 public static final java.lang.String CMDVAL_FORMAT_6Y = "6.Y"; 82 83 /** right value for a command line parameter to define an internal xml version! */ 84 public static final java.lang.String CMDVAL_FORMAT_INTERNAL = "internal"; 85 86 // general 87 public static final java.lang.String PROPNAME_DATA = "Data"; 88 public static final java.lang.String PROPNAME_NAME = "Name"; 89 public static final java.lang.String PROPNAME_UINAME = "UIName"; 90 public static final java.lang.String PROPNAME_UINAMES = "UINames"; 91 92 // type 6.0 ... 93 public static final java.lang.String PROPNAME_MEDIATYPE = "MediaType"; 94 public static final java.lang.String PROPNAME_PREFERRED = "Preferred"; 95 public static final java.lang.String PROPNAME_CLIPBOARDFORMAT = "ClipboardFormat"; 96 public static final java.lang.String PROPNAME_DOCUMENTICONID = "DocumentIconID"; 97 public static final java.lang.String PROPNAME_URLPATTERN = "URLPattern"; 98 public static final java.lang.String PROPNAME_EXTENSIONS = "Extensions"; 99 // ... +6.y 100 public static final java.lang.String PROPNAME_UIORDER = "UIOrder"; 101 public static final java.lang.String PROPNAME_PREFERREDFILTER = "PreferredFilter"; 102 public static final java.lang.String PROPNAME_DETECTSERVICE = "DetectService"; 103 public static final java.lang.String PROPNAME_FRAMELOADER = "FrameLoader"; 104 public static final java.lang.String PROPNAME_CONTENTHANDLER = "ContentHandler"; 105 106 // filter 107 public static final java.lang.String PROPNAME_DOCUMENTSERVICE = "DocumentService"; 108 public static final java.lang.String PROPNAME_FILEFORMATVERSION = "FileFormatVersion"; 109 public static final java.lang.String PROPNAME_FILTERSERVICE = "FilterService"; 110 public static final java.lang.String PROPNAME_FLAGS = "Flags"; 111 public static final java.lang.String PROPNAME_ORDER = "Order"; // -6.y 112 public static final java.lang.String PROPNAME_TEMPLATENAME = "TemplateName"; 113 public static final java.lang.String PROPNAME_TYPE = "Type"; 114 public static final java.lang.String PROPNAME_UICOMPONENT = "UIComponent"; 115 public static final java.lang.String PROPNAME_USERDATA = "UserData"; 116 117 // frame loader / detect services / content handler 118 public static final java.lang.String PROPNAME_TYPES = "Types"; 119 120 //___________________________________________ 121 // private const 122 123 private static final java.lang.String FILTERSERVICE_NATIVEWARPPER = "com.sun.star.filter.NativeFilterWrapper"; 124 private static final java.lang.String GENERIC_DETECTSERVICE = "com.sun.star.comp.office.FrameLoader"; 125 126 /** its the name of the cfg set, which contains all types. */ 127 private static final java.lang.String CFGNODE_TYPES = "Types"; 128 129 /** its the name of the cfg set, which contains all filters. */ 130 private static final java.lang.String CFGNODE_FILTERS = "Filters"; 131 132 /** its the name of the cfg set, which contains all detect services. */ 133 private static final java.lang.String CFGNODE_DETECTSERVICES = "DetectServices"; 134 135 /** its the name of the cfg set, which contains all frame loaders. */ 136 private static final java.lang.String CFGNODE_FRAMELOADERS = "FrameLoaders"; 137 138 /** its the name of the cfg set, which contains all content handlers. */ 139 private static final java.lang.String CFGNODE_CONTENTHANDLERS = "ContentHandlers"; 140 141 // names for filter flags 142 private static final java.lang.String FLAGNAME_3RDPARTYFILTER = "3RDPARTYFILTER"; 143 private static final java.lang.String FLAGNAME_ALIEN = "ALIEN"; 144 private static final java.lang.String FLAGNAME_ASYNCHRON = "ASYNCHRON"; 145 private static final java.lang.String FLAGNAME_BROWSERPREFERRED = "BROWSERPREFERRED"; 146 private static final java.lang.String FLAGNAME_CONSULTSERVICE = "CONSULTSERVICE"; 147 private static final java.lang.String FLAGNAME_DEFAULT = "DEFAULT"; 148 private static final java.lang.String FLAGNAME_EXPORT = "EXPORT"; 149 private static final java.lang.String FLAGNAME_IMPORT = "IMPORT"; 150 private static final java.lang.String FLAGNAME_INTERNAL = "INTERNAL"; 151 private static final java.lang.String FLAGNAME_NOTINCHOOSER = "NOTINCHOOSER"; 152 private static final java.lang.String FLAGNAME_NOTINFILEDIALOG = "NOTINFILEDIALOG"; 153 private static final java.lang.String FLAGNAME_NOTINSTALLED = "NOTINSTALLED"; 154 private static final java.lang.String FLAGNAME_OWN = "OWN"; 155 private static final java.lang.String FLAGNAME_PACKED = "PACKED"; 156 private static final java.lang.String FLAGNAME_PREFERRED = "PREFERRED"; 157 private static final java.lang.String FLAGNAME_READONLY = "READONLY"; 158 private static final java.lang.String FLAGNAME_TEMPLATE = "TEMPLATE"; 159 private static final java.lang.String FLAGNAME_TEMPLATEPATH = "TEMPLATEPATH"; 160 private static final java.lang.String FLAGNAME_USESOPTIONS = "USESOPTIONS"; 161 162 private static final java.lang.String FLAGNAME_COMBINED = "COMBINED"; 163 private static final java.lang.String FLAGNAME_SUPPORTSSELECTION= "SUPPORTSSELECTION"; 164 165 // values for filter flags 166 private static final int FLAGVAL_3RDPARTYFILTER = 0x00080000; // 524288 167 private static final int FLAGVAL_ALIEN = 0x00000040; // 64 168 private static final int FLAGVAL_ALL = 0xffffffff; // 4294967295 169 private static final int FLAGVAL_ASYNCHRON = 0x00004000; // 16384 170 private static final int FLAGVAL_BROWSERPREFERRED = 0x00400000; // 4194304 171 private static final int FLAGVAL_CONSULTSERVICE = 0x00040000; // 262144 172 private static final int FLAGVAL_DEFAULT = 0x00000100; // 256 173 private static final int FLAGVAL_EXPORT = 0x00000002; // 2 174 private static final int FLAGVAL_IMPORT = 0x00000001; // 1 175 private static final int FLAGVAL_INTERNAL = 0x00000008; // 8 176 private static final int FLAGVAL_NOTINCHOOSER = 0x00002000; // 8192 177 private static final int FLAGVAL_NOTINFILEDIALOG = 0x00001000; // 4096 178 private static final int FLAGVAL_NOTINSTALLED = 0x00020000; // 131072 179 private static final int FLAGVAL_OWN = 0x00000020; // 32 180 private static final int FLAGVAL_PACKED = 0x00100000; // 1048576 181 private static final int FLAGVAL_PREFERRED = 0x10000000; // 268435456 182 private static final int FLAGVAL_READONLY = 0x00010000; // 65536 183 private static final int FLAGVAL_TEMPLATE = 0x00000004; // 4 184 private static final int FLAGVAL_TEMPLATEPATH = 0x00000010; // 16 185 private static final int FLAGVAL_USESOPTIONS = 0x00000080; // 128 186 187 private static final int FLAGVAL_COMBINED = 0x00800000; // ... 188 private static final int FLAGVAL_SUPPORTSSELECTION = 0x00000400; // 1024 189 190 //___________________________________________ 191 // member 192 193 /** list of all located types. 194 * Format: [string,HashMap] 195 */ 196 private java.util.HashMap m_lTypes; 197 198 /** list of all located filters. 199 * Format: [string,HashMap] 200 */ 201 private java.util.HashMap m_lFilters; 202 203 /** list of all located detect services. 204 * Format: [string,HashMap] 205 */ 206 private java.util.HashMap m_lDetectServices; 207 208 /** list of all located frame loader. 209 * Format: [string,HashMap] 210 */ 211 private java.util.HashMap m_lFrameLoaders; 212 213 /** list of all located content handler. 214 * Format: [string,HashMap] 215 */ 216 private java.util.HashMap m_lContentHandlers; 217 218 /** contains all analyzed relations between 219 * filters and types. The key is an internal 220 * type name (can be used as reference into the 221 * list m_lTypes) and the value is a Vector of all 222 * internal filter names, which are registered for 223 * this type. 224 * Format: [string, Vector] 225 */ 226 private java.util.HashMap m_lFilterToTypeRegistrations; 227 228 private int m_nDoubleRegisteredFilters; 229 private int m_nTypesForFilters; 230 private int m_nTypesForDetectServices; 231 private int m_nTypesForFrameLoaders; 232 private int m_nTypesForContentHandlers; 233 234 /** can be used to log different informations. */ 235 private Logger m_aDebug; 236 237 //___________________________________________ 238 // interface 239 240 /** standard ctor. 241 * 242 * Initialize an empty cache instance. You have to use 243 * on of the fromXXX() methods to fill it from different 244 * sources with content. 245 */ Cache(Logger aDebug)246 public Cache(Logger aDebug) 247 { 248 reset(); 249 m_aDebug = aDebug; 250 } 251 252 //___________________________________________ 253 254 /** free memory and set default values on all members. 255 */ reset()256 public synchronized void reset() 257 { 258 m_lTypes = new java.util.HashMap(); 259 m_lFilters = new java.util.HashMap(); 260 m_lFrameLoaders = new java.util.HashMap(); 261 m_lDetectServices = new java.util.HashMap(); 262 m_lContentHandlers = new java.util.HashMap(); 263 m_lFilterToTypeRegistrations = new java.util.HashMap(); 264 m_aDebug = new Logger(); 265 m_nDoubleRegisteredFilters = 0; 266 m_nTypesForFilters = 0; 267 m_nTypesForDetectServices = 0; 268 m_nTypesForFrameLoaders = 0; 269 m_nTypesForContentHandlers = 0; 270 } 271 272 //___________________________________________ 273 274 /** converts a string representation of an xml format 275 * to its int value, which must be used at some interface 276 * methods of this cache. 277 * 278 * If the given string does not match to any well known format, 279 * the return value will be FORMAT_UNSUPPORTED. The calli have to 280 * check that. Otherwhise a called interface method at this cache 281 * instance will be rejected by an exception! 282 * 283 * @param sFormat 284 * the string representation 285 * Must be one of our public const values from type CMDVAL_FORMAT_xxx. 286 * 287 * @return [int] 288 * the int representation. 289 * Will be one of our public const values from type FORMAT_xxx. 290 */ mapFormatString2Format(java.lang.String sFormat)291 public static int mapFormatString2Format(java.lang.String sFormat) 292 { 293 int nFormat = FORMAT_UNSUPPORTED; 294 if (sFormat.equalsIgnoreCase(CMDVAL_FORMAT_60)) 295 nFormat = FORMAT_60; 296 else 297 if (sFormat.equalsIgnoreCase(CMDVAL_FORMAT_6Y)) 298 nFormat = FORMAT_6Y; 299 else 300 if (sFormat.equalsIgnoreCase(CMDVAL_FORMAT_INTERNAL)) 301 nFormat = FORMAT_INTERNAL; 302 return nFormat; 303 } 304 305 //___________________________________________ 306 307 /** return some statistic values. 308 * 309 * Such values can be: - count of container items, 310 * - ... 311 * 312 * @return [java.lang.String] 313 * a formated string, which contains al statistic data. 314 */ getStatistics()315 public synchronized java.lang.String getStatistics() 316 { 317 java.lang.StringBuffer sBuffer = new java.lang.StringBuffer(256); 318 319 sBuffer.append("types = "+m_lTypes.size() +"\n"); 320 sBuffer.append("filters = "+m_lFilters.size() +"\n"); 321 sBuffer.append("detect services = "+m_lDetectServices.size() +"\n"); 322 sBuffer.append("frame loaders = "+m_lFrameLoaders.size() +"\n"); 323 sBuffer.append("content handler = "+m_lContentHandlers.size() +"\n"); 324 sBuffer.append("double registered filters = "+m_nDoubleRegisteredFilters+"\n"); 325 sBuffer.append("types used by filters = "+m_nTypesForFilters +"\n"); 326 sBuffer.append("types used by detect services = "+m_nTypesForDetectServices +"\n"); 327 sBuffer.append("types used by frame loaders = "+m_nTypesForFrameLoaders +"\n"); 328 sBuffer.append("types used by content handlers = "+m_nTypesForContentHandlers+"\n"); 329 330 return sBuffer.toString(); 331 } 332 333 //___________________________________________ 334 335 /** reset this cache and fill it with new values using the given XML file. 336 * 337 * @param aXML 338 * must be a system file of a suitable XML file, which 339 * include all neccessary type/filter items. 340 * 341 * @param nFormat 342 * identifies the format of the specified xml file, 343 * which must be interpreted. 344 */ fromXML(java.io.File aXML , int nFormat)345 public synchronized void fromXML(java.io.File aXML , 346 int nFormat) 347 throws java.lang.Exception 348 { 349 // clear this cache 350 reset(); 351 352 // parse it 353 javax.xml.parsers.DocumentBuilderFactory aFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); 354 /* Attention: 355 * This call is important. It force right handling of entities during parsing and(!) 356 * writing. It let all possible signs for entities or it's quoted representations 357 * untouched. So this class don't change the original signs of the original file. 358 * Means: 359 * <ul> 360 * <li>(') => (')</li> 361 * <li>(") => (")</li> 362 * <li>(>) => (>)</li> 363 * <li>(<) => (<)</li> 364 * <li>(>) => (>)</li> 365 * <li>(&) => (&)</li> 366 * <li>...</li> 367 * </ul> 368 */ 369 370 System.out.println("TODO: must be adapted to java 1.3 :-("); 371 System.exit(-1); 372 //TODO_JAVA aFactory.setExpandEntityReferences(false); 373 374 javax.xml.parsers.DocumentBuilder aBuilder = aFactory.newDocumentBuilder(); 375 org.w3c.dom.Document aDOM = aBuilder.parse(aXML); 376 org.w3c.dom.Element aRoot = aDOM.getDocumentElement(); 377 378 // step over all sets 379 java.util.Vector lSetNodes = XMLHelper.extractChildNodesByTagName(aRoot, XMLHelper.XMLTAG_NODE); 380 java.util.Enumeration it1 = lSetNodes.elements(); 381 while (it1.hasMoreElements()) 382 { 383 // try to find out, which set should be read 384 org.w3c.dom.Node aSetNode = (org.w3c.dom.Node)it1.nextElement(); 385 java.lang.String sSetName = XMLHelper.extractNodeAttribByName(aSetNode, XMLHelper.XMLATTRIB_OOR_NAME); 386 if (sSetName == null) 387 throw new java.io.IOException("unsupported format: could not extract set name on node ...\n"+aSetNode); 388 389 // map some generic interfaces to the right members! 390 int eType = -1 ; 391 java.util.HashMap rMap = null; 392 393 if (sSetName.equals(CFGNODE_TYPES)) 394 { 395 eType = E_TYPE; 396 rMap = m_lTypes; 397 } 398 else 399 if (sSetName.equals(CFGNODE_FILTERS)) 400 { 401 eType = E_FILTER; 402 rMap = m_lFilters; 403 } 404 else 405 if (sSetName.equals(CFGNODE_FRAMELOADERS)) 406 { 407 eType = E_FRAMELOADER; 408 rMap = m_lFrameLoaders; 409 } 410 else 411 if (sSetName.equals(CFGNODE_DETECTSERVICES)) 412 { 413 eType = E_DETECTSERVICE; 414 rMap = m_lDetectServices; 415 } 416 else 417 if (sSetName.equals(CFGNODE_CONTENTHANDLERS)) 418 { 419 eType = E_CONTENTHANDLER; 420 rMap = m_lContentHandlers; 421 } 422 else 423 throw new java.io.IOException("unsupported format: unknown set name [\""+sSetName+"\"] detected on node ...\n"+aSetNode); 424 425 // load all set entries 426 java.util.Vector lChildNodes = XMLHelper.extractChildNodesByTagName(aSetNode, XMLHelper.XMLTAG_NODE); 427 java.util.Enumeration it2 = lChildNodes.elements(); 428 while (it2.hasMoreElements()) 429 { 430 org.w3c.dom.Node aChildNode = (org.w3c.dom.Node)it2.nextElement(); 431 java.lang.String sChildName = XMLHelper.extractNodeAttribByName(aChildNode, XMLHelper.XMLATTRIB_OOR_NAME); 432 if (sChildName == null) 433 throw new java.io.IOException("unsupported format: could not extract child node name on node ...\n"+aChildNode); 434 java.util.HashMap aPropSet = null; 435 436 // Note: Our internal format is different from the source format! 437 java.util.HashMap aTempSet = XMLHelper.convertNodeToPropSet(aChildNode); 438 switch(eType) 439 { 440 case E_TYPE : 441 { 442 aPropSet = Cache.convertTypePropsToInternal(aTempSet, nFormat); 443 m_aDebug.setDetailedInfo("type [\""+sChildName+"\"] converted to internal format"); 444 } 445 break; 446 447 case E_FILTER : 448 { 449 aPropSet = Cache.convertFilterPropsToInternal(aTempSet, nFormat); 450 m_aDebug.setDetailedInfo("filter [\""+sChildName+"\"] converted to internal format"); 451 } 452 break; 453 454 case E_DETECTSERVICE : 455 { 456 aPropSet = Cache.convertDetectServicePropsToInternal(aTempSet, nFormat); 457 m_aDebug.setDetailedInfo("detect service [\""+sChildName+"\"] converted to internal format"); 458 } 459 break; 460 461 case E_FRAMELOADER : 462 { 463 aPropSet = Cache.convertFrameLoaderPropsToInternal(aTempSet, nFormat); 464 m_aDebug.setDetailedInfo("frame loader [\""+sChildName+"\"] converted to internal format"); 465 } 466 break; 467 468 case E_CONTENTHANDLER : 469 { 470 aPropSet = Cache.convertContentHandlerPropsToInternal(aTempSet, nFormat); 471 m_aDebug.setDetailedInfo("content handler [\""+sChildName+"\"] converted to internal format"); 472 } 473 break; 474 } 475 m_aDebug.setDetailedInfo("props = "+aTempSet); 476 rMap.put(sChildName, aPropSet); 477 } 478 } 479 } 480 481 //___________________________________________ 482 483 /** create some hml views of the current content of this cache. 484 * 485 * The given directory is used to create different html files 486 * there. Every of them show another aspect of this cache. 487 * E.g.: - all type/filter properties 488 * - relation ships between types/filters/loaders etc. 489 * 490 * @param aDirectory 491 * points to a system directory, which 492 * can be used completely(!) to generate 493 * the results there. 494 * 495 * @param nFormat 496 * specify in which context the cache items should be 497 * interpreted. 498 */ toHTML(java.io.File aDirectory, int nFormat , java.lang.String sEncoding )499 public synchronized void toHTML(java.io.File aDirectory, 500 int nFormat , 501 java.lang.String sEncoding ) 502 throws java.lang.Exception 503 { 504 if (nFormat != FORMAT_6Y) 505 throw new java.lang.Exception("HTML views are supported for the new 6.y format only yet."); 506 507 java.lang.StringBuffer sRelationView = new java.lang.StringBuffer(1000); 508 sRelationView.append("<html><header><title>Relation View</title></header><body>"); 509 sRelationView.append("<table border=1>"); 510 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>"); 511 512 java.util.Iterator aIt = m_lTypes.keySet().iterator(); 513 while (aIt.hasNext()) 514 { 515 java.lang.String sType = (java.lang.String)aIt.next(); 516 java.util.HashMap aType = (java.util.HashMap)m_lTypes.get(sType); 517 518 sRelationView.append("<tr>"); 519 sRelationView.append("<td>"+sType+"</td>"); 520 521 java.lang.String sVal = (java.lang.String)aType.get(PROPNAME_DETECTSERVICE); 522 if (sVal == null || sVal.length()<1) 523 sRelationView.append("<td> - </td>"); 524 else 525 sRelationView.append("<td>"+sVal+"</td>"); 526 527 sVal = (java.lang.String)aType.get(PROPNAME_PREFERREDFILTER); 528 if (sVal == null || sVal.length()<1) 529 sRelationView.append("<td> - </td>"); 530 else 531 sRelationView.append("<td>"+sVal+"</td>"); 532 533 sVal = (java.lang.String)aType.get(PROPNAME_FRAMELOADER); 534 if (sVal == null || sVal.length()<1) 535 sRelationView.append("<td> - </td>"); 536 else 537 sRelationView.append("<td>"+sVal+"</td>"); 538 539 sVal = (java.lang.String)aType.get(PROPNAME_CONTENTHANDLER); 540 if (sVal == null || sVal.length()<1) 541 sRelationView.append("<td> - </td>"); 542 else 543 sRelationView.append("<td>"+sVal+"</td>"); 544 545 sRelationView.append("</tr>"); 546 } 547 548 sRelationView.append("</table>"); 549 sRelationView.append("</body>"); 550 551 FileHelper.writeEncodedBufferToFile(new java.io.File(aDirectory, "relation_view.html"), sEncoding, false, sRelationView); 552 553 java.util.HashMap lFilters2TypeRegistration = new java.util.HashMap(); 554 aIt = m_lFilters.keySet().iterator(); 555 while (aIt.hasNext()) 556 { 557 java.lang.String sFilter = (java.lang.String)aIt.next(); 558 java.util.HashMap aFilter = (java.util.HashMap)m_lFilters.get(sFilter); 559 java.lang.String sType = (java.lang.String)aFilter.get(PROPNAME_TYPE); 560 561 java.util.Vector lFilters = (java.util.Vector)lFilters2TypeRegistration.get(sType); 562 if (lFilters == null) 563 lFilters = new java.util.Vector(); 564 lFilters.add(sFilter); 565 lFilters2TypeRegistration.put(sType, lFilters); 566 } 567 568 java.lang.StringBuffer sType2FiltersView = new java.lang.StringBuffer(1000); 569 sType2FiltersView.append("<html><header><title>Type2Filters View</title></header><body>"); 570 sType2FiltersView.append("<table border=1>"); 571 sType2FiltersView.append("<tr><td><b>type</b></td><td><b>filters</b></td></tr>"); 572 573 aIt = lFilters2TypeRegistration.keySet().iterator(); 574 while (aIt.hasNext()) 575 { 576 java.lang.String sType = (java.lang.String)aIt.next(); 577 java.util.Vector lFilters = (java.util.Vector)lFilters2TypeRegistration.get(sType); 578 579 sType2FiltersView.append("<tr><td>"+sType+"</td><td>"); 580 java.util.Enumeration aEn = lFilters.elements(); 581 while(aEn.hasMoreElements()) 582 sType2FiltersView.append(aEn.nextElement()+"<br>"); 583 sType2FiltersView.append("</td></tr>"); 584 } 585 586 sType2FiltersView.append("</table>"); 587 sType2FiltersView.append("</body>"); 588 589 FileHelper.writeEncodedBufferToFile(new java.io.File(aDirectory, "type2filters_view.html"), sEncoding, false, sType2FiltersView); 590 } 591 592 //___________________________________________ 593 594 /** converts all items of this cache to its xml representation 595 * and write it to the given file. 596 * 597 * @param aXML 598 * the target file for output. 599 * 600 * @param nFormat 601 * the requested xml format. 602 * see const values FORMAT_xxx too. 603 * 604 * @param sEncoding 605 * specify the file encoding for the generated xml file. 606 * 607 * @throws [java.lang.Exception] 608 * if something fail during convertion. 609 */ toXML(java.io.File aXML , int nFormat , java.lang.String sEncoding)610 public synchronized void toXML(java.io.File aXML , 611 int nFormat , 612 java.lang.String sEncoding) 613 throws java.lang.Exception 614 { 615 java.lang.StringBuffer sXML = new java.lang.StringBuffer(500000); 616 617 for (int i=0; i<5; ++i) 618 { 619 // define right sub container 620 java.lang.String sSetName = null; 621 java.util.HashMap rMap = null; 622 int eType = -1; 623 624 switch(i) 625 { 626 case 0 : 627 { 628 sSetName = CFGNODE_TYPES; 629 rMap = m_lTypes; 630 eType = E_TYPE; 631 } 632 break; 633 634 case 1 : 635 { 636 sSetName = CFGNODE_FILTERS; 637 rMap = m_lFilters; 638 eType = E_FILTER; 639 } 640 break; 641 642 case 2 : 643 { 644 sSetName = CFGNODE_DETECTSERVICES; 645 rMap = m_lDetectServices; 646 eType = E_DETECTSERVICE; 647 } 648 break; 649 650 case 3 : 651 { 652 sSetName = CFGNODE_FRAMELOADERS; 653 rMap = m_lFrameLoaders; 654 eType = E_FRAMELOADER; 655 } 656 break; 657 658 case 4 : 659 { 660 sSetName = CFGNODE_CONTENTHANDLERS; 661 rMap = m_lContentHandlers; 662 eType = E_CONTENTHANDLER; 663 } 664 break; 665 } 666 667 // generate set 668 sXML.append("<node oor:name=\""+sSetName+"\" oor:op=\"replace\">\n"); 669 java.util.Iterator it = rMap.keySet().iterator(); 670 while(it.hasNext()) 671 { 672 java.lang.String sItem = (java.lang.String)it.next(); 673 sXML.append("<node oor:name=\""+sItem+"\" oor:op=\"replace\">\n"); 674 sXML.append(getItemAsXML(eType, sItem, nFormat)); 675 sXML.append("</node>\n"); 676 } 677 sXML.append("</node>\n"); 678 } 679 680 java.io.FileOutputStream aStream = new java.io.FileOutputStream(aXML.getAbsolutePath(), false); 681 java.io.OutputStreamWriter aWriter = new java.io.OutputStreamWriter(aStream, sEncoding); 682 java.lang.String sOut = sXML.toString(); 683 aWriter.write(sOut, 0, sOut.length()); 684 aWriter.flush(); 685 aWriter.close(); 686 } 687 688 //___________________________________________ 689 690 /** converts a type property set from internal format 691 * to an external one. 692 * 693 * @param aMap 694 * points to the item, which should be converted. 695 * 696 * @param nFormat 697 * specify the requested output format. 698 * 699 * @return [java.util.HashMap] 700 * contains the properties in the requested format. 701 * 702 * @throws [java.lang.Exception 703 * if something fail during convertion. 704 */ convertTypePropsToExternal(java.util.HashMap aMap , int nFormat)705 private static java.util.HashMap convertTypePropsToExternal(java.util.HashMap aMap , 706 int nFormat) 707 throws java.lang.Exception 708 { 709 java.util.HashMap aResultMap = new java.util.HashMap(); 710 // copy Name property ... if it exists! 711 if (aMap.containsKey(PROPNAME_NAME)) 712 aResultMap.put(PROPNAME_NAME, aMap.get(PROPNAME_NAME)); 713 switch(nFormat) 714 { 715 //----------------------------------- 716 case FORMAT_60 : 717 { 718 // copy UIName property unchanged 719 aResultMap.put(PROPNAME_UINAME, aMap.get(PROPNAME_UINAME)); 720 721 // ignore properties "UIOrder", "PreferredFilter", "DetectService" 722 // They are not supported for 6.0 types. 723 724 // pack all other properties to one "Data" string value 725 java.lang.StringBuffer sData = new java.lang.StringBuffer(256); 726 727 sData.append(aMap.get(PROPNAME_PREFERRED)); 728 sData.append(","); 729 sData.append(aMap.get(PROPNAME_MEDIATYPE)); 730 sData.append(","); 731 sData.append(aMap.get(PROPNAME_CLIPBOARDFORMAT)); 732 sData.append(","); 733 734 java.util.Vector lList = (java.util.Vector)aMap.get(PROPNAME_URLPATTERN); 735 int c = lList.size(); 736 int i = 0; 737 for (i=0; i<c; ++i) 738 { 739 sData.append(lList.elementAt(i)); 740 if (i<(c-1)) 741 sData.append(";"); 742 } 743 744 lList = (java.util.Vector)aMap.get(PROPNAME_EXTENSIONS); 745 c = lList.size(); 746 for (i=0; i<c; ++i) 747 { 748 sData.append(lList.elementAt(i)); 749 if (i<(c-1)) 750 sData.append(";"); 751 } 752 753 sData.append(","); 754 sData.append(aMap.get(PROPNAME_DOCUMENTICONID)); 755 sData.append(","); 756 757 aResultMap.put(PROPNAME_DATA, sData.toString()); 758 } 759 break; 760 761 //----------------------------------- 762 case FORMAT_6Y : 763 { 764 // copy all supported properties directly 765 aResultMap.put(PROPNAME_PREFERRED , aMap.get(PROPNAME_PREFERRED )); 766 aResultMap.put(PROPNAME_MEDIATYPE , aMap.get(PROPNAME_MEDIATYPE )); 767 aResultMap.put(PROPNAME_URLPATTERN , aMap.get(PROPNAME_URLPATTERN )); 768 aResultMap.put(PROPNAME_EXTENSIONS , aMap.get(PROPNAME_EXTENSIONS )); 769 aResultMap.put(PROPNAME_UINAME , aMap.get(PROPNAME_UINAME )); 770 aResultMap.put(PROPNAME_PREFERREDFILTER, aMap.get(PROPNAME_PREFERREDFILTER)); 771 aResultMap.put(PROPNAME_DETECTSERVICE , aMap.get(PROPNAME_DETECTSERVICE )); 772 aResultMap.put(PROPNAME_CLIPBOARDFORMAT, aMap.get(PROPNAME_CLIPBOARDFORMAT)); 773 aResultMap.put(PROPNAME_UIORDER , aMap.get(PROPNAME_UIORDER )); 774 /* REMOVED! 775 aResultMap.put(PROPNAME_DOCUMENTICONID , aMap.get(PROPNAME_DOCUMENTICONID )); 776 */ 777 } 778 break; 779 780 //----------------------------------- 781 default : 782 throw new java.lang.Exception("unknown format"); 783 } 784 785 return aResultMap; 786 } 787 788 //___________________________________________ 789 790 /** converts a filter property set from internal format 791 * to an external one. 792 * 793 * @param aMap 794 * points to the item, which should be converted. 795 * 796 * @param nFormat 797 * specify the requested output format. 798 * 799 * @return [java.util.HashMap] 800 * contains the properties in the requested format. 801 * 802 * @throws [java.lang.Exception 803 * if something fail during convertion. 804 */ convertFilterPropsToExternal(java.util.HashMap aMap , int nFormat)805 private static java.util.HashMap convertFilterPropsToExternal(java.util.HashMap aMap , 806 int nFormat) 807 throws java.lang.Exception 808 { 809 java.util.HashMap aResultMap = new java.util.HashMap(); 810 // copy Name property ... if it exists! 811 if (aMap.containsKey(PROPNAME_NAME)) 812 aResultMap.put(PROPNAME_NAME, aMap.get(PROPNAME_NAME)); 813 switch(nFormat) 814 { 815 //----------------------------------- 816 case FORMAT_60 : 817 { 818 // copy UIName property unchanged! 819 aResultMap.put(PROPNAME_UINAME, aMap.get(PROPNAME_UINAME)); 820 821 // but pack all other properties 822 java.lang.StringBuffer sData = new java.lang.StringBuffer(256); 823 824 sData.append(aMap.get(PROPNAME_ORDER)); 825 sData.append(","); 826 sData.append(aMap.get(PROPNAME_TYPE)); 827 sData.append(","); 828 sData.append(aMap.get(PROPNAME_DOCUMENTSERVICE)); 829 sData.append(","); 830 sData.append(aMap.get(PROPNAME_FILTERSERVICE)); 831 sData.append(","); 832 sData.append(aMap.get(PROPNAME_FLAGS)); 833 sData.append(","); 834 java.util.Vector lList = (java.util.Vector)aMap.get(PROPNAME_USERDATA); 835 int c = lList.size(); 836 int i = 0; 837 for (i=0; i<c; ++i) 838 { 839 sData.append(lList.elementAt(i)); 840 if (i<(c-1)) 841 sData.append(";"); 842 } 843 sData.append(","); 844 sData.append(aMap.get(PROPNAME_FILEFORMATVERSION)); 845 sData.append(","); 846 sData.append(aMap.get(PROPNAME_TEMPLATENAME)); 847 sData.append(","); 848 sData.append(aMap.get(PROPNAME_UICOMPONENT)); 849 sData.append(","); 850 851 aResultMap.put(PROPNAME_DATA, sData.toString()); 852 } 853 break; 854 855 //----------------------------------- 856 case FORMAT_6Y : 857 { 858 // supress "Order" property. 859 // Will be moved to type entries in 6.y version! 860 861 // supress "UIName" property. 862 // Only type entries will be localized in 6.y version! 863 /* TODO make it configurable :-) */ 864 aResultMap.put(PROPNAME_UINAME , aMap.get(PROPNAME_UINAME )); 865 866 // copy all supported properties directly 867 aResultMap.put(PROPNAME_TYPE , aMap.get(PROPNAME_TYPE )); 868 aResultMap.put(PROPNAME_DOCUMENTSERVICE , aMap.get(PROPNAME_DOCUMENTSERVICE )); 869 aResultMap.put(PROPNAME_FILTERSERVICE , aMap.get(PROPNAME_FILTERSERVICE )); 870 aResultMap.put(PROPNAME_USERDATA , aMap.get(PROPNAME_USERDATA )); 871 aResultMap.put(PROPNAME_FILEFORMATVERSION, aMap.get(PROPNAME_FILEFORMATVERSION)); 872 aResultMap.put(PROPNAME_TEMPLATENAME , aMap.get(PROPNAME_TEMPLATENAME )); 873 aResultMap.put(PROPNAME_UICOMPONENT , aMap.get(PROPNAME_UICOMPONENT )); 874 875 // "Flags" will be converted from internal format [int] to 876 // the 6.y format [string-list]! 877 java.lang.Integer nFlags = (java.lang.Integer)aMap.get(PROPNAME_FLAGS); 878 java.util.Vector lFlags = Cache.convertFilterFlagValues2Names(nFlags); 879 aResultMap.put(PROPNAME_FLAGS, lFlags); 880 } 881 break; 882 883 //----------------------------------- 884 default : 885 throw new java.lang.Exception("unknown format"); 886 } 887 888 return aResultMap; 889 } 890 891 //___________________________________________ 892 893 /** converts a detect service property set from internal format 894 * to an external one. 895 * 896 * @param aMap 897 * points to the item, which should be converted. 898 * 899 * @param nFormat 900 * specify the requested output format. 901 * 902 * @return [java.util.HashMap] 903 * contains the properties in the requested format. 904 * 905 * @throws [java.lang.Exception 906 * if something fail during convertion. 907 */ convertDetectServicePropsToExternal(java.util.HashMap aMap , int nFormat)908 private static java.util.HashMap convertDetectServicePropsToExternal(java.util.HashMap aMap , 909 int nFormat) 910 throws java.lang.Exception 911 { 912 java.util.HashMap aResultMap = null; 913 914 switch(nFormat) 915 { 916 //----------------------------------- 917 case FORMAT_60 : 918 { 919 // no changes! 920 aResultMap = aMap; 921 } 922 break; 923 924 //----------------------------------- 925 case FORMAT_6Y : 926 { 927 // remove localized name 928 aResultMap = aMap; 929 aResultMap.remove(PROPNAME_UINAME); 930 } 931 break; 932 933 //----------------------------------- 934 default : 935 throw new java.lang.Exception("unknown format"); 936 } 937 938 return aResultMap; 939 } 940 convertFrameLoaderPropsToExternal(java.util.HashMap aMap , int nFormat)941 private static java.util.HashMap convertFrameLoaderPropsToExternal(java.util.HashMap aMap , 942 int nFormat) 943 throws java.lang.Exception 944 { 945 java.util.HashMap aResultMap = null; 946 947 switch(nFormat) 948 { 949 //----------------------------------- 950 case FORMAT_60 : 951 { 952 // no changes! 953 aResultMap = aMap; 954 } 955 break; 956 957 //----------------------------------- 958 case FORMAT_6Y : 959 { 960 // remove localized name 961 aResultMap = aMap; 962 aResultMap.remove(PROPNAME_UINAME); 963 } 964 break; 965 966 //----------------------------------- 967 default : 968 throw new java.lang.Exception("unknown format"); 969 } 970 971 return aResultMap; 972 } 973 convertContentHandlerPropsToExternal(java.util.HashMap aMap , int nFormat)974 private static java.util.HashMap convertContentHandlerPropsToExternal(java.util.HashMap aMap , 975 int nFormat) 976 throws java.lang.Exception 977 { 978 java.util.HashMap aResultMap = null; 979 980 switch(nFormat) 981 { 982 //----------------------------------- 983 case FORMAT_60 : 984 { 985 // no changes! 986 aResultMap = aMap; 987 } 988 break; 989 990 //----------------------------------- 991 case FORMAT_6Y : 992 { 993 // remove localized name 994 aResultMap = aMap; 995 aResultMap.remove(PROPNAME_UINAME); 996 } 997 break; 998 999 //----------------------------------- 1000 default : 1001 throw new java.lang.Exception("unknown format"); 1002 } 1003 1004 return aResultMap; 1005 } 1006 1007 //___________________________________________ 1008 1009 /** converts a type property set (using an external format) to 1010 * our internal cache format. 1011 * 1012 * Especialy the data format string will be expanded 1013 * to its real properties. 1014 * 1015 * Schema: 1016 * aMap["UIName"] => aExpandedMap["UIName"] 1017 * aMap["Data" ] => aExpandedMap["Preferred" ], aExpandedMap["MediaType"] etc. ... 1018 * 1019 * @param aMap 1020 * points to the item, which should be converted. 1021 1022 * @param nFormat 1023 * specify the external format. 1024 * 1025 * @return [java.util.HashMap] 1026 * The new map in internal format. 1027 */ convertTypePropsToInternal(java.util.HashMap aMap , int nFormat)1028 private static java.util.HashMap convertTypePropsToInternal(java.util.HashMap aMap , 1029 int nFormat) 1030 throws java.lang.Exception 1031 { 1032 java.util.HashMap aResultMap = new java.util.HashMap(); 1033 // copy Name property ... if it exists! 1034 if (aMap.containsKey(PROPNAME_NAME)) 1035 aResultMap.put(PROPNAME_NAME, aMap.get(PROPNAME_NAME)); 1036 switch(nFormat) 1037 { 1038 //----------------------------------- 1039 case FORMAT_60 : 1040 { 1041 // copy UIName property unchanged! 1042 aResultMap.put(PROPNAME_UINAME, aMap.get(PROPNAME_UINAME)); 1043 1044 // generate new property "UIOrder" 1045 // Its the moved property "Order" of filters for versions >= 6.y! 1046 aResultMap.put(PROPNAME_UIORDER, new java.lang.Integer(0)); 1047 1048 // generate new property "PreferredFilter" 1049 // Its a the moved filter flag "Preferred" for versions >= 6.y! 1050 aResultMap.put(PROPNAME_PREFERREDFILTER, new java.lang.String()); 1051 1052 // generate new property "DetectService" 1053 // Every type know its detector diretcly from now. No search 1054 // will be neccessary any longer. 1055 aResultMap.put(PROPNAME_DETECTSERVICE, new java.lang.String()); 1056 1057 // analyze the Data property of the original map 1058 // and copy its results (means all expanded properties) 1059 // to the result map. 1060 java.lang.String sDataVal = (java.lang.String)aMap.get(PROPNAME_DATA); 1061 java.util.Vector lTokens = Cache.splitTokenString(sDataVal, ","); 1062 1063 int t = 0; 1064 java.util.Enumeration it = lTokens.elements(); 1065 while (it.hasMoreElements()) 1066 { 1067 java.lang.String sToken = (java.lang.String)it.nextElement(); 1068 switch(t) 1069 { 1070 case 0 : 1071 aResultMap.put(PROPNAME_PREFERRED, new java.lang.Boolean(sToken)); 1072 break; 1073 case 1 : 1074 aResultMap.put(PROPNAME_MEDIATYPE, sToken); 1075 break; 1076 case 2 : 1077 { 1078 /*HACK ersetze %20 mit " " ...*/ 1079 int ni = sToken.indexOf("%20"); 1080 if (ni!=-1) 1081 { 1082 java.lang.String sPatch = sToken.substring(0,ni) + " " + sToken.substring(ni+3); 1083 sToken = sPatch; 1084 } 1085 aResultMap.put(PROPNAME_CLIPBOARDFORMAT, sToken); 1086 } 1087 break; 1088 case 3 : 1089 aResultMap.put(PROPNAME_URLPATTERN, Cache.splitTokenString(sToken, ";")); 1090 break; 1091 case 4 : 1092 aResultMap.put(PROPNAME_EXTENSIONS, Cache.splitTokenString(sToken, ";")); 1093 break; 1094 case 5 : 1095 aResultMap.put(PROPNAME_DOCUMENTICONID, new java.lang.Integer(sToken)); 1096 break; 1097 default : 1098 throw new java.lang.Exception("unsupported format for data value of a type \""+aMap.get(PROPNAME_NAME)+"\" detected."); 1099 } 1100 ++t; 1101 } 1102 } 1103 break; 1104 1105 //----------------------------------- 1106 case FORMAT_6Y : 1107 { 1108 // copy all supported properties directly 1109 aResultMap.put(PROPNAME_PREFERRED , aMap.get(PROPNAME_PREFERRED )); 1110 aResultMap.put(PROPNAME_MEDIATYPE , aMap.get(PROPNAME_MEDIATYPE )); 1111 aResultMap.put(PROPNAME_CLIPBOARDFORMAT, aMap.get(PROPNAME_CLIPBOARDFORMAT)); 1112 aResultMap.put(PROPNAME_URLPATTERN , aMap.get(PROPNAME_URLPATTERN )); 1113 aResultMap.put(PROPNAME_EXTENSIONS , aMap.get(PROPNAME_EXTENSIONS )); 1114 aResultMap.put(PROPNAME_DOCUMENTICONID , aMap.get(PROPNAME_DOCUMENTICONID )); 1115 aResultMap.put(PROPNAME_UINAME , aMap.get(PROPNAME_UINAME )); 1116 aResultMap.put(PROPNAME_UIORDER , aMap.get(PROPNAME_UIORDER )); 1117 aResultMap.put(PROPNAME_PREFERREDFILTER, aMap.get(PROPNAME_PREFERREDFILTER)); 1118 aResultMap.put(PROPNAME_DETECTSERVICE , aMap.get(PROPNAME_DETECTSERVICE )); 1119 } 1120 break; 1121 1122 //----------------------------------- 1123 default : 1124 throw new java.lang.Exception("unknown format"); 1125 } 1126 1127 return aResultMap; 1128 } 1129 1130 //___________________________________________ 1131 1132 /** converts a filter property set (using an external format) to 1133 * our internal cache format. 1134 * 1135 * Especialy the data format string will be expanded 1136 * to its real properties. 1137 * 1138 * Schema: 1139 * aMap["UIName"] => aExpandedMap["UIName"] 1140 * aMap["Data" ] => aExpandedMap["Order" ], aExpandedMap["Flags"] etc. ... 1141 * 1142 * @param aMap 1143 * points to the item, which should be converted. 1144 * 1145 * @param nFormat 1146 * specify the external format. 1147 * 1148 * @return [java.util.HashMap] 1149 * The new map in internal format. 1150 */ convertFilterPropsToInternal(java.util.HashMap aMap , int nFormat)1151 private static java.util.HashMap convertFilterPropsToInternal(java.util.HashMap aMap , 1152 int nFormat) 1153 throws java.lang.Exception 1154 { 1155 java.util.HashMap aResultMap = new java.util.HashMap(); 1156 // copy Name property ... if it exists! 1157 if (aMap.containsKey(PROPNAME_NAME)) 1158 aResultMap.put(PROPNAME_NAME, aMap.get(PROPNAME_NAME)); 1159 switch(nFormat) 1160 { 1161 //----------------------------------- 1162 case FORMAT_60 : 1163 { 1164 // copy UIName property 1165 aResultMap.put(PROPNAME_UINAME, aMap.get(PROPNAME_UINAME)); 1166 1167 // analyze the Data property of the original map 1168 // and copy its results (means all expanded properties) 1169 // to the result map. 1170 java.lang.String sDataVal = (java.lang.String)aMap.get(PROPNAME_DATA); 1171 java.util.Vector lTokens = Cache.splitTokenString(sDataVal, ","); 1172 1173 int t = 0; 1174 java.util.Enumeration it = lTokens.elements(); 1175 while (it.hasMoreElements()) 1176 { 1177 java.lang.String sToken = (java.lang.String)it.nextElement(); 1178 switch(t) 1179 { 1180 case 0 : 1181 aResultMap.put(PROPNAME_ORDER, new java.lang.Integer(sToken)); 1182 break; 1183 case 1 : 1184 aResultMap.put(PROPNAME_TYPE, sToken); 1185 break; 1186 case 2 : 1187 aResultMap.put(PROPNAME_DOCUMENTSERVICE, sToken); 1188 break; 1189 case 3 : 1190 aResultMap.put(PROPNAME_FILTERSERVICE, sToken); 1191 break; 1192 case 4 : 1193 aResultMap.put(PROPNAME_FLAGS, new java.lang.Integer(sToken)); 1194 break; 1195 case 5 : 1196 aResultMap.put(PROPNAME_USERDATA, Cache.splitTokenString(sToken, ";")); 1197 break; 1198 case 6 : 1199 aResultMap.put(PROPNAME_FILEFORMATVERSION, new java.lang.Integer(sToken)); 1200 break; 1201 case 7 : 1202 aResultMap.put(PROPNAME_TEMPLATENAME, sToken); 1203 break; 1204 case 8 : 1205 aResultMap.put(PROPNAME_UICOMPONENT, sToken); 1206 break; 1207 default : 1208 throw new java.lang.Exception("unsupported format for data value of a filter detected."); 1209 } 1210 ++t; 1211 } 1212 1213 // its an optional property :-) 1214 if (!aResultMap.containsKey(PROPNAME_TEMPLATENAME)) 1215 aResultMap.put(PROPNAME_TEMPLATENAME, new java.lang.String("")); 1216 1217 // its an optional property :-) 1218 if (!aResultMap.containsKey(PROPNAME_UICOMPONENT)) 1219 aResultMap.put(PROPNAME_UICOMPONENT, new java.lang.String("")); 1220 } 1221 break; 1222 1223 //----------------------------------- 1224 case FORMAT_6Y : 1225 { 1226 // "Order" does not exist for 6.y versions! Use default. 1227 aResultMap.put(PROPNAME_ORDER, new java.lang.Integer(0)); 1228 1229 // "UIName" property does not exist for 6.y versions! use default. 1230 /* TODO make it configurable :-) */ 1231 aResultMap.put(PROPNAME_UINAME, aMap.get(PROPNAME_UINAME)); 1232 //aResultMap.put(PROPNAME_UINAME, new java.util.HashMap()); 1233 1234 // "Flags" must be converted from names to its values 1235 java.util.Vector lFlags = (java.util.Vector)aMap.get(PROPNAME_FLAGS); 1236 java.lang.Integer nFlags = Cache.convertFilterFlagNames2Values(lFlags); 1237 aResultMap.put(PROPNAME_FLAGS, nFlags); 1238 1239 // copy all direct supported properties 1240 aResultMap.put(PROPNAME_TYPE , aMap.get(PROPNAME_TYPE )); 1241 aResultMap.put(PROPNAME_DOCUMENTSERVICE , aMap.get(PROPNAME_DOCUMENTSERVICE )); 1242 aResultMap.put(PROPNAME_FILTERSERVICE , aMap.get(PROPNAME_ORDER )); 1243 aResultMap.put(PROPNAME_USERDATA , aMap.get(PROPNAME_USERDATA )); 1244 aResultMap.put(PROPNAME_FILEFORMATVERSION, aMap.get(PROPNAME_FILEFORMATVERSION)); 1245 aResultMap.put(PROPNAME_TEMPLATENAME , aMap.get(PROPNAME_TEMPLATENAME )); 1246 aResultMap.put(PROPNAME_UICOMPONENT , aMap.get(PROPNAME_UICOMPONENT )); 1247 } 1248 break; 1249 1250 //----------------------------------- 1251 default : 1252 throw new java.lang.Exception("unknown format"); 1253 } 1254 1255 return aResultMap; 1256 } 1257 convertDetectServicePropsToInternal(java.util.HashMap aMap , int nFormat)1258 private static java.util.HashMap convertDetectServicePropsToInternal(java.util.HashMap aMap , 1259 int nFormat) 1260 throws java.lang.Exception 1261 { 1262 /*FIXME*/ 1263 java.util.HashMap aResultMap = aMap; 1264 return aResultMap; 1265 } 1266 convertFrameLoaderPropsToInternal(java.util.HashMap aMap , int nFormat)1267 private static java.util.HashMap convertFrameLoaderPropsToInternal(java.util.HashMap aMap , 1268 int nFormat) 1269 throws java.lang.Exception 1270 { 1271 /*FIXME*/ 1272 java.util.HashMap aResultMap = aMap; 1273 return aResultMap; 1274 } 1275 convertContentHandlerPropsToInternal(java.util.HashMap aMap , int nFormat)1276 private static java.util.HashMap convertContentHandlerPropsToInternal(java.util.HashMap aMap , 1277 int nFormat) 1278 throws java.lang.Exception 1279 { 1280 /*FIXME*/ 1281 java.util.HashMap aResultMap = aMap; 1282 return aResultMap; 1283 } 1284 1285 //___________________________________________ 1286 1287 /** converts filter flag names to its int representation. 1288 * 1289 * @param lFlags 1290 * a list of flag names. 1291 * 1292 * @return [java.lang.Integer] 1293 * an integer field of all set flags. 1294 * 1295 * @throws [java.lang.Exception] 1296 * for unsupported flags or empty flag fields! 1297 */ convertFilterFlagNames2Values(java.util.Vector lFlags)1298 private static java.lang.Integer convertFilterFlagNames2Values(java.util.Vector lFlags) 1299 throws java.lang.Exception 1300 { 1301 int nFlags = 0; 1302 java.util.Enumeration it = lFlags.elements(); 1303 while(it.hasMoreElements()) 1304 { 1305 java.lang.String sFlagName = (java.lang.String)it.nextElement(); 1306 1307 if (sFlagName.equals(FLAGNAME_3RDPARTYFILTER)) 1308 nFlags |= FLAGVAL_3RDPARTYFILTER; 1309 else 1310 if (sFlagName.equals(FLAGNAME_ALIEN)) 1311 nFlags |= FLAGVAL_ALIEN; 1312 else 1313 if (sFlagName.equals(FLAGNAME_ASYNCHRON)) 1314 nFlags |= FLAGVAL_ASYNCHRON; 1315 else 1316 if (sFlagName.equals(FLAGNAME_BROWSERPREFERRED)) 1317 nFlags |= FLAGVAL_BROWSERPREFERRED; 1318 else 1319 if (sFlagName.equals(FLAGNAME_CONSULTSERVICE)) 1320 nFlags |= FLAGVAL_CONSULTSERVICE; 1321 else 1322 if (sFlagName.equals(FLAGNAME_DEFAULT)) 1323 nFlags |= FLAGVAL_DEFAULT; 1324 else 1325 if (sFlagName.equals(FLAGNAME_EXPORT)) 1326 nFlags |= FLAGVAL_EXPORT; 1327 else 1328 if (sFlagName.equals(FLAGNAME_IMPORT)) 1329 nFlags |= FLAGVAL_IMPORT; 1330 else 1331 if (sFlagName.equals(FLAGNAME_INTERNAL)) 1332 nFlags |= FLAGVAL_INTERNAL; 1333 else 1334 if (sFlagName.equals(FLAGNAME_NOTINCHOOSER)) 1335 nFlags |= FLAGVAL_NOTINCHOOSER; 1336 else 1337 if (sFlagName.equals(FLAGNAME_NOTINFILEDIALOG)) 1338 nFlags |= FLAGVAL_NOTINFILEDIALOG; 1339 else 1340 if (sFlagName.equals(FLAGNAME_NOTINSTALLED)) 1341 nFlags |= FLAGVAL_NOTINSTALLED; 1342 else 1343 if (sFlagName.equals(FLAGNAME_OWN)) 1344 nFlags |= FLAGVAL_OWN; 1345 else 1346 if (sFlagName.equals(FLAGNAME_PACKED)) 1347 nFlags |= FLAGVAL_PACKED; 1348 else 1349 if (sFlagName.equals(FLAGNAME_PREFERRED)) 1350 nFlags |= FLAGVAL_PREFERRED; 1351 else 1352 if (sFlagName.equals(FLAGNAME_READONLY)) 1353 nFlags |= FLAGVAL_READONLY; 1354 else 1355 if (sFlagName.equals(FLAGNAME_TEMPLATE)) 1356 nFlags |= FLAGVAL_TEMPLATE; 1357 else 1358 if (sFlagName.equals(FLAGNAME_TEMPLATEPATH)) 1359 nFlags |= FLAGVAL_TEMPLATEPATH; 1360 else 1361 if (sFlagName.equals(FLAGNAME_USESOPTIONS)) 1362 nFlags |= FLAGVAL_USESOPTIONS; 1363 else 1364 if (sFlagName.equals(FLAGNAME_COMBINED)) 1365 nFlags |= FLAGVAL_COMBINED; 1366 else 1367 throw new java.lang.Exception("unsupported filter flag detected: \""+sFlagName+"\""); 1368 } 1369 1370 if (nFlags == 0) 1371 throw new java.lang.Exception("no filter flags?"); 1372 1373 return new java.lang.Integer(nFlags); 1374 } 1375 1376 //___________________________________________ 1377 1378 /** converts filter flag values to its string representation. 1379 * 1380 * @param nFlags 1381 * the flag field as int value. 1382 * 1383 * @return [java.util.Vector] 1384 * a list of flag names. 1385 * 1386 * @throws [java.lang.Exception] 1387 * for unsupported flags or empty flag fields! 1388 */ convertFilterFlagValues2Names(java.lang.Integer nFlags)1389 private static java.util.Vector convertFilterFlagValues2Names(java.lang.Integer nFlags) 1390 throws java.lang.Exception 1391 { 1392 java.util.Vector lFlags = new java.util.Vector(); 1393 int field = nFlags.intValue(); 1394 1395 if (field == 0) 1396 throw new java.lang.Exception("no filter flags?"); 1397 1398 if((field & FLAGVAL_IMPORT) == FLAGVAL_IMPORT) 1399 lFlags.add(FLAGNAME_IMPORT); 1400 1401 if((field & FLAGVAL_EXPORT) == FLAGVAL_EXPORT) 1402 lFlags.add(FLAGNAME_EXPORT); 1403 1404 if((field & FLAGVAL_TEMPLATE) == FLAGVAL_TEMPLATE) 1405 lFlags.add(FLAGNAME_TEMPLATE); 1406 1407 if((field & FLAGVAL_INTERNAL) == FLAGVAL_INTERNAL) 1408 lFlags.add(FLAGNAME_INTERNAL); 1409 1410 if((field & FLAGVAL_TEMPLATEPATH) == FLAGVAL_TEMPLATEPATH) 1411 lFlags.add(FLAGNAME_TEMPLATEPATH); 1412 1413 if((field & FLAGVAL_OWN) == FLAGVAL_OWN) 1414 lFlags.add(FLAGNAME_OWN); 1415 1416 if((field & FLAGVAL_ALIEN) == FLAGVAL_ALIEN) 1417 lFlags.add(FLAGNAME_ALIEN); 1418 1419 if((field & FLAGVAL_USESOPTIONS) == FLAGVAL_USESOPTIONS) 1420 lFlags.add(FLAGNAME_USESOPTIONS); 1421 1422 if((field & FLAGVAL_DEFAULT) == FLAGVAL_DEFAULT) 1423 lFlags.add(FLAGNAME_DEFAULT); 1424 1425 if((field & FLAGVAL_NOTINFILEDIALOG) == FLAGVAL_NOTINFILEDIALOG) 1426 lFlags.add(FLAGNAME_NOTINFILEDIALOG); 1427 1428 if((field & FLAGVAL_NOTINCHOOSER) == FLAGVAL_NOTINCHOOSER) 1429 lFlags.add(FLAGNAME_NOTINCHOOSER); 1430 1431 if((field & FLAGVAL_ASYNCHRON) == FLAGVAL_ASYNCHRON) 1432 lFlags.add(FLAGNAME_ASYNCHRON); 1433 1434 if((field & FLAGVAL_READONLY) == FLAGVAL_READONLY) 1435 lFlags.add(FLAGNAME_READONLY); 1436 1437 if((field & FLAGVAL_NOTINSTALLED) == FLAGVAL_NOTINSTALLED) 1438 lFlags.add(FLAGNAME_NOTINSTALLED); 1439 1440 if((field & FLAGVAL_CONSULTSERVICE) == FLAGVAL_CONSULTSERVICE) 1441 lFlags.add(FLAGNAME_CONSULTSERVICE); 1442 1443 if((field & FLAGVAL_3RDPARTYFILTER) == FLAGVAL_3RDPARTYFILTER) 1444 lFlags.add(FLAGNAME_3RDPARTYFILTER); 1445 1446 if((field & FLAGVAL_PACKED) == FLAGVAL_PACKED) 1447 lFlags.add(FLAGNAME_PACKED); 1448 1449 if((field & FLAGVAL_BROWSERPREFERRED) == FLAGVAL_BROWSERPREFERRED) 1450 lFlags.add(FLAGNAME_BROWSERPREFERRED); 1451 1452 if((field & FLAGVAL_PREFERRED) == FLAGVAL_PREFERRED) 1453 lFlags.add(FLAGNAME_PREFERRED); 1454 1455 if((field & FLAGVAL_COMBINED) == FLAGVAL_COMBINED) 1456 lFlags.add(FLAGNAME_COMBINED); 1457 1458 if((field & FLAGVAL_COMBINED) == FLAGVAL_SUPPORTSSELECTION) 1459 lFlags.add(FLAGNAME_SUPPORTSSELECTION); 1460 1461 return lFlags; 1462 } 1463 1464 //___________________________________________ 1465 1466 /** return a reference to one of our member 1467 * lists for types/filters etc ... 1468 * 1469 * @param eItemType 1470 * specify, which item map is required. 1471 * 1472 * @return [java.util.HashMap] 1473 * a reference(!) to the right member. 1474 * 1475 * @throws [java.lang.Exception] 1476 * if the specified map does not exist. 1477 */ getItemMap(int eItemType)1478 private java.util.HashMap getItemMap(int eItemType) 1479 throws java.lang.Exception 1480 { 1481 java.util.HashMap rMap = null; 1482 switch(eItemType) 1483 { 1484 case E_TYPE : 1485 rMap = m_lTypes; 1486 break; 1487 1488 case E_FILTER : 1489 rMap = m_lFilters; 1490 break; 1491 1492 case E_DETECTSERVICE : 1493 rMap = m_lDetectServices; 1494 break; 1495 1496 case E_FRAMELOADER : 1497 rMap = m_lFrameLoaders; 1498 break; 1499 1500 case E_CONTENTHANDLER : 1501 rMap = m_lContentHandlers; 1502 break; 1503 1504 default: 1505 throw new java.lang.Exception("Invalid item map specified."); 1506 } 1507 return rMap; 1508 } 1509 1510 //___________________________________________ 1511 1512 /** return the count of items inside a sub container 1513 * of this cache. 1514 * 1515 * @param eItemType 1516 * specify, which item map is required. 1517 * 1518 * @throws [java.lang.Exception] 1519 * if the specified map does not exist. 1520 */ getItemCount(int eItemType)1521 public synchronized int getItemCount(int eItemType) 1522 throws java.lang.Exception 1523 { 1524 java.util.HashMap rMap = getItemMap(eItemType); 1525 return rMap.size(); 1526 } 1527 1528 //___________________________________________ 1529 1530 /** get a list of all item names of the specified 1531 * sub container. 1532 * 1533 * @param eItemType 1534 * specify, which item map is required. 1535 * 1536 * @throws [java.lang.Exception] 1537 * if the specified map does not exist. 1538 */ getItemNames(int eItemType)1539 public synchronized java.util.Vector getItemNames(int eItemType) 1540 throws java.lang.Exception 1541 { 1542 java.util.Vector lNames = new java.util.Vector(); 1543 java.util.HashMap rMap = getItemMap(eItemType); 1544 java.util.Iterator it = rMap.keySet().iterator(); 1545 while(it.hasNext()) 1546 lNames.add(it.next()); 1547 return lNames; 1548 } 1549 1550 //___________________________________________ 1551 1552 /** get a list of all item names of the specified 1553 * sub coontainer, where items match to given property set. 1554 * 1555 * Note: The given property set must exist at all 1556 * returned items as minimum and every checked property 1557 * value must be equals! Using of reg expressions or 1558 * similar mechanism will not be supported here. 1559 * 1560 * @param eItemType 1561 * specify, which item map is required. 1562 * 1563 * @param aPropSet 1564 * the set of properties, which must 1565 * exist at the returned item as minimum. 1566 * 1567 * @throws [java.lang.Exception] 1568 * if the specified map does not exist. 1569 */ getMatchedItemNames(int eItemType, java.util.HashMap aPropSet )1570 public synchronized java.util.Vector getMatchedItemNames(int eItemType, 1571 java.util.HashMap aPropSet ) 1572 throws java.lang.Exception 1573 { 1574 java.util.Vector lNames = new java.util.Vector(); 1575 java.util.HashMap rMap = getItemMap(eItemType); 1576 java.util.Iterator it = rMap.keySet().iterator(); 1577 while(it.hasNext()) 1578 { 1579 java.lang.String sItemName = (java.lang.String)it.next(); 1580 java.util.HashMap rItemProps = (java.util.HashMap)rMap.get(sItemName); 1581 1582 boolean bMatch = Cache.matchPropSet(rItemProps, aPropSet); 1583 if (bMatch) 1584 lNames.add(sItemName); 1585 else 1586 { 1587 java.lang.StringBuffer sBuffer = new java.lang.StringBuffer(1000); 1588 sBuffer.append("entry ["+eItemType+"] \""+sItemName+"\" does not match.\n"); 1589 sBuffer.append("\torg items = {"+rItemProps+"}\n"); 1590 sBuffer.append("\treq items = {"+aPropSet+"}\n"); 1591 1592 m_aDebug.setDetailedInfo(sBuffer.toString()); 1593 } 1594 } 1595 return lNames; 1596 } 1597 1598 //___________________________________________ 1599 1600 /** check if two property sets are equals in its 1601 * shared properties. 1602 * 1603 * Note: Only set properties of the match set will be searched 1604 * inside the original set. And its values must be equals. 1605 * Using of reg expressions or similar mechanism will not 1606 * be supported here. 1607 * 1608 * @param rOrgProps 1609 * the original property set, which should be checked. 1610 * 1611 * @param rMatchProps 1612 * contains the properties, which must be searched 1613 * inside rOrgProps. 1614 * 1615 * @return TRUE if all properties of rMatchProps could be located 1616 * inside rOrgProps. 1617 */ matchPropSet(java.util.HashMap rOrgProps , java.util.HashMap rMatchProps)1618 private static boolean matchPropSet(java.util.HashMap rOrgProps , 1619 java.util.HashMap rMatchProps) 1620 { 1621 java.util.Iterator it = rMatchProps.keySet().iterator(); 1622 while(it.hasNext()) 1623 { 1624 java.lang.String sMatchName = (java.lang.String)it.next(); 1625 java.lang.Object aMatchValue = rMatchProps.get(sMatchName); 1626 1627 if ( 1628 (!rOrgProps.containsKey(sMatchName) ) || 1629 (!rOrgProps.get(sMatchName).equals(aMatchValue)) 1630 ) 1631 { 1632 return false; 1633 } 1634 } 1635 return true; 1636 } 1637 1638 //___________________________________________ 1639 1640 /** return a property set for the queried container item. 1641 * 1642 * @param eItemType 1643 * specify, which item map is required. 1644 * 1645 * @param sItemName 1646 * must be a valid item name of the specified item map. 1647 * 1648 * @return [java.util.HashMap] 1649 * the property set of the queried item. 1650 * Always different from null! 1651 * 1652 * @throws [java.lang.Exception] 1653 * if the specified item does not exists or 1654 * seems to be invalid in general (means null!). 1655 */ getItem(int eItemType, java.lang.String sItemName)1656 public synchronized java.util.HashMap getItem(int eItemType, 1657 java.lang.String sItemName) 1658 throws java.lang.Exception 1659 { 1660 java.util.HashMap rMap = getItemMap(eItemType); 1661 java.util.HashMap rItem = (java.util.HashMap)rMap.get(sItemName); 1662 if (rItem == null) 1663 throw new java.lang.Exception("Queried item \""+sItemName+"\" does not exist inside this cache."); 1664 return rItem; 1665 } 1666 1667 //___________________________________________ 1668 1669 /** return a requested item in XML format. 1670 * 1671 * @param eItemType 1672 * identify the right sub set of this cache 1673 * inside which the requested item should exist. 1674 * e.g. E_TYPE, E_FILTER, ... 1675 * 1676 * @param sItemName 1677 * the name of the request item 1678 * 1679 * @param nXMLFormat 1680 * means the format of the generated xml source. 1681 * 1682 * @return [java.lang.String] 1683 * a xml formated string, which contains all properties 1684 * for this container item. 1685 */ getItemAsXML(int eItemType , java.lang.String sItemName , int nXMLFormat)1686 public synchronized java.lang.String getItemAsXML(int eItemType , 1687 java.lang.String sItemName , 1688 int nXMLFormat) 1689 throws java.lang.Exception 1690 { 1691 // Note: Our internal format must be converted to the target format! 1692 java.util.HashMap rItem = getItem(eItemType, sItemName); 1693 java.util.HashMap rFormatedItem = null; 1694 switch(eItemType) 1695 { 1696 case E_TYPE : 1697 { 1698 rFormatedItem = Cache.convertTypePropsToExternal(rItem, nXMLFormat); 1699 m_aDebug.setGlobalInfo("type to external \""+sItemName+"\""); 1700 } 1701 break; 1702 1703 case E_FILTER : 1704 { 1705 rFormatedItem = Cache.convertFilterPropsToExternal(rItem, nXMLFormat); 1706 m_aDebug.setGlobalInfo("filter to external \""+sItemName+"\""); 1707 } 1708 break; 1709 1710 case E_DETECTSERVICE : 1711 { 1712 rFormatedItem = Cache.convertDetectServicePropsToExternal(rItem, nXMLFormat); 1713 m_aDebug.setGlobalInfo("detect service to external \""+sItemName+"\""); 1714 } 1715 break; 1716 1717 case E_FRAMELOADER : 1718 { 1719 rFormatedItem = Cache.convertFrameLoaderPropsToExternal(rItem, nXMLFormat); 1720 m_aDebug.setGlobalInfo("frame loader to external \""+sItemName+"\""); 1721 } 1722 break; 1723 1724 case E_CONTENTHANDLER : 1725 { 1726 rFormatedItem = Cache.convertContentHandlerPropsToExternal(rItem, nXMLFormat); 1727 m_aDebug.setGlobalInfo("content handler to external \""+sItemName+"\""); 1728 } 1729 break; 1730 } 1731 1732 java.lang.StringBuffer sXML = new java.lang.StringBuffer(1000); 1733 int nPrettyTabs = 1; 1734 for (int t=0; t<nPrettyTabs; ++t) 1735 sXML.append("\t"); 1736 sXML.append("<"+XMLHelper.XMLTAG_NODE+" "+XMLHelper.XMLATTRIB_OOR_NAME+"=\""+XMLHelper.encodeHTMLSigns(sItemName)+"\" "+XMLHelper.XMLATTRIB_OOR_OP+"=\""+XMLHelper.XMLATTRIB_OP_REPLACE+"\">\n"); 1737 sXML.append(XMLHelper.convertPropSetToXML(rFormatedItem, nPrettyTabs+1)); 1738 for (int t=0; t<nPrettyTabs; ++t) 1739 sXML.append("\t"); 1740 sXML.append("</"+XMLHelper.XMLTAG_NODE+">\n"); 1741 1742 return sXML.toString(); 1743 } 1744 1745 //___________________________________________ 1746 1747 /** split the given string (using the specified delimiter) 1748 * and return alist of found string tokens. 1749 * 1750 * Note: Against the normal behaviour of the StringTokenizer class 1751 * this method returns empty tokens too. 1752 * E.g: "0,,1" will return "0" - "" - "1" 1753 * 1754 * @param sTokenString 1755 * the string value, which should be analyzed. 1756 * 1757 * @param sDelim 1758 * the delimiter, which will be used to differe between tokens. 1759 * 1760 * @return [java.util.Vector] 1761 * a list of string tokens. Can be empty - but not null! 1762 */ splitTokenString(java.lang.String sTokenString, java.lang.String sDelim )1763 private static java.util.Vector splitTokenString(java.lang.String sTokenString, 1764 java.lang.String sDelim ) 1765 { 1766 java.util.Vector lTokens = new java.util.Vector(); 1767 java.util.StringTokenizer aTokenizer = new java.util.StringTokenizer(sTokenString, sDelim, true); 1768 boolean bLastWasDelim = false; 1769 1770 while (aTokenizer.hasMoreTokens()) 1771 { 1772 java.lang.String sToken = aTokenizer.nextToken(); 1773 if (sToken.equals(sDelim)) 1774 { 1775 if (bLastWasDelim) 1776 { 1777 // last token was a delimiter - new one too 1778 // => an empty token must be placed between these 1779 // two delimiters! Add this empty value to the return list. 1780 lTokens.add(""); 1781 } 1782 else 1783 { 1784 // last token was not a delimiter - new one is such delim 1785 // => ignore this delimiter - but save the information, that 1786 // it occured 1787 bLastWasDelim = true; 1788 } 1789 } 1790 else 1791 { 1792 // new token is no delim 1793 // => Add it to the return list. 1794 lTokens.add(sToken); 1795 // Dont forget to reset this information - so next loop 1796 // will do the right things! 1797 bLastWasDelim = false; 1798 } 1799 } 1800 1801 return lTokens; 1802 } 1803 1804 //___________________________________________ 1805 1806 /** 1807 */ analyze()1808 public synchronized void analyze() 1809 { 1810 m_nDoubleRegisteredFilters = 0; 1811 m_nTypesForFilters = 0; 1812 m_nTypesForDetectServices = 0; 1813 m_nTypesForFrameLoaders = 0; 1814 m_nTypesForContentHandlers = 0; 1815 1816 // create table of types and all registered filters for such types 1817 // By the way: count all double registrations, where a filter 1818 // uses the same type then another filter. 1819 m_lFilterToTypeRegistrations = new java.util.HashMap(); 1820 java.util.Iterator aIt1 = m_lFilters.keySet().iterator(); 1821 while (aIt1.hasNext()) 1822 { 1823 java.lang.String sFilter = (java.lang.String)aIt1.next(); 1824 java.util.HashMap aFilter = (java.util.HashMap)m_lFilters.get(sFilter); 1825 java.lang.String sType = (java.lang.String)aFilter.get(PROPNAME_TYPE); 1826 1827 java.util.Vector lFilters = (java.util.Vector)m_lFilterToTypeRegistrations.get(sType); 1828 if (lFilters == null) 1829 lFilters = new java.util.Vector(); 1830 else 1831 ++m_nDoubleRegisteredFilters; 1832 lFilters.add(sFilter); 1833 m_lFilterToTypeRegistrations.put(sType, lFilters); 1834 } 1835 1836 // count, how many types are used by filters, frame loaders or content handlers 1837 aIt1 = m_lTypes.keySet().iterator(); 1838 while (aIt1.hasNext()) 1839 { 1840 java.lang.String sType = (java.lang.String)aIt1.next(); 1841 1842 java.util.Iterator aIt2 = m_lFilters.keySet().iterator(); 1843 while (aIt2.hasNext()) 1844 { 1845 java.lang.String sItem = (java.lang.String)aIt2.next(); 1846 java.util.HashMap aItem = (java.util.HashMap)m_lFilters.get(sItem); 1847 java.lang.String sTypeReg = (java.lang.String)aItem.get(PROPNAME_TYPE); 1848 1849 if (sTypeReg.equals(sType)) 1850 { 1851 ++m_nTypesForFilters; 1852 break; 1853 } 1854 } 1855 1856 aIt2 = m_lDetectServices.keySet().iterator(); 1857 while (aIt2.hasNext()) 1858 { 1859 java.lang.String sItem = (java.lang.String)aIt2.next(); 1860 java.util.HashMap aItem = (java.util.HashMap)m_lDetectServices.get(sItem); 1861 java.util.Vector lTypeReg = (java.util.Vector)aItem.get(PROPNAME_TYPES); 1862 1863 if (lTypeReg.contains(sType)) 1864 { 1865 ++m_nTypesForDetectServices; 1866 break; 1867 } 1868 } 1869 1870 aIt2 = m_lFrameLoaders.keySet().iterator(); 1871 while (aIt2.hasNext()) 1872 { 1873 java.lang.String sItem = (java.lang.String)aIt2.next(); 1874 java.util.HashMap aItem = (java.util.HashMap)m_lFrameLoaders.get(sItem); 1875 java.util.Vector lTypeReg = (java.util.Vector)aItem.get(PROPNAME_TYPES); 1876 1877 if (lTypeReg.contains(sType)) 1878 { 1879 ++m_nTypesForFrameLoaders; 1880 break; 1881 } 1882 } 1883 1884 aIt2 = m_lContentHandlers.keySet().iterator(); 1885 while (aIt2.hasNext()) 1886 { 1887 java.lang.String sItem = (java.lang.String)aIt2.next(); 1888 java.util.HashMap aItem = (java.util.HashMap)m_lContentHandlers.get(sItem); 1889 java.util.Vector lTypeReg = (java.util.Vector)aItem.get(PROPNAME_TYPES); 1890 1891 if (lTypeReg.contains(sType)) 1892 { 1893 ++m_nTypesForContentHandlers; 1894 break; 1895 } 1896 } 1897 } 1898 } 1899 1900 //___________________________________________ 1901 1902 /** validate all cache entries. 1903 * 1904 * It checks if all made registrations are valid; 1905 * try to repair some simple problems; 1906 * create missing informations on demand ... 1907 * 1908 * @param nFormat 1909 * specify, which configuration format 1910 * must be checked. 1911 * 1912 * @throws [java.lang.Exception] 1913 * if an unrecoverable problem occure. 1914 */ validate(int nFormat)1915 public synchronized void validate(int nFormat) 1916 throws java.lang.Exception 1917 { 1918 validateTypes(nFormat); 1919 validateFilters(nFormat); 1920 } 1921 1922 //___________________________________________ 1923 1924 /** validate all type entries of this cache. 1925 * 1926 * @param nFormat 1927 * specify, which configuration format 1928 * must be checked. 1929 * 1930 * @throws [java.lang.Exception] 1931 * if an unrecoverable problem occure. 1932 */ validateTypes(int nFormat)1933 private void validateTypes(int nFormat) 1934 throws java.lang.Exception 1935 { 1936 java.util.Iterator aIt1 = m_lTypes.keySet().iterator(); 1937 while(aIt1.hasNext()) 1938 { 1939 java.lang.String sType = (java.lang.String)aIt1.next(); 1940 java.util.HashMap aType = (java.util.HashMap)m_lTypes.get(sType); 1941 if (aType == null) 1942 throw new java.lang.Exception("type ["+sType+"] dos not exist realy?!"); 1943 1944 if ( 1945 (!aType.containsKey(PROPNAME_MEDIATYPE )) || 1946 (!aType.containsKey(PROPNAME_PREFERRED )) || 1947 (!aType.containsKey(PROPNAME_CLIPBOARDFORMAT)) || 1948 (!aType.containsKey(PROPNAME_DOCUMENTICONID )) || 1949 (!aType.containsKey(PROPNAME_URLPATTERN )) || 1950 (!aType.containsKey(PROPNAME_EXTENSIONS )) || 1951 (!aType.containsKey(PROPNAME_UINAME )) 1952 ) 1953 { 1954 throw new java.lang.Exception("Type \""+sType+"\" does not contain all neccessary properties for a 6.0/6.Y format."); 1955 } 1956 1957 if ( 1958 (((java.util.Vector)aType.get(PROPNAME_EXTENSIONS)).isEmpty()) && 1959 (((java.util.Vector)aType.get(PROPNAME_URLPATTERN)).isEmpty()) 1960 ) 1961 { 1962 throw new java.lang.Exception("Type \""+sType+"\" does not contain any extension nor an url pattern."); 1963 } 1964 1965 if (((java.util.HashMap)aType.get(PROPNAME_UINAME)).isEmpty()) 1966 throw new java.lang.Exception("Type \""+sType+"\" is not localized."); 1967 1968 if (nFormat == FORMAT_6Y) 1969 { 1970 if ( 1971 (!aType.containsKey(PROPNAME_UIORDER )) || 1972 (!aType.containsKey(PROPNAME_PREFERREDFILTER)) || 1973 (!aType.containsKey(PROPNAME_DETECTSERVICE )) 1974 ) 1975 { 1976 throw new java.lang.Exception("Type \""+sType+"\" does not contain all neccessary properties for a 6.Y format."); 1977 } 1978 1979 if (((java.lang.Integer)aType.get(PROPNAME_UIORDER)).intValue() < 0) 1980 throw new java.lang.Exception("Type \""+sType+"\" has invalid value for prop UIOrder."); 1981 1982 if (((java.lang.String)aType.get(PROPNAME_DETECTSERVICE)).length() < 1) 1983 m_aDebug.setWarning("Type \""+sType+"\" has no detect service registered."); 1984 1985 java.lang.String sPreferredReg = (java.lang.String)aType.get(PROPNAME_PREFERREDFILTER); 1986 if ( 1987 (sPreferredReg == null) || 1988 (sPreferredReg.length() < 1 ) 1989 ) 1990 { 1991 m_aDebug.setWarning("Type \""+sType+"\" has no preferred filter ..."); 1992 /*FIXME 1993 * OK - not every type has a filter registered .. but the 1994 * a frame loader MUST(!) exist! Check it. 1995 */ 1996 } 1997 else 1998 { 1999 if (!m_lFilters.containsKey(sPreferredReg)) 2000 throw new java.lang.Exception("Type \""+sType+"\" has no valid preferred filter registration [\""+sPreferredReg+"\"]."); 2001 } 2002 } 2003 } 2004 } 2005 2006 //___________________________________________ 2007 2008 /** validate all filter entries of this cache. 2009 * 2010 * @param nFormat 2011 * specify, which configuration format 2012 * must be checked. 2013 * 2014 * @throws [java.lang.Exception] 2015 * if an unrecoverable problem occure. 2016 */ validateFilters(int nFormat)2017 public synchronized void validateFilters(int nFormat) 2018 throws java.lang.Exception 2019 { 2020 java.util.Iterator aIt1 = m_lFilters.keySet().iterator(); 2021 while(aIt1.hasNext()) 2022 { 2023 java.lang.String sFilter = (java.lang.String)aIt1.next(); 2024 java.util.HashMap aFilter = (java.util.HashMap)m_lFilters.get(sFilter); 2025 if (aFilter == null) 2026 throw new java.lang.Exception("filter ["+sFilter+"] dos not exist realy?!"); 2027 2028 if ( 2029 (!aFilter.containsKey(PROPNAME_DOCUMENTSERVICE )) || 2030 (!aFilter.containsKey(PROPNAME_FILEFORMATVERSION)) || 2031 (!aFilter.containsKey(PROPNAME_FILTERSERVICE )) || 2032 (!aFilter.containsKey(PROPNAME_FLAGS )) || 2033 (!aFilter.containsKey(PROPNAME_TEMPLATENAME )) || 2034 (!aFilter.containsKey(PROPNAME_TYPE )) || 2035 (!aFilter.containsKey(PROPNAME_UICOMPONENT )) || 2036 (!aFilter.containsKey(PROPNAME_USERDATA )) 2037 ) 2038 { 2039 throw new java.lang.Exception("Filter \""+sFilter+"\" does not contain all neccessary properties for a 6.0/6.Y format."); 2040 } 2041 2042 if (((java.lang.Integer)aFilter.get(PROPNAME_FLAGS)).intValue() < 1) 2043 throw new java.lang.Exception("Filter \""+sFilter+"\" does not have a valid flag field."); 2044 2045 if (!m_lTypes.containsKey(aFilter.get(PROPNAME_TYPE))) 2046 throw new java.lang.Exception("Filter \""+sFilter+"\" is not registered for a well known type."); 2047 2048 if (nFormat == FORMAT_60) 2049 { 2050 if ( 2051 (!aFilter.containsKey(PROPNAME_ORDER )) || 2052 (!aFilter.containsKey(PROPNAME_UINAME)) 2053 ) 2054 { 2055 throw new java.lang.Exception("Filter \""+sFilter+"\" does not contain all neccessary properties for a 6.0 format."); 2056 } 2057 2058 if (((java.lang.Integer)aFilter.get(PROPNAME_ORDER)).intValue() < 0) 2059 throw new java.lang.Exception("Filter \""+sFilter+"\" does not have a valid Order value."); 2060 2061 if (((java.util.HashMap)aFilter.get(PROPNAME_UINAME)).isEmpty()) 2062 throw new java.lang.Exception("Filter \""+sFilter+"\" is not localized."); 2063 } 2064 /*TODO 2065 depends from the configuration item "remove_filter_flag_preferred" ... 2066 2067 if (nFormat == FORMAT_6Y) 2068 { 2069 int flags = ((java.lang.Integer)aFilter.get(PROPNAME_FLAGS)).intValue(); 2070 if ((flags & FLAGVAL_PREFERRED) == FLAGVAL_PREFERRED) 2071 throw new java.lang.Exception("Filter \""+sFilter+"\" has superflous Preferred flag set. Please remove this flag. ["+flags+"]"); 2072 } 2073 */ 2074 } 2075 } 2076 2077 /*TODO 2078 * - remove graphic filters! 2079 * - move detect services to types 2080 */ 2081 transform60to6Y(boolean bCreateCombineFilterFlag , boolean bRemoveFilterFlagBrowserPreferred, boolean bRemoveFilterFlagPreferred , boolean bRemoveFilterFlag3rdparty , boolean bRemoveFilterUINames , boolean bRemoveGraphicFilters , boolean bSetDefaultDetector )2082 public synchronized void transform60to6Y(boolean bCreateCombineFilterFlag , 2083 boolean bRemoveFilterFlagBrowserPreferred, 2084 boolean bRemoveFilterFlagPreferred , 2085 boolean bRemoveFilterFlag3rdparty , 2086 boolean bRemoveFilterUINames , 2087 boolean bRemoveGraphicFilters , 2088 boolean bSetDefaultDetector ) 2089 throws java.lang.Exception 2090 { 2091 // remove some superflous cache entries ... 2092 // everything related to "load macros" 2093 // Macros should be dispatched instead of loaded! 2094 if (m_lTypes.containsKey("macro")) 2095 { 2096 m_lTypes.remove("macro"); 2097 m_aDebug.setDetailedInfo("superflous type \"macro\" was removed"); 2098 } 2099 if (m_lFrameLoaders.containsKey("com.sun.star.comp.sfx2.SfxMacroLoader")) 2100 { 2101 m_lFrameLoaders.remove("com.sun.star.comp.sfx2.SfxMacroLoader"); 2102 m_aDebug.setDetailedInfo("superflous frame loader \"com.sun.star.comp.sfx2.SfxMacroLoader\" was removed"); 2103 } 2104 2105 // step over all filters and check her properties and references 2106 java.util.Vector lPreferredFilters = new java.util.Vector(); 2107 java.util.Vector lNoRealFilters = new java.util.Vector(); 2108 java.util.Iterator aIt1 = m_lFilters.keySet().iterator(); 2109 while(aIt1.hasNext()) 2110 { 2111 java.lang.String sFilter = (java.lang.String)aIt1.next(); 2112 java.util.HashMap aFilter = (java.util.HashMap)m_lFilters.get(sFilter); 2113 2114 // remove the "graphic helper filters" used by draw and impress 2115 // They dont have any valid document service name set and cant be handled 2116 // by our generic FrameLoader! 2117 // They must be moved to her own configuration ... 2118 2119 if ( 2120 (bRemoveGraphicFilters ) && 2121 (((java.lang.String)aFilter.get(PROPNAME_DOCUMENTSERVICE)).length() < 1) 2122 ) 2123 { 2124 lNoRealFilters.add(sFilter); 2125 continue; 2126 } 2127 2128 java.lang.String sTypeReg = (java.lang.String)aFilter.get(PROPNAME_TYPE); 2129 java.util.HashMap aType = (java.util.HashMap)m_lTypes.get(sTypeReg); 2130 2131 // move UINames of filters to types 2132 java.util.HashMap lFilterUINames = (java.util.HashMap)aFilter.get(PROPNAME_UINAME); 2133 java.util.HashMap lTypeUINames = (java.util.HashMap)aType.get(PROPNAME_UINAME); 2134 java.util.HashMap lPatchUINames = new java.util.HashMap(); 2135 2136 java.util.Iterator pUINames = lTypeUINames.keySet().iterator(); 2137 while(pUINames.hasNext()) 2138 { 2139 java.lang.String sLocale = (java.lang.String)pUINames.next(); 2140 java.lang.String sValue = (java.lang.String)lTypeUINames.get(sLocale); 2141 lPatchUINames.put(sLocale, sValue); 2142 } 2143 2144 pUINames = lFilterUINames.keySet().iterator(); 2145 while(pUINames.hasNext()) 2146 { 2147 java.lang.String sLocale = (java.lang.String)pUINames.next(); 2148 java.lang.String sValue = (java.lang.String)lFilterUINames.get(sLocale); 2149 lPatchUINames.put(sFilter+":"+sLocale, sValue); 2150 } 2151 aType.put(PROPNAME_UINAME, lPatchUINames); 2152 2153 // set generic filter service wrapper for our own native filters! 2154 // By the way: The format types of such filters can be detected by our 2155 // generic detector too. 2156 if ( 2157 (bSetDefaultDetector ) && 2158 (((java.lang.String)aFilter.get(PROPNAME_FILTERSERVICE)).length() < 1) 2159 ) 2160 { 2161 /*ME_THINKING aFilter.put(PROPNAME_FILTERSERVICE, FILTERSERVICE_NATIVEWARPPER);*/ 2162 aType.put(PROPNAME_DETECTSERVICE, GENERIC_DETECTSERVICE); 2163 } 2164 2165 // move the preferred filter information to any type 2166 // Set the filter name to the type for which the filter is registered. 2167 // If this type already have a set PreferredFilter value, check if the current filter 2168 // has the preferred flag set. If not ignore it - otherwhise overwrite the 2169 // current information at the type. But look for multiple preferred filter relations ... 2170 // means: look if more the one filter has set the preferred flag for the same type! 2171 2172 /* Attention! 2173 * 2174 * Dont remove the preferred flag from any filter! ... not here. 2175 * Otherwhise next loop can't detect ambigous preferred registrations! 2176 * Add filter to a temp. list, which can be used later to remove the preferred 2177 * flag ... 2178 */ 2179 2180 int flags1 = ((java.lang.Integer)aFilter.get(PROPNAME_FLAGS)).intValue(); 2181 java.lang.String sDocSrv = (java.lang.String)aFilter.get(PROPNAME_DOCUMENTSERVICE); 2182 if (sDocSrv.length()>0)// without a doc service its not a real filter - its a graphic filter! 2183 { 2184 boolean preferred1 = ((flags1 & FLAGVAL_PREFERRED) == FLAGVAL_PREFERRED); 2185 if (preferred1) 2186 lPreferredFilters.add(aFilter); 2187 2188 java.lang.String sAlreadyRegisteredFilter = (java.lang.String)aType.get(PROPNAME_PREFERREDFILTER); 2189 // no registration => set this filter as "any possible one"! 2190 if (sAlreadyRegisteredFilter.length() < 1) 2191 aType.put(PROPNAME_PREFERREDFILTER, sFilter); 2192 else 2193 { 2194 java.util.HashMap aAlreadyRegisteredFilter = (java.util.HashMap)m_lFilters.get(sAlreadyRegisteredFilter); 2195 int flags2 = ((java.lang.Integer)aAlreadyRegisteredFilter.get(PROPNAME_FLAGS)).intValue(); 2196 boolean preferred2 = ((flags2 & FLAGVAL_PREFERRED) == FLAGVAL_PREFERRED); 2197 2198 // two preferred filters for the same type! => error 2199 if (preferred1 && preferred2) 2200 { 2201 java.lang.StringBuffer sMsg = new java.lang.StringBuffer(256); 2202 sMsg.append("More the one preferred filter detected for the same type.\n"); 2203 sMsg.append("\ttype = \""+sTypeReg+"\"\n"); 2204 sMsg.append("\tfilter[1] = \""+sAlreadyRegisteredFilter+"\"\n"); 2205 sMsg.append("\tfilter[2] = \""+sFilter+"\"\n"); 2206 throw new java.lang.Exception(sMsg.toString()); 2207 } 2208 else 2209 // overwrite the "any possible" filter with a real preferred one 2210 if (preferred1 && !preferred2) 2211 aType.put(PROPNAME_PREFERREDFILTER, sFilter); 2212 } 2213 } 2214 2215 // create the new combined filter flag if required 2216 if (bCreateCombineFilterFlag) 2217 { 2218 if ( 2219 ((flags1 & FLAGVAL_IMPORT) == FLAGVAL_IMPORT) && 2220 ((flags1 & FLAGVAL_EXPORT) == FLAGVAL_EXPORT) 2221 ) 2222 { 2223 flags1 |= FLAGVAL_COMBINED; 2224 flags1 &= ~FLAGVAL_IMPORT ; 2225 flags1 &= ~FLAGVAL_EXPORT ; 2226 aFilter.put(PROPNAME_FLAGS, new java.lang.Integer(flags1)); 2227 } 2228 } 2229 2230 // remove some obsolete filter flags 2231 if (bRemoveFilterFlagBrowserPreferred) 2232 { 2233 flags1 &= ~FLAGVAL_BROWSERPREFERRED; 2234 aFilter.put(PROPNAME_FLAGS, new java.lang.Integer(flags1)); 2235 } 2236 2237 if (bRemoveFilterFlag3rdparty) 2238 { 2239 flags1 &= ~FLAGVAL_3RDPARTYFILTER; 2240 aFilter.put(PROPNAME_FLAGS, new java.lang.Integer(flags1)); 2241 } 2242 2243 // if its a filter with an UI order ... 2244 // move this information to the registered type. 2245 // Note: Because more then one filter can be registered for the same type. 2246 // Handle it as an error ... till we find a better transformation! 2247 java.lang.Integer nOrder = (java.lang.Integer)aFilter.get(PROPNAME_ORDER); 2248 java.lang.Integer nUIOrder = (java.lang.Integer)aType.get(PROPNAME_UIORDER); 2249 int order = nOrder.intValue(); 2250 int uiorder = nUIOrder.intValue(); 2251 2252 if (order > 0) 2253 { 2254 if ( 2255 (uiorder < 1 ) || 2256 (uiorder > order) 2257 ) 2258 { 2259 aType.put(PROPNAME_UIORDER, nOrder); 2260 m_aDebug.setDetailedInfo("moved order value "+nOrder+" from filter \""+sFilter+"\" to type \""+sTypeReg+"\""); 2261 } 2262 else 2263 m_aDebug.setDetailedInfo("ignore order value [order="+nOrder+",uiorder="+nUIOrder+"] for filter \""+sFilter+"\" and type \""+sTypeReg+"\""); 2264 } 2265 } 2266 2267 // NOW ... remove the preferred flags from every filter, which it has set. 2268 java.util.Enumeration aIt2 = null; 2269 if (bRemoveFilterFlagPreferred) 2270 { 2271 aIt2 = lPreferredFilters.elements(); 2272 while (aIt2.hasMoreElements()) 2273 { 2274 java.util.HashMap aFilter = (java.util.HashMap)aIt2.nextElement(); 2275 int flags = ((java.lang.Integer)aFilter.get(PROPNAME_FLAGS)).intValue(); 2276 flags &= ~FLAGVAL_PREFERRED; 2277 aFilter.put(PROPNAME_FLAGS, new java.lang.Integer(flags)); 2278 } 2279 } 2280 2281 // NOW ... remove all "no real filters" like the graphich helper filters of 2282 // draw and impress! 2283 aIt2 = lNoRealFilters.elements(); 2284 while (aIt2.hasMoreElements()) 2285 m_lFilters.remove(aIt2.nextElement()); 2286 2287 // step over all detect services and move this information directly to 2288 // the corresponding types 2289 // Overwrite possibel default registrations with a real existing one! 2290 aIt1 = m_lDetectServices.keySet().iterator(); 2291 while(aIt1.hasNext()) 2292 { 2293 java.lang.String sDetector = (java.lang.String)aIt1.next(); 2294 java.util.HashMap aDetector = (java.util.HashMap)m_lDetectServices.get(sDetector); 2295 java.util.Vector lTypeReg = (java.util.Vector)aDetector.get(PROPNAME_TYPES); 2296 aIt2 = lTypeReg.elements(); 2297 while(aIt2.hasMoreElements()) 2298 { 2299 java.lang.String sTypeReg = (java.lang.String)aIt2.nextElement(); 2300 java.util.HashMap aType = (java.util.HashMap)m_lTypes.get(sTypeReg); 2301 2302 if (aType == null) 2303 { 2304 m_aDebug.setWarning("Detector \""+sDetector+"\" seem to be registered for unknown type \""+sTypeReg+"\""); 2305 continue; 2306 } 2307 2308 java.lang.Object aAlreadyRegisteredDetector = aType.get(PROPNAME_DETECTSERVICE); 2309 if (aAlreadyRegisteredDetector != null && ((java.lang.String)aAlreadyRegisteredDetector).length() > 0) 2310 { 2311 java.lang.StringBuffer sMsg = new java.lang.StringBuffer(256); 2312 sMsg.append("type \""+sTypeReg+"\" has ambigous registrations of a detect service\n"); 2313 sMsg.append("\tdetect service[1] = \""+(java.lang.String)aAlreadyRegisteredDetector+"\"\n"); 2314 sMsg.append("\tdetect service[2] = \""+sDetector+"\"\n"); 2315 m_aDebug.setWarning(sMsg.toString()); 2316 } 2317 aType.put(PROPNAME_DETECTSERVICE, sDetector); 2318 m_aDebug.setGlobalInfo("move detector \""+sDetector+"\" to type \""+sTypeReg+"\""); 2319 } 2320 } 2321 2322 // because all detect service was registered as type properties directly ... 2323 // remove all detect service objects of this cache! 2324 m_lDetectServices.clear(); 2325 2326 // step over all frame loader and move this information directly to 2327 // the corresponding types 2328 // Overwrite possibel default registrations with a real existing one! 2329 aIt1 = m_lFrameLoaders.keySet().iterator(); 2330 while(aIt1.hasNext()) 2331 { 2332 java.lang.String sLoader = (java.lang.String)aIt1.next(); 2333 java.util.HashMap aLoader = (java.util.HashMap)m_lFrameLoaders.get(sLoader); 2334 java.util.Vector lTypeReg = (java.util.Vector)aLoader.get(PROPNAME_TYPES); 2335 aIt2 = lTypeReg.elements(); 2336 while(aIt2.hasMoreElements()) 2337 { 2338 java.lang.String sTypeReg = (java.lang.String)aIt2.nextElement(); 2339 java.util.HashMap aType = (java.util.HashMap)m_lTypes.get(sTypeReg); 2340 java.lang.String sAlreadyRegisteredLoader = (java.lang.String)aType.get(PROPNAME_FRAMELOADER); 2341 if (sAlreadyRegisteredLoader != null && sAlreadyRegisteredLoader.length() > 0) 2342 { 2343 java.lang.StringBuffer sMsg = new java.lang.StringBuffer(256); 2344 sMsg.append("type \""+sTypeReg+"\" has ambigous registrations of a frame loader\n"); 2345 sMsg.append("\tframe loader[1] = \""+sAlreadyRegisteredLoader+"\"\n"); 2346 sMsg.append("\tframe loader[2] = \""+sLoader+"\"\n"); 2347 m_aDebug.setWarning(sMsg.toString()); 2348 } 2349 aType.put(PROPNAME_FRAMELOADER, sLoader); 2350 System.out.println("move loader \""+sLoader+"\" to type \""+sTypeReg+"\""); 2351 } 2352 } 2353 2354 m_lFrameLoaders.clear(); 2355 2356 // step over all content handler and move this information directly to 2357 // the corresponding types 2358 // Overwrite possibel default registrations with a real existing one! 2359 aIt1 = m_lContentHandlers.keySet().iterator(); 2360 while(aIt1.hasNext()) 2361 { 2362 java.lang.String sHandler = (java.lang.String)aIt1.next(); 2363 java.util.HashMap aHandler = (java.util.HashMap)m_lContentHandlers.get(sHandler); 2364 java.util.Vector lTypeReg = (java.util.Vector)aHandler.get(PROPNAME_TYPES); 2365 aIt2 = lTypeReg.elements(); 2366 while(aIt2.hasMoreElements()) 2367 { 2368 java.lang.String sTypeReg = (java.lang.String)aIt2.nextElement(); 2369 java.util.HashMap aType = (java.util.HashMap)m_lTypes.get(sTypeReg); 2370 java.lang.String sAlreadyRegisteredHandler = (java.lang.String)aType.get(PROPNAME_CONTENTHANDLER); 2371 if (sAlreadyRegisteredHandler != null && sAlreadyRegisteredHandler.length() > 0) 2372 { 2373 java.lang.StringBuffer sMsg = new java.lang.StringBuffer(256); 2374 sMsg.append("type \""+sTypeReg+"\" has ambigous registrations of a content handler\n"); 2375 sMsg.append("\tcontent handler[1] = \""+sAlreadyRegisteredHandler+"\"\n"); 2376 sMsg.append("\tcontent handler[2] = \""+sHandler+"\"\n"); 2377 m_aDebug.setWarning(sMsg.toString()); 2378 } 2379 aType.put(PROPNAME_CONTENTHANDLER, sHandler); 2380 System.out.println("move handler \""+sHandler+"\" to type \""+sTypeReg+"\""); 2381 } 2382 } 2383 2384 m_lContentHandlers.clear(); 2385 2386 /* 2387 int c = m_lTypes.size(); 2388 java.lang.String[] lT1 = new java.lang.String[c]; 2389 java.lang.String[] lT2 = new java.lang.String[c]; 2390 long nUPS = 0; 2391 2392 int i = 0; 2393 aIt1 = m_lTypes.keySet().iterator(); 2394 while(aIt1.hasNext()) 2395 { 2396 lT1[i] = (java.lang.String)aIt1.next(); 2397 lT2[i] = lT1[i]; 2398 ++i; 2399 } 2400 2401 for (int i1=0; i1<c; ++i1) 2402 { 2403 java.lang.String sT1 = lT1[i1]; 2404 java.util.HashMap aT1 = (java.util.HashMap)m_lTypes.get(sT1); 2405 2406 for (int i2=i1; i2<c; ++i2) 2407 { 2408 java.lang.String sT2 = lT1[i2]; 2409 java.util.HashMap aT2 = (java.util.HashMap)m_lTypes.get(sT2); 2410 2411 if (!sT1.equals(sT2)) 2412 { 2413 if ( 2414 aT1.get(PROPNAME_MEDIATYPE).equals(aT2.get(PROPNAME_MEDIATYPE)) && 2415 aT1.get(PROPNAME_CLIPBOARDFORMAT).equals(aT2.get(PROPNAME_CLIPBOARDFORMAT)) && 2416 aT1.get(PROPNAME_URLPATTERN).equals(aT2.get(PROPNAME_URLPATTERN)) && 2417 aT1.get(PROPNAME_EXTENSIONS).equals(aT2.get(PROPNAME_EXTENSIONS)) 2418 ) 2419 { 2420 System.err.println("UUPPSS----------------------------------------------------------------------------"); 2421 System.err.println("[1]\""+sT1+"\" equals [2]\""+sT2+"\""); 2422 System.err.println("\tprops 1: "+aT1); 2423 System.err.println("\tprops 2: "+aT2); 2424 System.err.println("----------------------------------------------------------------------------------\n"); 2425 ++nUPS; 2426 // throw new java.lang.Exception("UUPPS :-)"); 2427 } 2428 } 2429 } 2430 } 2431 System.err.println("count of UPS = "+nUPS); 2432 */ 2433 } 2434 } 2435