cnd

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 » IDE Netbeans » cnd 
License:
URL:
Description:
Package NameComment
antlr
antlr.actions.java
antlr.ASdebug
antlr.build
antlr.collections
antlr.collections.impl
antlr.debug
antlr.debug.misc
antlr.preprocessor
dwarfclassview
dwarfclassview.consts
dwarfclassview.kindresolver
dwarfdump
dwarfvsmodel
modeldump
modelutils
org.netbeans.cnd.api.lexer
org.netbeans.modules.cnd
org.netbeans.modules.cnd.actions
org.netbeans.modules.cnd.api.compilers
org.netbeans.modules.cnd.api.execution
org.netbeans.modules.cnd.api.model
org.netbeans.modules.cnd.api.model.deep
org.netbeans.modules.cnd.api.model.services
org.netbeans.modules.cnd.api.model.util
org.netbeans.modules.cnd.api.model.xref
org.netbeans.modules.cnd.api.picklist
org.netbeans.modules.cnd.api.project
org.netbeans.modules.cnd.api.utils
org.netbeans.modules.cnd.api.xml Overview of XML package.

Terms

codec Abbreviation for Coder/Decoder terminal node A XML node of the form <tag>content</tag>

Goals

R1 XML writing utility. SAX parses but there's no utiltity to help with indentation, attributes, escaping and XML document headers and footers. R2 codec to be separate from actual object. Alternative schemes involve serializable objects to implement a particular codec interface. Separate codecs are good for these reasons: - Allows us to write codecs for classes which we can't modify. - Decoding typically benefits from class extension. But extending a decoder class might conflict with the object classes existing inheritance. Sure, one can use interfaces and then create "Support" classes to be delagated to, but that becomes increasingly inconvenient. R3 codecs to not be associated with documents. We might have an XML document which contains <breakpoints> at the top level. Some other day we might want to embed the <breakpoints> as part of <profile> in another document. The <breakpoints> codec should not have to know about whether it's in a document or where it is embedded. R4 Single codec class Not have to write a separate class for encoding and another for decoding. This will allow the encapsulation of all XML-specific codecing, primarily tag and attribute names, info in one class. R* tags to driver object construction [ tentative ]

Motivational history

