Index: core/windows/src/org/netbeans/core/windows/persistence/GroupParser.java =================================================================== RCS file: /cvs/core/windows/src/org/netbeans/core/windows/persistence/GroupParser.java,v retrieving revision 1.13 diff -u -r1.13 GroupParser.java --- core/windows/src/org/netbeans/core/windows/persistence/GroupParser.java 2 Nov 2004 15:32:29 -0000 1.13 +++ core/windows/src/org/netbeans/core/windows/persistence/GroupParser.java 19 Nov 2004 11:03:06 -0000 @@ -36,7 +36,7 @@ class GroupParser { - private static final String INSTANCE_DTD_ID_2_0 + public static final String INSTANCE_DTD_ID_2_0 = "-//NetBeans//DTD Group Properties 2.0//EN"; // NOI18N private static final boolean DEBUG = Debug.isLoggable(GroupParser.class); @@ -394,9 +394,6 @@ /** Internal configuration data */ private InternalConfig internalConfig = null; - /** xml parser */ - private XMLReader parser; - /** Lock to prevent mixing readData and writeData */ private final Object RW_LOCK = new Object(); @@ -466,7 +463,7 @@ if (DEBUG) Debug.log(GroupParser.class, s);*/ //DUMP END - getXMLParser().parse(new InputSource(cfgFOInput.getInputStream())); + PersistenceManager.getDefault().getXMLParser(this).parse(new InputSource(cfgFOInput.getInputStream())); } } catch (SAXException exc) { //Turn into annotated IOException @@ -506,14 +503,6 @@ throw ex; } - public void fatalError(SAXParseException ex) throws SAXException { - throw ex; - } - - public void warning(SAXParseException ex) throws SAXException { - // ignore - } - /** Reads element "group" */ private void handleGroup (Attributes attrs) { String version = attrs.getValue("version"); // NOI18N @@ -606,41 +595,6 @@ } } - public void endDocument() throws SAXException { - } - - public void ignorableWhitespace(char[] values, int param, int param2) - throws SAXException { - } - - public void endElement(String str, String str1, String str2) - throws SAXException { - } - - public void skippedEntity(String str) throws SAXException { - } - - public void processingInstruction(String str, String str1) - throws SAXException { - } - - public void endPrefixMapping(String str) throws SAXException { - } - - public void startPrefixMapping(String str, String str1) - throws SAXException { - } - - public void characters(char[] values, int param, int param2) - throws SAXException { - } - - public void setDocumentLocator(org.xml.sax.Locator locator) { - } - - public void startDocument() throws SAXException { - } - /** Writes data from asociated group to the xml representation */ void writeData (GroupConfig sc, InternalConfig ic) throws IOException { final StringBuffer buff = fillBuffer(sc, ic); @@ -721,20 +675,6 @@ buff.append(" />\n"); // NOI18N } - /** @return Newly created parser with group content handler, errror handler - * and entity resolver - */ - private XMLReader getXMLParser () throws SAXException { - if (parser == null) { - // get non validating, not namespace aware parser - parser = XMLUtil.createXMLReader(); - parser.setContentHandler(this); - parser.setErrorHandler(this); - parser.setEntityResolver(this); - } - return parser; - } - /** Implementation of entity resolver. Points to the local DTD * for our public ID */ public InputSource resolveEntity (String publicId, String systemId) Index: core/windows/src/org/netbeans/core/windows/persistence/ModeParser.java =================================================================== RCS file: /cvs/core/windows/src/org/netbeans/core/windows/persistence/ModeParser.java,v retrieving revision 1.18 diff -u -r1.18 ModeParser.java --- core/windows/src/org/netbeans/core/windows/persistence/ModeParser.java 16 Nov 2004 15:17:16 -0000 1.18 +++ core/windows/src/org/netbeans/core/windows/persistence/ModeParser.java 19 Nov 2004 11:03:06 -0000 @@ -25,7 +25,6 @@ import org.openide.util.NbBundle; import org.openide.util.TopologicalSortException; import org.openide.util.Utilities; -import org.openide.xml.XMLUtil; import org.xml.sax.*; import org.xml.sax.helpers.DefaultHandler; @@ -43,15 +42,15 @@ class ModeParser { - private static final String INSTANCE_DTD_ID_1_0 + public static final String INSTANCE_DTD_ID_1_0 = "-//NetBeans//DTD Mode Properties 1.0//EN"; // NOI18N - private static final String INSTANCE_DTD_ID_1_1 + public static final String INSTANCE_DTD_ID_1_1 = "-//NetBeans//DTD Mode Properties 1.1//EN"; // NOI18N - private static final String INSTANCE_DTD_ID_1_2 + public static final String INSTANCE_DTD_ID_1_2 = "-//NetBeans//DTD Mode Properties 1.2//EN"; // NOI18N - private static final String INSTANCE_DTD_ID_2_0 + public static final String INSTANCE_DTD_ID_2_0 = "-//NetBeans//DTD Mode Properties 2.0//EN"; // NOI18N - private static final String INSTANCE_DTD_ID_2_1 + public static final String INSTANCE_DTD_ID_2_1 = "-//NetBeans//DTD Mode Properties 2.1//EN"; // NOI18N /** Name of extended attribute for order of children */ @@ -919,9 +918,6 @@ /** List to store parsed path items */ private List itemList = new ArrayList(10); - /** xml parser */ - private XMLReader parser; - /** Lock to prevent mixing readData and writeData */ private final Object RW_LOCK = new Object(); @@ -993,7 +989,7 @@ }*/ //DUMP END - getXMLParser().parse(new InputSource(cfgFOInput.getInputStream())); + PersistenceManager.getDefault().getXMLParser(this).parse(new InputSource(cfgFOInput.getInputStream())); } } catch (SAXException exc) { //Turn into annotated IOException @@ -1057,14 +1053,6 @@ throw ex; } - public void fatalError(SAXParseException ex) throws SAXException { - throw ex; - } - - public void warning(SAXParseException ex) throws SAXException { - // ignore - } - /** Reads element "mode" */ private void handleMode (Attributes attrs) { String version = attrs.getValue("version"); // NOI18N @@ -1428,43 +1416,6 @@ } } - public void endDocument() throws org.xml.sax.SAXException { - } - - public void ignorableWhitespace(char[] values, int param, int param2) - throws org.xml.sax.SAXException { - } - - public void endElement(java.lang.String str, java.lang.String str1, java.lang.String str2) - throws org.xml.sax.SAXException { - } - - public void skippedEntity(java.lang.String str) - throws org.xml.sax.SAXException { - } - - public void processingInstruction(java.lang.String str, java.lang.String str1) - throws org.xml.sax.SAXException { - } - - public void endPrefixMapping(java.lang.String str) - throws org.xml.sax.SAXException { - } - - public void startPrefixMapping(java.lang.String str, java.lang.String str1) - throws org.xml.sax.SAXException { - } - - public void characters(char[] values, int param, int param2) - throws org.xml.sax.SAXException { - } - - public void setDocumentLocator(org.xml.sax.Locator locator) { - } - - public void startDocument() throws org.xml.sax.SAXException { - } - /** Writes data from asociated mode to the xml representation */ void writeData (ModeConfig mc, InternalConfig ic) throws IOException { final StringBuffer buff = fillBuffer(mc, ic); @@ -1624,38 +1575,6 @@ buff.append(" \n"); // NOI18N } - /** @return Newly created parser with set content handler, errror handler - * and entity resolver - */ - private XMLReader getXMLParser () throws SAXException { - if (parser == null) { - // get non validating, not namespace aware parser - parser = XMLUtil.createXMLReader(); - parser.setContentHandler(this); - parser.setErrorHandler(this); - parser.setEntityResolver(this); - } - return parser; - } - - /** Implementation of entity resolver. Points to the local DTD - * for our public ID */ - public InputSource resolveEntity (String publicId, String systemId) - throws SAXException { - if (INSTANCE_DTD_ID_1_0.equals(publicId) - || INSTANCE_DTD_ID_1_1.equals(publicId) - || INSTANCE_DTD_ID_1_2.equals(publicId) - || INSTANCE_DTD_ID_2_0.equals(publicId) - || INSTANCE_DTD_ID_2_1.equals(publicId)) { - InputStream is = new ByteArrayInputStream(new byte[0]); - //getClass().getResourceAsStream(INSTANCE_DTD_LOCAL); -// if (is == null) { -// throw new IllegalStateException ("Entity cannot be resolved."); // NOI18N -// } - return new InputSource(is); - } - return null; // i.e. follow advice of systemID - } } } Index: core/windows/src/org/netbeans/core/windows/persistence/PersistenceManager.java =================================================================== RCS file: /cvs/core/windows/src/org/netbeans/core/windows/persistence/PersistenceManager.java,v retrieving revision 1.26 diff -u -r1.26 PersistenceManager.java --- core/windows/src/org/netbeans/core/windows/persistence/PersistenceManager.java 20 Oct 2004 15:06:04 -0000 1.26 +++ core/windows/src/org/netbeans/core/windows/persistence/PersistenceManager.java 19 Nov 2004 11:03:07 -0000 @@ -13,10 +13,7 @@ package org.netbeans.core.windows.persistence; -import org.netbeans.core.windows.Constants; import org.netbeans.core.windows.Debug; -import org.netbeans.core.windows.RegistryImpl; -import org.netbeans.core.windows.WindowManagerImpl; import org.openide.ErrorManager; import org.openide.cookies.InstanceCookie; import org.openide.cookies.SaveCookie; @@ -36,12 +33,20 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.io.ByteArrayInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.io.InvalidObjectException; import java.io.NotSerializableException; import java.lang.ref.WeakReference; import java.util.*; +import org.openide.xml.XMLUtil; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; /** Manages persistent data of window system, currently stored in XML format. @@ -132,8 +137,8 @@ /** Lock for synchronizing access to IDs. */ private final Object LOCK_IDS = new Object(); - /** true if we are saving just now, false otherwise */ - private boolean isSaveInProgress; + /** xml parser */ + private XMLReader parser; private static PersistenceManager defaultInstance; @@ -533,14 +538,6 @@ } } - /** Destroys settings files of component with given string ID. */ - private void deleteTopComponentFile(String stringId) throws IOException { - DataObject dob = findTopComponentDataObject(getComponentsLocalFolder(), stringId); - if(dob != null) { - dob.delete(); - } - } - /** Try to find the data object representing a top component ref in some folder. * Only the TC name is known, but we can guess at some likely filenames before * doing an exhaustive search. Produces either a FileObject or DataObject, @@ -810,69 +807,6 @@ return srcName; } - /** Called during projects switch BEFORE new project is loaded and AFTER - * project layer is switched. */ - public void resetAfterLayerSwitch() { - resetAllTCPairs(); - resetWindowManagerParser(); - copySettingsFiles(); - restoreAllTCPairs(); - } - - /** Must be called during Project switch */ - private void resetAllTCPairs () { - synchronized(LOCK_IDS) { - invalidIds = new HashSet(topComponent2IDMap.values()); - /*System.out.println("-- PM.resetAllTCPairs ENTER"); - for (Iterator it = invalidIds.iterator(); it.hasNext(); ) { - System.out.println("-- item:" + it.next()); - }*/ - - id2TopComponentMap.clear(); - } - } - - /** Must be called during Project switch */ - private void restoreAllTCPairs () { - synchronized(LOCK_IDS) { - //System.out.println("-- PM.restoreAllTCPairs ENTER"); - - for (Iterator it = topComponent2IDMap.keySet().iterator(); it.hasNext(); ) { - TopComponent tc = (TopComponent) it.next(); - String id = (String) topComponent2IDMap.get(tc); - //System.out.println("-- PM.restoreAllTCPairs id:" + id); - if (isInvalidId(id)) { - restorePair(tc, id); - } - } - - /*for (Iterator it = id2TopComponentMap.keySet().iterator(); it.hasNext(); ) { - System.out.println("-- item:" + it.next()); - }*/ - - Set toRemove = new HashSet(); - for (Iterator it = topComponent2IDMap.keySet().iterator(); it.hasNext(); ) { - TopComponent tc = (TopComponent) it.next(); - String id = (String) topComponent2IDMap.get(tc); - if (!id2TopComponentMap.containsKey(id)) { - //System.out.println("-- PM.restoreAllTCPairs REMOVE tc:" + tc.getName()); - toRemove.add(tc); - } /*else { - System.out.println("-- PM.restoreAllTCPairs KEEP tc:" + tc.getName()); - }*/ - } - - for (Iterator it = toRemove.iterator(); it.hasNext(); ) { - topComponent2IDMap.remove(it.next()); - } - - /*System.out.println("-- PM.restoreAllTCPairs topComponent2IDMap.size:" - + topComponent2IDMap.size()); - System.out.println("-- PM.restoreAllTCPairs id2TopComponentMap.size:" - + id2TopComponentMap.size());*/ - } - } - /** Reuses existing settings files */ private String restorePair (TopComponent tc, String id) { //System.out.println("++ PM.restorePair ENTER" @@ -941,17 +875,6 @@ failedCompsMap = null; } - private void setSaveInProgress (boolean isSaveInProgress) { - this.isSaveInProgress = isSaveInProgress; - } // TEMP - - /** @return true if saving of window system is currently being processed, - * false otherwise. Used to disallow interferation of parsing and saving. - */ - boolean isSaveInProgress () { - return isSaveInProgress; - } // TEMP - /** Accessor to WindowManagerParser instance. */ public WindowManagerParser getWindowManagerParser () { if (windowManagerParser == null) { @@ -960,9 +883,45 @@ return windowManagerParser; } - /** Reset WindowManagerParser instance. Called during project switch. */ - private void resetWindowManagerParser() { - windowManagerParser = null; + /** Returns a XML parser. The same parser can be returned assuming that config files + * are parser sequentially. + * + * @return XML parser with set content handler, errror handler + * and entity resolver. + */ + public XMLReader getXMLParser (DefaultHandler h) throws SAXException { + if (parser == null) { + // get non validating, not namespace aware parser + parser = XMLUtil.createXMLReader(); + parser.setEntityResolver(new EntityResolver () { + /** Implementation of entity resolver. Points to the local DTD + * for our public ID */ + public InputSource resolveEntity (String publicId, String systemId) + throws SAXException { + if (ModeParser.INSTANCE_DTD_ID_1_0.equals(publicId) + || ModeParser.INSTANCE_DTD_ID_1_1.equals(publicId) + || ModeParser.INSTANCE_DTD_ID_1_2.equals(publicId) + || ModeParser.INSTANCE_DTD_ID_2_0.equals(publicId) + || ModeParser.INSTANCE_DTD_ID_2_1.equals(publicId) + || GroupParser.INSTANCE_DTD_ID_2_0.equals(publicId) + || TCGroupParser.INSTANCE_DTD_ID_2_0.equals(publicId) + || TCRefParser.INSTANCE_DTD_ID_1_0.equals(publicId) + || TCRefParser.INSTANCE_DTD_ID_2_0.equals(publicId) + || TCRefParser.INSTANCE_DTD_ID_2_1.equals(publicId) + || WindowManagerParser.INSTANCE_DTD_ID_1_0.equals(publicId) + || WindowManagerParser.INSTANCE_DTD_ID_1_1.equals(publicId) + || WindowManagerParser.INSTANCE_DTD_ID_2_0.equals(publicId) + || WindowManagerParser.INSTANCE_DTD_ID_2_1.equals(publicId)) { + InputStream is = new ByteArrayInputStream(new byte[0]); + return new InputSource(is); + } + return null; // i.e. follow advice of systemID + } + }); + } + parser.setContentHandler(h); + parser.setErrorHandler(h); + return parser; } /** Adds TopComponent Id to set of used Ids. Called from ModeParser and @@ -1024,7 +983,7 @@ * @return window system configuration */ public WindowManagerConfig loadWindowSystem() { - //long start = System.currentTimeMillis(); +// long start = System.currentTimeMillis(); //Clear set of used tc_id synchronized (LOCK_IDS) { @@ -1050,9 +1009,11 @@ changeHandler = new ModuleChangeHandler(); changeHandler.startHandling(); } - //long end = System.currentTimeMillis(); - //long diff = end - start; - //System.out.println("Loading of window system takes " + diff + " ms"); + parser = null; // clear the ref to XML parser + +// long end = System.currentTimeMillis(); +// long diff = end - start; +// System.out.println("Loading of window system takes " + diff + " ms"); return wmc; } @@ -1245,7 +1206,6 @@ Lookup.getDefault().lookup(new Lookup.Template(ModuleInfo.class)); Collection infos = modulesResult.allInstances(); ModuleInfo curInfo = null; - boolean equalsName = false; for (Iterator iter = infos.iterator(); iter.hasNext(); ) { curInfo = (ModuleInfo)iter.next(); // search for equal base name and then compare release and Index: core/windows/src/org/netbeans/core/windows/persistence/TCGroupParser.java =================================================================== RCS file: /cvs/core/windows/src/org/netbeans/core/windows/persistence/TCGroupParser.java,v retrieving revision 1.9 diff -u -r1.9 TCGroupParser.java --- core/windows/src/org/netbeans/core/windows/persistence/TCGroupParser.java 28 Jul 2004 09:40:04 -0000 1.9 +++ core/windows/src/org/netbeans/core/windows/persistence/TCGroupParser.java 19 Nov 2004 11:03:07 -0000 @@ -131,9 +131,6 @@ /** internal configuration data */ private InternalConfig internalConfig = null; - /** xml parser */ - private XMLReader parser; - /** Lock to prevent mixing readData and writeData */ private final Object RW_LOCK = new Object(); @@ -202,7 +199,7 @@ log(s);*/ //DUMP END - getXMLParser().parse(new InputSource(cfgFOInput.getInputStream())); + PersistenceManager.getDefault().getXMLParser(this).parse(new InputSource(cfgFOInput.getInputStream())); } } catch (SAXException exc) { //Turn into annotated IOException @@ -243,14 +240,6 @@ throw ex; } - public void fatalError(SAXParseException ex) throws SAXException { - throw ex; - } - - public void warning(SAXParseException ex) throws SAXException { - // ignore - } - /** Reads element "tc-group" */ private void handleTCGroup (Attributes attrs) { String version = attrs.getValue("version"); // NOI18N @@ -383,41 +372,6 @@ } } - public void endDocument() throws SAXException { - } - - public void ignorableWhitespace(char[] values, int param, int param2) - throws SAXException { - } - - public void endElement(String str, String str1, String str2) - throws SAXException { - } - - public void skippedEntity(String str) throws SAXException { - } - - public void processingInstruction(String str, String str1) - throws SAXException { - } - - public void endPrefixMapping(String str) throws SAXException { - } - - public void startPrefixMapping(String str, String str1) - throws SAXException { - } - - public void characters(char[] values, int param, int param2) - throws SAXException { - } - - public void setDocumentLocator(org.xml.sax.Locator locator) { - } - - public void startDocument() throws SAXException { - } - /** Writes data from asociated tcRef to the xml representation */ void writeData (TCGroupConfig tcGroupCfg, InternalConfig ic) throws IOException { final StringBuffer buff = fillBuffer(tcGroupCfg, ic); @@ -488,34 +442,6 @@ append("\" was-opened=\"").append(tcGroupCfg.wasOpened).append("\"/>\n"); // NOI18N } - /** @return Newly created parser with grou content handler, errror handler - * and entity resolver - */ - private XMLReader getXMLParser () throws SAXException { - if (parser == null) { - // get non validating, not namespace aware parser - parser = XMLUtil.createXMLReader(); - parser.setContentHandler(this); - parser.setErrorHandler(this); - parser.setEntityResolver(this); - } - return parser; - } - - /** Implementation of entity resolver. Points to the local DTD - * for our public ID */ - public InputSource resolveEntity (String publicId, String systemId) - throws SAXException { - if (INSTANCE_DTD_ID_2_0.equals(publicId)) { - InputStream is = new ByteArrayInputStream(new byte[0]); - //getClass().getResourceAsStream(INSTANCE_DTD_LOCAL); -// if (is == null) { -// throw new IllegalStateException ("Entity cannot be resolved."); // NOI18N -// } - return new InputSource(is); - } - return null; // i.e. follow advice of systemID - } } } Index: core/windows/src/org/netbeans/core/windows/persistence/TCRefParser.java =================================================================== RCS file: /cvs/core/windows/src/org/netbeans/core/windows/persistence/TCRefParser.java,v retrieving revision 1.10 diff -u -r1.10 TCRefParser.java --- core/windows/src/org/netbeans/core/windows/persistence/TCRefParser.java 28 Jul 2004 09:40:04 -0000 1.10 +++ core/windows/src/org/netbeans/core/windows/persistence/TCRefParser.java 19 Nov 2004 11:03:07 -0000 @@ -142,9 +142,6 @@ /** internal configuration data */ private InternalConfig internalConfig = null; - /** xml parser */ - private XMLReader parser; - /** Lock to prevent mixing readData and writeData */ private final Object RW_LOCK = new Object(); @@ -212,7 +209,7 @@ log(s);*/ //DUMP END - getXMLParser().parse(new InputSource(cfgFOInput.getInputStream())); + PersistenceManager.getDefault().getXMLParser(this).parse(new InputSource(cfgFOInput.getInputStream())); } } catch (SAXException exc) { //Turn into annotated IOException @@ -255,14 +252,6 @@ throw ex; } - public void fatalError(SAXParseException ex) throws SAXException { - throw ex; - } - - public void warning(SAXParseException ex) throws SAXException { - // ignore - } - /** Reads element "tc-ref" */ private void handleTCRef (Attributes attrs) { String version = attrs.getValue("version"); // NOI18N @@ -381,41 +370,6 @@ } } - - public void endDocument() throws SAXException { - } - - public void ignorableWhitespace(char[] values, int param, int param2) - throws SAXException { - } - - public void endElement(String str, String str1, String str2) - throws SAXException { - } - - public void skippedEntity(String str) throws SAXException { - } - - public void processingInstruction(String str, String str1) - throws SAXException { - } - - public void endPrefixMapping(String str) throws SAXException { - } - - public void startPrefixMapping(String str, String str1) throws SAXException { - } - - public void characters(char[] values, int param, int param2) - throws SAXException { - } - - public void setDocumentLocator(org.xml.sax.Locator locator) { - } - - public void startDocument() throws SAXException { - } - /** Writes data from asociated tcRef to the xml representation */ void writeData (TCRefConfig tcRefCfg, InternalConfig ic) throws IOException { final StringBuffer buff = fillBuffer(tcRefCfg, ic); @@ -506,36 +460,6 @@ buff.append("\" />\n"); // NOI18N } - /** @return Newly created parser with set content handler, errror handler - * and entity resolver - */ - private XMLReader getXMLParser () throws SAXException { - if (parser == null) { - // get non validating, not namespace aware parser - parser = XMLUtil.createXMLReader(); - parser.setContentHandler(this); - parser.setErrorHandler(this); - parser.setEntityResolver(this); - } - return parser; - } - - /** Implementation of entity resolver. Points to the local DTD - * for our public ID */ - public InputSource resolveEntity (String publicId, String systemId) - throws SAXException { - if (INSTANCE_DTD_ID_1_0.equals(publicId) - || INSTANCE_DTD_ID_2_0.equals(publicId) - || INSTANCE_DTD_ID_2_1.equals(publicId)) { - InputStream is = new ByteArrayInputStream(new byte[0]); - //getClass().getResourceAsStream(INSTANCE_DTD_LOCAL); -// if (is == null) { -// throw new IllegalStateException ("Entity cannot be resolved."); // NOI18N -// } - return new InputSource(is); - } - return null; // i.e. follow advice of systemID - } } } Index: core/windows/src/org/netbeans/core/windows/persistence/WindowManagerParser.java =================================================================== RCS file: /cvs/core/windows/src/org/netbeans/core/windows/persistence/WindowManagerParser.java,v retrieving revision 1.17 diff -u -r1.17 WindowManagerParser.java --- core/windows/src/org/netbeans/core/windows/persistence/WindowManagerParser.java 2 Nov 2004 15:32:29 -0000 1.17 +++ core/windows/src/org/netbeans/core/windows/persistence/WindowManagerParser.java 19 Nov 2004 11:03:08 -0000 @@ -40,13 +40,13 @@ public class WindowManagerParser { - private static final String INSTANCE_DTD_ID_1_0 + public static final String INSTANCE_DTD_ID_1_0 = "-//NetBeans//DTD Window Manager Properties 1.0//EN"; // NOI18N - private static final String INSTANCE_DTD_ID_1_1 + public static final String INSTANCE_DTD_ID_1_1 = "-//NetBeans//DTD Window Manager Properties 1.1//EN"; // NOI18N - private static final String INSTANCE_DTD_ID_2_0 + public static final String INSTANCE_DTD_ID_2_0 = "-//NetBeans//DTD Window Manager Properties 2.0//EN"; // NOI18N - private static final String INSTANCE_DTD_ID_2_1 + public static final String INSTANCE_DTD_ID_2_1 = "-//NetBeans//DTD Window Manager Properties 2.1//EN"; // NOI18N private static final boolean DEBUG = Debug.isLoggable(WindowManagerParser.class); @@ -733,9 +733,6 @@ /** List to store parsed tc-ids */ private List tcIdList = new ArrayList(10); - /** xml parser */ - private XMLReader parser; - /** Lock to prevent mixing readData and writeData */ private final Object RW_LOCK = new Object(); @@ -820,7 +817,7 @@ if (DEBUG) Debug.log(WindowManagerParser.class, s);*/ //DUMP END // long time = System.currentTimeMillis(); - getXMLParser().parse(new InputSource(cfgFOInput.getInputStream())); + PersistenceManager.getDefault().getXMLParser(this).parse(new InputSource(cfgFOInput.getInputStream())); // System.out.println("WindowManagerParser.readData "+(System.currentTimeMillis()-time)); } } catch (SAXException exc) { @@ -887,14 +884,6 @@ throw ex; } - public void fatalError(SAXParseException ex) throws SAXException { - throw ex; - } - - public void warning(SAXParseException ex) throws SAXException { - // ignore - } - /** Reads element "windowmanager" */ private void handleWindowManager (Attributes attrs) { String version = attrs.getValue("version"); // NOI18N @@ -1709,36 +1698,6 @@ } } - public void endDocument() throws org.xml.sax.SAXException { - } - - public void ignorableWhitespace(char[] values, int param, int param2) throws org.xml.sax.SAXException { - } - - public void endElement(java.lang.String str, java.lang.String str1, java.lang.String str2) throws org.xml.sax.SAXException { - } - - public void skippedEntity(java.lang.String str) throws org.xml.sax.SAXException { - } - - public void processingInstruction(java.lang.String str, java.lang.String str1) throws org.xml.sax.SAXException { - } - - public void endPrefixMapping(java.lang.String str) throws org.xml.sax.SAXException { - } - - public void startPrefixMapping(java.lang.String str, java.lang.String str1) throws org.xml.sax.SAXException { - } - - public void characters(char[] values, int param, int param2) throws org.xml.sax.SAXException { - } - - public void setDocumentLocator(org.xml.sax.Locator locator) { - } - - public void startDocument() throws SAXException { - } - /** Writes data from asociated window manager to the xml representation */ void writeData (WindowManagerConfig wmc) throws IOException { final StringBuffer buff = fillBuffer(wmc); @@ -1893,37 +1852,6 @@ buff.append(" \n"); // NOI18N } - /** @return Newly created parser with set content handler, errror handler - * and entity resolver - */ - private XMLReader getXMLParser () throws SAXException { - if (parser == null) { - // get non validating, not namespace aware parser - parser = XMLUtil.createXMLReader(); - parser.setContentHandler(this); - parser.setErrorHandler(this); - parser.setEntityResolver(this); - } - return parser; - } - - /** Implementation of entity resolver. Points to the local DTD - * for our public ID */ - public InputSource resolveEntity (String publicId, String systemId) - throws SAXException { - if (INSTANCE_DTD_ID_1_0.equals(publicId) - || INSTANCE_DTD_ID_1_1.equals(publicId) - || INSTANCE_DTD_ID_2_0.equals(publicId) - || INSTANCE_DTD_ID_2_1.equals(publicId)) { - InputStream is = new ByteArrayInputStream(new byte[0]); - //getClass().getResourceAsStream(INSTANCE_DTD_LOCAL); -// if (is == null) { -// throw new IllegalStateException ("Entity cannot be resolved."); // NOI18N -// } - return new InputSource(is); - } - return null; // i.e. follow advice of systemID - } } /** Float.parseFloat() shows up as a startup hotspot (classloading?), so this uses a