Source Code Cross Referenced for JEditRegisterSaver.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » jEdit » org.gjt.sp.jedit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * :tabSize=8:indentSize=8:noTabs=false:
003:         * :folding=explicit:collapseFolds=1:
004:         *
005:         * Copyright (C) 2006 Matthieu Casanova
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         */
021:        package org.gjt.sp.jedit;
022:
023:        import org.gjt.sp.util.Log;
024:        import org.gjt.sp.util.XMLUtilities;
025:        import org.gjt.sp.util.IOUtilities;
026:        import org.xml.sax.helpers.DefaultHandler;
027:        import org.xml.sax.InputSource;
028:        import org.xml.sax.Attributes;
029:
030:        import java.io.IOException;
031:
032:        /**
033:         * The concrete RegisterSaver for jEdit.
034:         * @author Matthieu Casanova
035:         * @version $Id: FoldHandler.java 5568 2006-07-10 20:52:23Z kpouer $
036:         */
037:        class JEditRegisterSaver implements  RegisterSaver {
038:            //{{{ Constructor
039:            public JEditRegisterSaver() {
040:                String settingsDirectory = jEdit.getSettingsDirectory();
041:                if (settingsDirectory != null) {
042:                    registersXML = new SettingsXML(settingsDirectory,
043:                            "registers");
044:                }
045:            } //}}}
046:
047:            //{{{ loadRegisters() method
048:            public void loadRegisters() {
049:                if (registersXML == null)
050:                    return;
051:
052:                if (!registersXML.fileExists())
053:                    return;
054:
055:                Log.log(Log.MESSAGE, jEdit.class, "Loading " + registersXML);
056:
057:                RegistersHandler handler = new RegistersHandler();
058:                try {
059:                    Registers.setLoading(true);
060:                    registersXML.load(handler);
061:                } catch (IOException ioe) {
062:                    Log.log(Log.ERROR, Registers.class, ioe);
063:                } finally {
064:                    Registers.setLoading(false);
065:                }
066:            } //}}}
067:
068:            //{{{ saveRegisters() method
069:            public void saveRegisters() {
070:                if (registersXML == null)
071:                    return;
072:
073:                if (registersXML.hasChangedOnDisk()) {
074:                    Log.log(Log.WARNING, Registers.class, registersXML
075:                            + " changed on disk; will not save registers");
076:                    return;
077:                }
078:
079:                Log.log(Log.MESSAGE, Registers.class, "Saving " + registersXML);
080:
081:                String lineSep = System.getProperty("line.separator");
082:
083:                SettingsXML.Saver out = null;
084:
085:                try {
086:                    out = registersXML.openSaver();
087:                    out.writeXMLDeclaration();
088:
089:                    out.write("<!DOCTYPE REGISTERS SYSTEM \"registers.dtd\">");
090:                    out.write(lineSep);
091:                    out.write("<REGISTERS>");
092:                    out.write(lineSep);
093:
094:                    Registers.Register[] registers = Registers.getRegisters();
095:                    for (int i = 0; i < registers.length; i++) {
096:                        Registers.Register register = registers[i];
097:                        if (register == null || i == '$' || i == '%'
098:                                || register.toString().length() == 0)
099:                            continue;
100:
101:                        out.write("<REGISTER NAME=\"");
102:                        if (i == '"')
103:                            out.write("&quot;");
104:                        else
105:                            out.write((char) i);
106:                        out.write("\">");
107:
108:                        out.write(XMLUtilities.charsToEntities(register
109:                                .toString(), false));
110:
111:                        out.write("</REGISTER>");
112:                        out.write(lineSep);
113:                    }
114:
115:                    out.write("</REGISTERS>");
116:                    out.write(lineSep);
117:
118:                    out.finish();
119:                } catch (Exception e) {
120:                    Log.log(Log.ERROR, Registers.class, e);
121:                } finally {
122:                    IOUtilities.closeQuietly(out);
123:                }
124:            } //}}}
125:
126:            //{{{ Private members
127:            private SettingsXML registersXML;
128:
129:            //{{{ RegistersHandler class
130:            private static class RegistersHandler extends DefaultHandler {
131:                //{{{ resolveEntity() method
132:                public InputSource resolveEntity(String publicId,
133:                        String systemId) {
134:                    return XMLUtilities.findEntity(systemId, "registers.dtd",
135:                            getClass());
136:                } //}}}
137:
138:                //{{{ startElement() method
139:                public void startElement(String uri, String localName,
140:                        String qName, Attributes attrs) {
141:                    registerName = attrs.getValue("NAME");
142:                    inRegister = "REGISTER".equals(qName);
143:                } //}}}
144:
145:                //{{{ endElement() method
146:                public void endElement(String uri, String localName, String name) {
147:                    if (name.equals("REGISTER")) {
148:                        if (registerName == null || registerName.length() != 1)
149:                            Log.log(Log.ERROR, this , "Malformed NAME: "
150:                                    + registerName);
151:                        else
152:                            Registers.setRegister(registerName.charAt(0),
153:                                    charData.toString());
154:                        inRegister = false;
155:                        charData.setLength(0);
156:                    }
157:                } //}}}
158:
159:                //{{{ characters() method
160:                public void characters(char[] ch, int start, int length) {
161:                    if (inRegister)
162:                        charData.append(ch, start, length);
163:                } //}}}
164:
165:                //{{{ Private members
166:                private String registerName;
167:                private StringBuffer charData = new StringBuffer();
168:                private boolean inRegister;
169:                //}}}
170:            } //}}}
171:            //}}}
172:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.