- While developing SunStudio we found that we often migrated where colelctions of data are stored (both in mmeory and under persistence) and adapting to distinct XML persistence infrastructures was a PIB. From this we get R3. - The cnd makeproject introduced the notion of dispatching the parsing and writing of sub-systems to ... the sub-systems via the so-called ConfigurationAuxObject interface. But this mechanism was hard-coded in ConfigurationDescriptorHelper and no-one else could benefit from it. That implementation was a first-approximation solution to R3 and in this package we generalize it. - A large amount of copy-pasted code, especially in the area of writing out XML, would drop various features: - Proper XML encoding attribute (sometimes it needs to be other than "UTF-8". - Inconsistent quoting. Attribute value quoting, via XMLUtil.toAttributeValue was used only in some places. Content coding, via XMLUtil.toElementContent wasn't used _anywhere_. - Lot of code relied on converting to XML strings before passing them on to other places. Having Codecs just write to a stream is more efficient.

Example

In the following example Methods with empty definitions are elided for brevity although in actual code they need to be implemented to satisfy interfaces. Consider data which would be stored as follows:
	<family>
		<father>
			<person firstName="X"
				lastName="L"
				gender="M"/>
		</father>
		<mother>
			<person firstName="Y"
				lastName="L"
				gender="F"/>
		</mother>
		<children>
			<person firstName="Z"
				lastName="L"
				gender="M"/>
		</children>
	</family>
based on
	class Family {
		Person mother;
		Person father;
		Vector<Person> children;
	}
Let's see how one would write this out.

	FamilyXMLDocWriter writer = new FamilyXMLDocWriter(family);
	writer.setIndentChars(4);	// as opposed to default of 2
	writer.write(new File("family.html");


	FamilyXMLDocWriter extends XMLDocWriter {

		FamilyXMLCodec codec;

		FamilyXMLDocWriter(Family family) {
			codec = new FamilyXMLCodec(family);
		}

		public void write(File file) {
			OutputStream os = file.();
			write(os);
		}


		// interface XMLEncoder
		public void encode(XMLEncoderStream xes) {
			codec.encode(xes);
		}
	}

	FamilyXMLCodec extends XMLDecoder implements XMLEncoder {

		private Family family		// being written out
		private PersonXMLCodec personCodec;
		private ChildrenXMLCodec childrenCodec;

		FamilyXMLCodec(Family family) {
			this.family = family;
			personCodec = new PersonXMLCodec();
			childrenCodec = new ChildrenXMLCodec(family.children);
		}

		// interface XMLDecoder
		protected String tag() {
			return "family"
		}

		// interface XMLEncoder
		public void encode(XMLEncoderStream xes) {
			xes.elementOpen(tag());
				xes.elementOpen("father");
					personCodec.setPerson(father);
					personCodec.encode(xes)
				xes.elementClose("father");

				xes.elementOpen("mother");
					personCodec.setPerson(mother);
					personCodec.encode(xes)
				xes.elementClose("mother");

				childrenCodec.encode(xes);
			xes.elementClose(tag());
		}
	}

	ChildrenXMLCodec extends XMLDecoder implements XMLEncoder {

		private Vector<PErson> children;
		private PersonXMLCodec personCodec;

		ChildrenXMLCodec(Vector<Person> children) {
			this.children = children;
			personCodec = new PersonXMLCodec();
		}

		// interface XMLDecoder
		protected String tag() {
			return "children"
		}

		// interface XMLEncoder
		public void encode(XMLEncoderStream xes) {
			xes.elementOpen(tag());
			for (Person p in children) {
				personCodec.setPerson(p);
				personCodec.encode(xes);
			}
			xes.elementClose(tag());
		}
	}

	PersonXMLCodec extends XMLDecoder implements XMLEncoder {

		private Person person;
		private Vector<Person> list;

		PersonXMLCodec(Person person {
			this.person = person;
		}

		PersonXMLCodec(Vector<Person> list) {
			this.list = list;
		}

		public void setPerson(Person person) {
			this.person = person;
		}

		// interface XMLDecoder
		protected String tag() {
			return "person"
		}

		// interface XMLEncoder
		public void encode(XMLEncoderStream xes) {
			AttrValuePair attrs[] = new AttrValuePair[] {
				new AttrValuePair("firstName",
						  person.firstName);
				new AttrValuePair("lastName",
						  person.lastName);
				new AttrValuePair("gender",
						  person.gender);
			}
			xes.element(tag(), attrs);
		}
	}
Now let's see how one would read it in.

These are the same classes as above but with the encoding related code taken out and only decoding code appearing.

	FamilyXMLDocReader writer = new FamilyXMLDocReader(family);
	writer.write(new File("family.html");


	FamilyXMLDocReader extends XMLDocReader {

		FamilyXMLCodec codec;

		FamilyXMLDocReader(Family family) {
			codec = new FamilyXMLCodec(family);
			registerXMLDecoder(codec);
		}

		public void write(File file) {
			InputStream is = file.();
			String what = "family"
			read(is, what);
		}
	}

	FamilyXMLCodec extends XMLDecoder implements XMLEncoder {

		private Family family
		private PersonXMLCodec personCodec;
		private ChildrenXMLCodec childrenCodec;

		FamilyXMLCodec(Family family) {
			this.family = family;

			personCodec = new PersonXMLCodec();
			registerXMLEncoder(personCodec);

			childrenCodec = new ChildrenXMLCodec(family.children);
			registerXMLEncoder(childrenCodec);
		}

		// interface XMLDecoder
		protected String tag() {
			return "family"
		}

		// interface XMLDecoder
		protected void startElement(String name, Attributes atts) {

			// personCode.start() will automatically be called when
			//  is seen due to the above registration.
			// Here we just ensure that we decode into the 
			// right Person instance

			if (name.equals("mother")) {
				family.mother = new Person();
				personCodec.setPerson(family.mother);
			}
			else if (name.equals("father")) {
				family.father = new Person();
				personCodec.setPerson(family.father);
			}

			// children handled by registration
		}
	}

	/**
	 * For decosing children we cheat a bit.
	 * We instantiate and register a version of PersonXMLCodec which
	 * takes a container (Vector) to stuff new Persons into.
	 */
	ChildrenXMLCodec extends XMLDecoder implements XMLEncoder {

		private Vector<PErson> children;
		private PersonXMLCodec personCodec;

		ChildrenXMLCodec(Vector<Person> children) {
			this.children = children;

			personCodec = new PersonXMLCodec(children);
			registerXMLEncoder(personCodec);
		}

		// interface XMLDecoder
		protected String tag() {
			return "children"
		}
	}

	PersonXMLCodec extends XMLDecoder implements XMLEncoder {

		private Person person;
		private Vector<Person> list;

		PersonXMLCodec(Person person {
			this.person = person;
		}

		/**
		 * Form used when we delay setting the person to be decoded
		 * into til setPerson().
		 */
		PersonXMLCodec(Person person {
			this.person = null;
		}

		/**
		 * Form used when we create Persons, decode them and add them
		 * to 'list'
		 */
		PersonXMLCodec(Vector<Person> list) {
			this.list = list;
		}

		public void setPerson(Person person) {
			this.person = person;
		}

		// interface XMLDecoder
		protected String tag() {
			return "person"
		}

		// interface XMLDecoder
		protected void start(Attributes atts) {
			Person newPerson = person;
			if (!newPerson)
				newPerson = new Person();
			person.firstName = atts.getValue("firstName");
			person.familyName = atts.getValue("familyName");
			person.gender = atts.getValue("gender");
			if (list != null)
				list.add(newPerson);
		}
	}
org.netbeans.modules.cnd.apt.debug
org.netbeans.modules.cnd.apt.impl.structure
org.netbeans.modules.cnd.apt.impl.support
org.netbeans.modules.cnd.apt.impl.support.lang
org.netbeans.modules.cnd.apt.structure
org.netbeans.modules.cnd.apt.support
org.netbeans.modules.cnd.apt.utils
org.netbeans.modules.cnd.builds
org.netbeans.modules.cnd.classview
org.netbeans.modules.cnd.classview.actions
org.netbeans.modules.cnd.classview.model
org.netbeans.modules.cnd.classview.resources
org.netbeans.modules.cnd.compilers
org.netbeans.modules.cnd.completion
org.netbeans.modules.cnd.completion.cplusplus
org.netbeans.modules.cnd.completion.cplusplus.ext
org.netbeans.modules.cnd.completion.cplusplus.hyperlink
org.netbeans.modules.cnd.completion.cplusplus.utils
org.netbeans.modules.cnd.completion.csm
org.netbeans.modules.cnd.completion.impl.xref
org.netbeans.modules.cnd.completion.includes
org.netbeans.modules.cnd.completion.spi.dynhelp
org.netbeans.modules.cnd.debugger.gdb
org.netbeans.modules.cnd.debugger.gdb.actions
org.netbeans.modules.cnd.debugger.gdb.attach
org.netbeans.modules.cnd.debugger.gdb.breakpoints
org.netbeans.modules.cnd.debugger.gdb.disassembly
org.netbeans.modules.cnd.debugger.gdb.event
org.netbeans.modules.cnd.debugger.gdb.expr
org.netbeans.modules.cnd.debugger.gdb.models
org.netbeans.modules.cnd.debugger.gdb.profiles
org.netbeans.modules.cnd.debugger.gdb.profiles.ui
org.netbeans.modules.cnd.debugger.gdb.proxy
org.netbeans.modules.cnd.debugger.gdb.timer
org.netbeans.modules.cnd.debugger.gdb.utils
org.netbeans.modules.cnd.discovery.api
org.netbeans.modules.cnd.discovery.wizard
org.netbeans.modules.cnd.discovery.wizard.api
org.netbeans.modules.cnd.discovery.wizard.bridge
org.netbeans.modules.cnd.discovery.wizard.checkedtree
org.netbeans.modules.cnd.discovery.wizard.tree
org.netbeans.modules.cnd.dwarfdiscovery
org.netbeans.modules.cnd.dwarfdiscovery.provider
org.netbeans.modules.cnd.dwarfdump
org.netbeans.modules.cnd.dwarfdump.dwarf
org.netbeans.modules.cnd.dwarfdump.dwarfconsts
org.netbeans.modules.cnd.dwarfdump.elf
org.netbeans.modules.cnd.dwarfdump.exception
org.netbeans.modules.cnd.dwarfdump.reader
org.netbeans.modules.cnd.dwarfdump.section
org.netbeans.modules.cnd.dwarfdump.trace
org.netbeans.modules.cnd.editor
org.netbeans.modules.cnd.editor.api
org.netbeans.modules.cnd.editor.cplusplus
org.netbeans.modules.cnd.editor.filecreation
org.netbeans.modules.cnd.editor.fortran
org.netbeans.modules.cnd.editor.makefile
org.netbeans.modules.cnd.editor.options
org.netbeans.modules.cnd.editor.parser
org.netbeans.modules.cnd.editor.reformat
org.netbeans.modules.cnd.editor.shell
org.netbeans.modules.cnd.editor.spi.cplusplus
org.netbeans.modules.cnd.execution
org.netbeans.modules.cnd.execution41.org.openide.actions
org.netbeans.modules.cnd.execution41.org.openide.cookies
org.netbeans.modules.cnd.execution41.org.openide.execution
org.netbeans.modules.cnd.execution41.org.openide.loaders
org.netbeans.modules.cnd.folding
org.netbeans.modules.cnd.gotodeclaration.element.providers
org.netbeans.modules.cnd.gotodeclaration.element.spi
org.netbeans.modules.cnd.gotodeclaration.element.ui
org.netbeans.modules.cnd.gotodeclaration.resources
org.netbeans.modules.cnd.gotodeclaration.type
org.netbeans.modules.cnd.gotodeclaration.util
org.netbeans.modules.cnd.highlight
org.netbeans.modules.cnd.highlight.error
org.netbeans.modules.cnd.highlight.error.includes
org.netbeans.modules.cnd.highlight.semantic
org.netbeans.modules.cnd.highlight.semantic.actions
org.netbeans.modules.cnd.highlight.semantic.options
org.netbeans.modules.cnd.lexer
org.netbeans.modules.cnd.loaders
org.netbeans.modules.cnd.makeproject
org.netbeans.modules.cnd.makeproject.api
org.netbeans.modules.cnd.makeproject.api.actions
org.netbeans.modules.cnd.makeproject.api.compilers
org.netbeans.modules.cnd.makeproject.api.configurations
org.netbeans.modules.cnd.makeproject.api.configurations.ui
org.netbeans.modules.cnd.makeproject.api.platforms
org.netbeans.modules.cnd.makeproject.api.remote
org.netbeans.modules.cnd.makeproject.api.runprofiles
org.netbeans.modules.cnd.makeproject.api.ui
org.netbeans.modules.cnd.makeproject.api.wizards
org.netbeans.modules.cnd.makeproject.configurations
org.netbeans.modules.cnd.makeproject.configurations.ui
org.netbeans.modules.cnd.makeproject.runprofiles
org.netbeans.modules.cnd.makeproject.runprofiles.ui
org.netbeans.modules.cnd.makeproject.ui
org.netbeans.modules.cnd.makeproject.ui.customizer
org.netbeans.modules.cnd.makeproject.ui.options
org.netbeans.modules.cnd.makeproject.ui.utils
org.netbeans.modules.cnd.makeproject.ui.wizards
org.netbeans.modules.cnd.makewizard
org.netbeans.modules.cnd.model.services
org.netbeans.modules.cnd.model.tasks
org.netbeans.modules.cnd.modeldiscovery.provider
org.netbeans.modules.cnd.modelimpl
org.netbeans.modules.cnd.modelimpl.cache
org.netbeans.modules.cnd.modelimpl.cache.impl
org.netbeans.modules.cnd.modelimpl.csm
org.netbeans.modules.cnd.modelimpl.csm.container
org.netbeans.modules.cnd.modelimpl.csm.core
org.netbeans.modules.cnd.modelimpl.csm.deep
org.netbeans.modules.cnd.modelimpl.csm.guard
org.netbeans.modules.cnd.modelimpl.csm.typehierarchy
org.netbeans.modules.cnd.modelimpl.debug
org.netbeans.modules.cnd.modelimpl.impl.services
org.netbeans.modules.cnd.modelimpl.memory
org.netbeans.modules.cnd.modelimpl.options
org.netbeans.modules.cnd.modelimpl.parser
org.netbeans.modules.cnd.modelimpl.parser.apt
org.netbeans.modules.cnd.modelimpl.platform
org.netbeans.modules.cnd.modelimpl.repository
org.netbeans.modules.cnd.modelimpl.spi
org.netbeans.modules.cnd.modelimpl.test
org.netbeans.modules.cnd.modelimpl.textcache
org.netbeans.modules.cnd.modelimpl.trace
org.netbeans.modules.cnd.modelimpl.uid
org.netbeans.modules.cnd.modelimpl.util
org.netbeans.modules.cnd.modelui
org.netbeans.modules.cnd.modelui.switcher
org.netbeans.modules.cnd.modelutil
org.netbeans.modules.cnd.navigation.classhierarchy
org.netbeans.modules.cnd.navigation.hierarchy
org.netbeans.modules.cnd.navigation.includeview
org.netbeans.modules.cnd.navigation.services
org.netbeans.modules.cnd.navigation.switchfiles
org.netbeans.modules.cnd.qnavigator.navigator
org.netbeans.modules.cnd.refactoring.actions
org.netbeans.modules.cnd.refactoring.api
org.netbeans.modules.cnd.refactoring.editor
org.netbeans.modules.cnd.refactoring.elements
org.netbeans.modules.cnd.refactoring.plugins
org.netbeans.modules.cnd.refactoring.support
org.netbeans.modules.cnd.refactoring.ui
org.netbeans.modules.cnd.refactoring.ui.tree
org.netbeans.modules.cnd.repository.access
org.netbeans.modules.cnd.repository.api
org.netbeans.modules.cnd.repository.disk
org.netbeans.modules.cnd.repository.disk.api
org.netbeans.modules.cnd.repository.impl
org.netbeans.modules.cnd.repository.queue
org.netbeans.modules.cnd.repository.sfs
org.netbeans.modules.cnd.repository.sfs.index
org.netbeans.modules.cnd.repository.sfs.statistics
org.netbeans.modules.cnd.repository.spi
org.netbeans.modules.cnd.repository.support
org.netbeans.modules.cnd.repository.testbench
org.netbeans.modules.cnd.repository.testbench.sfs
org.netbeans.modules.cnd.repository.translator
org.netbeans.modules.cnd.repository.util
org.netbeans.modules.cnd.settings
org.netbeans.modules.cnd.test
org.netbeans.modules.cnd.test.base
org.netbeans.modules.cnd.ui.options
org.netbeans.modules.cnd.utils.cache
org.netbeans.modules.cnd.xref.impl
test.sfs
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.