From commits-return-2940-apmail-jackrabbit-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Mon Oct 09 17:12:10 2006 Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 7121 invoked from network); 9 Oct 2006 17:12:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Oct 2006 17:12:10 -0000 Received: (qmail 14160 invoked by uid 500); 9 Oct 2006 17:12:10 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 14126 invoked by uid 500); 9 Oct 2006 17:12:10 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 14112 invoked by uid 99); 9 Oct 2006 17:12:09 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Oct 2006 10:12:09 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Oct 2006 10:12:06 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 2F14F1A981A; Mon, 9 Oct 2006 10:11:45 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r454430 [1/2] - in /jackrabbit/trunk/contrib/jackrabbit-ntdoc: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/ntdoc/ src/main/java/org/a... Date: Mon, 09 Oct 2006 17:11:44 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061009171145.2F14F1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: jukka Date: Mon Oct 9 10:11:42 2006 New Revision: 454430 URL: http://svn.apache.org/viewvc?view=rev&rev=454430 Log: JCR-548: Added the NTDoc tool contributed by Sten Roger Sandvik. Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/HEADER.txt (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/LICENSE.txt (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/NOTICE.txt (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/README.txt (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/pom.xml (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/Main.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/NTDoc.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/ItemDef.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeDef.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeType.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeTypeSet.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/PropertyDef.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/CNDNodeTypeParser.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/NodeTypeParser.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/NodeTypeParserFactory.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/XMLNodeTypeParser.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/producer/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/producer/HtmlProducer.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/producer/Producer.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/producer/StandardProducer.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/reporter/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/reporter/Reporter.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/reporter/ReporterDelegator.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/reporter/SimpleReporter.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/util/ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/util/CssWriter.java (with props) jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/util/HtmlWriter.java (with props) Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/HEADER.txt URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/HEADER.txt?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/HEADER.txt (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/HEADER.txt Mon Oct 9 10:11:42 2006 @@ -0,0 +1,16 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/HEADER.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/LICENSE.txt URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/LICENSE.txt?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/LICENSE.txt (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/LICENSE.txt Mon Oct 9 10:11:42 2006 @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/LICENSE.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/NOTICE.txt URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/NOTICE.txt?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/NOTICE.txt (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/NOTICE.txt Mon Oct 9 10:11:42 2006 @@ -0,0 +1,5 @@ +Apache Jackrabbit +Copyright 2006 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/NOTICE.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/README.txt URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/README.txt?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/README.txt (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/README.txt Mon Oct 9 10:11:42 2006 @@ -0,0 +1,60 @@ + +=========================================================================== +Jackrabbit NTDoc - Node Type Documentation System +=========================================================================== + +Overview +-------- + +This package holds the NTDoc tool. It is a node type documentation tool +for Jackrabbit that is able to parse both CND and XML node type definitions. +Documentation output is generated in HTML and is very similar to JavaDoc. + +Building +-------- + +To build the NTDoc package using Maven 2, use the package target. Write the +following on the command line: + + mvn package + +Running +------- + +The jar file is created as an executable jar. To run the tool to get usage +information, type the following: + + java -jar jackrabbit-ntdoc-1.0.jar + +To generate node type documentation for both buildtin types and my custom +types, type the following: + + java -jar jackrabbit-ntdoc-1.0.jar -d output -t "My Docs" + nodetypes/buildin.cnd nodetypes/mycustom.cnd + +NOTE: The tool will not generate any links between node types in different +files if not both files are specified. + +License (see also LICENSE.txt) +------------------------------ + +Collective work: Copyright 2006 The Apache Software Foundation. + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + + + Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/README.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/pom.xml URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/pom.xml?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/pom.xml (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/pom.xml Mon Oct 9 10:11:42 2006 @@ -0,0 +1,49 @@ + + + 4.0.0 + + org.apache.jackrabbit + jackrabbit-ntdoc + Jackrabbit NTDoc + 1.0 + NTDoc is a node type documentation tool for Jackrabbit node type definitions. + http://jackrabbit.apache.org + + http://issues.apache.org/jira/browse/JCR + + + + The Apache Software License, Version 2.0 + /LICENSE.txt + repo + + + + The Apache Software Foundation + http://www.apache.org + + + + + maven-compiler-plugin + + 1.4 + 1.4 + + + + maven-jar-plugin + + + + org.apache.jackrabbit.ntdoc.Main + + + + + + + + + Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/Main.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/Main.java?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/Main.java (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/Main.java Mon Oct 9 10:11:42 2006 @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ntdoc; + +import java.util.*; +import org.apache.jackrabbit.ntdoc.reporter.*; + +/** + * This is the main entry point for ntdoc. + */ +public final class Main { + /** + * Print the usage. + */ + private static void printUsage() { + System.out.println("ntdoc -d [-t ] <file(s)>"); + } + + /** + * Set the parameters and return the producer if succesful. + */ + private static NTDoc prepare(String[] args) { + Map switches = new HashMap(); + List files = new LinkedList(); + + String sw = null; + for (int i = 0; i < args.length; i++) { + if (args[i].startsWith("-")) { + sw = args[i].substring(1); + } else if (sw != null) { + switches.put(sw, args[i]); + sw = null; + } else { + files.add(args[i]); + } + } + + String[] tmp = new String[files.size()]; + return prepare(switches, (String[]) files.toArray(tmp)); + } + + /** + * Set the parameters. Return true if it is valid, false otherwise. + */ + private static NTDoc prepare(Map switches, String[] files) { + String dir = (String) switches.get("d"); + String title = (String) switches.get("t"); + + if ((dir == null) || (files.length == 0)) { + return null; + } + + NTDoc doc = new NTDoc(); + doc.setTitle(title); + doc.setOutputDir(dir); + doc.setInputFiles(files); + doc.setReporter(new SimpleReporter(System.out)); + return doc; + } + + /** + * Execute ntdoc. + */ + public static void main(String[] args) { + NTDoc doc = prepare(args); + if (doc != null) { + doc.produce(); + } else { + printUsage(); + } + } +} Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/Main.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/NTDoc.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/NTDoc.java?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/NTDoc.java (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/NTDoc.java Mon Oct 9 10:11:42 2006 @@ -0,0 +1,173 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ntdoc; + +import java.io.*; + +import org.apache.jackrabbit.ntdoc.model.*; +import org.apache.jackrabbit.ntdoc.parser.*; +import org.apache.jackrabbit.ntdoc.producer.*; +import org.apache.jackrabbit.ntdoc.reporter.*; + +/** + * This is the main entry point for ntdoc. + */ +public final class NTDoc + extends ReporterDelegator { + /** + * Default title. + */ + private final static String DEFAULT_TITLE = + "Generated Documentation"; + + /** + * Title. + */ + private String title; + + /** + * Output directory. + */ + private File outputDir; + + /** + * Input files. + */ + private File[] inputFiles; + + /** + * Return the title. + */ + public String getTitle() { + return this.title != null ? this.title : DEFAULT_TITLE; + } + + /** + * Set the title. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Return the output directory. + */ + public File getOutputDir() { + return this.outputDir; + } + + /** + * Set the output directory. + */ + public void setOutputDir(File outputDir) { + this.outputDir = outputDir; + } + + /** + * Set the output directory. + */ + public void setOutputDir(String outputDir) { + setOutputDir(new File(outputDir)); + } + + /** + * Return the input files. + */ + public File[] getInputFiles() { + return this.inputFiles; + } + + /** + * Set the input files. + */ + public void setInputFiles(File[] inputFiles) { + this.inputFiles = inputFiles; + } + + /** + * Set the input files. + */ + public void setInputFiles(String[] inputFiles) { + File[] tmp = new File[inputFiles.length]; + for (int i = 0; i < inputFiles.length; i++) { + tmp[i] = new File(inputFiles[i]); + } + + setInputFiles(tmp); + } + + /** + * Parse node types. + */ + private NodeTypeSet parseNodeTypes() + throws IOException { + NodeTypeSet nodeTypes = new NodeTypeSet(); + for (int i = 0; i < this.inputFiles.length; i++) { + nodeTypes.addNodeTypes(parseNodeTypes(this.inputFiles[i])); + } + + return nodeTypes; + } + + /** + * Parse node types. + */ + private NodeTypeSet parseNodeTypes(File file) + throws IOException { + NodeTypeParser parser = NodeTypeParserFactory.newParser(file); + parser.parse(); + return parser.getNodeTypes(); + } + + /** + * Produce the documentation. + */ + public boolean produce() { + try { + doProduce(); + return true; + } catch (IOException e) { + error(e.getMessage()); + return false; + } + } + + /** + * Produce the documentation. + */ + private void doProduce() + throws IOException { + NodeTypeSet nodeTypes = parseNodeTypes(); + info("Parsed " + nodeTypes.getSize() + " node type definitions"); + doProduce(nodeTypes); + } + + /** + * Produce the documentation. + */ + private void doProduce(NodeTypeSet nodeTypes) + throws IOException { + Producer producer = new StandardProducer(); + producer.setReporter(getReporter()); + producer.setTitle(getTitle()); + producer.setOutputDir(getOutputDir()); + producer.setNodeTypes(nodeTypes); + info("Producing node type documentation to '" + this.outputDir.getPath() + "'"); + producer.produce(); + } +} + Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/NTDoc.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/ItemDef.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/ItemDef.java?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/ItemDef.java (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/ItemDef.java Mon Oct 9 10:11:42 2006 @@ -0,0 +1,209 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ntdoc.model; + +/** + * This class defines the item type. + */ +public abstract class ItemDef + implements Comparable { + /** + * On parent version options. + */ + public final static int OPV_COPY = 0; + public final static int OPV_VERSION = 1; + public final static int OPV_INITIALIZE = 2; + public final static int OPV_COMPUTE = 3; + public final static int OPV_IGNORE = 4; + public final static int OPV_ABORT = 5; + + /** + * On parent version names. + */ + private final static String[] OPV_NAMES = { + "COPY", "VERSION", "INITIALIZE", "COMPUTE", + "IGNORE", "ABORT" + }; + + /** + * Name of item. + */ + private final String name; + + /** + * Declaring node type. + */ + private NodeType declNodeType; + + /** + * On parent version. + */ + private int onParentVersion; + + /** + * Auto created. + */ + private boolean autoCreated; + + /** + * Mandatory. + */ + private boolean mandatory; + + /** + * Protected. + */ + private boolean prot; + + /** + * Primary item. + */ + private boolean primary; + + /** + * Multiple. + */ + private boolean multiple; + + /** + * Construct the item def. + */ + public ItemDef(String name) { + this.name = name; + } + + /** + * Return the name. + */ + public String getName() { + return this.name; + } + + /** + * Return the on parent version. + */ + public int getOnParentVersion() { + return this.onParentVersion; + } + + /** + * Return the on parent version. + */ + public String getOnParentVersionString() { + return OPV_NAMES[this.onParentVersion]; + } + + /** + * Return true if auto created. + */ + public boolean isAutoCreated() { + return this.autoCreated; + } + + /** + * Return true if mandatory. + */ + public boolean isMandatory() { + return this.mandatory; + } + + /** + * Return true if protected. + */ + public boolean isProtected() { + return this.prot; + } + + /** + * Return true if primary. + */ + public boolean isPrimary() { + return this.primary; + } + + /** + * Return true if multiple. + */ + public boolean isMultiple() { + return this.multiple; + } + + /** + * Set the on parent version. + */ + public void setOnParentVersion(int onParentVersion) { + if ((onParentVersion >= OPV_COPY) && (onParentVersion <= OPV_ABORT)) { + this.onParentVersion = onParentVersion; + } + } + + /** + * Set true if auto created. + */ + public void setAutoCreated(boolean autoCreated) { + this.autoCreated = autoCreated; + } + + /** + * Set true if mandatory. + */ + public void setMandatory(boolean mandatory) { + this.mandatory = mandatory; + } + + /** + * Set true if protected. + */ + public void setProtected(boolean prot) { + this.prot = prot; + } + + /** + * Set true if primary. + */ + public void setPrimary(boolean primary) { + this.primary = primary; + } + + /** + * Set true if multiple. + */ + public void setMultiple(boolean multiple) { + this.multiple = multiple; + } + + /** + * Return the declaring node type. + */ + public NodeType getDeclaringNodeType() { + return this.declNodeType; + } + + /** + * Set the declaring node type. + */ + public void setDeclaringNodeType(NodeType nodeType) { + this.declNodeType = nodeType; + } + + /** + * Compare to. + */ + public int compareTo(Object o) { + return this.name.compareTo(((ItemDef) o).name); + } +} Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/ItemDef.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeDef.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeDef.java?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeDef.java (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeDef.java Mon Oct 9 10:11:42 2006 @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ntdoc.model; + +import java.util.*; + +/** + * This class implements the child node definition. + */ +public final class NodeDef + extends ItemDef { + /** + * Default primary type. + */ + private String defPrimaryType; + + /** + * Required primary types. + */ + private final HashSet reqPrimaryTypes; + + /** + * Construct the item. + */ + public NodeDef(String name) { + super(name); + this.reqPrimaryTypes = new HashSet(); + } + + /** + * Return the default primary type. + */ + public String getDefaultPrimaryType() { + return this.defPrimaryType != null ? this.defPrimaryType : ""; + } + + /** + * Set the default primary type. + */ + public void setDefaultPrimaryType(String defPrimaryType) { + this.defPrimaryType = defPrimaryType; + } + + /** + * Return the required primary types. + */ + public String[] getRequiredPrimaryTypes() { + return (String[]) this.reqPrimaryTypes.toArray(new String[this.reqPrimaryTypes.size()]); + } + + /** + * Set the required primary types. + */ + public void setRequiredPrimaryTypes(String[] reqPrimaryTypes) { + setRequiredPrimaryTypes(Arrays.asList(reqPrimaryTypes)); + } + + /** + * Set the required primary types. + */ + public void setRequiredPrimaryTypes(Collection reqPrimaryTypes) { + this.reqPrimaryTypes.clear(); + this.reqPrimaryTypes.addAll(reqPrimaryTypes != null ? reqPrimaryTypes : Collections.EMPTY_LIST); + } + + /** + * Add required primary type value. + */ + public void addRequiredPrimaryType(String reqPrimaryType) { + this.reqPrimaryTypes.add(reqPrimaryType); + } +} Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeDef.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeType.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeType.java?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeType.java (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeType.java Mon Oct 9 10:11:42 2006 @@ -0,0 +1,299 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ntdoc.model; + +import java.util.*; + +/** + * This class implements the node type. + */ +public final class NodeType + implements Comparable { + /** + * Name of type. + */ + private final String name; + + /** + * Namespace. + */ + private String namespace; + + /** + * Super types. + */ + private final HashSet superTypes; + + /** + * Mixin. + */ + private boolean mixin; + + /** + * Orderable. + */ + private boolean orderable; + + /** + * List of child items. + */ + private final List itemDefs; + + /** + * Node type set. + */ + private NodeTypeSet nodeTypeSet; + + /** + * Construct the node type. + */ + public NodeType(String name) { + this.name = name; + this.itemDefs = new ArrayList(); + this.superTypes = new HashSet(); + } + + /** + * Return the name. + */ + public String getName() { + return this.name; + } + + /** + * Return the namespace URI. + */ + public String getNamespace() { + return this.namespace != null ? this.namespace : ""; + } + + /** + * Set the namespace URI. + */ + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + /** + * Return the super types. + */ + public String[] getSuperTypes() { + if (!isMixin()) { + addSuperType("nt:base"); + } + + return (String[]) this.superTypes.toArray(new String[this.superTypes.size()]); + } + + /** + * Set the super types. + */ + public void setSuperTypes(String[] superTypes) { + setSuperTypes(Arrays.asList(superTypes)); + } + + /** + * Set the super types. + */ + public void setSuperTypes(Collection superTypes) { + this.superTypes.clear(); + this.superTypes.addAll(superTypes != null ? superTypes : Collections.EMPTY_LIST); + } + + /** + * Add a super type. + */ + public void addSuperType(String superType) { + this.superTypes.add(superType); + } + + /** + * Return true if mixin type. + */ + public boolean isMixin() { + return this.mixin; + } + + /** + * Set true if mixin type. + */ + public void setMixin(boolean mixin) { + this.mixin = mixin; + } + + /** + * Return true if it has orderable child nodes. + */ + public boolean isOrderable() { + return this.orderable; + } + + /** + * Set true if it has orderable child nodes. + */ + public void setOrderable(boolean orderable) { + this.orderable = orderable; + } + + /** + * Return the primary item name. + */ + public ItemDef getPrimaryItem() { + for (Iterator i = this.itemDefs.iterator(); i.hasNext();) { + ItemDef def = (ItemDef) i.next(); + if (def.isPrimary()) { + return def; + } + } + + return null; + } + + /** + * Return the primary item name. + */ + public String getPrimaryItemName() { + ItemDef def = getPrimaryItem(); + return def != null ? def.getName() : ""; + } + + /** + * Add item def. + */ + public void addItemDef(ItemDef def) { + this.itemDefs.add(def); + def.setDeclaringNodeType(this); + } + + /** + * Find all inherited nodes. + */ + public NodeType[] getInheritedTypes() { + return this.nodeTypeSet.getInheritedTypes(this); + } + + /** + * Return item def list. + */ + private List getItemDefList(boolean properties, boolean nodes) { + return getItemDefList(this.itemDefs, properties, nodes); + } + + /** + * Return inherited item def list. + */ + private List getInheritedItemDefList(boolean properties, boolean nodes) { + ArrayList list = new ArrayList(); + NodeType[] types = getInheritedTypes(); + + for (int i = 0; i < types.length; i++) { + list.addAll(Arrays.asList(types[i].getItemDefs())); + } + + return getItemDefList(list, properties, nodes); + } + + /** + * Return item def list. + */ + private List getItemDefList(List source, boolean properties, boolean nodes) { + ArrayList list = new ArrayList(); + for (Iterator i = source.iterator(); i.hasNext();) { + ItemDef def = (ItemDef) i.next(); + + if (properties && (def instanceof PropertyDef)) { + list.add(def); + } + + if (nodes && (def instanceof NodeDef)) { + list.add(def); + } + } + + Collections.sort(list); + return list; + } + + /** + * Return item defs. + */ + public ItemDef[] getItemDefs() { + List list = getItemDefList(true, true); + return (ItemDef[]) list.toArray(new ItemDef[list.size()]); + } + + /** + * Return property defs. + */ + public PropertyDef[] getPropertyDefs() { + List list = getItemDefList(true, false); + return (PropertyDef[]) list.toArray(new PropertyDef[list.size()]); + } + + /** + * Return node defs. + */ + public NodeDef[] getNodeDefs() { + List list = getItemDefList(false, true); + return (NodeDef[]) list.toArray(new NodeDef[list.size()]); + } + + /** + * Return inherited item defs. + */ + public ItemDef[] getInheritedItemDefs() { + List list = getInheritedItemDefList(true, true); + return (ItemDef[]) list.toArray(new ItemDef[list.size()]); + } + + /** + * Return inherited property defs. + */ + public PropertyDef[] getInheritedPropertyDefs() { + List list = getInheritedItemDefList(true, false); + return (PropertyDef[]) list.toArray(new PropertyDef[list.size()]); + } + + /** + * Return inherited node defs. + */ + public NodeDef[] getInheritedNodeDefs() { + List list = getInheritedItemDefList(false, true); + return (NodeDef[]) list.toArray(new NodeDef[list.size()]); + } + + /** + * Return the node type set. + */ + public NodeTypeSet getNodeTypeSet() { + return this.nodeTypeSet; + } + + /** + * Set the node type set. + */ + public void setNodeTypeSet(NodeTypeSet nodeTypeSet) { + this.nodeTypeSet = nodeTypeSet; + } + + /** + * Compare to. + */ + public int compareTo(Object o) { + return this.name.compareTo(((NodeType) o).name); + } +} Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeType.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeTypeSet.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeTypeSet.java?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeTypeSet.java (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeTypeSet.java Mon Oct 9 10:11:42 2006 @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ntdoc.model; + +import java.util.*; + +/** + * This class defines the node type set. + */ +public final class NodeTypeSet { + /** + * Node types. + */ + private final Map nodeTypes; + + /** + * Construct the node type set. + */ + public NodeTypeSet() { + this.nodeTypes = new TreeMap(); + } + + /** + * Return node types. + */ + public NodeType[] getNodeTypes() { + return getNodeTypes(true, true); + } + + /** + * Return node types. + */ + public NodeType[] getMixinNodeTypes() { + return getNodeTypes(true, false); + } + + /** + * Return node types. + */ + public NodeType[] getConcreteNodeTypes() { + return getNodeTypes(false, true); + } + + /** + * Return node types. + */ + public NodeType[] getNodeTypes(boolean mixin, boolean concrete) { + ArrayList list = new ArrayList(); + + for (Iterator i = this.nodeTypes.values().iterator(); i.hasNext();) { + NodeType nt = (NodeType) i.next(); + if (nt.isMixin() && mixin) { + list.add(nt); + } else if (!nt.isMixin() && concrete) { + list.add(nt); + } + } + + Collections.sort(list); + return (NodeType[]) list.toArray(new NodeType[list.size()]); + } + + /** + * Return node type by name. + */ + public NodeType getNodeType(String name) { + if (name != null) { + return (NodeType) this.nodeTypes.get(name); + } else { + return null; + } + } + + /** + * Add node type. + */ + public void addNodeType(NodeType nodeType) { + if (nodeType != null) { + this.nodeTypes.put(nodeType.getName(), nodeType); + nodeType.setNodeTypeSet(this); + } + } + + /** + * Add node types. + */ + public void addNodeTypes(NodeType[] nodeTypes) { + for (int i = 0; i < nodeTypes.length; i++) { + addNodeType(nodeTypes[i]); + } + } + + /** + * Add node types. + */ + public void addNodeTypes(NodeTypeSet nodeTypes) { + addNodeTypes(nodeTypes.getNodeTypes()); + } + + /** + * Return the size of set. + */ + public int getSize() { + return this.nodeTypes.size(); + } + + /** + * Find all inherited nodes. + */ + public NodeType[] getInheritedTypes(NodeType type) { + Set set = new TreeSet(); + findInheritedTypes(type, set); + return (NodeType[]) set.toArray(new NodeType[set.size()]); + } + + /** + * Find all inherited nodes. + */ + private void findInheritedTypes(NodeType type, Set nodes) { + String[] supertypes = type.getSuperTypes(); + for (int i = 0; i < supertypes.length; i++) { + NodeType tmp = getNodeType(supertypes[i]); + if ((tmp != null) && !nodes.contains(tmp)) { + nodes.add(tmp); + findInheritedTypes(tmp, nodes); + } + } + } + + /** + * Return the node type at index. + */ + public NodeType getNodeType(int index) { + NodeType[] list = getNodeTypes(); + if ((index >= 0) && (index < list.length)) { + return list[index]; + } else { + return null; + } + } +} Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/NodeTypeSet.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/PropertyDef.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/PropertyDef.java?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/PropertyDef.java (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/PropertyDef.java Mon Oct 9 10:11:42 2006 @@ -0,0 +1,156 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ntdoc.model; + +import java.util.*; + +/** + * This class implements the property definition. + */ +public final class PropertyDef + extends ItemDef { + /** + * Property types. + */ + public final static int TYPE_STRING = 0; + public final static int TYPE_BINARY = 1; + public final static int TYPE_LONG = 2; + public final static int TYPE_DOUBLE = 3; + public final static int TYPE_BOOLEAN = 4; + public final static int TYPE_DATE = 5; + public final static int TYPE_NAME = 6; + public final static int TYPE_PATH = 7; + public final static int TYPE_REFERENCE = 8; + public final static int TYPE_UNDEFINED = 9; + + /** + * Property type strings. + */ + private final static String[] TYPE_NAMES = { + "STRING", "BINARY", "LONG", "DOUBLE", "BOOLEAN", "DATE", + "NAME", "PATH", "REFERENCE", "UNDEFINED" + }; + + /** + * Required type. + */ + private int reqType; + + /** + * Default values. + */ + private final HashSet defValues; + + /** + * Constraints. + */ + private final HashSet constraints; + + /** + * Construct the item. + */ + public PropertyDef(String name) { + super(name); + this.defValues = new HashSet(); + this.constraints = new HashSet(); + } + + /** + * Return the type. + */ + public int getRequiredType() { + return this.reqType; + } + + /** + * Set the required type. + */ + public void setRequiredType(int reqType) { + if ((reqType >= TYPE_STRING) && (reqType <= TYPE_UNDEFINED)) { + this.reqType = reqType; + } + } + + /** + * Return the type. + */ + public String getRequiredTypeString() { + if ((this.reqType >= 0) && (this.reqType < TYPE_NAMES.length)) { + return TYPE_NAMES[this.reqType]; + } else { + return TYPE_NAMES[0]; + } + } + + /** + * Return the default values. + */ + public String[] getDefaultValues() { + return (String[]) this.defValues.toArray(new String[this.defValues.size()]); + } + + /** + * Set the default values. + */ + public void setDefaultValues(String[] defValues) { + setDefaultValues(Arrays.asList(defValues)); + } + + /** + * Set the default values. + */ + public void setDefaultValues(Collection defValues) { + this.defValues.clear(); + this.defValues.addAll(defValues != null ? defValues : Collections.EMPTY_LIST); + } + + /** + * Add default value. + */ + public void addDefaultValue(String defValue) { + this.defValues.add(defValue); + } + + /** + * Return the constraints. + */ + public String[] getConstraints() { + return (String[]) this.constraints.toArray(new String[this.constraints.size()]); + } + + /** + * Set the constraints. + */ + public void setConstraints(String[] constraints) { + setConstraints(Arrays.asList(constraints)); + } + + /** + * Set the constraints. + */ + public void setConstraints(Collection constraints) { + this.constraints.clear(); + this.constraints.addAll(constraints != null ? constraints : Collections.EMPTY_LIST); + } + + /** + * Add constraint value. + */ + public void addConstraint(String constraint) { + this.constraints.add(constraint); + } +} Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/model/PropertyDef.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/CNDNodeTypeParser.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/CNDNodeTypeParser.java?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/CNDNodeTypeParser.java (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/CNDNodeTypeParser.java Mon Oct 9 10:11:42 2006 @@ -0,0 +1,604 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ntdoc.parser; + +import java.io.*; +import java.util.*; + +import org.apache.jackrabbit.ntdoc.model.*; +import org.apache.jackrabbit.ntdoc.parser.*; + +/** + * This class implements the CND parser. + */ +public final class CNDNodeTypeParser + extends NodeTypeParser { + /** + * Orderable opt strings. + */ + private final static String[] TOK_ORDERABLE = + {"orderable", "ord", "o"}; + + /** + * Mixin opt strings. + */ + private final static String[] TOK_MIXIN = + {"mixin", "mix", "m"}; + + /** + * Primary opt strings. + */ + private final static String[] TOK_PRIMARY = + {"primary", "pri", "!"}; + + /** + * Autocreated opt strings. + */ + private final static String[] TOK_AUTOCREATED = + {"autocreated", "aut", "a"}; + + /** + * Mandatory opt strings. + */ + private final static String[] TOK_MANDATORY = + {"mandatory", "man", "m"}; + + /** + * Protected opt strings. + */ + private final static String[] TOK_PROTECTED = + {"protected", "pro", "p"}; + + /** + * Multiple opt strings. + */ + private final static String[] TOK_MULTIPLE = + {"multiple", "mul", "*"}; + + /** + * Copy option. + */ + private final static String[] TOK_COPY = + {"copy", "Copy", "COPY"}; + + /** + * Version option. + */ + private final static String[] TOK_VERSION = + {"version", "Version", "VERSION"}; + + /** + * Initialize option. + */ + private final static String[] TOK_INITIALIZE = + {"initialize", "Initialize", "INITIALIZE"}; + + /** + * Compute option. + */ + private final static String[] TOK_COMPUTE = + {"compute", "Compute", "COMPUTE"}; + + /** + * Ignore option. + */ + private final static String[] TOK_IGNORE = + {"ignore", "Ignore", "IGNORE"}; + + /** + * Abort option. + */ + private final static String[] TOK_ABORT = + {"abort", "Abort", "ABORT"}; + + /** + * String type. + */ + private final static String[] TOK_STRING = + {"string", "String", "STRING"}; + + /** + * String type. + */ + private final static String[] TOK_BINARY = + {"binary", "Binary", "BINARY"}; + + /** + * Long type. + */ + private final static String[] TOK_LONG = + {"long", "Long", "LONG"}; + + /** + * Double type. + */ + private final static String[] TOK_DOUBLE = + {"double", "Double", "DOUBLE"}; + + /** + * Boolean type. + */ + private final static String[] TOK_BOOLEAN = + {"boolean", "Boolean", "BOOLEAN"}; + + /** + * Date type. + */ + private final static String[] TOK_DATE = + {"date", "Date", "DATE"}; + + /** + * Name type. + */ + private final static String[] TOK_NAME = + {"name", "Name", "NAME"}; + + /** + * Path type. + */ + private final static String[] TOK_PATH = + {"path", "Path", "PATH"}; + + /** + * Reference type. + */ + private final static String[] TOK_REFERENCE = + {"reference", "Reference", "REFERENCE"}; + + /** + * Undefined type. + */ + private final static String[] TOK_UNDEFINED = + {"undefined", "Undefined", "UNDEFINED", "*"}; + + /** + * Tokenizer. + */ + private StreamTokenizer tok; + + /** + * Current token. + */ + private String currentToken; + + /** + * Initialize the parser. + */ + private void initialize() { + this.currentToken = null; + this.tok = new StreamTokenizer(getReader()); + this.tok.lowerCaseMode(false); + this.tok.eolIsSignificant(false); + this.tok.slashStarComments(true); + this.tok.slashSlashComments(true); + this.tok.quoteChar('\''); + this.tok.quoteChar('"'); + this.tok.wordChars('a', 'z'); + this.tok.wordChars('A', 'Z'); + this.tok.wordChars(':', ':'); + this.tok.wordChars('_', '_'); + this.tok.ordinaryChar('['); + this.tok.ordinaryChar(']'); + this.tok.ordinaryChar('<'); + this.tok.ordinaryChar('>'); + this.tok.ordinaryChar('('); + this.tok.ordinaryChar(')'); + this.tok.ordinaryChar('+'); + this.tok.ordinaryChar('-'); + this.tok.ordinaryChar('='); + this.tok.ordinaryChar(','); + } + + /** + * Return the next token. + */ + private void nextToken() + throws IOException { + try { + int tokenType = this.tok.nextToken(); + if (tokenType == StreamTokenizer.TT_EOF) { + this.currentToken = null; + } else if (tokenType == StreamTokenizer.TT_WORD) { + this.currentToken = this.tok.sval; + } else if ((tokenType == '\'') || (tokenType == '"')) { + this.currentToken = this.tok.sval; + } else if (tokenType == StreamTokenizer.TT_NUMBER) { + this.currentToken = String.valueOf(this.tok.nval); + } else { + this.currentToken = Character.toString((char) tokenType); + } + } catch (IOException e) { + throw createFailure("Failed to read stream", e); + } + } + + /** + * Return true if current token is value. + */ + private boolean currentTokenEquals(String value) { + if (value == this.currentToken) { + return true; + } else if ((value == null) || (this.currentToken == null)) { + return false; + } else { + return this.currentToken.equals(value); + } + } + + /** + * Return true if current token is value. + */ + private boolean currentTokenEquals(char value) { + return currentTokenEquals(Character.toString(value)); + } + + /** + * Return true if current token is value. + */ + private boolean currentTokenEquals(String[] values) { + if (values != null) { + for (int i = 0; i < values.length; i++) { + if (values[i].equals(this.currentToken)) { + return true; + } + } + } + + return false; + } + + /** + * Parse the stream. + */ + public void parse() + throws IOException { + initialize(); + nextToken(); + while (this.currentToken != null) { + if (!parseNamespace()) { + parseNodeType(); + } + } + } + + /** + * Parse namespace. Return true if namespace is parsed. + */ + private boolean parseNamespace() + throws IOException { + if (!currentTokenEquals('<')) { + return false; + } + + nextToken(); + String prefix = this.currentToken; + + nextToken(); + if (!currentTokenEquals('=')) { + throw createFailure("Missing '=' in namespace declaration"); + } + + nextToken(); + String uri = this.currentToken; + + nextToken(); + if (!currentTokenEquals('>')) { + throw createFailure("Missing '>' in namespace declaration"); + } + + nextToken(); + addNamespace(prefix, uri); + return true; + } + + /** + * Parse node type. + */ + private void parseNodeType() + throws IOException { + String name = parseNodeTypeName(); + NodeType nt = addNodeType(name); + nt.setSuperTypes(parseSuperTypes()); + parseNodeTypeOptions(nt); + parseChildItemDefs(nt); + } + + /** + * Parse node type name. + */ + private String parseNodeTypeName() + throws IOException { + if (!currentTokenEquals('[')) { + throw createFailure("Missing '[' delimiter for beginning of node type name"); + } + + nextToken(); + String name = this.currentToken; + + nextToken(); + if (!currentTokenEquals(']')) { + throw createFailure("Missing ']' delimiter for end of node type name"); + } + + nextToken(); + return name; + } + + /** + * Parse string list names. + */ + private List parseStringList() + throws IOException { + ArrayList list = new ArrayList(); + while (true) { + nextToken(); + list.add(this.currentToken); + + nextToken(); + if (!currentTokenEquals(',')) { + break; + } + } + + return list; + } + + /** + * Parse super type names. + */ + private List parseSuperTypes() + throws IOException { + if (!currentTokenEquals('>')) { + return null; + } + + return parseStringList(); + } + + /** + * Parse the node type options. + */ + private void parseNodeTypeOptions(NodeType nt) + throws IOException { + if (currentTokenEquals(TOK_ORDERABLE)) { + nt.setOrderable(true); + nextToken(); + if (currentTokenEquals(TOK_MIXIN)) { + nt.setMixin(true); + nextToken(); + } + } else if (currentTokenEquals(TOK_MIXIN)) { + nt.setMixin(true); + nextToken(); + if (currentTokenEquals(TOK_ORDERABLE)) { + nt.setOrderable(true); + nextToken(); + } + } + } + + /** + * Parse child item definitions. + */ + private void parseChildItemDefs(NodeType nt) + throws IOException { + while (currentTokenEquals('-') || currentTokenEquals('+')) { + if (currentTokenEquals('-')) { + parsePropertyDef(nt); + } else if (currentTokenEquals('+')) { + parseChildNodeDef(nt); + } + } + } + + /** + * Parse property definition. + */ + private void parsePropertyDef(NodeType nt) + throws IOException { + nextToken(); + PropertyDef def = new PropertyDef(this.currentToken); + nt.addItemDef(def); + + nextToken(); + parsePropertyType(def); + def.setDefaultValues(parsePropertyDefaultValues()); + parseChildItemOptions(def); + def.setConstraints(parsePropertyConstraints()); + } + + /** + * Parse the property type. + */ + private void parsePropertyType(PropertyDef def) + throws IOException { + def.setRequiredType(PropertyDef.TYPE_STRING); + if (currentTokenEquals('(')) { + nextToken(); + if (currentTokenEquals(TOK_STRING)) { + def.setRequiredType(PropertyDef.TYPE_STRING); + } else if (currentTokenEquals(TOK_BINARY)) { + def.setRequiredType(PropertyDef.TYPE_BINARY); + } else if (currentTokenEquals(TOK_LONG)) { + def.setRequiredType(PropertyDef.TYPE_LONG); + } else if (currentTokenEquals(TOK_DOUBLE)) { + def.setRequiredType(PropertyDef.TYPE_DOUBLE); + } else if (currentTokenEquals(TOK_BOOLEAN)) { + def.setRequiredType(PropertyDef.TYPE_BOOLEAN); + } else if (currentTokenEquals(TOK_DATE)) { + def.setRequiredType(PropertyDef.TYPE_DATE); + } else if (currentTokenEquals(TOK_NAME)) { + def.setRequiredType(PropertyDef.TYPE_NAME); + } else if (currentTokenEquals(TOK_PATH)) { + def.setRequiredType(PropertyDef.TYPE_PATH); + } else if (currentTokenEquals(TOK_REFERENCE)) { + def.setRequiredType(PropertyDef.TYPE_REFERENCE); + } else if (currentTokenEquals(TOK_UNDEFINED)) { + def.setRequiredType(PropertyDef.TYPE_UNDEFINED); + } else { + throw createFailure("Unkown property type '" + this.currentToken + "' specified"); + } + + nextToken(); + if (!currentTokenEquals(')')) { + throw createFailure("Missing ')' delimiter for end of property type"); + } + + nextToken(); + } + } + + /** + * Parse property default values. + */ + private List parsePropertyDefaultValues() + throws IOException { + if (!currentTokenEquals('=')) { + return null; + } + + return parseStringList(); + } + + /** + * Parse property constraints. + */ + private List parsePropertyConstraints() + throws IOException { + if (!currentTokenEquals('<')) { + return null; + } + + return parseStringList(); + } + + /** + * Parse child item options. + */ + private void parseChildItemOptions(ItemDef def) + throws IOException { + def.setOnParentVersion(ItemDef.OPV_COPY); + while (true) { + if (currentTokenEquals(TOK_PRIMARY)) { + def.setPrimary(true); + } else if (currentTokenEquals(TOK_AUTOCREATED)) { + def.setAutoCreated(true); + } else if (currentTokenEquals(TOK_MANDATORY)) { + def.setMandatory(true); + } else if (currentTokenEquals(TOK_PROTECTED)) { + def.setProtected(true); + } else if (currentTokenEquals(TOK_MULTIPLE)) { + def.setMultiple(true); + } else if (currentTokenEquals(TOK_COPY)) { + def.setOnParentVersion(ItemDef.OPV_COPY); + } else if (currentTokenEquals(TOK_VERSION)) { + def.setOnParentVersion(ItemDef.OPV_VERSION); + } else if (currentTokenEquals(TOK_INITIALIZE)) { + def.setOnParentVersion(ItemDef.OPV_INITIALIZE); + } else if (currentTokenEquals(TOK_COMPUTE)) { + def.setOnParentVersion(ItemDef.OPV_COMPUTE); + } else if (currentTokenEquals(TOK_IGNORE)) { + def.setOnParentVersion(ItemDef.OPV_IGNORE); + } else if (currentTokenEquals(TOK_ABORT)) { + def.setOnParentVersion(ItemDef.OPV_ABORT); + } else { + break; + } + + nextToken(); + } + } + + /** + * Parse child node definition. + */ + private void parseChildNodeDef(NodeType nt) + throws IOException { + nextToken(); + NodeDef def = new NodeDef(this.currentToken); + nt.addItemDef(def); + + nextToken(); + def.setRequiredPrimaryTypes(parseChildNodeRequiredTypes()); + def.setDefaultPrimaryType(parseChildNodeDefaultType()); + parseChildItemOptions(def); + } + + /** + * Parse child node required types. + */ + private List parseChildNodeRequiredTypes() + throws IOException { + if (!currentTokenEquals('(')) { + return null; + } + + List list = parseStringList(); + if (!currentTokenEquals(')')) { + throw createFailure("Missing ')' delimiter for end of child node required types"); + } + + nextToken(); + return list; + } + + /** + * Parse child node default type. + */ + private String parseChildNodeDefaultType() + throws IOException { + if (!currentTokenEquals('=')) { + return null; + } + + nextToken(); + String defaultType = this.currentToken; + nextToken(); + + return defaultType; + } + + + /** + * Return a failure message. + */ + private IOException createFailure(String message) { + return createFailure(message, null); + } + + /** + * Return a failure message. + */ + private IOException createFailure(String message, Throwable cause) { + IOException e = new IOException(createFailureMessage(message)); + if (cause != null) { + e.initCause(cause); + } + + return e; + } + + /** + * Create failure message. + */ + private String createFailureMessage(String message) { + StringBuffer str = new StringBuffer(message); + str.append(" [").append(getSystemId()).append(":"); + str.append(this.tok.lineno()).append("]"); + return str.toString(); + } +} Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/CNDNodeTypeParser.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/NodeTypeParser.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/NodeTypeParser.java?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/NodeTypeParser.java (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/NodeTypeParser.java Mon Oct 9 10:11:42 2006 @@ -0,0 +1,148 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ntdoc.parser; + +import java.io.*; +import java.util.*; + +import org.apache.jackrabbit.ntdoc.model.*; + +/** + * This class defines the parser. + */ +public abstract class NodeTypeParser { + /** + * System id. + */ + private String systemId; + + /** + * Reader. + */ + private InputStream stream; + + /** + * Node Types. + */ + private final NodeTypeSet nodeTypes; + + /** + * Namespace mapping. + */ + private final HashMap namespaces; + + /** + * Construct the parser. + */ + public NodeTypeParser() { + this.nodeTypes = new NodeTypeSet(); + this.namespaces = new HashMap(); + } + + /** + * Return the reader. + */ + public InputStream getInputStream() { + return this.stream; + } + + /** + * Set the reader. + */ + public void setInputStream(InputStream stream) { + this.stream = stream; + } + + /** + * Return the reader. + */ + public Reader getReader() { + return new InputStreamReader(getInputStream()); + } + + /** + * Return the system id. + */ + public String getSystemId() { + return this.systemId; + } + + /** + * Set the system id. + */ + public void setSystemId(String systemId) { + this.systemId = systemId; + } + + /** + * Return the node types. + */ + public NodeTypeSet getNodeTypes() { + return this.nodeTypes; + } + + /** + * Add namespace declaration. + */ + protected void addNamespace(String prefix, String uri) + throws IOException { + this.namespaces.put(prefix, uri); + } + + /** + * Return prefix from name. + */ + private String getPrefix(String ntName) { + int pos = ntName.indexOf(':'); + if (pos > -1) { + return ntName.substring(0, pos); + } else { + return null; + } + } + + /** + * Return namespace from node type name. + */ + private String getNamespace(String ntName) { + String uri = null; + String prefix = getPrefix(ntName); + + if (prefix != null) { + uri = (String) this.namespaces.get(prefix); + } + + return uri != null ? uri : ""; + } + + /** + * Create a node type. + */ + protected NodeType addNodeType(String name) + throws IOException { + NodeType nt = new NodeType(name); + nt.setNamespace(getNamespace(name)); + this.nodeTypes.addNodeType(nt); + return nt; + } + + /** + * Parse the file. + */ + public abstract void parse() + throws IOException; +} Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/NodeTypeParser.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/NodeTypeParserFactory.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/NodeTypeParserFactory.java?view=auto&rev=454430 ============================================================================== --- jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/NodeTypeParserFactory.java (added) +++ jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/NodeTypeParserFactory.java Mon Oct 9 10:11:42 2006 @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ntdoc.parser; + +import java.io.*; + +/** + * This class defines the node type parser helper. + */ +public final class NodeTypeParserFactory { + /** + * Return the parser for extension. + */ + public static NodeTypeParser newParser(String ext) + throws IOException { + if (ext.equalsIgnoreCase("cnd")) { + return new CNDNodeTypeParser(); + } else if (ext.equalsIgnoreCase("xml")) { + return new XMLNodeTypeParser(); + } else { + throw new IOException("Extension '" + ext + "' is not supported"); + } + } + + /** + * Create a new parser for file. + */ + public static NodeTypeParser newParser(File file) + throws IOException { + String systemId = file.getPath(); + InputStream in = new FileInputStream(file); + return newParser(systemId, in); + } + + /** + * Create a new parser for reader. + */ + public static NodeTypeParser newParser(String systemId, InputStream in) + throws IOException { + int pos = systemId.lastIndexOf('.'); + NodeTypeParser parser = newParser(pos > -1 ? systemId.substring(pos + 1) : ""); + parser.setSystemId(systemId); + parser.setInputStream(in); + return parser; + } +} Propchange: jackrabbit/trunk/contrib/jackrabbit-ntdoc/src/main/java/org/apache/jackrabbit/ntdoc/parser/NodeTypeParserFactory.java ------------------------------------------------------------------------------ svn:eol-style = native