src/0000755000000000000000000000000012124530534010342 5ustar rootrootsrc/doc/0000755000000000000000000000000012124530526011110 5ustar rootrootsrc/doc/manpage.xml0000644000000000000000000004011312124530526013241 0ustar rootroot Michael Fuchs Software Engineer herold herold 1 User Commands herold HTML to DocBook converter herold OPTIONS Description The reuse of HTML content in presentation-neutral form is a frequent problem. One possible solution is to convert HTML to DocBook XML, because DocBook is a semantic markup language for documentation, which enables its users to create document content that captures the logical structure of the content. The command line tool herold can be used to convert HTML to DocBook. Because HTML elements are often used not as intended, the possibilities for such a transformation are somewhat limited. herold is part of the dbdoclet suite of tools. For more information visit http://www.dbdoclet.org. Options --docbook-add-index, -x Automatically add an index element at the end of the document. --docbook-decompose-tables, -T Decomposes the tables from the HTML code into single paragraphs. This can be useful, if a document contains a lot of tables for formatting reasons. --docbook-encoding, -d Specifies the encoding of the generated DocBook XML files. --docbook-root-element, -r The root element of the document. Possible values are: book, article, reference, part, chapter or section. The default value for this option is 'article' --docbook-title, -t The title for the resulting document. --in, -i Specifies the HTML input file. --help, -h Prints a help page on the console. --html-encoding, -s Specifies the encoding of the HTML source files, such as ISO-8859-1. --out, -o Specifies the DocBook XML destination file. --profile, -p A profile file with predefined settings. --verbose, v Enables the verbosity for the console output. --version, -V Displays the version of herold. Configuration The details of a transformation are controlled by a profile file. A profile file offers more possibilities to influence the transformation than the command line arguments. The following example shows a typical profile file. transformation html2docbook; section section-detection { attribute-class = ["^MsoHeading(\d+)$"]; section-numbering-pattern = "((\d+\.)+)?\d*\.?\p{Z}*"; } section list-detection { itemized-attribute-class = ["^MsoListBullet(\w*)$", "Aufzhlung(\w+)$]; itemized-strip-prefix = [ "-", "o", "\u00b7" ]; ordered-attribute-class = ["^MsoListNumbered(\w*)$"]; ordered-strip-prefix = [ "\d+\.\s+" ]; } section HTML { encoding = "windows-1252"; exclude = [ "//p[starts-with(@class, 'MsoToc')]", "" ]; } section DocBook { abstract = """<title>Lorem ipsum</title> <para>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.sed, dolor amet.</para>"""; add-index = true; author-email = "me@somewhere.de"; author-firstname = "Michael"; author-surname = "Fuchs"; collapse-protected-space = "true"; copyright-holder = "Ingenieurbüro Michael Fuchs"; copyright-year = "2012"; corporation = ""; create-condition-attribute = false; create-prolog = true; create-remap-attribute = false; create-xref-label = false; decompose-tables = false; detect-trapped-br = true; documentation-id = "doc01"; document-element = "book"; encoding = "UTF-8"; hyphenation-char = "soft-hyphen"; image-data-formats = [ "gif", "base64" ]; image-path = "./figures"; language = "de"; release-info = "Version 3.1"; table-style = "all"; title = "Tutorial"; title-normalize-space = true; use-absolute-image-path = false; } Syntax A profile file consists mainly of sections. Sections are used to group parameters which share the same context. Every section must start with the keyword section followed by the name of the section. After the name comes the block of parameters, which is surrounded by curly braces. Parameters can be of type String, Number, Boolean or Array. Strings must be framed with double quotes. If the String contains newlines, use three double quotes instead of one. Arrays are framed with square brackets. Inside an array, the elements must be comma separated. Every assignment must be finished by a semicolon. Multi line comments have the form /* my comment */ , single line comments look like // my comment\n. Mandatory Elements A profile for herold must start with the line transformation html2docbook;. Section section-detection The section section-detection is used to detect section elements in HTML code and to strip off any numbering prefix from the titles. Many authoring tools allow deeply nested sections. While exporting HTML, it happens, that the nesting becomes deeper than six levels. HTML provides header elements for up to six levels, h1-h6, but no h7 or even more. At this point, the formatting is normally done with the help of CSS and div or p elements. herold is able to detect the header element of HTML, but it can not know about the export format of a specific tool. To solve this problem even for some cases, you can specify the parameter attribute-class. It consists of a list of regular expressions, which are matched against the class attribute of each HTML element. If a match is found, the element is considered as a section element. The regular expression can have group, which is interpreted as level indicator. The group must be the first group and it must match against a number, e.g. ^heading(\d+)$. If the level can not be detected, a level of seven is assumed. Because DocBook XSL stylesheets take care of the section numbering while transforming the DocBook XML to a specific output, it is often necessary to strip the numbering already defined in the HTML page. Otherwise you end up with two numbering texts in front of your titles. To help herold with the detection of numbering patterns, use the parameter section-numbering-pattern. attribute-class A regular expression, which is applied to every p and div element. If the expression matches, the current element is handled as a section element. If the regular expression has groups, the first group will be used as nesting level, otherwise level seven is assumed. section-numbering-pattern Normally you want to get rid of the section numbering that comes with the HTML data, because it becomes part of the title text in DocBook. The section numbers will the appear twice in your target media. One from HTML and one from the DocBook XSL processing. The parameter section-numbering-pattern defines a regular expression, which is matched against the beginning of every section title. If it matches, the matching part is removed. Section list-detection Sometimes lists are not represented with ul, ol or dl tags, but they are represented as p tags with additional css formatting. If you use a tool, which creates or exports HTML with such a construct, the conversion will end up with para elements, instead of the corresponding list elements in DocBook. To recreate the lists in some cases, you can use the section list-detection. The parameters itemized-attribute-class and ordered-attribute-class let you define lists of regular expression, which match against listitems in the HTML. herold tries to rebuild the proper list structure from this information, even for nested lists. Section HTML The section HTML defines parameters, which control the loading and parsing of the HTML input data. encoding The character set used to read the input stream. exclude Defines an array of xpath expressions. All matches are removed from the HTML DOM tree before transformation. Section DocBook abstract The text for the abstract element of the info section. If the text is structured with newlines, use three double quotes as delimiters. If the text starts with a "<" character, it is embedded into an abstract element, otherwise the text is embedded into an para element inside of an abstract element. The text will parsed and can contain DocBook elements. add-index If set to true, an index element is inserted at the end of the DocBook XML. create-xref-label if set to false, anchor elements doesn't get a xreflabel attribute. decompose-tables If set to true, tables structures will be ignored. The content of the table cells will be inserted into the DocBook XML as a sequence of paragraphs. This parameter can be useful if your HTML contains tables for formatting purposes. Normally you want to get rid of them, because they tamper the logical structure. document-element The document element you want to use. Must be one of article, book, part or reference. encoding The character set which will be used for writing the output file. image-data-formats An array of image formats. These formats will be inserted as imageobject elements, additionally to the format found in the src attribute of the corresponding img element. The original format is inserted twice with the roles "html" and "fo". The other formats are inserted as "html-<FORMAT>" and "fo-<FORMAT>". title The title of the resulting document. If this parameter is undefined, herold tries to dected the title from the head section of the HTML data. use-absolute-image-path If you want absolute image paths in the fileref attribute of the imagedata element, set this parameter to true. Copyright Copyright 2001-2013 Michael Fuchs. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. src/conf/0000755000000000000000000000000012124530526011270 5ustar rootrootsrc/conf/config.properties0000644000000000000000000000773712124530526014671 0ustar rootroot# 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. # # Framework config properties. # # To override the packages the framework exports by default from the # class path, set this variable. #org.osgi.framework.system.packages= # To append packages to the default set of exported system packages, # set this value. #org.osgi.framework.system.packages.extra= # The following property makes specified packages from the class path # available to all bundles. You should avoid using this property. #org.osgi.framework.bootdelegation=sun.*,com.sun.* # Felix tries to guess when to implicitly boot delegate in certain # situations to ease integration without outside code. This feature # is enabled by default, uncomment the following line to disable it. #felix.bootdelegation.implicit=false # The following property explicitly specifies the location of the bundle # cache, which defaults to "felix-cache" in the current working directory. # If this value is not absolute, then the felix.cache.rootdir controls # how the absolute location is calculated. (See next property) #org.osgi.framework.storage=${felix.cache.rootdir}/felix-cache # The following property is used to convert a relative bundle cache # location into an absolute one by specifying the root to prepend to # the relative cache path. The default for this property is the # current working directory. #felix.cache.rootdir=${user.dir} # The following property controls whether the bundle cache is flushed # the first time the framework is initialized. Possible values are # "none" and "onFirstInit"; the default is "none". #org.osgi.framework.storage.clean=onFirstInit # The following property determines which actions are performed when # processing the auto-deploy directory. It is a comma-delimited list of # the following values: 'install', 'start', 'update', and 'uninstall'. # An undefined or blank value is equivalent to disabling auto-deploy # processing. felix.auto.deploy.action=install,start # The following property specifies the directory to use as the bundle # auto-deploy directory; the default is 'bundle' in the working directory. #felix.auto.deploy.dir=bundle # The following property is a space-delimited list of bundle URLs # to install when the framework starts. The ending numerical component # is the target start level. Any number of these properties may be # specified for different start levels. #felix.auto.install.1= # The following property is a space-delimited list of bundle URLs # to install and start when the framework starts. The ending numerical # component is the target start level. Any number of these properties # may be specified for different start levels. #felix.auto.start.1= felix.log.level=1 # Sets the initial start level of the framework upon startup. #org.osgi.framework.startlevel.beginning=1 # Sets the start level of newly installed bundles. #felix.startlevel.bundle=1 # Felix installs a stream and content handler factories by default, # uncomment the following line to not install them. #felix.service.urlhandlers=false # The launcher registers a shutdown hook to cleanly stop the framework # by default, uncomment the following line to disable it. #felix.shutdown.hook=false # # Bundle config properties. # org.osgi.service.http.port=8080 obr.repository.url=http://felix.apache.org/obr/releases.xml src/conf/log4j.xml0000644000000000000000000000175012124530526013034 0ustar rootroot src/icons/0000755000000000000000000000000012124530526011456 5ustar rootrootsrc/icons/48x48/0000755000000000000000000000000012124530526012255 5ustar rootrootsrc/icons/48x48/herold.ico0000644000000000000000000002170612124530526014234 0ustar rootroothF v 00( @"s‚YGrhE);<Ť:SAvڣQXPu/h~8ZOlEyI>)GvUƇ7GQS2̜ZbqtYeEb'{EđV$geΦ3M{J4ԛTƍ`HGȊRo{YEj`Nqo>ϙTɑXKQ#vKy<C#i 8IE$h٢QӚTDI4|ZGP HHEcGqKz9'L ?HB @L 2J &!#403+*46$;/ 8(GF. :K1IO5%"MD<>5N7P- ,)ECA=????????(0"sW?YȎ®o5lCHI}{<٬uGXu5FvFo^4]Vw֞Sl{(9*qőmܽ[zc>xXI0:~^P`i΢E]F]cKqMM]Vvb͜ʒV#{ӹm$d\htYUB ɼ5zG/dYI<{4ESŃKzPZfw[Rl5'rWh[WŗEb xaїU!|ݧO%lMtŇYL6IP^0;|7yY+iHB٣QȌXASV~ZEj#xIv!#h=I1I8Ef6( WΖU͒W֞VƒYI5z[9C$iGOGq$f:?~YEaKuE` }RĄ$g՝SҘU:јVBD}YJ1xYHCHHGpL{ݧN$f$hڣQ٢Q֝SCEјUňY‚YI1tYI6I=HHGPEaEgEkGpLzEm} m}}m}}~fm}}_m}}i6u v`z-  |:Y*h7S:ex(@O\Jd.s/ =C!A;5TVaL%&Zw>")cB{p$^#yNHcB<jrI9 q?Glr'[2X1lQK3g+MlFPD4Rt]8oUnb,k0W??( @"rƒY?\ʒʢQlFGOEQƫD΢NfCBK`ElhHU#iSÏ[ܼɑXKyVăѠT`I2I>JH-~Yʢ ?ΒVAx!ܦOE_'t֞RM8HIņY&g(TЖUFRc͞e"1:Mb4[NwRĀEhId#yBuY,I0KSuZȐ%q>ʎWFoEI;$kʼnYIwM{WNj@|Y:u$g%5GSFaJr #k$e%i<D̑VȎXYI3H@HFI5 }!#hןSgwYtYFmQt!$h"s$fڣQ%h+ԛTԚU28їU699AˑWFzYrZI<IEHJE`EiGpJxLzN~O!$d٣QןRЖV?7ʨ777 777 777777Bs˝777ʨ777QS kP79q$K; qgRUI46q^6ؽ]8/HWZo:nb_dmG`i<}_A3(#X |b[F"L)c+*b>&ae҄C,Tb2 eе5~-N=O e5χDxNl% 5uxNw! tVxN'z@vxNæhYMrĤ10.{j?߿fp➶E괋 J\yז?0?(0` "sƒY?^˖ƹtZoCKObP۴:?y*kȡu{xDY>ڤPIvF,̦sZC~am5}gZ/é;Pm~PWfU;cmoB_"P'xHkt=˗sV_l[0qYִcR;sG?{7nFbϔPVńKUΡ%c9~81j/JD#Gœ^cz*`7sաagϣqյ";Rg/ssI2Z9IH/{``Xv֮ÇeI@R+̜ZDcM|X\ƠS.Uڼ|}V/lOmycORzYȎ^o;pwXElOa(7ԛTŐx;yʍX_HX%jʚ~FS>${|^-yƫ_BʡީND)|_bxY2hHHPÀuI//j4c͝bջ&rVЖUʼnZu_DaN2'|\5oެGiB~YE^ZǗI:OAMԤPB?L{pXxZ *9hMeGp%o3^\L[GSF]:~:u>}$g7E#ןR._x^EgOrTň%vKtY!}5fƇX}\&AHF]GN?ȎZHD`̑W\ʓWŋ"wF111111111J :dJiT ]4d˾먨?Үh =먨q\Nx=먨~[=먨'mk#=먨9sFb먨>p ؼWW(E7?WVf$웠Ot妱VCLa6{ Az~Ve).r2-@jj<~&^UQ0jjjjj}B~ªujjjjjG5*"yujjjjGc_ۖujjjGIIZ/ujjIIHuujjԍIێuunXԍIII!, ӇԍIImRلMԍII+;ӇKoԍIIIKv8ߗԍԫ|3l֗ߗ3SwѺ̫֗``1V֗P``1VVPPP``1VPPYΉȜg%D%P??src/profiles/0000755000000000000000000000000012124530526012166 5ustar rootrootsrc/profiles/part.her0000644000000000000000000000030212124530526013627 0ustar rootroottransformation html2docbook; section HTML { encoding = "UTF-8"; section-numbering-pattern = "((\d+\.)+)?\d*\.?\p{Z}*"; } section DocBook { document-element = "part"; encoding = "UTF-8"; } src/profiles/book.her0000644000000000000000000000032512124530526013620 0ustar rootroottransformation html2docbook; section HTML { encoding = "UTF-8"; section-numbering-pattern = "((\d+\.)+)?\d*\.?\p{Z}*"; } section DocBook { document-element = "book"; encoding = "UTF-8"; add-index = true; } src/profiles/paragraph.her0000644000000000000000000000030712124530526014633 0ustar rootroottransformation html2docbook; section HTML { encoding = "UTF-8"; section-numbering-pattern = "((\d+\.)+)?\d*\.?\p{Z}*"; } section DocBook { document-element = "paragraph"; encoding = "UTF-8"; } src/profiles/default.her0000644000000000000000000000032712124530526014314 0ustar rootroottransformation html2docbook; section HTML { encoding = "UTF-8"; section-numbering-pattern = "((\d+\.)+)?\d*\.?\p{Z}*"; } section DocBook { encoding = "UTF-8"; add-index = true; emphasis-role-bold = "bold"; } src/profiles/section.her0000644000000000000000000000030512124530526014330 0ustar rootroottransformation html2docbook; section HTML { encoding = "UTF-8"; section-numbering-pattern = "((\d+\.)+)?\d*\.?\p{Z}*"; } section DocBook { document-element = "section"; encoding = "UTF-8"; } src/profiles/word.her0000644000000000000000000000117612124530526013646 0ustar rootroottransformation html2docbook; /** * Transformation of HTML exported from Winword 2003 as filtered HTML. */ section section-detection { attribute-class = ["^MsoHeading(\d+)$"]; section-numbering-pattern = "((\d+\.)+)?\d*\.?\p{Z}*"; } section list-detection { itemized-attribute-class = ["^MsoListBullet(\w*)$"]; itemized-strip-prefix = [ "-", "\u00b7" ]; ordered-attribute-class = ["^MsoListNumbered(\w*)$"]; ordered-strip-prefix = [ "\d+\.\s+" ]; } section HTML { encoding = "windows-1252"; exclude = [ "//p[starts-with(@class, 'MsoToc')]" ]; } section DocBook { encoding = "UTF-8"; collapse-protected-space = true; } src/profiles/article.her0000644000000000000000000000030512124530526014307 0ustar rootroottransformation html2docbook; section HTML { encoding = "UTF-8"; section-numbering-pattern = "((\d+\.)+)?\d*\.?\p{Z}*"; } section DocBook { document-element = "article"; encoding = "UTF-8"; } src/profiles/chapter.her0000644000000000000000000000030512124530526014312 0ustar rootroottransformation html2docbook; section HTML { encoding = "UTF-8"; section-numbering-pattern = "((\d+\.)+)?\d*\.?\p{Z}*"; } section DocBook { document-element = "chapter"; encoding = "UTF-8"; } src/profiles/reference.her0000644000000000000000000000030712124530526014624 0ustar rootroottransformation html2docbook; section HTML { encoding = "UTF-8"; section-numbering-pattern = "((\d+\.)+)?\d*\.?\p{Z}*"; } section DocBook { document-element = "reference"; encoding = "UTF-8"; } src/build.xml0000644000000000000000000000150412124530526012164 0ustar rootroot src/java/0000755000000000000000000000000012124530526011264 5ustar rootrootsrc/java/org/0000755000000000000000000000000012124530526012053 5ustar rootrootsrc/java/org/dbdoclet/0000755000000000000000000000000012124530534013632 5ustar rootrootsrc/java/org/dbdoclet/FileAccessDeniedException.java0000644000000000000000000000061112124530526021465 0ustar rootrootpackage org.dbdoclet; import java.io.File; public class FileAccessDeniedException extends RuntimeException { /** * */ private static final long serialVersionUID = 1L; private File file; public FileAccessDeniedException(File file) { super(file.getAbsolutePath()); this.file = file; } public File getFile() { return file; } } src/java/org/dbdoclet/trafo/0000755000000000000000000000000012124530534014745 5ustar rootrootsrc/java/org/dbdoclet/trafo/xml/0000755000000000000000000000000012124530526015546 5ustar rootrootsrc/java/org/dbdoclet/trafo/xml/tokenizer/0000755000000000000000000000000012124530526017560 5ustar rootrootsrc/java/org/dbdoclet/trafo/xml/tokenizer/parser/0000755000000000000000000000000012124530526021054 5ustar rootrootsrc/java/org/dbdoclet/trafo/xml/tokenizer/parser/SimpleCharStream.java0000644000000000000000000002674112124530526025134 0ustar rootroot/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package org.dbdoclet.trafo.xml.tokenizer.parser; /** * An implementation of interface CharStream, where the stream is assumed to * contain only ASCII characters (without unicode processing). */ @SuppressWarnings("all") public class SimpleCharStream { /** Whether parser is static. */ public static final boolean staticFlag = false; int bufsize; int available; int tokenBegin; /** Position in buffer. */ public int bufpos = -1; protected int bufline[]; protected int bufcolumn[]; protected int column = 0; protected int line = 1; protected boolean prevCharIsCR = false; protected boolean prevCharIsLF = false; protected java.io.Reader inputStream; protected char[] buffer; protected int maxNextCharInd = 0; protected int inBuf = 0; protected int tabSize = 8; protected void setTabSize(int i) { tabSize = i; } protected int getTabSize(int i) { return tabSize; } protected void ExpandBuff(boolean wrapAround) { char[] newbuffer = new char[bufsize + 2048]; int newbufline[] = new int[bufsize + 2048]; int newbufcolumn[] = new int[bufsize + 2048]; try { if (wrapAround) { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); bufcolumn = newbufcolumn; maxNextCharInd = (bufpos += (bufsize - tokenBegin)); } else { System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); buffer = newbuffer; System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); bufline = newbufline; System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); bufcolumn = newbufcolumn; maxNextCharInd = (bufpos -= tokenBegin); } } catch (Throwable t) { throw new Error(t.getMessage()); } bufsize += 2048; available = bufsize; tokenBegin = 0; } protected void FillBuff() throws java.io.IOException { if (maxNextCharInd == available) { if (available == bufsize) { if (tokenBegin > 2048) { bufpos = maxNextCharInd = 0; available = tokenBegin; } else if (tokenBegin < 0) bufpos = maxNextCharInd = 0; else ExpandBuff(false); } else if (available > tokenBegin) available = bufsize; else if ((tokenBegin - available) < 2048) ExpandBuff(true); else available = tokenBegin; } int i; try { if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) { inputStream.close(); throw new java.io.IOException(); } else maxNextCharInd += i; return; } catch(java.io.IOException e) { --bufpos; backup(0); if (tokenBegin == -1) tokenBegin = bufpos; throw e; } } /** Start. */ public char BeginToken() throws java.io.IOException { tokenBegin = -1; char c = readChar(); tokenBegin = bufpos; return c; } protected void UpdateLineColumn(char c) { column++; if (prevCharIsLF) { prevCharIsLF = false; line += (column = 1); } else if (prevCharIsCR) { prevCharIsCR = false; if (c == '\n') { prevCharIsLF = true; } else line += (column = 1); } switch (c) { case '\r' : prevCharIsCR = true; break; case '\n' : prevCharIsLF = true; break; case '\t' : column--; column += (tabSize - (column % tabSize)); break; default : break; } bufline[bufpos] = line; bufcolumn[bufpos] = column; } /** Read a character. */ public char readChar() throws java.io.IOException { if (inBuf > 0) { --inBuf; if (++bufpos == bufsize) bufpos = 0; return buffer[bufpos]; } if (++bufpos >= maxNextCharInd) FillBuff(); char c = buffer[bufpos]; UpdateLineColumn(c); return c; } @Deprecated /** * @deprecated * @see #getEndColumn */ public int getColumn() { return bufcolumn[bufpos]; } @Deprecated /** * @deprecated * @see #getEndLine */ public int getLine() { return bufline[bufpos]; } /** Get token end column number. */ public int getEndColumn() { return bufcolumn[bufpos]; } /** Get token end line number. */ public int getEndLine() { return bufline[bufpos]; } /** Get token beginning column number. */ public int getBeginColumn() { return bufcolumn[tokenBegin]; } /** Get token beginning line number. */ public int getBeginLine() { return bufline[tokenBegin]; } /** Backup a number of characters. */ public void backup(int amount) { inBuf += amount; if ((bufpos -= amount) < 0) bufpos += bufsize; } /** Constructor. */ public SimpleCharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; } /** Constructor. */ public SimpleCharStream(java.io.Reader dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } /** Constructor. */ public SimpleCharStream(java.io.Reader dstream) { this(dstream, 1, 1, 4096); } /** Reinitialise. */ public void ReInit(java.io.Reader dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; if (buffer == null || buffersize != buffer.length) { available = bufsize = buffersize; buffer = new char[buffersize]; bufline = new int[buffersize]; bufcolumn = new int[buffersize]; } prevCharIsLF = prevCharIsCR = false; tokenBegin = inBuf = maxNextCharInd = 0; bufpos = -1; } /** Reinitialise. */ public void ReInit(java.io.Reader dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } /** Reinitialise. */ public void ReInit(java.io.Reader dstream) { ReInit(dstream, 1, 1, 4096); } /** Constructor. */ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } /** Constructor. */ public SimpleCharStream(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); } /** Constructor. */ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException { this(dstream, encoding, startline, startcolumn, 4096); } /** Constructor. */ public SimpleCharStream(java.io.InputStream dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } /** Constructor. */ public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { this(dstream, encoding, 1, 1, 4096); } /** Constructor. */ public SimpleCharStream(java.io.InputStream dstream) { this(dstream, 1, 1, 4096); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, int startline, int startcolumn, int buffersize) { ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { ReInit(dstream, encoding, 1, 1, 4096); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream) { ReInit(dstream, 1, 1, 4096); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, String encoding, int startline, int startcolumn) throws java.io.UnsupportedEncodingException { ReInit(dstream, encoding, startline, startcolumn, 4096); } /** Reinitialise. */ public void ReInit(java.io.InputStream dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } /** Get token literal value. */ public String GetImage() { if (bufpos >= tokenBegin) return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); else return new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); } /** Get the suffix. */ public char[] GetSuffix(int len) { char[] ret = new char[len]; if ((bufpos + 1) >= len) System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); else { System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); } return ret; } /** Reset buffer when finished. */ public void Done() { buffer = null; bufline = null; bufcolumn = null; } /** * Method to adjust line and column numbers for the start of a token. */ public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; if (bufpos >= tokenBegin) { len = bufpos - tokenBegin + inBuf + 1; } else { len = bufsize - tokenBegin + bufpos + 1 + inBuf; } int i = 0, j = 0, k = 0; int nextColDiff = 0, columnDiff = 0; while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { bufline[j] = newLine; nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; bufcolumn[j] = newCol + columnDiff; columnDiff = nextColDiff; i++; } if (i < len) { bufline[j] = newLine++; bufcolumn[j] = newCol + columnDiff; while (i++ < len) { if (bufline[j = start % bufsize] != bufline[++start % bufsize]) bufline[j] = newLine++; else bufline[j] = newLine; } } line = bufline[j]; column = bufcolumn[j]; } } /* JavaCC - OriginalChecksum=9a3504a592609e3b6677f1a2932b2ed9 (do not edit this line) */ src/java/org/dbdoclet/trafo/xml/tokenizer/parser/XmlTokenizerTreeConstants.java0000644000000000000000000000170612124530526027073 0ustar rootroot/* Generated By:JavaCC: Do not edit this line. XmlTokenizerTreeConstants.java Version 5.0 */ package org.dbdoclet.trafo.xml.tokenizer.parser; @SuppressWarnings("all") public interface XmlTokenizerTreeConstants { public int JJTSTART = 0; public int JJTTAG = 1; public int JJTCOMMENT = 2; public int JJTTEXT = 3; public int JJTNCNAME = 4; public int JJTEQUALS = 5; public int JJTATTRNAME = 6; public int JJTATTRVALUE = 7; public int JJTSKIPTO = 8; public int JJTTOATTRIBUTESASTEXT = 9; public int JJTSETPROGRESSLISTENERS = 10; public int JJTFIREPROGRESSEVENT = 11; public int JJTTRACE = 12; public String[] jjtNodeName = { "start", "tag", "comment", "text", "ncname", "equals", "attrName", "attrValue", "skipTo", "toAttributesAsText", "setProgressListeners", "fireProgressEvent", "trace", }; } /* JavaCC - OriginalChecksum=0f63aa722cebb1e2e6c00b0755cc0e11 (do not edit this line) */ src/java/org/dbdoclet/trafo/xml/tokenizer/parser/TokenMgrError.java0000644000000000000000000001057212124530526024464 0ustar rootroot/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */ /* JavaCCOptions: */ package org.dbdoclet.trafo.xml.tokenizer.parser; /** Token Manager Error. */ @SuppressWarnings("all") public class TokenMgrError extends Error { /** * The version identifier for this Serializable class. * Increment only if the serialized form of the * class changes. */ private static final long serialVersionUID = 1L; /* * Ordinals for various reasons why an Error of this type can be thrown. */ /** * Lexical error occurred. */ static final int LEXICAL_ERROR = 0; /** * An attempt was made to create a second instance of a static token manager. */ static final int STATIC_LEXER_ERROR = 1; /** * Tried to change to an invalid lexical state. */ static final int INVALID_LEXICAL_STATE = 2; /** * Detected (and bailed out of) an infinite loop in the token manager. */ static final int LOOP_DETECTED = 3; /** * Indicates the reason why the exception is thrown. It will have * one of the above 4 values. */ int errorCode; /** * Replaces unprintable characters by their escaped (or unicode escaped) * equivalents in the given string */ protected static final String addEscapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0 : continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } continue; } } return retval.toString(); } /** * Returns a detailed message for the Error when it is thrown by the * token manager to indicate a lexical error. * Parameters : * EOFSeen : indicates if EOF caused the lexical error * curLexState : lexical state in which this error occurred * errorLine : line number when the error occurred * errorColumn : column number when the error occurred * errorAfter : prefix that was seen before this error occurred * curchar : the offending character * Note: You can customize the lexical error message by modifying this method. */ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + "after : \"" + addEscapes(errorAfter) + "\""); } /** * You can also modify the body of this method to customize your error messages. * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not * of end-users concern, so you can return something like : * * "Internal Error : Please file a bug report .... " * * from this method for such cases in the release version of your parser. */ public String getMessage() { return super.getMessage(); } /* * Constructors of various flavors follow. */ /** No arg constructor. */ public TokenMgrError() { } /** Constructor with message and reason. */ public TokenMgrError(String message, int reason) { super(message); errorCode = reason; } /** Full Constructor. */ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } /* JavaCC - OriginalChecksum=4018fc262b3912b4de27d74aafb44b22 (do not edit this line) */ src/java/org/dbdoclet/trafo/xml/tokenizer/parser/ParseException.java0000644000000000000000000001411612124530526024653 0ustar rootroot/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */ /* JavaCCOptions:KEEP_LINE_COL=null */ package org.dbdoclet.trafo.xml.tokenizer.parser; /** * This exception is thrown when parse errors are encountered. * You can explicitly create objects of this exception type by * calling the method generateParseException in the generated * parser. * * You can modify this class to customize your error reporting * mechanisms so long as you retain the public fields. */ @SuppressWarnings("all") public class ParseException extends Exception { /** * The version identifier for this Serializable class. * Increment only if the serialized form of the * class changes. */ private static final long serialVersionUID = 1L; /** * This constructor is used by the method "generateParseException" * in the generated parser. Calling this constructor generates * a new object of this type with the fields "currentToken", * "expectedTokenSequences", and "tokenImage" set. */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal ) { super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal)); currentToken = currentTokenVal; expectedTokenSequences = expectedTokenSequencesVal; tokenImage = tokenImageVal; } /** * The following constructors are for use by you for whatever * purpose you can think of. Constructing the exception in this * manner makes the exception behave in the normal way - i.e., as * documented in the class "Throwable". The fields "errorToken", * "expectedTokenSequences", and "tokenImage" do not contain * relevant information. The JavaCC generated code does not use * these constructors. */ public ParseException() { super(); } /** Constructor with message. */ public ParseException(String message) { super(message); } /** * This is the last token that has been consumed successfully. If * this object has been created due to a parse error, the token * followng this token will (therefore) be the first error token. */ public Token currentToken; /** * Each entry in this array is an array of integers. Each array * of integers represents a sequence of tokens (by their ordinal * values) that is expected at this point of the parse. */ public int[][] expectedTokenSequences; /** * This is a reference to the "tokenImage" array of the generated * parser within which the parse error occurred. This array is * defined in the generated ...Constants interface. */ public String[] tokenImage; /** * It uses "currentToken" and "expectedTokenSequences" to generate a parse * error message and returns it. If this object has been created * due to a parse error, and you do not catch it (it gets thrown * from the parser) the correct error message * gets displayed. */ private static String initialise(Token currentToken, int[][] expectedTokenSequences, String[] tokenImage) { String eol = System.getProperty("line.separator", "\n"); StringBuffer expected = new StringBuffer(); int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { maxSize = expectedTokenSequences[i].length; } for (int j = 0; j < expectedTokenSequences[i].length; j++) { expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); } if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { expected.append("..."); } expected.append(eol).append(" "); } String retval = "Encountered \""; Token tok = currentToken.next; for (int i = 0; i < maxSize; i++) { if (i != 0) retval += " "; if (tok.kind == 0) { retval += tokenImage[0]; break; } retval += " " + tokenImage[tok.kind]; retval += " \""; retval += add_escapes(tok.image); retval += " \""; tok = tok.next; } retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; retval += "." + eol; if (expectedTokenSequences.length == 1) { retval += "Was expecting:" + eol + " "; } else { retval += "Was expecting one of:" + eol + " "; } retval += expected.toString(); return retval; } /** * The end of line string for this machine. */ protected String eol = System.getProperty("line.separator", "\n"); /** * Used to convert raw characters to their escaped version * when these raw version cannot be used as part of an ASCII * string literal. */ static String add_escapes(String str) { StringBuffer retval = new StringBuffer(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { case 0 : continue; case '\b': retval.append("\\b"); continue; case '\t': retval.append("\\t"); continue; case '\n': retval.append("\\n"); continue; case '\f': retval.append("\\f"); continue; case '\r': retval.append("\\r"); continue; case '\"': retval.append("\\\""); continue; case '\'': retval.append("\\\'"); continue; case '\\': retval.append("\\\\"); continue; default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); retval.append("\\u" + s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } continue; } } return retval.toString(); } } /* JavaCC - OriginalChecksum=bcba1e3171c5b52c551f24ada466f825 (do not edit this line) */ src/java/org/dbdoclet/trafo/xml/tokenizer/parser/SimpleNode.java0000644000000000000000000000434412124530526023763 0ustar rootroot/* Generated By:JJTree: Do not edit this line. SimpleNode.java Version 4.3 */ /* JavaCCOptions:MULTI=false,NODE_USES_PARSER=false,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package org.dbdoclet.trafo.xml.tokenizer.parser; public @SuppressWarnings("all") class SimpleNode implements Node { protected Node parent; protected Node[] children; protected int id; protected Object value; protected XmlTokenizer parser; public SimpleNode(int i) { id = i; } public SimpleNode(XmlTokenizer p, int i) { this(i); parser = p; } public void jjtOpen() { } public void jjtClose() { } public void jjtSetParent(Node n) { parent = n; } public Node jjtGetParent() { return parent; } public void jjtAddChild(Node n, int i) { if (children == null) { children = new Node[i + 1]; } else if (i >= children.length) { Node c[] = new Node[i + 1]; System.arraycopy(children, 0, c, 0, children.length); children = c; } children[i] = n; } public Node jjtGetChild(int i) { return children[i]; } public int jjtGetNumChildren() { return (children == null) ? 0 : children.length; } public void jjtSetValue(Object value) { this.value = value; } public Object jjtGetValue() { return value; } /* You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding toString() is probably all you need to do. */ public String toString() { return XmlTokenizerTreeConstants.jjtNodeName[id]; } public String toString(String prefix) { return prefix + toString(); } /* Override this method if you want to customize how the node dumps out its children. */ public void dump(String prefix) { System.out.println(toString(prefix)); if (children != null) { for (int i = 0; i < children.length; ++i) { SimpleNode n = (SimpleNode)children[i]; if (n != null) { n.dump(prefix + " "); } } } } } /* JavaCC - OriginalChecksum=9244c0ee103002e3a1afbc2b734b2384 (do not edit this line) */ src/java/org/dbdoclet/trafo/xml/tokenizer/parser/JJTXmlTokenizerState.java0000644000000000000000000000634512124530526025733 0ustar rootroot/* Generated By:JavaCC: Do not edit this line. JJTXmlTokenizerState.java Version 5.0 */ package org.dbdoclet.trafo.xml.tokenizer.parser; @SuppressWarnings("all") public class JJTXmlTokenizerState { private java.util.List nodes; private java.util.List marks; private int sp; // number of nodes on stack private int mk; // current mark private boolean node_created; public JJTXmlTokenizerState() { nodes = new java.util.ArrayList(); marks = new java.util.ArrayList(); sp = 0; mk = 0; } /* Determines whether the current node was actually closed and pushed. This should only be called in the final user action of a node scope. */ public boolean nodeCreated() { return node_created; } /* Call this to reinitialize the node stack. It is called automatically by the parser's ReInit() method. */ public void reset() { nodes.clear(); marks.clear(); sp = 0; mk = 0; } /* Returns the root node of the AST. It only makes sense to call this after a successful parse. */ public Node rootNode() { return nodes.get(0); } /* Pushes a node on to the stack. */ public void pushNode(Node n) { nodes.add(n); ++sp; } /* Returns the node on the top of the stack, and remove it from the stack. */ public Node popNode() { if (--sp < mk) { mk = marks.remove(marks.size()-1); } return nodes.remove(nodes.size()-1); } /* Returns the node currently on the top of the stack. */ public Node peekNode() { return nodes.get(nodes.size()-1); } /* Returns the number of children on the stack in the current node scope. */ public int nodeArity() { return sp - mk; } public void clearNodeScope(Node n) { while (sp > mk) { popNode(); } mk = marks.remove(marks.size()-1); } public void openNodeScope(Node n) { marks.add(mk); mk = sp; n.jjtOpen(); } /* A definite node is constructed from a specified number of children. That number of nodes are popped from the stack and made the children of the definite node. Then the definite node is pushed on to the stack. */ public void closeNodeScope(Node n, int num) { mk = marks.remove(marks.size()-1); while (num-- > 0) { Node c = popNode(); c.jjtSetParent(n); n.jjtAddChild(c, num); } n.jjtClose(); pushNode(n); node_created = true; } /* A conditional node is constructed if its condition is true. All the nodes that have been pushed since the node was opened are made children of the conditional node, which is then pushed on to the stack. If the condition is false the node is not constructed and they are left on the stack. */ public void closeNodeScope(Node n, boolean condition) { if (condition) { int a = nodeArity(); mk = marks.remove(marks.size()-1); while (a-- > 0) { Node c = popNode(); c.jjtSetParent(n); n.jjtAddChild(c, a); } n.jjtClose(); pushNode(n); node_created = true; } else { mk = marks.remove(marks.size()-1); node_created = false; } } } /* JavaCC - OriginalChecksum=7976a7fc6b42226222ed044a2869e827 (do not edit this line) */ src/java/org/dbdoclet/trafo/xml/tokenizer/parser/Token.java0000644000000000000000000001004212124530526022774 0ustar rootroot/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */ /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package org.dbdoclet.trafo.xml.tokenizer.parser; /** * Describes the input token stream. */ @SuppressWarnings("all") public class Token implements java.io.Serializable { /** * The version identifier for this Serializable class. * Increment only if the serialized form of the * class changes. */ private static final long serialVersionUID = 1L; /** * An integer that describes the kind of this token. This numbering * system is determined by JavaCCParser, and a table of these numbers is * stored in the file ...Constants.java. */ public int kind; /** The line number of the first character of this Token. */ public int beginLine; /** The column number of the first character of this Token. */ public int beginColumn; /** The line number of the last character of this Token. */ public int endLine; /** The column number of the last character of this Token. */ public int endColumn; /** * The string image of the token. */ public String image; /** * A reference to the next regular (non-special) token from the input * stream. If this is the last token from the input stream, or if the * token manager has not read tokens beyond this one, this field is * set to null. This is true only if this token is also a regular * token. Otherwise, see below for a description of the contents of * this field. */ public Token next; /** * This field is used to access special tokens that occur prior to this * token, but after the immediately preceding regular (non-special) token. * If there are no such special tokens, this field is set to null. * When there are more than one such special token, this field refers * to the last of these special tokens, which in turn refers to the next * previous special token through its specialToken field, and so on * until the first special token (whose specialToken field is null). * The next fields of special tokens refer to other special tokens that * immediately follow it (without an intervening regular token). If there * is no such token, this field is null. */ public Token specialToken; /** * An optional attribute value of the Token. * Tokens which are not used as syntactic sugar will often contain * meaningful values that will be used later on by the compiler or * interpreter. This attribute value is often different from the image. * Any subclass of Token that actually wants to return a non-null value can * override this method as appropriate. */ public Object getValue() { return null; } /** * No-argument constructor */ public Token() {} /** * Constructs a new token for the specified Image. */ public Token(int kind) { this(kind, null); } /** * Constructs a new token for the specified Image and Kind. */ public Token(int kind, String image) { this.kind = kind; this.image = image; } /** * Returns the image. */ public String toString() { return image; } /** * Returns a new Token object, by default. However, if you want, you * can create and return subclass objects based on the value of ofKind. * Simply add the cases to the switch for all those special cases. * For example, if you have a subclass of Token called IDToken that * you want to create if ofKind is ID, simply add something like : * * case MyParserConstants.ID : return new IDToken(ofKind, image); * * to the following switch statement. Then you can cast matchedToken * variable to the appropriate type and use sit in your lexical actions. */ public static Token newToken(int ofKind, String image) { switch(ofKind) { default : return new Token(ofKind, image); } } public static Token newToken(int ofKind) { return newToken(ofKind, null); } } /* JavaCC - OriginalChecksum=32dcceb3d060b8c3753de8b101388514 (do not edit this line) */ src/java/org/dbdoclet/trafo/xml/tokenizer/parser/XmlTokenizerTokenManager.java0000644000000000000000000010177612124530526026662 0ustar rootroot/* Generated By:JJTree&JavaCC: Do not edit this line. XmlTokenizerTokenManager.java */ package org.dbdoclet.trafo.xml.tokenizer.parser; import java.util.ArrayList; import java.util.HashMap; import java.io.ByteArrayInputStream; import java.io.UnsupportedEncodingException; import org.dbdoclet.progress.ProgressListener; import org.dbdoclet.progress.ProgressEvent; import org.dbdoclet.progress.ProgressManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** Token Manager. */ @SuppressWarnings("all") public class XmlTokenizerTokenManager implements XmlTokenizerConstants { /** Debug output. */ public java.io.PrintStream debugStream = System.out; /** Set debug output. */ public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } private final int jjStopStringLiteralDfa_0(int pos, long active0) { switch (pos) { case 0: if ((active0 & 0x900L) != 0L) return 21; if ((active0 & 0x1eL) != 0L) return 22; return -1; case 1: if ((active0 & 0x800L) != 0L) return 4; return -1; default : return -1; } } private final int jjStartNfa_0(int pos, long active0) { return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); } private int jjStopAtPos(int pos, int kind) { jjmatchedKind = kind; jjmatchedPos = pos; return pos + 1; } private int jjMoveStringLiteralDfa0_0() { switch(curChar) { case 9: return jjStartNfaWithStates_0(0, 3, 22); case 10: return jjStartNfaWithStates_0(0, 4, 22); case 13: return jjStartNfaWithStates_0(0, 2, 22); case 32: return jjStartNfaWithStates_0(0, 1, 22); case 60: jjmatchedKind = 8; return jjMoveStringLiteralDfa1_0(0x800L); default : return jjMoveNfa_0(0, 0); } } private int jjMoveStringLiteralDfa1_0(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(0, active0); return 1; } switch(curChar) { case 33: return jjMoveStringLiteralDfa2_0(active0, 0x800L); default : break; } return jjStartNfa_0(0, active0); } private int jjMoveStringLiteralDfa2_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(0, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(1, active0); return 2; } switch(curChar) { case 45: return jjMoveStringLiteralDfa3_0(active0, 0x800L); default : break; } return jjStartNfa_0(1, active0); } private int jjMoveStringLiteralDfa3_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(1, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(2, active0); return 3; } switch(curChar) { case 45: if ((active0 & 0x800L) != 0L) return jjStopAtPos(3, 11); break; default : break; } return jjStartNfa_0(2, active0); } private int jjStartNfaWithStates_0(int pos, int kind, int state) { jjmatchedKind = kind; jjmatchedPos = pos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return pos + 1; } return jjMoveNfa_0(state, pos + 1); } static final long[] jjbitVec0 = { 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec2 = { 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec3 = { 0xffc00000000L, 0x0L, 0x0L, 0x1ffffffff000000L }; static final long[] jjbitVec4 = { 0x0L, 0x0L, 0xffffffffffffffffL, 0x80000000800000L }; static final long[] jjbitVec5 = { 0xffffffffffffffffL, 0x4000ffffffffffffL, 0x0L, 0x0L }; static final long[] jjbitVec6 = { 0xffffffffffffcfffL, 0xffffffffffffL, 0x0L, 0x0L }; static final long[] jjbitVec7 = { 0x0L, 0x0L, 0xffffffffffff0000L, 0xffffffffffffffffL }; static final long[] jjbitVec8 = { 0x0L, 0x0L, 0x0L, 0xffff000000000000L }; static final long[] jjbitVec9 = { 0x1L, 0x0L, 0x0L, 0x0L }; static final long[] jjbitVec10 = { 0x0L, 0x0L, 0x0L, 0xffffffff0000L }; static final long[] jjbitVec11 = { 0x0L, 0x0L, 0x0L, 0xc000000000000000L }; private int jjMoveNfa_0(int startState, int curPos) { int startsAt = 0; jjnewStateCnt = 21; int i = 1; jjstateSet[0] = startState; int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) ReInitRounds(); if (curChar < 64) { long l = 1L << curChar; do { switch(jjstateSet[--i]) { case 0: if ((0xefffff7bffffffffL & l) != 0L) { if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); } else if ((0x8400000000L & l) != 0L) { if (kind > 9) kind = 9; } else if (curChar == 60) jjCheckNAddStates(3, 6); if (curChar == 45) jjstateSet[jjnewStateCnt++] = 6; break; case 21: if ((0xfbff7ffdffffffffL & l) != 0L) { if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); } else if (curChar == 33) jjstateSet[jjnewStateCnt++] = 4; if ((0x100002600L & l) != 0L) jjCheckNAddTwoStates(10, 11); break; case 22: if ((0xefffff7bffffffffL & l) != 0L) { if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); } else if (curChar == 60) jjCheckNAddTwoStates(3, 8); if (curChar == 45) jjstateSet[jjnewStateCnt++] = 6; break; case 1: if ((0xefffff7bffffffffL & l) == 0L) break; if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); break; case 2: if (curChar == 60) jjCheckNAddTwoStates(3, 8); break; case 3: if (curChar == 33) jjstateSet[jjnewStateCnt++] = 4; break; case 4: if ((0xffffdfffffffffffL & l) != 0L) jjstateSet[jjnewStateCnt++] = 5; break; case 5: if ((0xffffdfffffffffffL & l) == 0L) break; if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); break; case 6: if (curChar != 62) break; if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); break; case 7: if (curChar == 45) jjstateSet[jjnewStateCnt++] = 6; break; case 8: if ((0xfbff7ffdffffffffL & l) == 0L) break; if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); break; case 9: if (curChar == 60) jjCheckNAddStates(3, 6); break; case 10: if ((0x100002600L & l) != 0L) jjCheckNAddTwoStates(10, 11); break; default : break; } } while(i != startsAt); } else if (curChar < 128) { long l = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 0: case 1: case 5: if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); break; case 21: if ((0xf800000178000001L & l) != 0L) { if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); } else if (curChar == 115) jjAddStates(7, 8); break; case 22: if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); break; case 4: jjstateSet[jjnewStateCnt++] = 5; break; case 8: if ((0xf800000178000001L & l) == 0L) break; if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); break; case 11: if (curChar == 115) jjAddStates(7, 8); break; case 12: if (curChar == 116 && kind > 5) kind = 5; break; case 13: if (curChar == 112) jjstateSet[jjnewStateCnt++] = 12; break; case 14: if (curChar == 105) jjstateSet[jjnewStateCnt++] = 13; break; case 15: if (curChar == 114) jjstateSet[jjnewStateCnt++] = 14; break; case 16: if (curChar == 99) jjstateSet[jjnewStateCnt++] = 15; break; case 17: if (curChar == 101 && kind > 5) kind = 5; break; case 18: if (curChar == 108) jjstateSet[jjnewStateCnt++] = 17; break; case 19: if (curChar == 121) jjstateSet[jjnewStateCnt++] = 18; break; case 20: if (curChar == 116) jjstateSet[jjnewStateCnt++] = 19; break; default : break; } } while(i != startsAt); } else { int hiByte = (int)(curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 0: case 1: case 5: if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) break; if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); break; case 21: case 8: if (!jjCanMove_1(hiByte, i1, i2, l1, l2)) break; if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); break; case 22: if (!jjCanMove_0(hiByte, i1, i2, l1, l2)) break; if (kind > 10) kind = 10; jjCheckNAddStates(0, 2); break; case 4: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) jjstateSet[jjnewStateCnt++] = 5; break; default : break; } } while(i != startsAt); } if (kind != 0x7fffffff) { jjmatchedKind = kind; jjmatchedPos = curPos; kind = 0x7fffffff; } ++curPos; if ((i = jjnewStateCnt) == (startsAt = 21 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } private final int jjStopStringLiteralDfa_2(int pos, long active0) { switch (pos) { default : return -1; } } private final int jjStartNfa_2(int pos, long active0) { return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1); } private int jjMoveStringLiteralDfa0_2() { switch(curChar) { case 47: return jjStopAtPos(0, 18); case 61: return jjStopAtPos(0, 17); case 62: return jjStopAtPos(0, 16); default : return jjMoveNfa_2(0, 0); } } static final long[] jjbitVec12 = { 0xfffe7000fffffff6L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0x5e00000000ffffffL }; static final long[] jjbitVec13 = { 0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL }; static final long[] jjbitVec14 = { 0x0L, 0xbfff000000000000L, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec15 = { 0x3000L, 0xffff000000000000L, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec16 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L }; static final long[] jjbitVec17 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffL }; static final long[] jjbitVec18 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffff00000000ffffL }; static final long[] jjbitVec19 = { 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffffffffL }; static final long[] jjbitVec20 = { 0x0L, 0x0L, 0x80000000000000L, 0xff7fffffff7fffffL }; static final long[] jjbitVec21 = { 0xffffffffffffffffL, 0xbfffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL }; static final long[] jjbitVec22 = { 0x8000000000003000L, 0xffff000000000001L, 0xffffffffffffffffL, 0xffffffffffffffffL }; private int jjMoveNfa_2(int startState, int curPos) { int startsAt = 0; jjnewStateCnt = 10; int i = 1; jjstateSet[0] = startState; int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) ReInitRounds(); if (curChar < 64) { long l = 1L << curChar; do { switch(jjstateSet[--i]) { case 0: if ((0x7ff600000000000L & l) != 0L) { if (kind > 20) kind = 20; jjCheckNAdd(9); } else if (curChar == 39) jjCheckNAddTwoStates(6, 7); else if (curChar == 34) jjCheckNAddTwoStates(3, 4); if (curChar == 58) { if (kind > 19) kind = 19; jjCheckNAdd(1); } break; case 1: if ((0x7ff600000000000L & l) == 0L) break; if (kind > 19) kind = 19; jjCheckNAdd(1); break; case 2: if (curChar == 34) jjCheckNAddTwoStates(3, 4); break; case 3: if ((0xbffffffbffffffffL & l) != 0L) jjCheckNAddTwoStates(3, 4); break; case 4: if (curChar == 34 && kind > 20) kind = 20; break; case 5: if (curChar == 39) jjCheckNAddTwoStates(6, 7); break; case 6: if ((0xbfffff7fffffffffL & l) != 0L) jjCheckNAddTwoStates(6, 7); break; case 7: if (curChar == 39 && kind > 20) kind = 20; break; case 8: if ((0x7ff600000000000L & l) == 0L) break; if (kind > 20) kind = 20; jjCheckNAdd(9); break; case 9: if ((0x87ffe04000000000L & l) == 0L) break; if (kind > 20) kind = 20; jjCheckNAdd(9); break; default : break; } } while(i != startsAt); } else if (curChar < 128) { long l = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 0: if ((0x7fffffe87fffffeL & l) != 0L) { if (kind > 20) kind = 20; jjCheckNAdd(9); } if ((0x7fffffe87fffffeL & l) != 0L) { if (kind > 19) kind = 19; jjCheckNAdd(1); } break; case 1: if ((0x7fffffe87fffffeL & l) == 0L) break; if (kind > 19) kind = 19; jjCheckNAdd(1); break; case 3: jjAddStates(9, 10); break; case 6: jjAddStates(11, 12); break; case 8: case 9: if ((0x7fffffe87fffffeL & l) == 0L) break; if (kind > 20) kind = 20; jjCheckNAdd(9); break; default : break; } } while(i != startsAt); } else { int hiByte = (int)(curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 0: if (jjCanMove_2(hiByte, i1, i2, l1, l2)) { if (kind > 19) kind = 19; jjCheckNAdd(1); } if (jjCanMove_3(hiByte, i1, i2, l1, l2)) { if (kind > 20) kind = 20; jjCheckNAdd(9); } break; case 1: if (!jjCanMove_3(hiByte, i1, i2, l1, l2)) break; if (kind > 19) kind = 19; jjCheckNAdd(1); break; case 3: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) jjAddStates(9, 10); break; case 6: if (jjCanMove_0(hiByte, i1, i2, l1, l2)) jjAddStates(11, 12); break; case 8: case 9: if (!jjCanMove_3(hiByte, i1, i2, l1, l2)) break; if (kind > 20) kind = 20; jjCheckNAdd(9); break; default : break; } } while(i != startsAt); } if (kind != 0x7fffffff) { jjmatchedKind = kind; jjmatchedPos = curPos; kind = 0x7fffffff; } ++curPos; if ((i = jjnewStateCnt) == (startsAt = 10 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } private int jjMoveStringLiteralDfa0_1() { return jjMoveNfa_1(14, 0); } private int jjMoveNfa_1(int startState, int curPos) { int startsAt = 0; jjnewStateCnt = 15; int i = 1; jjstateSet[0] = startState; int kind = 0x7fffffff; for (;;) { if (++jjround == 0x7fffffff) ReInitRounds(); if (curChar < 64) { long l = 1L << curChar; do { switch(jjstateSet[--i]) { case 0: if (curChar == 47) jjCheckNAddTwoStates(1, 2); break; case 1: if ((0x100002600L & l) != 0L) jjCheckNAddTwoStates(1, 2); break; case 4: if ((0x100002600L & l) != 0L) jjAddStates(13, 14); break; case 5: if (curChar == 62) kind = 6; break; case 14: if (curChar == 60) jjstateSet[jjnewStateCnt++] = 0; break; default : break; } } while(i != startsAt); } else if (curChar < 128) { long l = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { case 2: if (curChar == 115) jjAddStates(15, 16); break; case 3: if (curChar == 116) jjCheckNAddTwoStates(4, 5); break; case 6: if (curChar == 112) jjstateSet[jjnewStateCnt++] = 3; break; case 7: if (curChar == 105) jjstateSet[jjnewStateCnt++] = 6; break; case 8: if (curChar == 114) jjstateSet[jjnewStateCnt++] = 7; break; case 9: if (curChar == 99) jjstateSet[jjnewStateCnt++] = 8; break; case 10: if (curChar == 101) jjCheckNAddTwoStates(4, 5); break; case 11: if (curChar == 108) jjstateSet[jjnewStateCnt++] = 10; break; case 12: if (curChar == 121) jjstateSet[jjnewStateCnt++] = 11; break; case 13: if (curChar == 116) jjstateSet[jjnewStateCnt++] = 12; break; default : break; } } while(i != startsAt); } else { int hiByte = (int)(curChar >> 8); int i1 = hiByte >> 6; long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); do { switch(jjstateSet[--i]) { default : break; } } while(i != startsAt); } if (kind != 0x7fffffff) { jjmatchedKind = kind; jjmatchedPos = curPos; kind = 0x7fffffff; } ++curPos; if ((i = jjnewStateCnt) == (startsAt = 15 - (jjnewStateCnt = startsAt))) return curPos; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return curPos; } } } private int jjMoveStringLiteralDfa0_3() { switch(curChar) { case 45: return jjMoveStringLiteralDfa1_3(0x400000L); default : return 1; } } private int jjMoveStringLiteralDfa1_3(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return 1; } switch(curChar) { case 45: return jjMoveStringLiteralDfa2_3(active0, 0x400000L); default : return 2; } } private int jjMoveStringLiteralDfa2_3(long old0, long active0) { if (((active0 &= old0)) == 0L) return 2; try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return 2; } switch(curChar) { case 62: if ((active0 & 0x400000L) != 0L) return jjStopAtPos(2, 22); break; default : return 3; } return 3; } static final int[] jjnextStates = { 1, 2, 7, 10, 3, 8, 11, 16, 20, 3, 4, 6, 7, 4, 5, 9, 13, }; private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec2[i2] & l2) != 0L); default : if ((jjbitVec0[i1] & l1) != 0L) return true; return false; } } private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec4[i2] & l2) != 0L); case 3: return ((jjbitVec5[i2] & l2) != 0L); case 32: return ((jjbitVec6[i2] & l2) != 0L); case 33: return ((jjbitVec7[i2] & l2) != 0L); case 47: return ((jjbitVec8[i2] & l2) != 0L); case 48: return ((jjbitVec9[i2] & l2) != 0L); case 253: return ((jjbitVec10[i2] & l2) != 0L); case 255: return ((jjbitVec11[i2] & l2) != 0L); default : if ((jjbitVec3[i1] & l1) != 0L) return true; return false; } } private static final boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec13[i2] & l2) != 0L); case 3: return ((jjbitVec14[i2] & l2) != 0L); case 32: return ((jjbitVec15[i2] & l2) != 0L); case 33: return ((jjbitVec16[i2] & l2) != 0L); case 47: return ((jjbitVec17[i2] & l2) != 0L); case 48: return ((jjbitVec0[i2] & l2) != 0L); case 253: return ((jjbitVec18[i2] & l2) != 0L); case 255: return ((jjbitVec19[i2] & l2) != 0L); default : if ((jjbitVec12[i1] & l1) != 0L) return true; return false; } } private static final boolean jjCanMove_3(int hiByte, int i1, int i2, long l1, long l2) { switch(hiByte) { case 0: return ((jjbitVec20[i2] & l2) != 0L); case 3: return ((jjbitVec21[i2] & l2) != 0L); case 32: return ((jjbitVec22[i2] & l2) != 0L); case 33: return ((jjbitVec16[i2] & l2) != 0L); case 47: return ((jjbitVec17[i2] & l2) != 0L); case 48: return ((jjbitVec0[i2] & l2) != 0L); case 253: return ((jjbitVec18[i2] & l2) != 0L); case 255: return ((jjbitVec19[i2] & l2) != 0L); default : if ((jjbitVec12[i1] & l1) != 0L) return true; return false; } } /** Token literal values. */ public static final String[] jjstrLiteralImages = { "", null, null, null, null, null, null, null, "\74", null, null, null, null, null, null, null, "\76", "\75", "\57", null, null, null, null, null, null, null, null, null, null, null, }; /** Lexer state names. */ public static final String[] lexStateNames = { "DEFAULT", "WithinIgnorable", "TAG_CONTEXT", "COMMENT_CONTEXT", }; /** Lex State array. */ public static final int[] jjnewLexState = { -1, -1, -1, -1, -1, 1, 0, -1, 2, -1, -1, 3, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, }; static final long[] jjtoToken = { 0x5f0701L, }; static final long[] jjtoSkip = { 0xf07eL, }; static final long[] jjtoMore = { 0x200880L, }; protected SimpleCharStream input_stream; private final int[] jjrounds = new int[21]; private final int[] jjstateSet = new int[42]; protected char curChar; /** Constructor. */ public XmlTokenizerTokenManager(SimpleCharStream stream){ if (SimpleCharStream.staticFlag) throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); input_stream = stream; } /** Constructor. */ public XmlTokenizerTokenManager(SimpleCharStream stream, int lexState){ this(stream); SwitchTo(lexState); } /** Reinitialise parser. */ public void ReInit(SimpleCharStream stream) { jjmatchedPos = jjnewStateCnt = 0; curLexState = defaultLexState; input_stream = stream; ReInitRounds(); } private void ReInitRounds() { int i; jjround = 0x80000001; for (i = 21; i-- > 0;) jjrounds[i] = 0x80000000; } /** Reinitialise parser. */ public void ReInit(SimpleCharStream stream, int lexState) { ReInit(stream); SwitchTo(lexState); } /** Switch to specified lex state. */ public void SwitchTo(int lexState) { if (lexState >= 4 || lexState < 0) throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); else curLexState = lexState; } protected Token jjFillToken() { final Token t; final String curTokenImage; final int beginLine; final int endLine; final int beginColumn; final int endColumn; String im = jjstrLiteralImages[jjmatchedKind]; curTokenImage = (im == null) ? input_stream.GetImage() : im; beginLine = input_stream.getBeginLine(); beginColumn = input_stream.getBeginColumn(); endLine = input_stream.getEndLine(); endColumn = input_stream.getEndColumn(); t = Token.newToken(jjmatchedKind, curTokenImage); t.beginLine = beginLine; t.endLine = endLine; t.beginColumn = beginColumn; t.endColumn = endColumn; return t; } int curLexState = 0; int defaultLexState = 0; int jjnewStateCnt; int jjround; int jjmatchedPos; int jjmatchedKind; /** Get the next Token. */ public Token getNextToken() { Token matchedToken; int curPos = 0; EOFLoop : for (;;) { try { curChar = input_stream.BeginToken(); } catch(java.io.IOException e) { jjmatchedKind = 0; matchedToken = jjFillToken(); return matchedToken; } for (;;) { switch(curLexState) { case 0: jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_0(); break; case 1: jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_1(); if (jjmatchedPos == 0 && jjmatchedKind > 7) { jjmatchedKind = 7; } break; case 2: try { input_stream.backup(0); while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L) curChar = input_stream.BeginToken(); } catch (java.io.IOException e1) { continue EOFLoop; } jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_2(); break; case 3: jjmatchedKind = 0x7fffffff; jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_3(); if (jjmatchedPos == 0 && jjmatchedKind > 21) { jjmatchedKind = 21; } break; } if (jjmatchedKind != 0x7fffffff) { if (jjmatchedPos + 1 < curPos) input_stream.backup(curPos - jjmatchedPos - 1); if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { matchedToken = jjFillToken(); if (jjnewLexState[jjmatchedKind] != -1) curLexState = jjnewLexState[jjmatchedKind]; return matchedToken; } else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) { if (jjnewLexState[jjmatchedKind] != -1) curLexState = jjnewLexState[jjmatchedKind]; continue EOFLoop; } if (jjnewLexState[jjmatchedKind] != -1) curLexState = jjnewLexState[jjmatchedKind]; curPos = 0; jjmatchedKind = 0x7fffffff; try { curChar = input_stream.readChar(); continue; } catch (java.io.IOException e1) { } } int error_line = input_stream.getEndLine(); int error_column = input_stream.getEndColumn(); String error_after = null; boolean EOFSeen = false; try { input_stream.readChar(); input_stream.backup(1); } catch (java.io.IOException e1) { EOFSeen = true; error_after = curPos <= 1 ? "" : input_stream.GetImage(); if (curChar == '\n' || curChar == '\r') { error_line++; error_column = 0; } else error_column++; } if (!EOFSeen) { input_stream.backup(1); error_after = curPos <= 1 ? "" : input_stream.GetImage(); } throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); } } } private void jjCheckNAdd(int state) { if (jjrounds[state] != jjround) { jjstateSet[jjnewStateCnt++] = state; jjrounds[state] = jjround; } } private void jjAddStates(int start, int end) { do { jjstateSet[jjnewStateCnt++] = jjnextStates[start]; } while (start++ != end); } private void jjCheckNAddTwoStates(int state1, int state2) { jjCheckNAdd(state1); jjCheckNAdd(state2); } private void jjCheckNAddStates(int start, int end) { do { jjCheckNAdd(jjnextStates[start]); } while (start++ != end); } } src/java/org/dbdoclet/trafo/xml/tokenizer/parser/Node.java0000644000000000000000000000251512124530526022607 0ustar rootroot/* Generated By:JJTree: Do not edit this line. Node.java Version 4.3 */ /* JavaCCOptions:MULTI=false,NODE_USES_PARSER=false,VISITOR=false,TRACK_TOKENS=false,NODE_PREFIX=AST,NODE_EXTENDS=,NODE_FACTORY=,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package org.dbdoclet.trafo.xml.tokenizer.parser; /* All AST nodes must implement this interface. It provides basic machinery for constructing the parent and child relationships between nodes. */ public @SuppressWarnings("all") interface Node { /** This method is called after the node has been made the current node. It indicates that child nodes can now be added to it. */ public void jjtOpen(); /** This method is called after all the child nodes have been added. */ public void jjtClose(); /** This pair of methods are used to inform the node of its parent. */ public void jjtSetParent(Node n); public Node jjtGetParent(); /** This method tells the node to add its argument to the node's list of children. */ public void jjtAddChild(Node n, int i); /** This method returns a child node. The children are numbered from zero, left to right. */ public Node jjtGetChild(int i); /** Return the number of children the node has. */ public int jjtGetNumChildren(); } /* JavaCC - OriginalChecksum=d1e356b8f784f3d6e222b2264e1a7432 (do not edit this line) */ src/java/org/dbdoclet/trafo/xml/tokenizer/parser/XmlTokenizerConstants.java0000644000000000000000000000360412124530526026252 0ustar rootroot/* Generated By:JJTree&JavaCC: Do not edit this line. XmlTokenizerConstants.java */ package org.dbdoclet.trafo.xml.tokenizer.parser; /** * Token literal values and constants. * Generated by org.javacc.parser.OtherFilesGen#start() */ @SuppressWarnings("all") public interface XmlTokenizerConstants { /** End of File. */ int EOF = 0; /** RegularExpression Id. */ int TAG_START = 8; /** RegularExpression Id. */ int QUOTE = 9; /** RegularExpression Id. */ int TEXT = 10; /** RegularExpression Id. */ int TAG_END = 16; /** RegularExpression Id. */ int EQUALS = 17; /** RegularExpression Id. */ int SLASH = 18; /** RegularExpression Id. */ int NCNAME = 19; /** RegularExpression Id. */ int VALUE = 20; /** RegularExpression Id. */ int COMMENT = 22; /** RegularExpression Id. */ int DIGIT = 23; /** RegularExpression Id. */ int LETTER = 24; /** RegularExpression Id. */ int WHITESPACE = 25; /** RegularExpression Id. */ int NAME_START_CHAR = 26; /** RegularExpression Id. */ int TEXT_AFTER_GT = 27; /** RegularExpression Id. */ int NAME_CHAR = 28; /** RegularExpression Id. */ int NAME = 29; /** Lexical state. */ int DEFAULT = 0; /** Lexical state. */ int WithinIgnorable = 1; /** Lexical state. */ int TAG_CONTEXT = 2; /** Lexical state. */ int COMMENT_CONTEXT = 3; /** Literal token values. */ String[] tokenImage = { "", "\" \"", "\"\\r\"", "\"\\t\"", "\"\\n\"", "", "", "", "\"<\"", "", "", "\"\"", "", "", "", "", "", "", "", }; } src/java/org/dbdoclet/trafo/xml/tokenizer/parser/XmlTokenizer.java0000644000000000000000000004346412124530526024365 0ustar rootroot/* Generated By:JJTree&JavaCC: Do not edit this line. XmlTokenizer.java */ package org.dbdoclet.trafo.xml.tokenizer.parser; import java.util.ArrayList; import java.util.HashMap; import java.io.ByteArrayInputStream; import java.io.UnsupportedEncodingException; import org.dbdoclet.progress.ProgressListener; import org.dbdoclet.progress.ProgressEvent; import org.dbdoclet.progress.ProgressManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @SuppressWarnings("all") public class XmlTokenizer/*@bgen(jjtree)*/implements XmlTokenizerTreeConstants, XmlTokenizerConstants {/*@bgen(jjtree)*/ protected JJTXmlTokenizerState jjtree = new JJTXmlTokenizerState();private static Log logger = LogFactory.getLog(XmlTokenizer.class); private ArrayList tokenList; private ArrayList listeners; public XmlTokenizer(String buffer, String encoding) throws UnsupportedEncodingException { this (new ByteArrayInputStream(buffer.getBytes(encoding)), encoding); } public synchronized ArrayList < org.dbdoclet.trafo.tokenizer.Token > parse() throws ParseException { tokenList = new ArrayList < org.dbdoclet.trafo.tokenizer.Token > (); start(); return tokenList; } final public void start() throws ParseException { /*@bgen(jjtree) start */ SimpleNode jjtn000 = new SimpleNode(JJTSTART); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { label_1: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TAG_START: case QUOTE: case TEXT: case COMMENT: ; break; default: jj_la1[0] = jj_gen; break label_1; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TAG_START: tag(); break; case QUOTE: case TEXT: text(); break; case COMMENT: comment(); break; default: jj_la1[1] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } final public void tag() throws ParseException { /*@bgen(jjtree) tag */ SimpleNode jjtn000 = new SimpleNode(JJTTAG); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);Token tag = null; Token name = null; Token value = null; Token slash1 = null; Token slash2 = null; HashMap < String, String > attributeMap = new HashMap < String, String > (); try { org.dbdoclet.trafo.tokenizer.Token token = new org.dbdoclet.trafo.tokenizer.Token(); tokenList.add(token); fireProgressEvent(token.toString()); try { jj_consume_token(TAG_START); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SLASH: slash1 = jj_consume_token(SLASH); break; default: jj_la1[2] = jj_gen; ; } tag = ncname(); token.setTagName(tag.image); token.setLine(tag.beginLine); token.setColumn(tag.beginColumn); trace("Tag: " + tag.image); label_2: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NCNAME: ; break; default: jj_la1[3] = jj_gen; break label_2; } name = attrName(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EQUALS: equals(); value = attrValue(); break; default: jj_la1[4] = jj_gen; ; } if (value != null) { String buffer = value.image; if (buffer != null) { if (buffer.startsWith("\u005c"") || buffer.startsWith("'")) { buffer = buffer.substring(1, buffer.length()); } if (buffer.endsWith("\u005c"") || buffer.endsWith("'")) { buffer = buffer.substring(0, buffer.length() - 1); } attributeMap.put(name.image, buffer); } } } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SLASH: slash2 = jj_consume_token(SLASH); break; default: jj_la1[5] = jj_gen; ; } jj_consume_token(TAG_END); } catch (Throwable oops) { logger.warn(String.format("Invalid attributes in Element %s line %d column %d", token.getTagName(), token.getLine(), token.getColumn())); logger.warn(oops.getMessage()); Token t = skipTo(DEFAULT, DEFAULT, token.toString(), TAG_END, TAG_START); token.setValue("<" + token.getTagName() + toAttributesAsText(attributeMap) + t.image); {if (true) return;} } jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; StringBuilder buffer = new StringBuilder(); buffer.append('<'); if (slash1 != null) { buffer.append('/'); } if (tag != null) { buffer.append(tag.image); } buffer.append(toAttributesAsText(attributeMap)); if (slash2 != null) { buffer.append('/'); } buffer.append('>'); trace(buffer.toString()); token.setValue(buffer.toString()); token.setAttributes(attributeMap); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } final public void comment() throws ParseException { /*@bgen(jjtree) comment */ SimpleNode jjtn000 = new SimpleNode(JJTCOMMENT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);Token comment; try { comment = jj_consume_token(COMMENT); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; org.dbdoclet.trafo.tokenizer.Token token = new org.dbdoclet.trafo.tokenizer.Token(comment.image); tokenList.add(token); fireProgressEvent(token.toString()); } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } final public void text() throws ParseException { /*@bgen(jjtree) text */ SimpleNode jjtn000 = new SimpleNode(JJTTEXT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);Token text; try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TEXT: text = jj_consume_token(TEXT); break; case QUOTE: text = jj_consume_token(QUOTE); break; default: jj_la1[6] = jj_gen; jj_consume_token(-1); throw new ParseException(); } jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; org.dbdoclet.trafo.tokenizer.Token token = new org.dbdoclet.trafo.tokenizer.Token(text.image); trace("text() " + token); tokenList.add(token); fireProgressEvent(token.toString()); } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } final public Token ncname() throws ParseException { /*@bgen(jjtree) ncname */ SimpleNode jjtn000 = new SimpleNode(JJTNCNAME); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);Token t; try { t = jj_consume_token(NCNAME); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; {if (true) return t;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } throw new Error("Missing return statement in function"); } final public void equals() throws ParseException { /*@bgen(jjtree) equals */ SimpleNode jjtn000 = new SimpleNode(JJTEQUALS); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { jj_consume_token(EQUALS); } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } final public Token attrName() throws ParseException { /*@bgen(jjtree) attrName */ SimpleNode jjtn000 = new SimpleNode(JJTATTRNAME); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);Token token = null; try { try { token = jj_consume_token(NCNAME); // System.out.println(token.image); {if (true) return token;} } catch (Throwable oops) { logger.warn(String.format("Invalid attributes in Element %s line %d column %d", token.image, token.beginLine, token.beginColumn)); logger.warn(oops.getMessage()); {if (true) return skipTo(DEFAULT, TAG_CONTEXT, "", TAG_END, QUOTE);} } } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } throw new Error("Missing return statement in function"); } final public Token attrValue() throws ParseException { /*@bgen(jjtree) attrValue */ SimpleNode jjtn000 = new SimpleNode(JJTATTRVALUE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);Token token = null; try { try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case VALUE: token = jj_consume_token(VALUE); break; case NCNAME: token = jj_consume_token(NCNAME); break; default: jj_la1[7] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return token;} } catch (Throwable oops) { logger.warn(String.format("Invalid attributes in Element %s line %d column %d", token.image, token.beginLine, token.beginColumn)); logger.warn(oops.getMessage()); {if (true) return skipTo(DEFAULT, TAG_CONTEXT, "", TAG_END, QUOTE);} } } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } throw new Error("Missing return statement in function"); } private Token skipTo(int preContext, int postContext, String prev, int... kind) throws ParseException { /*@bgen(jjtree) skipTo */ SimpleNode jjtn000 = new SimpleNode(JJTSKIPTO); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try {StringBuilder buffer = new StringBuilder(); boolean skip = true; token_source.SwitchTo(preContext); while (skip) { Token t = getNextToken(); buffer.append(t.image); if (t.kind == EOF) { break; } for (int stop : kind) { if (t.kind == stop) { skip = false; } } } token_source.SwitchTo(postContext); return new Token(VALUE, buffer.toString());/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } private String toAttributesAsText(HashMap attributeMap) throws ParseException { /*@bgen(jjtree) toAttributesAsText */ SimpleNode jjtn000 = new SimpleNode(JJTTOATTRIBUTESASTEXT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try {StringBuilder buffer = new StringBuilder(); for (String attr : attributeMap.keySet()) { buffer.append(' '); buffer.append(attr); buffer.append("=\u005c""); buffer.append(attributeMap.get(attr)); buffer.append("\u005c""); } return buffer.toString();/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } public void setProgressListeners(ArrayList listeners) throws ParseException { /*@bgen(jjtree) setProgressListeners */ SimpleNode jjtn000 = new SimpleNode(JJTSETPROGRESSLISTENERS); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try {this.listeners = listeners;/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } public void fireProgressEvent(String action) throws ParseException { /*@bgen(jjtree) fireProgressEvent */ SimpleNode jjtn000 = new SimpleNode(JJTFIREPROGRESSEVENT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try {if (listeners != null) { ProgressEvent event = new ProgressEvent("Tokenizer: " + action); event.setStage(ProgressEvent.STAGE_PREPARE); ProgressManager pm = new ProgressManager(listeners); pm.fireProgressEvent(event); }/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } private void trace(String text) throws ParseException { /*@bgen(jjtree) trace */ SimpleNode jjtn000 = new SimpleNode(JJTTRACE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try {/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } /** Generated Token Manager. */ public XmlTokenizerTokenManager token_source; SimpleCharStream jj_input_stream; /** Current token. */ public Token token; /** Next token. */ public Token jj_nt; private int jj_ntk; private int jj_gen; final private int[] jj_la1 = new int[8]; static private int[] jj_la1_0; static { jj_la1_init_0(); } private static void jj_la1_init_0() { jj_la1_0 = new int[] {0x400700,0x400700,0x40000,0x80000,0x20000,0x40000,0x600,0x180000,}; } /** Constructor with InputStream. */ public XmlTokenizer(java.io.InputStream stream) { this(stream, null); } /** Constructor with InputStream and supplied encoding */ public XmlTokenizer(java.io.InputStream stream, String encoding) { try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source = new XmlTokenizerTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 8; i++) jj_la1[i] = -1; } /** Reinitialise. */ public void ReInit(java.io.InputStream stream) { ReInit(stream, null); } /** Reinitialise. */ public void ReInit(java.io.InputStream stream, String encoding) { try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jjtree.reset(); jj_gen = 0; for (int i = 0; i < 8; i++) jj_la1[i] = -1; } /** Constructor. */ public XmlTokenizer(java.io.Reader stream) { jj_input_stream = new SimpleCharStream(stream, 1, 1); token_source = new XmlTokenizerTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 8; i++) jj_la1[i] = -1; } /** Reinitialise. */ public void ReInit(java.io.Reader stream) { jj_input_stream.ReInit(stream, 1, 1); token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jjtree.reset(); jj_gen = 0; for (int i = 0; i < 8; i++) jj_la1[i] = -1; } /** Constructor with generated Token Manager. */ public XmlTokenizer(XmlTokenizerTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 8; i++) jj_la1[i] = -1; } /** Reinitialise. */ public void ReInit(XmlTokenizerTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jjtree.reset(); jj_gen = 0; for (int i = 0; i < 8; i++) jj_la1[i] = -1; } private Token jj_consume_token(int kind) throws ParseException { Token oldToken; if ((oldToken = token).next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; if (token.kind == kind) { jj_gen++; return token; } token = oldToken; jj_kind = kind; throw generateParseException(); } /** Get the next Token. */ final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; jj_gen++; return token; } /** Get the specific Token. */ final public Token getToken(int index) { Token t = token; for (int i = 0; i < index; i++) { if (t.next != null) t = t.next; else t = t.next = token_source.getNextToken(); } return t; } private int jj_ntk() { if ((jj_nt=token.next) == null) return (jj_ntk = (token.next=token_source.getNextToken()).kind); else return (jj_ntk = jj_nt.kind); } private java.util.List jj_expentries = new java.util.ArrayList(); private int[] jj_expentry; private int jj_kind = -1; /** Generate ParseException. */ public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[30]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 8; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Abbrev.getTag(), Abbrev.getAttributeMap()); invalidParentMap.put(Acronym.getTag(), Acronym.getAttributeMap()); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); invalidParentMap.put(Subscript.getTag(), Subscript.getAttributeMap()); invalidParentMap.put(Superscript.getTag(), Superscript.getAttributeMap()); invalidParentMap.put(Title.getTag(), Title.getAttributeMap()); invalidParentMap.put(ProgramListing.getTag(), ProgramListing.getAttributeMap()); } public static String getTag() { return TAG; } Figure(String title) { super("figure"); if (title == null) { throw new IllegalArgumentException(" The argument title must not be null!"); } setFormatType(FORMAT_BLOCK); appendChild(new Title(title)); } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/BlockQuote.java0000644000000000000000000000135712124530526022062 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class BlockQuote extends DocBookElement { private static String tag = "blockquote"; BlockQuote() { super("blockquote"); setFormatType(FORMAT_BLOCK); isContentModel(true); } BlockQuote(String text) { this(); appendChild(text); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/Spanspec.java0000644000000000000000000000121112124530526021553 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Spanspec extends DocBookElement { Spanspec() { super("spanspec"); isEmpty(true); } Spanspec(String name, String start, String end, String align) { super("spanspec"); setAttribute("spanname", name); setAttribute("namest", start); setAttribute("nameend", end); setAttribute("align", align); isEmpty(true); } } src/java/org/dbdoclet/trafo/tag/docbook/Sect4.java0000644000000000000000000000112612124530526020766 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Sect4 extends SectionElement { private final static String tag = "sect4"; Sect4() { super(tag); isContentModel(true); } Sect4(String title) { super(tag); appendChild(new Title(title)); isContentModel(true); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Article.java0000644000000000000000000000114012124530526021363 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Article extends SectionElement { private static final String tag = "article"; Article() { super(tag); setFormatType(FORMAT_BLOCK); isContentModel(true); } Article(String title) { this(); appendChild(new Title(title)); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/InformalFigure.java0000644000000000000000000000240512124530526022716 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class InformalFigure extends DocBookElement { private static final String TAG = "informalfigure"; private static final HashMap> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Abbrev.getTag(), Abbrev.getAttributeMap()); invalidParentMap.put(Acronym.getTag(), Acronym.getAttributeMap()); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); invalidParentMap.put(Subscript.getTag(), Subscript.getAttributeMap()); invalidParentMap.put(Superscript.getTag(), Superscript.getAttributeMap()); invalidParentMap.put(Title.getTag(), Title.getAttributeMap()); invalidParentMap.put(ProgramListing.getTag(), ProgramListing.getAttributeMap()); } public static String getTag() { return TAG; } InformalFigure() { super("informalfigure"); setFormatType(FORMAT_BLOCK); } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/Tip.java0000644000000000000000000000145412124530526020544 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Tip extends DocBookElement { private static String tag = "tip"; Tip() { super(tag); setFormatType(FORMAT_BLOCK); } Tip(String strTitle) { super(tag); Title title = new Title(strTitle); title.setParentNode(this); appendChild(title); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/InformalExample.java0000644000000000000000000000115112124530526023065 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class InformalExample extends DocBookElement { private static String tag = "informalexample"; public static HashMap getAttributeMap() { return new HashMap(); } public static String getTag() { return tag; } InformalExample() { super(tag); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/ImageObject.java0000644000000000000000000000057012124530526022157 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class ImageObject extends DocBookElement { ImageObject() { super("imageobject"); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/BridgeHead.java0000644000000000000000000000132312124530526021761 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class BridgeHead extends DocBookElement { BridgeHead() { super("bridgehead"); setFormatType(FORMAT_BLOCK); } BridgeHead(String bridgehead) { this(); appendChild(bridgehead); } BridgeHead(String bridgehead, String renderAs) { this(); setAttribute("renderas", renderAs); appendChild(bridgehead); } public void setRenderAs(String renderAs) { setAttribute("renderas", renderAs); } } src/java/org/dbdoclet/trafo/tag/docbook/RefSect5.java0000644000000000000000000000111412124530526021421 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class RefSect5 extends DocBookElement { private static String tag = "refsect3"; RefSect5() { super(tag); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/VarListEntry.java0000644000000000000000000000205212124530526022411 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.dom.NodeImpl; public class VarListEntry extends DocBookElement { VarListEntry() { super("varlistentry"); setFormatType(FORMAT_BLOCK); } @Override public void closed() { if (hasChildNodes() == false) { appendChild(new Term()); appendChild(new ListItem().appendChild(new SimPara())); return; } if (getNumberOfChildNodes() == 1) { NodeImpl node = (NodeImpl) getTrafoChildNodes().get(0); if (node instanceof Term) { appendChild(new ListItem().appendChild(new SimPara())); return; } if (node instanceof ListItem) { insertChild(0, new Term()); return; } } } } src/java/org/dbdoclet/trafo/tag/docbook/Table.java0000644000000000000000000000120212124530526021026 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Table extends DocBookElement { Table() { super("table"); setFormatType(FORMAT_BLOCK); setFrame("none"); } Table(String tagname) { super(tagname); setFormatType(FORMAT_BLOCK); setFrame("none"); } public DocBookElement setFrame(String frame) { setAttribute("frame", frame); return this; } } src/java/org/dbdoclet/trafo/tag/docbook/XMLDocument.java0000644000000000000000000000042412124530526022143 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class XMLDocument { } src/java/org/dbdoclet/trafo/tag/docbook/VariableList.java0000644000000000000000000000156212124530526022371 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class VariableList extends DocBookElement { private static String tag = "variablelist"; VariableList() { super(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } @Override public void closed() { if (hasChildNodes() == false) { appendChild(new VarListEntry().appendChild(new Term()).appendChild( new ListItem().appendChild(new SimPara()))); } } } src/java/org/dbdoclet/trafo/tag/docbook/Type.java0000644000000000000000000000063212124530526020726 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Type extends DocBookElement { Type() { super("type"); } Type(String type) { this(); appendChild(type); } } src/java/org/dbdoclet/trafo/tag/docbook/Synopsis.java0000644000000000000000000000053212124530526021633 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Synopsis extends DocBookElement { Synopsis() { super("synopsis"); } } src/java/org/dbdoclet/trafo/tag/docbook/RefName.java0000644000000000000000000000060312124530526021320 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class RefName extends DocBookElement { RefName(String refname) { super("refname"); appendChild(refname); } } src/java/org/dbdoclet/trafo/tag/docbook/Sect5.java0000644000000000000000000000112512124530526020766 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Sect5 extends SectionElement { private final static String tag = "sect5"; Sect5() { super(tag); isContentModel(true); } Sect5(String title) { super(tag); appendChild(new Title(title)); isContentModel(true); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Emphasis.java0000644000000000000000000000506412124530526021562 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Emphasis extends DocBookElement { private static String tag = "emphasis"; private static HashMap> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); invalidParentMap.put(Article.getTag(), Article.getAttributeMap()); invalidParentMap.put(BlockQuote.getTag(), BlockQuote.getAttributeMap()); invalidParentMap.put(Book.getTag(), Book.getAttributeMap()); invalidParentMap.put(Chapter.getTag(), Chapter.getAttributeMap()); invalidParentMap.put(ListItem.getTag(), ListItem.getAttributeMap()); invalidParentMap.put(Sect1.getTag(), Sect1.getAttributeMap()); invalidParentMap.put(Sect2.getTag(), Sect2.getAttributeMap()); invalidParentMap.put(Sect3.getTag(), Sect3.getAttributeMap()); invalidParentMap.put(Sect4.getTag(), Sect4.getAttributeMap()); invalidParentMap.put(Sect5.getTag(), Sect5.getAttributeMap()); invalidParentMap.put(Section.getTag(), Section.getAttributeMap()); invalidParentMap.put(SimpleSect.getTag(), SimpleSect.getAttributeMap()); invalidParentMap.put(Subscript.getTag(), Subscript.getAttributeMap()); invalidParentMap.put(Superscript.getTag(), Superscript.getAttributeMap()); } Emphasis() { super(tag); setFormatType(FORMAT_INLINE); } Emphasis(String text) { super(tag); appendChild(text); setFormatType(FORMAT_INLINE); } Emphasis(String text, String role) { super(tag); appendChild(text); setAttribute("role", role); setFormatType(FORMAT_INLINE); } Emphasis(DocBookElement elem) { super(tag); appendChild(elem); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public boolean validate() { return validate(invalidParentMap); } @Override public boolean isValidParent(DocBookElement elem) { if (elem == null) { throw new IllegalArgumentException("Parameter elem is null!"); } if (invalidParentMap.get(elem.getNodeName()) != null) { return false; } return true; } } src/java/org/dbdoclet/trafo/tag/docbook/SimpleSect.java0000644000000000000000000000111012124530526022045 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class SimpleSect extends SectionElement { private final static String tag = "simplesect"; SimpleSect() { super(tag); isContentModel(true); } SimpleSect(String title) { this(); appendChild(new Title(title)); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Section.java0000644000000000000000000000116412124530526021412 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Section extends SectionElement { private final static String tagName = "section"; Section() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } Section(String title) { this(); appendChild(new Title(title)); } public static String getTag() { return tagName; } } src/java/org/dbdoclet/trafo/tag/docbook/Sect3.java0000644000000000000000000000124112124530526020763 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Sect3 extends SectionElement { private final static String tag = "sect3"; Sect3() { super(tag); setFormatType(FORMAT_BLOCK); isContentModel(true); } Sect3(String title) { super(tag); setFormatType(FORMAT_BLOCK); appendChild(new Title(title)); isContentModel(true); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Title.java0000644000000000000000000000243112124530526021065 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; import org.dbdoclet.xiphias.XmlServices; public class Title extends DocBookElement { private static final String tag = "title"; private static final HashMap> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(InformalExample.getTag(), InformalExample.getAttributeMap()); invalidParentMap.put(InformalFigure.getTag(), InformalFigure.getAttributeMap()); invalidParentMap.put(InformalTable.getTag(), InformalTable.getAttributeMap()); invalidParentMap.put(Para.getTag(), Para.getAttributeMap()); } public static HashMap getAttributeMap() { return new HashMap(); } public static String getTag() { return tag; } Title() { super(tag); } Title(String title) { super(tag); if (title != null) { appendChild(XmlServices.textToXml(title)); } } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/InformalTable.java0000644000000000000000000000101512124530526022520 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class InformalTable extends Table { private static final String tag = "informaltable"; InformalTable() { super(tag); setFormatType(FORMAT_BLOCK); setFrame("none"); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Subject.java0000644000000000000000000000067612124530526021414 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Subject extends DocBookElement { private static String tag = "subject"; Subject() { super(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Tfoot.java0000644000000000000000000000055512124530526021104 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Tfoot extends Telem { Tfoot() { super("tfoot"); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/PartIntro.java0000644000000000000000000000116512124530526021731 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class PartIntro extends SectionElement { private static final String tagName = "partintro"; PartIntro() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } PartIntro(String title) { this(); appendChild(new Title(title)); } public static String getTag() { return tagName; } } src/java/org/dbdoclet/trafo/tag/docbook/DocBookVersion.java0000644000000000000000000000013012124530526022664 0ustar rootrootpackage org.dbdoclet.trafo.tag.docbook; public enum DocBookVersion { V4_5, V5_0; } src/java/org/dbdoclet/trafo/tag/docbook/SectionElement.java0000644000000000000000000000536612124530526022734 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.dom.CommentImpl; import org.dbdoclet.xiphias.dom.ElementImpl; import org.dbdoclet.xiphias.dom.NodeImpl; import org.dbdoclet.xiphias.dom.TextImpl; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class SectionElement extends DocBookElement { SectionElement(String name) { super(name); } public SectionElement getFirstSectionChild() { NodeList children = getChildNodes(); int length = children.getLength(); for (int i = 0; i < length; i++) { Node node = children.item(i); if (node != null && node instanceof SectionElement) { return (SectionElement) node; } } return null; } SectionElement getLastSectionChild() { NodeList children = getChildNodes(); int length = children.getLength(); SectionElement sectionChild = null; for (int i = 0; i < length; i++) { Node node = children.item(i); if (node != null && node instanceof SectionElement) { sectionChild = (SectionElement) node; } } return sectionChild; } public String getTitle() { NodeImpl titleElement = (NodeImpl) findChildElement("title"); if (titleElement != null) { return titleElement.getTextContent(); } return ""; } public void setTitle(String title) { NodeImpl titleElement = (NodeImpl) findChildElement("title"); if (titleElement != null) { titleElement.setTextContent(title); } } public boolean hasContentChildren() { NodeList children = getChildNodes(); int counter = 0; int length = children.getLength(); for (int i = 0; i < length; i++) { Node node = children.item(i); if (node != null && node instanceof ElementImpl) { if (node instanceof Title || node instanceof IndexTerm || node instanceof CommentImpl) { continue; } if (node instanceof TextImpl) { TextImpl text = (TextImpl) node; String buffer = text.getData(); if ((buffer == null) || (buffer.trim().length() == 0)) { continue; } } if (node instanceof Para) { if (node.hasChildNodes() == false) { continue; } } counter++; } } if (counter > 0) { return true; } else { return false; } } public boolean hasSectionChildren() { NodeList children = getChildNodes(); int length = children.getLength(); for (int i = 0; i < length; i++) { Node node = children.item(i); if (node != null && node instanceof DocBookElement) { DocBookElement elem = (DocBookElement) node; if (elem.isSection()) { return true; } } } return false; } } src/java/org/dbdoclet/trafo/tag/docbook/ULink.java0000644000000000000000000000223012124530526021023 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class ULink extends DocBookElement { private static final String tag = "ulink"; private static final HashMap> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); } ULink() { super(tag); setFormatType(FORMAT_INLINE); } ULink(String text) { this(); appendChild(text); } public void setUrl(String url) { if ((url == null) || (url.length() == 0)) { url = "#"; } setAttribute("url", url); } public String getUrl() { return getAttribute("url"); } public static String getTag() { return tag; } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/Quote.java0000644000000000000000000000076012124530526021104 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Quote extends DocBookElement { Quote() { super("quote"); setFormatType(FORMAT_INLINE); } Quote(String text) { super("quote"); appendChild(text); setFormatType(FORMAT_INLINE); } } src/java/org/dbdoclet/trafo/tag/docbook/TagFactory.java0000644000000000000000000014227512124530526022062 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.io.IOException; import java.text.SimpleDateFormat; import org.dbdoclet.xiphias.NodeSerializer; public class TagFactory { private DocBookVersion docBookVersion = DocBookVersion.V5_0; public TagFactory() { this(DocBookVersion.V5_0); } public TagFactory(DocBookVersion docBookVersion) { this.docBookVersion = docBookVersion; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createAbbrev() */ public Abbrev createAbbrev() { Abbrev abbrev = new Abbrev(); abbrev.setDocBookVersion(docBookVersion); return abbrev; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createAbstract() */ public Abstract createAbstract() { Abstract _abstract = new Abstract(); _abstract.setDocBookVersion(docBookVersion); return _abstract; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createAcronym() */ public Acronym createAcronym() { Acronym acronym = new Acronym(); acronym.setDocBookVersion(docBookVersion); return acronym; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createAddress() */ public Address createAddress() { Address address = new Address(); address.setDocBookVersion(docBookVersion); return address; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createAffiliation() */ public Affiliation createAffiliation() { Affiliation affiliation = new Affiliation(); affiliation.setDocBookVersion(docBookVersion); return affiliation; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createAnchor() */ public Anchor createAnchor() { Anchor anchor = new Anchor(); anchor.setDocBookVersion(docBookVersion); return anchor; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createAppendix() */ public Appendix createAppendix() { Appendix appendix = new Appendix(); appendix.setDocBookVersion(docBookVersion); return appendix; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createArticle() */ public Article createArticle() { Article article = new Article(); article.setDocBookVersion(docBookVersion); return article; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createArticleInfo() */ public ArticleInfo createArticleInfo() { ArticleInfo articleInfo = new ArticleInfo(); articleInfo.setDocBookVersion(docBookVersion); return articleInfo; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createAuthor() */ public Author createAuthor() { Author author = new Author(); author.setDocBookVersion(docBookVersion); return author; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createBlockQuote() */ public BlockQuote createBlockQuote() { BlockQuote blockQuote = new BlockQuote(); blockQuote.setDocBookVersion(docBookVersion); return blockQuote; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createBook() */ public Book createBook() { Book book = new Book(); book.setDocBookVersion(docBookVersion); return book; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createBookInfo() */ public BookInfo createBookInfo() { BookInfo bookInfo = new BookInfo(); bookInfo.setDocBookVersion(docBookVersion); return bookInfo; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createBridgeHead() */ public BridgeHead createBridgeHead() { BridgeHead bridgeHead = new BridgeHead(); bridgeHead.setDocBookVersion(docBookVersion); return bridgeHead; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createCaption() */ public Caption createCaption() { Caption caption = new Caption(); caption.setDocBookVersion(docBookVersion); return caption; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createCaution() */ public Caution createCaution() { Caution caution = new Caution(); caution.setDocBookVersion(docBookVersion); return caution; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createChapter() */ public Chapter createChapter() { Chapter chapter = new Chapter(); chapter.setDocBookVersion(docBookVersion); return chapter; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createClassName() */ public ClassName createClassName() { ClassName className = new ClassName(); className.setDocBookVersion(docBookVersion); return className; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createClassName(java.lang.String) */ public ClassName createClassName(String name) { ClassName className = new ClassName(name); className.setDocBookVersion(docBookVersion); return className; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createClassSynopsis() */ public ClassSynopsis createClassSynopsis() { ClassSynopsis classSynopsis = new ClassSynopsis(); classSynopsis.setDocBookVersion(docBookVersion); return classSynopsis; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createClassSynopsisInfo() */ public ClassSynopsisInfo createClassSynopsisInfo() { ClassSynopsisInfo classSynopsisInfo = new ClassSynopsisInfo(); classSynopsisInfo.setDocBookVersion(docBookVersion); return classSynopsisInfo; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createClassSynopsisInfo(java.lang.String) */ public ClassSynopsisInfo createClassSynopsisInfo(String text) { ClassSynopsisInfo classSynopsisInfo = new ClassSynopsisInfo(text); classSynopsisInfo.setDocBookVersion(docBookVersion); return classSynopsisInfo; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createCode() */ public Code createCode() { Code code = new Code(); code.setDocBookVersion(docBookVersion); return code; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createColspec() */ public Colspec createColspec() { Colspec colspec = new Colspec(); colspec.setDocBookVersion(docBookVersion); return colspec; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createColspec(java.lang.String, java.lang.String) */ public Colspec createColspec(String string, String width) { Colspec colspec = new Colspec(string, width); colspec.setDocBookVersion(docBookVersion); return colspec; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createComputerOutput() */ public ComputerOutput createComputerOutput() { ComputerOutput computerOutput = new ComputerOutput(); computerOutput.setDocBookVersion(docBookVersion); return computerOutput; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createComputerOutput(java.lang.String) */ public ComputerOutput createComputerOutput(String text) { ComputerOutput computerOutput = new ComputerOutput(text); computerOutput.setDocBookVersion(docBookVersion); return computerOutput; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createConstructorSynopsis() */ public ConstructorSynopsis createConstructorSynopsis() { ConstructorSynopsis constructorSynopsis = new ConstructorSynopsis(); constructorSynopsis.setDocBookVersion(docBookVersion); return constructorSynopsis; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createCopyright() */ public Copyright createCopyright() { Copyright copyright = new Copyright(); copyright.setDocBookVersion(docBookVersion); return copyright; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createDate() */ public Date createDate() { java.util.Date today = new java.util.Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(sdf.format(today)); date.setDocBookVersion(docBookVersion); return date; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createDate(java.lang.String) */ public Date createDate(String text) { Date date = new Date(text); date.setDocBookVersion(docBookVersion); return date; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createEmail() */ public Email createEmail() { Email email = new Email(); email.setDocBookVersion(docBookVersion); return email; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createEmail(java.lang.String) */ public Email createEmail(String address) { Email email = new Email(); email.appendChild(address); email.setDocBookVersion(docBookVersion); return email; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createEmphasis() */ public Emphasis createEmphasis() { Emphasis emphasis = new Emphasis(); emphasis.setDocBookVersion(docBookVersion); return emphasis; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createEmphasis(java.lang.String) */ public Emphasis createEmphasis(String str) { Emphasis emphasis = new Emphasis(str); emphasis.setDocBookVersion(docBookVersion); return emphasis; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createEmphasis(java.lang.String, java.lang.String) */ public Emphasis createEmphasis(String str, String role) { Emphasis emphasis = createEmphasis(str); emphasis.setRole(role); return emphasis; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createEntry() */ public Entry createEntry() { Entry entry = new Entry(); entry.setDocBookVersion(docBookVersion); return entry; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createEntry(java.lang.String) */ public Entry createEntry(String text) { Entry entry = new Entry(text); entry.setDocBookVersion(docBookVersion); return entry; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createEntryTbl() */ public EntryTbl createEntryTbl() { EntryTbl entryTbl = new EntryTbl(); entryTbl.setDocBookVersion(docBookVersion); return entryTbl; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createExample(java.lang.String) */ public Example createExample(String title) { Example example = new Example(title); example.setDocBookVersion(docBookVersion); return example; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createExceptionName() */ public ExceptionName createExceptionName() { ExceptionName exceptionName = new ExceptionName(); exceptionName.setDocBookVersion(docBookVersion); return exceptionName; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createExceptionName(java.lang.String) */ public ExceptionName createExceptionName(String text) { ExceptionName exceptionName = new ExceptionName(text); exceptionName.setDocBookVersion(docBookVersion); return exceptionName; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createFieldSynopsis() */ public FieldSynopsis createFieldSynopsis() { FieldSynopsis fieldSynopsis = new FieldSynopsis(); fieldSynopsis.setDocBookVersion(docBookVersion); return fieldSynopsis; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createFigure(java.lang.String) */ public Figure createFigure(String title) { Figure figure = new Figure(title); figure.setDocBookVersion(docBookVersion); return figure; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createFirstName() */ public FirstName createFirstName() { FirstName firstName = new FirstName(); firstName.setDocBookVersion(docBookVersion); return firstName; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createFirstName(java.lang.String) */ public FirstName createFirstName(String name) { FirstName firstName = new FirstName(); firstName.appendChild(name); firstName.setDocBookVersion(docBookVersion); return firstName; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createFormalPara() */ public FormalPara createFormalPara() { FormalPara formalPara = new FormalPara(); formalPara.setDocBookVersion(docBookVersion); return formalPara; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createFormalPara(java.lang.String) */ public DocBookElement createFormalPara(String title) { FormalPara formalPara = new FormalPara(title); formalPara.setDocBookVersion(docBookVersion); return formalPara; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createFuncDef() */ public FuncDef createFuncDef() { FuncDef funcDef = new FuncDef(); funcDef.setDocBookVersion(docBookVersion); return funcDef; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createFuncPrototype() */ public FuncPrototype createFuncPrototype() { FuncPrototype funcPrototype = new FuncPrototype(); funcPrototype.setDocBookVersion(docBookVersion); return funcPrototype; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createFuncSynopsis() */ public FuncSynopsis createFuncSynopsis() { FuncSynopsis funcSynopsis = new FuncSynopsis(); funcSynopsis.setDocBookVersion(docBookVersion); return funcSynopsis; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createFunction(java.lang.String) */ public Function createFunction(String func) { Function function = new Function(func); function.setDocBookVersion(docBookVersion); return function; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createHolder() */ public Holder createHolder() { Holder holder = new Holder(); holder.setDocBookVersion(docBookVersion); return holder; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createHolder(java.lang.String) */ public Holder createHolder(String text) { Holder holder = new Holder(); holder.appendChild(text); holder.setDocBookVersion(docBookVersion); return holder; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createImage(java.lang.String, java.lang.String, java.lang.String) */ public MediaObject createImage(String image, String width, String height) { MediaObject mediaObject = new MediaObject(); mediaObject.setDocBookVersion(docBookVersion); ImageObject imageObject = new ImageObject(); imageObject.setDocBookVersion(docBookVersion); mediaObject.appendChild(imageObject); ImageData imageData = new ImageData(); imageData.setDocBookVersion(docBookVersion); imageObject.appendChild(imageData); imageData.setFileRef(image); if (width != null && width.trim().length() > 0) { imageData.setWidth(String.valueOf(width)); } if (height != null && height.trim().length() > 0) { imageData.setDepth(String.valueOf(height)); } return mediaObject; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createImage(java.lang.String) */ public MediaObject createImage(String image) { return createImage(image, null, null); } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createImageData() */ public ImageData createImageData() { ImageData imageData = new ImageData(); imageData.setDocBookVersion(docBookVersion); return imageData; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createImageObject() */ public ImageObject createImageObject() { ImageObject imageObject = new ImageObject(); imageObject.setDocBookVersion(docBookVersion); return imageObject; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createImportant() */ public Important createImportant() { Important important = new Important(); important.setDocBookVersion(docBookVersion); return important; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createIndex() */ public Index createIndex() { Index index = new Index(); index.setDocBookVersion(docBookVersion); return index; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createIndexTerm() */ public IndexTerm createIndexTerm() { IndexTerm indexTerm = new IndexTerm(); indexTerm.setDocBookVersion(docBookVersion); return indexTerm; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createInfo() */ public Info createInfo() { Info info = new Info(); info.setDocBookVersion(docBookVersion); return info; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createPersonname() */ public Personname createPersonname() { Personname personname = new Personname(); personname.setDocBookVersion(docBookVersion); return personname; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createInformalExample() */ public InformalExample createInformalExample() { InformalExample informalExample = new InformalExample(); informalExample.setDocBookVersion(docBookVersion); return informalExample; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createInformalFigure() */ public InformalFigure createInformalFigure() { InformalFigure informalFigure = new InformalFigure(); informalFigure.setDocBookVersion(docBookVersion); return informalFigure; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createInformalTable() */ public InformalTable createInformalTable() { InformalTable informalTable = new InformalTable(); informalTable.setDocBookVersion(docBookVersion); return informalTable; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createInitializer() */ public Initializer createInitializer() { Initializer initializer = new Initializer(); initializer.setDocBookVersion(docBookVersion); return initializer; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createInitializer(java.lang.String) */ public Initializer createInitializer(String text) { Initializer initializer = new Initializer(text); initializer.setDocBookVersion(docBookVersion); return initializer; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createInlineMediaObject() */ public InlineMediaObject createInlineMediaObject() { InlineMediaObject inlineMediaObject = new InlineMediaObject(); inlineMediaObject.setDocBookVersion(docBookVersion); return inlineMediaObject; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createInterfaceName() */ public InterfaceName createInterfaceName() { InterfaceName interfaceName = new InterfaceName(); interfaceName.setDocBookVersion(docBookVersion); return interfaceName; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createInterfaceName(java.lang.String) */ public InterfaceName createInterfaceName(String name) { InterfaceName interfaceName = new InterfaceName(name); interfaceName.setDocBookVersion(docBookVersion); return interfaceName; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createItemizedList() */ public ItemizedList createItemizedList() { ItemizedList itemizedList = new ItemizedList(); itemizedList.setDocBookVersion(docBookVersion); return itemizedList; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createLegalNotice() */ public LegalNotice createLegalNotice() { LegalNotice legalNotice = new LegalNotice(); legalNotice.setDocBookVersion(docBookVersion); return legalNotice; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createLink() */ public Link createLink() { Link link = new Link(); link.setDocBookVersion(docBookVersion); return link; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createLink(org.dbdoclet.trafo.tag.docbook.Literal, java.lang.String) */ public Link createLink(Literal literal, String ref) { Link link = new Link(literal, ref); link.setDocBookVersion(docBookVersion); return link; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createLink(org.dbdoclet.trafo.tag.docbook.VarName, java.lang.String) */ public Link createLink(VarName varName, String ref) { Link link = new Link(varName, ref); link.setDocBookVersion(docBookVersion); return link; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createLink(java.lang.String) */ public Link createLink(String href) { Link link = new Link(href); link.setDocBookVersion(docBookVersion); return link; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createLink(java.lang.String, java.lang.String) */ public Link createLink(String label, String ref) { Link link = new Link(label, ref); link.setDocBookVersion(docBookVersion); return link; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createLinkAsString(java.lang.String, java.lang.String) */ public String createLinkAsString(String label, String ref) throws IOException { Link link = new Link(label, ref); link.setDocBookVersion(docBookVersion); return NodeSerializer.toXML(link); } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createListItem() */ public ListItem createListItem() { ListItem listItem = new ListItem(); listItem.setDocBookVersion(docBookVersion); return listItem; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createLiteral() */ public Literal createLiteral() { Literal literal = new Literal(); literal.setDocBookVersion(docBookVersion); return literal; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createLiteral(java.lang.String) */ public Literal createLiteral(String text) { Literal literal = new Literal(text); literal.setDocBookVersion(docBookVersion); return literal; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createManVolNum(java.lang.String) */ public ManVolNum createManVolNum(String num) { ManVolNum manVolNum = new ManVolNum(num); manVolNum.setDocBookVersion(docBookVersion); return manVolNum; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createMediaObject() */ public MediaObject createMediaObject() { MediaObject mediaObject = new MediaObject(); mediaObject.setDocBookVersion(docBookVersion); return mediaObject; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createMember() */ public Member createMember() { Member member = new Member(); member.setDocBookVersion(docBookVersion); return member; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createMethodName() */ public MethodName createMethodName() { MethodName methodName = new MethodName(); methodName.setDocBookVersion(docBookVersion); return methodName; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createMethodName(java.lang.String) */ public MethodName createMethodName(String text) { MethodName methodName = new MethodName(text); methodName.setDocBookVersion(docBookVersion); return methodName; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createMethodParam() */ public MethodParam createMethodParam() { MethodParam methodParam = new MethodParam(); methodParam.setDocBookVersion(docBookVersion); return methodParam; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createMethodSynopsis() */ public MethodSynopsis createMethodSynopsis() { MethodSynopsis methodSynopsis = new MethodSynopsis(); methodSynopsis.setDocBookVersion(docBookVersion); return methodSynopsis; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createModifier() */ public Modifier createModifier() { Modifier modifier = new Modifier(); modifier.setDocBookVersion(docBookVersion); return modifier; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createModifier(java.lang.String) */ public Modifier createModifier(String text) { Modifier modifier = new Modifier(); modifier.appendChild(text); modifier.setDocBookVersion(docBookVersion); return modifier; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createNote() */ public Note createNote() { Note note = new Note(); note.setDocBookVersion(docBookVersion); return note; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createOoClass() */ public OoClass createOoClass() { OoClass ooClass = new OoClass(); ooClass.setDocBookVersion(docBookVersion); return ooClass; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createOoException() */ public OoException createOoException() { OoException ooException = new OoException(); ooException.setDocBookVersion(docBookVersion); return ooException; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createOoInterface() */ public OoInterface createOoInterface() { OoInterface ooInterface = new OoInterface(); ooInterface.setDocBookVersion(docBookVersion); return ooInterface; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createOrderedList() */ public OrderedList createOrderedList() { OrderedList orderedList = new OrderedList(); orderedList.setDocBookVersion(docBookVersion); return orderedList; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createOlink(java.lang.String, java.lang.String, java.lang.String) */ public Olink createOlink(String label, String targetdoc, String targetptr) { Olink olink = new Olink(label, targetdoc, targetptr); olink.setDocBookVersion(docBookVersion); return olink; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createPara() */ public Para createPara() { Para para = new Para(); para.setDocBookVersion(docBookVersion); return para; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createPara(java.lang.String) */ public Para createPara(String text) { Para para = new Para(text); para.setDocBookVersion(docBookVersion); return para; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createParamDef() */ public ParamDef createParamDef() { ParamDef paramDef = new ParamDef(); paramDef.setDocBookVersion(docBookVersion); return paramDef; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createParameter(java.lang.String) */ public Parameter createParameter(String name) { Parameter parameter = new Parameter(name); parameter.setDocBookVersion(docBookVersion); return parameter; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createPart() */ public Part createPart() { Part part = new Part(); part.setDocBookVersion(docBookVersion); return part; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createPartInfo() */ public PartInfo createPartInfo() { PartInfo partInfo = new PartInfo(); partInfo.setDocBookVersion(docBookVersion); return partInfo; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createPartIntro() */ public PartIntro createPartIntro() { PartIntro partIntro = new PartIntro(); partIntro.setDocBookVersion(docBookVersion); return partIntro; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createPhrase() */ public Phrase createPhrase() { Phrase phrase = new Phrase(); phrase.setDocBookVersion(docBookVersion); return phrase; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createPrimary(java.lang.String) */ public Primary createPrimary(String key) { Primary primary = new Primary(key); primary.setDocBookVersion(docBookVersion); return primary; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createProgramListing() */ public ProgramListing createProgramListing() { ProgramListing programListing = new ProgramListing(); programListing.setDocBookVersion(docBookVersion); return programListing; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createProgramListing(java.lang.String) */ public ProgramListing createProgramListing(String str) { ProgramListing programListing = new ProgramListing(str); programListing.setDocBookVersion(docBookVersion); return programListing; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createQuote() */ public Quote createQuote() { Quote quote = new Quote(); quote.setDocBookVersion(docBookVersion); return quote; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefEntry() */ public RefEntry createRefEntry() { RefEntry refEntry = new RefEntry(); refEntry.setDocBookVersion(docBookVersion); return refEntry; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefEntryInfo() */ public RefEntryInfo createRefEntryInfo() { RefEntryInfo refEntryInfo = new RefEntryInfo(); refEntryInfo.setDocBookVersion(docBookVersion); return refEntryInfo; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createReference() */ public Reference createReference() { Reference reference = new Reference(); reference.setDocBookVersion(docBookVersion); return reference; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefMeta() */ public RefMeta createRefMeta() { RefMeta refMeta = new RefMeta(); refMeta.setDocBookVersion(docBookVersion); return refMeta; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefMiscInfo(java.lang.String, java.lang.String) */ public RefMiscInfo createRefMiscInfo(String clazz, String info) { RefMiscInfo refMiscInfo = new RefMiscInfo(clazz, info); refMiscInfo.setDocBookVersion(docBookVersion); return refMiscInfo; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefName(java.lang.String) */ public RefName createRefName(String name) { RefName refName = new RefName(name); refName.setDocBookVersion(docBookVersion); return refName; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefNameDiv() */ public RefNameDiv createRefNameDiv() { RefNameDiv refNameDiv = new RefNameDiv(); refNameDiv.setDocBookVersion(docBookVersion); return refNameDiv; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefPurpose() */ public RefPurpose createRefPurpose() { RefPurpose refPurpose = new RefPurpose(); refPurpose.setDocBookVersion(docBookVersion); return refPurpose; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefSect1() */ public RefSect1 createRefSect1() { RefSect1 refSect1 = new RefSect1(); refSect1.setDocBookVersion(docBookVersion); return refSect1; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefSect1(java.lang.String) */ public RefSect1 createRefSect1(String title) { RefSect1 refSect1 = new RefSect1(title); refSect1.setDocBookVersion(docBookVersion); return refSect1; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefSect2() */ public RefSect2 createRefSect2() { RefSect2 refSect2 = new RefSect2(); refSect2.setDocBookVersion(docBookVersion); return refSect2; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefSect2(java.lang.String) */ public RefSect2 createRefSect2(String title) { RefSect2 refSect2 = new RefSect2(title); refSect2.setDocBookVersion(docBookVersion); return refSect2; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefSect3() */ public RefSect3 createRefSect3() { RefSect3 refSect3 = new RefSect3(); refSect3.setDocBookVersion(docBookVersion); return refSect3; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefSect4() */ public RefSect4 createRefSect4() { RefSect4 refSect4 = new RefSect4(); refSect4.setDocBookVersion(docBookVersion); return refSect4; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefSect5() */ public RefSect5 createRefSect5() { RefSect5 refSect5 = new RefSect5(); refSect5.setDocBookVersion(docBookVersion); return refSect5; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRefSynopsisDiv() */ public RefSynopsisDiv createRefSynopsisDiv() { RefSynopsisDiv refSynopsisDiv = new RefSynopsisDiv(); refSynopsisDiv.setDocBookVersion(docBookVersion); return refSynopsisDiv; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createReleaseInfo() */ public ReleaseInfo createReleaseInfo() { ReleaseInfo releaseInfo = new ReleaseInfo(); releaseInfo.setDocBookVersion(docBookVersion); return releaseInfo; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createReleaseInfo(java.lang.String) */ public ReleaseInfo createReleaseInfo(String text) { ReleaseInfo releaseInfo = new ReleaseInfo(); releaseInfo.appendChild(text); releaseInfo.setDocBookVersion(docBookVersion); return releaseInfo; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createRow() */ public Row createRow() { Row row = new Row(); row.setDocBookVersion(docBookVersion); return row; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createScreen() */ public Screen createScreen() { Screen screen = new Screen(); screen.setDocBookVersion(docBookVersion); return screen; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSecondary(java.lang.String) */ public Secondary createSecondary(String key) { Secondary secondary = new Secondary(key); secondary.setDocBookVersion(docBookVersion); return secondary; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSect1() */ public Sect1 createSect1() { Sect1 sect1 = new Sect1(); sect1.setDocBookVersion(docBookVersion); return sect1; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSect1(java.lang.String) */ public Sect1 createSect1(String title) { Sect1 sect1 = new Sect1(title); sect1.setDocBookVersion(docBookVersion); return sect1; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSect2() */ public Sect2 createSect2() { Sect2 sect2 = new Sect2(); sect2.setDocBookVersion(docBookVersion); return sect2; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSect2(java.lang.String) */ public Sect2 createSect2(String str) { Sect2 sect2 = new Sect2(str); sect2.setDocBookVersion(docBookVersion); return sect2; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSect3() */ public Sect3 createSect3() { Sect3 sect3 = new Sect3(); sect3.setDocBookVersion(docBookVersion); return sect3; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSect3(java.lang.String) */ public Sect3 createSect3(String str) { Sect3 sect3 = new Sect3(str); sect3.setDocBookVersion(docBookVersion); return sect3; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSect4() */ public Sect4 createSect4() { Sect4 sect4 = new Sect4(); sect4.setDocBookVersion(docBookVersion); return sect4; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSect5() */ public Sect5 createSect5() { Sect5 sect5 = new Sect5(); sect5.setDocBookVersion(docBookVersion); return sect5; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSection() */ public Section createSection() { Section section = new Section(); section.setDocBookVersion(docBookVersion); return section; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSection(java.lang.String) */ public Section createSection(String title) { Section section = new Section(title); section.setDocBookVersion(docBookVersion); return section; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSimPara() */ public SimPara createSimPara() { SimPara simPara = new SimPara(); simPara.setDocBookVersion(docBookVersion); return simPara; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSimPara(java.lang.String) */ public SimPara createSimPara(String text) { SimPara simPara = new SimPara(); simPara.appendChild(text); simPara.setDocBookVersion(docBookVersion); return simPara; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSimpleList() */ public SimpleList createSimpleList() { SimpleList simpleList = new SimpleList(); simpleList.setDocBookVersion(docBookVersion); return simpleList; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSimpleList(int) */ public SimpleList createSimpleList(int type) { SimpleList simpleList = createSimpleList(); simpleList.setType(type); return simpleList; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSimpleSect() */ public SimpleSect createSimpleSect() { SimpleSect simpleSect = new SimpleSect(); simpleSect.setDocBookVersion(docBookVersion); return simpleSect; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSpanspec() */ public Spanspec createSpanspec() { Spanspec spanspec = new Spanspec(); spanspec.setDocBookVersion(docBookVersion); return spanspec; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSubscript() */ public Subscript createSubscript() { Subscript subscript = new Subscript(); subscript.setDocBookVersion(docBookVersion); return subscript; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSuperscript() */ public Superscript createSuperscript() { Superscript superscript = new Superscript(); superscript.setDocBookVersion(docBookVersion); return superscript; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSurname() */ public Surname createSurname() { Surname surname = new Surname(); surname.setDocBookVersion(docBookVersion); return surname; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSurname(java.lang.String) */ public Surname createSurname(String name) { Surname surname = new Surname(); surname.appendChild(name); surname.setDocBookVersion(docBookVersion); return surname; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createSynopsis() */ public Synopsis createSynopsis() { Synopsis synopsis = new Synopsis(); synopsis.setDocBookVersion(docBookVersion); return synopsis; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createTable() */ public Table createTable() { Table table = new Table(); table.setDocBookVersion(docBookVersion); return table; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createTag(java.lang.String) */ public DocBookElement createTag(String name) throws DocBookTagFactoryException { DocBookElement docBookElement = new DocBookElement(name); docBookElement.setDocBookVersion(docBookVersion); return docBookElement; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createTbody() */ public Tbody createTbody() { Tbody tbody = new Tbody(); tbody.setDocBookVersion(docBookVersion); return tbody; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createTerm() */ public Term createTerm() { Term term = new Term(); term.setDocBookVersion(docBookVersion); return term; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createTextObject() */ public TextObject createTextObject() { TextObject textObject = new TextObject(); textObject.setDocBookVersion(docBookVersion); return textObject; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createTfoot() */ public Tfoot createTfoot() { Tfoot tfoot = new Tfoot(); tfoot.setDocBookVersion(docBookVersion); return tfoot; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createTgroup() */ public Tgroup createTgroup() { Tgroup tgroup = new Tgroup(); tgroup.setDocBookVersion(docBookVersion); return tgroup; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createTgroup(int) */ public Tgroup createTgroup(int cols) { Tgroup tgroup = new Tgroup(); tgroup.setDocBookVersion(docBookVersion); tgroup.setCols(2); tgroup.appendChild(new Colspec("c1", "1*")); tgroup.appendChild(new Colspec("c2", "1*")); return tgroup; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createThead() */ public Thead createThead() { Thead thead = new Thead(); thead.setDocBookVersion(docBookVersion); return thead; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createTip() */ public Tip createTip() { Tip tip = new Tip(); tip.setDocBookVersion(docBookVersion); return tip; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createTitle() */ public Title createTitle() { Title title = new Title(); title.setDocBookVersion(docBookVersion); return title; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createTitle(java.lang.String) */ public Title createTitle(String str) { Title title = new Title(str); title.setDocBookVersion(docBookVersion); return title; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createType() */ public Type createType() { Type type = new Type(); type.setDocBookVersion(docBookVersion); return type; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createULink() */ public ULink createULink() { ULink uLink = new ULink(); uLink.setDocBookVersion(docBookVersion); return uLink; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createVariableList() */ public VariableList createVariableList() { VariableList variableList = new VariableList(); variableList.setDocBookVersion(docBookVersion); return variableList; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createVarListEntry() */ public VarListEntry createVarListEntry() { VarListEntry varListEntry = new VarListEntry(); varListEntry.setDocBookVersion(docBookVersion); return varListEntry; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createVarName() */ public VarName createVarName() { VarName varName = new VarName(); varName.setDocBookVersion(docBookVersion); return varName; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createVarName(java.lang.String) */ public VarName createVarName(String text) { VarName varName = new VarName(text); varName.setDocBookVersion(docBookVersion); return varName; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createVoid() */ public Void createVoid() { Void _void = new Void(); _void.setDocBookVersion(docBookVersion); return _void; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createWarning() */ public Warning createWarning() { Warning warning = new Warning(); warning.setDocBookVersion(docBookVersion); return warning; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createWarning(java.lang.String) */ public Warning createWarning(String text) { Warning warning = new Warning(text); warning.setDocBookVersion(docBookVersion); return warning; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createXRef(java.lang.String) */ public XRef createXRef(String linkend) { XRef xref = new XRef(linkend); xref.setDocBookVersion(docBookVersion); return xref; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createYear() */ public Year createYear() { Year year = new Year(); year.setDocBookVersion(docBookVersion); return year; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#createYear(java.lang.String) */ public Year createYear(String text) { Year year = new Year(); year.appendChild(text); year.setDocBookVersion(docBookVersion); return year; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#getDocBookVersion() */ public DocBookVersion getDocBookVersion() { return docBookVersion; } /* (non-Javadoc) * @see org.dbdoclet.trafo.tag.docbook.TagFactory#isDocBook5() */ public boolean isDocBook5() { if (docBookVersion != null && docBookVersion == DocBookVersion.V5_0) { return true; } return false; } }src/java/org/dbdoclet/trafo/tag/docbook/Function.java0000644000000000000000000000065412124530526021576 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Function extends DocBookElement { Function(String function) { super("function"); appendChild(function); setFormatType(FORMAT_INLINE); } } src/java/org/dbdoclet/trafo/tag/docbook/ImageData.java0000644000000000000000000000423512124530526021624 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.service.StringServices; public class ImageData extends DocBookElement { ImageData() { super("imagedata"); isEmpty(true); setFormatType(FORMAT_INLINE); } public DocBookElement setAlign(String align) { if (align == null) { throw new IllegalArgumentException("Parameter align is null!"); } setAttribute("align", align); return this; } public DocBookElement setContentDepth(String depth) { if (depth == null || depth.trim().length() == 0) { removeAttribute("contentdepth"); } setAttribute("contentdepth", depth); return this; } public DocBookElement setContentWidth(String width) { if (width == null || width.trim().length() == 0) { removeAttribute("contentwidth"); } setAttribute("contentwidth", width); return this; } public DocBookElement setDepth(String depth) { if (depth == null || depth.trim().length() == 0) { removeAttribute("depth"); } setAttribute("depth", depth); return this; } public DocBookElement setFileRef(String fileref) { if (fileref == null) { throw new IllegalArgumentException("Parameter fileref is null!"); } fileref = StringServices.replace(fileref, "\\", "/"); setAttribute("fileref", fileref); return this; } public DocBookElement setFormat(String format) { if (format == null) { throw new IllegalArgumentException("Parameter format is null!"); } setAttribute("format", format.toUpperCase()); return this; } public DocBookElement setScale(int scale) { setAttribute("scale", String.valueOf(scale)); return this; } public DocBookElement setScaleFit(boolean scalefit) { if (scalefit == true) { setAttribute("scalefit", "1"); } else { setAttribute("scalefit", "0"); } return this; } public DocBookElement setWidth(String width) { if (width == null) { throw new IllegalArgumentException("Parameter width is null!"); } setAttribute("width", width); return this; } } src/java/org/dbdoclet/trafo/tag/docbook/Note.java0000644000000000000000000000136512124530526020716 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Note extends DocBookElement { private static String tag = "note"; public static HashMap getAttributeMap() { return new HashMap(); } public static String getTag() { return tag; } Note() { super("note"); setFormatType(FORMAT_BLOCK); } Note(String strTitle) { super("note"); Title title = new Title(strTitle); title.setParentNode(this); appendChild(title); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/Literal.java0000644000000000000000000000327212124530526021404 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Literal extends DocBookElement { private static String tag = "literal"; private static HashMap> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Abbrev.getTag(), Abbrev.getAttributeMap()); invalidParentMap.put(Acronym.getTag(), Acronym.getAttributeMap()); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); invalidParentMap.put(ExceptionName.getTag(), ExceptionName.getAttributeMap()); invalidParentMap.put(Literal.getTag(), Literal.getAttributeMap()); invalidParentMap.put(Section.getTag(), Section.getAttributeMap()); invalidParentMap.put(Subscript.getTag(), Subscript.getAttributeMap()); invalidParentMap.put(Superscript.getTag(), Superscript.getAttributeMap()); } public static String getTag() { return tag; } Literal() { super(tag); setFormatType(FORMAT_INLINE); } Literal(String text) { super(tag); appendChild(text); setFormatType(FORMAT_INLINE); } @Override public boolean validate() { return validate(invalidParentMap); } @Override public boolean isValidParent(DocBookElement elem) { if (elem == null) { throw new IllegalArgumentException("Parameter elem is null!"); } if (invalidParentMap.get(elem.getNodeName()) != null) { return false; } return true; } } src/java/org/dbdoclet/trafo/tag/docbook/DocBookElement.java0000644000000000000000000001374312124530526022646 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; import org.dbdoclet.xiphias.dom.ElementImpl; public class DocBookElement extends ElementImpl { public static final String DOCBOOK_NAMESPACE = "http://docbook.org/ns/docbook"; public static final String XLINK_NAMESPACE = "http://www.w3.org/1999/xlink"; private DocBookVersion docBookVersion = DocBookVersion.V5_0; private boolean isContentModel = false; private boolean isNew = true; DocBookElement(String name) { super(name); } public static HashMap getAttributeMap() { return new HashMap(); } public static void setFlavour(String flavour) { if (flavour == null) { throw new IllegalArgumentException( " The argument flavour must not be null!"); } if (flavour.equalsIgnoreCase("xml") || flavour.equalsIgnoreCase("sgml")) { flavour.toLowerCase(); } } public static boolean validate2( HashMap> validParentMap, DocBookElement element, DocBookElement parent) { if (validParentMap == null) { throw new IllegalArgumentException( "Variable validParentMap is null!"); } if (element == null) { throw new IllegalArgumentException( "The argument element must not be null!"); } if (parent == null) { throw new IllegalArgumentException("Variable parent is null!"); } if (element.isSection() == false && parent.isSection() == true) { SectionElement sect = (SectionElement) parent; if (sect.hasSectionChildren()) { return false; } } if (validParentMap.get(parent.getNodeName()) != null) { return true; } return false; } public void closed() { // } public String getCondition() { return getAttribute("condition"); } public DocBookVersion getDocBookVersion() { return docBookVersion; } @Override public String getId() { if (docBookVersion == DocBookVersion.V4_5) { return getAttribute("id"); } else { return getAttribute("xml:id"); } } public String getRemap() { return getAttribute("remap"); } public boolean isContentModel() { if (getNodeName().equalsIgnoreCase(".")) { return true; } return isContentModel; } public void isContentModel(boolean isContentModel) { this.isContentModel = isContentModel; } public boolean isList() { String name = getNodeName(); if (name == null) { return false; } if (name.equalsIgnoreCase("orderedlist")) { return true; } if (name.equalsIgnoreCase("itemizedlist")) { return true; } if (name.equalsIgnoreCase("variablelist")) { return true; } return false; } public boolean isMixedContentModel() { return !isContentModel(); } public void isMixedContentModel(boolean isMixedContentModel) { this.isContentModel = !isMixedContentModel; } public boolean isNew() { return isNew; } public void isNew(boolean isNew) { this.isNew = isNew; } public boolean isSection() { String name = getNodeName(); if (name.equalsIgnoreCase("book")) { return true; } if (name.equalsIgnoreCase("article")) { return true; } if (name.equalsIgnoreCase("chapter")) { return true; } if (name.equalsIgnoreCase("sect1")) { return true; } if (name.equalsIgnoreCase("sect2")) { return true; } if (name.equalsIgnoreCase("sect3")) { return true; } if (name.equalsIgnoreCase("sect4")) { return true; } if (name.equalsIgnoreCase("sect5")) { return true; } if (name.equalsIgnoreCase("section")) { return true; } if (name.equalsIgnoreCase("simplesect")) { return true; } return false; } public boolean isValidParent(DocBookElement elem) { return true; } public DocBookElement setCondition(String condition) { if (condition == null) { return this; } setAttribute("condition", condition); return this; } public void setDocBookVersion(DocBookVersion docBookVersion) { this.docBookVersion = docBookVersion; } @Override public void setId(int number) { if (docBookVersion == DocBookVersion.V4_5) { setAttribute("id", String.valueOf(number)); } else { setAttribute("xml:id", String.valueOf(number)); } } @Override public void setId(String id) { if (id == null || id.length() == 0) { return; } if (docBookVersion == DocBookVersion.V5_0) { setAttribute("xml:id", hardenId(id)); } else { setAttribute("id", hardenId(id)); } } public void setLang(String lang) { if (lang == null || lang.length() == 0) { return; } if (docBookVersion == DocBookVersion.V5_0) { setAttribute("xml:lang", lang); } else { setAttribute("lang", lang); } } public DocBookElement setRemap(String remap) { if (remap == null) { return this; } setAttribute("remap", remap); return this; } public DocBookElement setRole(String role) { if (role == null) { return this; } setAttribute("role", role); return this; } public DocBookElement setXrefLabel(String label) { if (label == null) { return this; } setAttribute("xreflabel", label); return this; } public boolean validate() { DocBookElement parent = (DocBookElement) getParentNode(); if (parent != null) { if (isSection() == false && parent.isSection() == true) { SectionElement sect = (SectionElement) parent; if (sect.hasSectionChildren()) { return false; } } } return true; } public boolean validate( HashMap> invalidParentMap) { if (invalidParentMap.get(getParentNode().getNodeName()) != null) { return false; } return true; } public boolean validate2( HashMap> validParentMap) { return validate2(validParentMap, this, (DocBookElement) getParentNode()); } protected boolean isDocBook5() { if (docBookVersion == DocBookVersion.V5_0) { return true; } else { return false; } } } src/java/org/dbdoclet/trafo/tag/docbook/TextObject.java0000644000000000000000000000117112124530526022057 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class TextObject extends DocBookElement { private static String tag = "textobject"; TextObject() { super(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/Caution.java0000644000000000000000000000145612124530526021414 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Caution extends DocBookElement { private static String tag = "caution"; Caution() { super("caution"); setFormatType(FORMAT_BLOCK); } Caution(String strTitle) { this(); Title title = new Title(strTitle); title.setParentNode(this); appendChild(title); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/Holder.java0000644000000000000000000000113012124530526021214 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.XmlServices; public class Holder extends DocBookElement { private static String tagName = "holder"; Holder() { super(tagName); setFormatType(FORMAT_INLINE); isMixedContentModel(true); } Holder(String text) { this(); appendChild(XmlServices.textToXml(text)); } } src/java/org/dbdoclet/trafo/tag/docbook/Date.java0000644000000000000000000000112012124530526020653 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.XmlServices; public class Date extends DocBookElement { private static String tagName = "date"; Date() { super(tagName); setFormatType(FORMAT_INLINE); isMixedContentModel(true); } Date(String text) { this(); appendChild(XmlServices.textToXml(text)); } } src/java/org/dbdoclet/trafo/tag/docbook/RefSect2.java0000644000000000000000000000137012124530526021422 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class RefSect2 extends DocBookElement { private static String tagName = "refsect2"; RefSect2() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } RefSect2(String title) { this(); appendChild(new Title(title)); } public static String getTag() { return tagName; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/InterfaceName.java0000644000000000000000000000074512124530526022513 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class InterfaceName extends DocBookElement { private static String tagName = "interfacename"; InterfaceName() { super(tagName); } InterfaceName(String interfacename) { this(); appendChild(interfacename); } } src/java/org/dbdoclet/trafo/tag/docbook/ReleaseInfo.java0000644000000000000000000000115412124530526022201 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.XmlServices; public class ReleaseInfo extends DocBookElement { private static String tagName = "releaseinfo"; ReleaseInfo() { super(tagName); setFormatType(FORMAT_INLINE); isMixedContentModel(true); } ReleaseInfo(String text) { this(); appendChild(XmlServices.textToXml(text)); } } src/java/org/dbdoclet/trafo/tag/docbook/Screen.java0000644000000000000000000000066412124530526021231 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Screen extends DocBookElement { Screen() { super("screen"); setFormatType(FORMAT_CONTENT); isLiteral(true); } Screen(String text) { this(); appendChild(text); } } src/java/org/dbdoclet/trafo/tag/docbook/ClassSynopsisInfo.java0000644000000000000000000000107212124530526023435 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class ClassSynopsisInfo extends DocBookElement { private static final String tag = "classsynopsisinfo"; ClassSynopsisInfo() { super(tag); setFormatType(FORMAT_CONTENT); isLiteral(true); } ClassSynopsisInfo(String text) { this(); appendChild(text); } } src/java/org/dbdoclet/trafo/tag/docbook/LegalNotice.java0000644000000000000000000000072312124530526022174 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class LegalNotice extends DocBookElement { private static String tagName = "legalnotice"; LegalNotice() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } } src/java/org/dbdoclet/trafo/tag/docbook/Appendix.java0000644000000000000000000000115612124530526021557 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Appendix extends SectionElement { private static final String tagName = "appendix"; Appendix() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } Appendix(String title) { this(); appendChild(new Title(title)); } public static String getTag() { return tagName; } }src/java/org/dbdoclet/trafo/tag/docbook/Entry.java0000644000000000000000000000422212124530526021105 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.dom.ElementImpl; public class Entry extends DocBookElement { private static String tag = "entry"; public static String getTag() { return tag; } Entry() { super(tag); } Entry(String text) { super(tag); appendChild(new Para(text).setFormatType(ElementImpl.FORMAT_INLINE)); } public Entry setAlign(String align) { if (align != null) { align = align.toLowerCase(); } setAttribute("align", align); return this; } public Entry setChar(String charAttr) { setAttribute("char", charAttr); return this; } public Entry setCharOff(String charOff) { setAttribute("charOff", charOff); return this; } public Entry setMorerows(int mr) { setAttribute("morerows", new Integer(mr)); return this; } public Entry setNameEnd(String s) { setAttribute("nameend", s); return this; } public Entry setNameSt(String s) { setAttribute("namest", s); return this; } Entry setSpanname(String sn) { setAttribute("spanname", sn); return this; } public Entry setVAlign(String valign) { if (valign != null) { valign = valign.toLowerCase(); } setAttribute("valign", valign); return this; } @Override protected boolean validateAttributes() { String attr; attr = getAttribute("align"); if ((attr != null) && (attr.equalsIgnoreCase("left") == false) && (attr.equalsIgnoreCase("right") == false) && (attr.equalsIgnoreCase("center") == false) && (attr.equalsIgnoreCase("justify") == false) && (attr.equalsIgnoreCase("char") == false)) { setAttribute("align", "center"); } attr = getAttribute("valign"); if ((attr != null) && (attr.equalsIgnoreCase("top") == false) && (attr.equalsIgnoreCase("middle") == false) && (attr.equalsIgnoreCase("baseline") == false) && (attr.equalsIgnoreCase("bottom") == false)) { setAttribute("valign", "middle"); } return true; } } src/java/org/dbdoclet/trafo/tag/docbook/Tbody.java0000644000000000000000000000055512124530526021072 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Tbody extends Telem { Tbody() { super("tbody"); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/Phrase.java0000644000000000000000000000057112124530526021231 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Phrase extends DocBookElement { Phrase() { super("phrase"); setFormatType(FORMAT_INLINE); } } src/java/org/dbdoclet/trafo/tag/docbook/MethodSynopsis.java0000644000000000000000000000111512124530526022772 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class MethodSynopsis extends DocBookElement { private static final String tagName = "methodsynopsis"; MethodSynopsis() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); setAttribute("language", "java"); } public void setLanguage(String language) { setAttribute("language", language); } } src/java/org/dbdoclet/trafo/tag/docbook/XRef.java0000644000000000000000000000075112124530526020653 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class XRef extends DocBookElement { XRef(String linkend) { super("xref"); setAttribute("linkend", hardenId(linkend)); setFormatType(FORMAT_INLINE); isEmpty(true); needsPadding(false); } } src/java/org/dbdoclet/trafo/tag/docbook/InlineMediaObject.java0000644000000000000000000000061412124530526023312 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class InlineMediaObject extends DocBookElement { InlineMediaObject() { super("inlinemediaobject"); setFormatType(FORMAT_INLINE); } } src/java/org/dbdoclet/trafo/tag/docbook/RefNameDiv.java0000644000000000000000000000060512124530526021765 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class RefNameDiv extends DocBookElement { RefNameDiv() { super("refnamediv"); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/Copyright.java0000644000000000000000000000071512124530526021757 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Copyright extends DocBookElement { private static String tagName = "copyright"; Copyright() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } } src/java/org/dbdoclet/trafo/tag/docbook/Link.java0000644000000000000000000000227212124530526020704 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; import org.dbdoclet.xiphias.XmlServices; public class Link extends DocBookElement { private static final HashMap> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); } Link() { super("link"); } Link(DocBookElement label, String linkend) { this(linkend); appendChild(label); } Link(String linkend) { this(); setAttribute("linkend", hardenId(linkend)); setFormatType(FORMAT_INLINE); } Link(String label, String linkend) { this(linkend); appendChild(XmlServices.textToXml(label)); } public void setHref(String href) { if (isDocBook5() == true) { setAttribute("xl:href", href); } else { setAttribute("linkend", href); } } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/Index.java0000644000000000000000000000053012124530526021051 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Index extends DocBookElement { Index() { super("index"); isEmpty(true); } } src/java/org/dbdoclet/trafo/tag/docbook/Abstract.java0000644000000000000000000000071212124530526021547 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Abstract extends DocBookElement { private static String tagName = "abstract"; Abstract() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } } src/java/org/dbdoclet/trafo/tag/docbook/ItemizedList.java0000644000000000000000000000113212124530526022407 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class ItemizedList extends DocBookElement { private static String tag = "itemizedlist"; public static HashMap getAttributeMap() { return new HashMap(); } public static String getTag() { return tag; } ItemizedList() { super("itemizedlist"); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/IndexTerm.java0000644000000000000000000000056312124530526021707 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class IndexTerm extends DocBookElement { IndexTerm() { super("indexterm"); setFormatType(FORMAT_INLINE); } } src/java/org/dbdoclet/trafo/tag/docbook/Address.java0000644000000000000000000000222212124530526021367 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; import org.dbdoclet.xiphias.XmlServices; public class Address extends DocBookElement { private static final String tagName = "address"; private static final HashMap> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Subscript.getTag(), Subscript.getAttributeMap()); invalidParentMap.put(Superscript.getTag(), Superscript.getAttributeMap()); } Address() { super(tagName); setFormatType(FORMAT_BLOCK); isMixedContentModel(true); } Address(String text) { this(); appendChild(XmlServices.textToXml(text)); } public static String getTag() { return tagName; } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/RefSection.java0000644000000000000000000000127312124530526022050 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class RefSection extends DocBookElement { private static String tagName = "refsection"; RefSection() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } RefSection(String title) { this(); appendChild(new Title(title)); } public static String getTag() { return tagName; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/DocBookTagFactoryException.java0000644000000000000000000000066012124530526025171 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class DocBookTagFactoryException extends Exception { private static final long serialVersionUID = 1L; DocBookTagFactoryException(String msg) { super(msg); } } src/java/org/dbdoclet/trafo/tag/docbook/FormalPara.java0000644000000000000000000000131712124530526022032 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class FormalPara extends DocBookElement { private static String tag = "formalpara"; FormalPara() { super("formalpara"); setFormatType(FORMAT_BLOCK); } FormalPara(String text) { this(); appendChild(text); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/RefSynopsisDiv.java0000644000000000000000000000114012124530526022727 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class RefSynopsisDiv extends DocBookElement { private static String tag = "refsynopsisdiv"; RefSynopsisDiv() { super(tag); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/Reference.java0000644000000000000000000000076212124530526021707 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Reference extends DocBookElement { private static String tagName = "reference"; Reference() { super(tagName); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tagName; } } src/java/org/dbdoclet/trafo/tag/docbook/Secondary.java0000644000000000000000000000066412124530526021741 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Secondary extends DocBookElement { Secondary(String secondary) { super("secondary"); setFormatType(FORMAT_INLINE); appendChild(secondary); } } src/java/org/dbdoclet/trafo/tag/docbook/Markup.java0000644000000000000000000000505012124530526021243 0ustar rootroot/* * ### Copyright (C) 2011 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Markup extends DocBookElement { private static String tag = "markup"; private static HashMap> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); invalidParentMap.put(Article.getTag(), Article.getAttributeMap()); invalidParentMap.put(BlockQuote.getTag(), BlockQuote.getAttributeMap()); invalidParentMap.put(Book.getTag(), Book.getAttributeMap()); invalidParentMap.put(Chapter.getTag(), Chapter.getAttributeMap()); invalidParentMap.put(ListItem.getTag(), ListItem.getAttributeMap()); invalidParentMap.put(Sect1.getTag(), Sect1.getAttributeMap()); invalidParentMap.put(Sect2.getTag(), Sect2.getAttributeMap()); invalidParentMap.put(Sect3.getTag(), Sect3.getAttributeMap()); invalidParentMap.put(Sect4.getTag(), Sect4.getAttributeMap()); invalidParentMap.put(Sect5.getTag(), Sect5.getAttributeMap()); invalidParentMap.put(Section.getTag(), Section.getAttributeMap()); invalidParentMap.put(SimpleSect.getTag(), SimpleSect.getAttributeMap()); invalidParentMap.put(Subscript.getTag(), Subscript.getAttributeMap()); invalidParentMap.put(Superscript.getTag(), Superscript.getAttributeMap()); } Markup() { super(tag); setFormatType(FORMAT_INLINE); } Markup(String text) { super(tag); appendChild(text); setFormatType(FORMAT_INLINE); } Markup(String text, String role) { super(tag); appendChild(text); setAttribute("role", role); setFormatType(FORMAT_INLINE); } Markup(DocBookElement elem) { super(tag); appendChild(elem); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public boolean validate() { return validate(invalidParentMap); } @Override public boolean isValidParent(DocBookElement elem) { if (elem == null) { throw new IllegalArgumentException("Parameter elem is null!"); } if (invalidParentMap.get(elem.getNodeName()) != null) { return false; } return true; } } src/java/org/dbdoclet/trafo/tag/docbook/Sect2.java0000644000000000000000000000123712124530526020767 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Sect2 extends SectionElement { private final static String tag = "sect2"; Sect2() { super(tag); setFormatType(FORMAT_BLOCK); isContentModel(true); } Sect2(String title) { super(tag); appendChild(new Title(title)); setFormatType(FORMAT_BLOCK); isContentModel(true); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/DocBookTagFactory.java0000644000000000000000000007162612124530526023324 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.io.IOException; import java.text.SimpleDateFormat; import org.dbdoclet.xiphias.NodeSerializer; public class DocBookTagFactory { private DocBookVersion docBookVersion = DocBookVersion.V5_0; public DocBookTagFactory() { this(DocBookVersion.V5_0); } public DocBookTagFactory(DocBookVersion docBookVersion) { this.docBookVersion = docBookVersion; } public Abbrev createAbbrev() { Abbrev abbrev = new Abbrev(); abbrev.setDocBookVersion(docBookVersion); return abbrev; } public Abstract createAbstract() { Abstract _abstract = new Abstract(); _abstract.setDocBookVersion(docBookVersion); return _abstract; } public Acronym createAcronym() { Acronym acronym = new Acronym(); acronym.setDocBookVersion(docBookVersion); return acronym; } public Address createAddress() { Address address = new Address(); address.setDocBookVersion(docBookVersion); return address; } public Affiliation createAffiliation() { Affiliation affiliation = new Affiliation(); affiliation.setDocBookVersion(docBookVersion); return affiliation; } public Anchor createAnchor() { Anchor anchor = new Anchor(); anchor.setDocBookVersion(docBookVersion); return anchor; } public Appendix createAppendix() { Appendix appendix = new Appendix(); appendix.setDocBookVersion(docBookVersion); return appendix; } public Article createArticle() { Article article = new Article(); article.setDocBookVersion(docBookVersion); return article; } public ArticleInfo createArticleInfo() { ArticleInfo articleInfo = new ArticleInfo(); articleInfo.setDocBookVersion(docBookVersion); return articleInfo; } public Author createAuthor() { Author author = new Author(); author.setDocBookVersion(docBookVersion); return author; } public BlockQuote createBlockQuote() { BlockQuote blockQuote = new BlockQuote(); blockQuote.setDocBookVersion(docBookVersion); return blockQuote; } public Book createBook() { Book book = new Book(); book.setDocBookVersion(docBookVersion); return book; } public BookInfo createBookInfo() { BookInfo bookInfo = new BookInfo(); bookInfo.setDocBookVersion(docBookVersion); return bookInfo; } public BridgeHead createBridgeHead() { BridgeHead bridgeHead = new BridgeHead(); bridgeHead.setDocBookVersion(docBookVersion); return bridgeHead; } public Caption createCaption() { Caption caption = new Caption(); caption.setDocBookVersion(docBookVersion); return caption; } public Caution createCaution() { Caution caution = new Caution(); caution.setDocBookVersion(docBookVersion); return caution; } public Chapter createChapter() { Chapter chapter = new Chapter(); chapter.setDocBookVersion(docBookVersion); return chapter; } public Chapter createChapter(String titleText) { Chapter chapter = new Chapter(); chapter.setDocBookVersion(docBookVersion); Info info = new Info(); chapter.appendChild(info); Title title = new Title(titleText); info.appendChild(title); return chapter; } public ClassName createClassName() { ClassName className = new ClassName(); className.setDocBookVersion(docBookVersion); return className; } public ClassName createClassName(String name) { ClassName className = new ClassName(name); className.setDocBookVersion(docBookVersion); return className; } public ClassSynopsis createClassSynopsis() { ClassSynopsis classSynopsis = new ClassSynopsis(); classSynopsis.setDocBookVersion(docBookVersion); return classSynopsis; } public ClassSynopsisInfo createClassSynopsisInfo() { ClassSynopsisInfo classSynopsisInfo = new ClassSynopsisInfo(); classSynopsisInfo.setDocBookVersion(docBookVersion); return classSynopsisInfo; } public ClassSynopsisInfo createClassSynopsisInfo(String text) { ClassSynopsisInfo classSynopsisInfo = new ClassSynopsisInfo(text); classSynopsisInfo.setDocBookVersion(docBookVersion); return classSynopsisInfo; } public Code createCode() { Code code = new Code(); code.setDocBookVersion(docBookVersion); return code; } public Colspec createColspec() { Colspec colspec = new Colspec(); colspec.setDocBookVersion(docBookVersion); return colspec; } public Colspec createColspec(String string, String width) { Colspec colspec = new Colspec(string, width); colspec.setDocBookVersion(docBookVersion); return colspec; } public ComputerOutput createComputerOutput() { ComputerOutput computerOutput = new ComputerOutput(); computerOutput.setDocBookVersion(docBookVersion); return computerOutput; } public ComputerOutput createComputerOutput(String text) { ComputerOutput computerOutput = new ComputerOutput(text); computerOutput.setDocBookVersion(docBookVersion); return computerOutput; } public ConstructorSynopsis createConstructorSynopsis() { ConstructorSynopsis constructorSynopsis = new ConstructorSynopsis(); constructorSynopsis.setDocBookVersion(docBookVersion); return constructorSynopsis; } public Copyright createCopyright() { Copyright copyright = new Copyright(); copyright.setDocBookVersion(docBookVersion); return copyright; } public Date createDate() { java.util.Date today = new java.util.Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date = new Date(sdf.format(today)); date.setDocBookVersion(docBookVersion); return date; } public Date createDate(String text) { Date date = new Date(text); date.setDocBookVersion(docBookVersion); return date; } public Email createEmail() { Email email = new Email(); email.setDocBookVersion(docBookVersion); return email; } public Email createEmail(String address) { Email email = new Email(); email.appendChild(address); email.setDocBookVersion(docBookVersion); return email; } public Emphasis createEmphasis() { Emphasis emphasis = new Emphasis(); emphasis.setDocBookVersion(docBookVersion); return emphasis; } public Emphasis createEmphasis(String str) { Emphasis emphasis = new Emphasis(str); emphasis.setDocBookVersion(docBookVersion); return emphasis; } public Emphasis createEmphasis(String str, String role) { Emphasis emphasis = createEmphasis(str); emphasis.setRole(role); return emphasis; } public Entry createEntry() { Entry entry = new Entry(); entry.setDocBookVersion(docBookVersion); return entry; } public Entry createEntry(String text) { Entry entry = new Entry(text); entry.setDocBookVersion(docBookVersion); return entry; } public EntryTbl createEntryTbl() { EntryTbl entryTbl = new EntryTbl(); entryTbl.setDocBookVersion(docBookVersion); return entryTbl; } public Example createExample(String title) { Example example = new Example(title); example.setDocBookVersion(docBookVersion); return example; } public ExceptionName createExceptionName() { ExceptionName exceptionName = new ExceptionName(); exceptionName.setDocBookVersion(docBookVersion); return exceptionName; } public ExceptionName createExceptionName(String text) { ExceptionName exceptionName = new ExceptionName(text); exceptionName.setDocBookVersion(docBookVersion); return exceptionName; } public FieldSynopsis createFieldSynopsis() { FieldSynopsis fieldSynopsis = new FieldSynopsis(); fieldSynopsis.setDocBookVersion(docBookVersion); return fieldSynopsis; } public Figure createFigure(String title) { Figure figure = new Figure(title); figure.setDocBookVersion(docBookVersion); return figure; } public FirstName createFirstName() { FirstName firstName = new FirstName(); firstName.setDocBookVersion(docBookVersion); return firstName; } public FirstName createFirstName(String name) { FirstName firstName = new FirstName(); firstName.appendChild(name); firstName.setDocBookVersion(docBookVersion); return firstName; } public FormalPara createFormalPara() { FormalPara formalPara = new FormalPara(); formalPara.setDocBookVersion(docBookVersion); return formalPara; } public DocBookElement createFormalPara(String title) { FormalPara formalPara = new FormalPara(title); formalPara.setDocBookVersion(docBookVersion); return formalPara; } public FuncDef createFuncDef() { FuncDef funcDef = new FuncDef(); funcDef.setDocBookVersion(docBookVersion); return funcDef; } public FuncPrototype createFuncPrototype() { FuncPrototype funcPrototype = new FuncPrototype(); funcPrototype.setDocBookVersion(docBookVersion); return funcPrototype; } public FuncSynopsis createFuncSynopsis() { FuncSynopsis funcSynopsis = new FuncSynopsis(); funcSynopsis.setDocBookVersion(docBookVersion); return funcSynopsis; } public Function createFunction(String func) { Function function = new Function(func); function.setDocBookVersion(docBookVersion); return function; } public Holder createHolder() { Holder holder = new Holder(); holder.setDocBookVersion(docBookVersion); return holder; } public Holder createHolder(String text) { Holder holder = new Holder(); holder.appendChild(text); holder.setDocBookVersion(docBookVersion); return holder; } public MediaObject createImage(String image) { return createImage(image, null, null); } public MediaObject createImage(String image, String width, String height) { MediaObject mediaObject = new MediaObject(); mediaObject.setDocBookVersion(docBookVersion); ImageObject imageObject = new ImageObject(); imageObject.setDocBookVersion(docBookVersion); mediaObject.appendChild(imageObject); ImageData imageData = new ImageData(); imageData.setDocBookVersion(docBookVersion); imageObject.appendChild(imageData); imageData.setFileRef(image); if (width != null && width.trim().length() > 0) { imageData.setWidth(String.valueOf(width)); } if (height != null && height.trim().length() > 0) { imageData.setDepth(String.valueOf(height)); } return mediaObject; } public ImageData createImageData() { ImageData imageData = new ImageData(); imageData.setDocBookVersion(docBookVersion); return imageData; } public ImageObject createImageObject() { ImageObject imageObject = new ImageObject(); imageObject.setDocBookVersion(docBookVersion); return imageObject; } public Important createImportant() { Important important = new Important(); important.setDocBookVersion(docBookVersion); return important; } public Index createIndex() { Index index = new Index(); index.setDocBookVersion(docBookVersion); return index; } public IndexTerm createIndexTerm() { IndexTerm indexTerm = new IndexTerm(); indexTerm.setDocBookVersion(docBookVersion); return indexTerm; } public Info createInfo() { Info info = new Info(); info.setDocBookVersion(docBookVersion); return info; } public InformalExample createInformalExample() { InformalExample informalExample = new InformalExample(); informalExample.setDocBookVersion(docBookVersion); return informalExample; } public InformalFigure createInformalFigure() { InformalFigure informalFigure = new InformalFigure(); informalFigure.setDocBookVersion(docBookVersion); return informalFigure; } public InformalTable createInformalTable() { InformalTable informalTable = new InformalTable(); informalTable.setDocBookVersion(docBookVersion); return informalTable; } public Initializer createInitializer() { Initializer initializer = new Initializer(); initializer.setDocBookVersion(docBookVersion); return initializer; } public Initializer createInitializer(String text) { Initializer initializer = new Initializer(text); initializer.setDocBookVersion(docBookVersion); return initializer; } public InlineMediaObject createInlineMediaObject() { InlineMediaObject inlineMediaObject = new InlineMediaObject(); inlineMediaObject.setDocBookVersion(docBookVersion); return inlineMediaObject; } public InterfaceName createInterfaceName() { InterfaceName interfaceName = new InterfaceName(); interfaceName.setDocBookVersion(docBookVersion); return interfaceName; } public InterfaceName createInterfaceName(String name) { InterfaceName interfaceName = new InterfaceName(name); interfaceName.setDocBookVersion(docBookVersion); return interfaceName; } public ItemizedList createItemizedList() { ItemizedList itemizedList = new ItemizedList(); itemizedList.setDocBookVersion(docBookVersion); return itemizedList; } public Keyword createKeyword() { Keyword keyword = new Keyword(); keyword.setDocBookVersion(docBookVersion); return keyword; } public Keywordset createKeywordset() { Keywordset keywordset = new Keywordset(); keywordset.setDocBookVersion(docBookVersion); return keywordset; } public LegalNotice createLegalNotice() { LegalNotice legalNotice = new LegalNotice(); legalNotice.setDocBookVersion(docBookVersion); return legalNotice; } public Link createLink() { Link link = new Link(); link.setDocBookVersion(docBookVersion); return link; } public Link createLink(Literal literal, String ref) { Link link = new Link(literal, ref); link.setDocBookVersion(docBookVersion); return link; } public Link createLink(String href) { Link link = new Link(href); link.setDocBookVersion(docBookVersion); return link; } public Link createLink(String label, String ref) { Link link = new Link(label, ref); link.setDocBookVersion(docBookVersion); return link; } public Link createLink(VarName varName, String ref) { Link link = new Link(varName, ref); link.setDocBookVersion(docBookVersion); return link; } public String createLinkAsString(String label, String ref) throws IOException { Link link = new Link(label, ref); link.setDocBookVersion(docBookVersion); return NodeSerializer.toXML(link); } public ListItem createListItem() { ListItem listItem = new ListItem(); listItem.setDocBookVersion(docBookVersion); return listItem; } public Literal createLiteral() { Literal literal = new Literal(); literal.setDocBookVersion(docBookVersion); return literal; } public Literal createLiteral(String text) { Literal literal = new Literal(text); literal.setDocBookVersion(docBookVersion); return literal; } public ManVolNum createManVolNum(String num) { ManVolNum manVolNum = new ManVolNum(num); manVolNum.setDocBookVersion(docBookVersion); return manVolNum; } public MediaObject createMediaObject() { MediaObject mediaObject = new MediaObject(); mediaObject.setDocBookVersion(docBookVersion); return mediaObject; } public Member createMember() { Member member = new Member(); member.setDocBookVersion(docBookVersion); return member; } public MethodName createMethodName() { MethodName methodName = new MethodName(); methodName.setDocBookVersion(docBookVersion); return methodName; } public MethodName createMethodName(String text) { MethodName methodName = new MethodName(text); methodName.setDocBookVersion(docBookVersion); return methodName; } public MethodParam createMethodParam() { MethodParam methodParam = new MethodParam(); methodParam.setDocBookVersion(docBookVersion); return methodParam; } public MethodSynopsis createMethodSynopsis() { MethodSynopsis methodSynopsis = new MethodSynopsis(); methodSynopsis.setDocBookVersion(docBookVersion); return methodSynopsis; } public Modifier createModifier() { Modifier modifier = new Modifier(); modifier.setDocBookVersion(docBookVersion); return modifier; } public Modifier createModifier(String text) { Modifier modifier = new Modifier(); modifier.appendChild(text); modifier.setDocBookVersion(docBookVersion); return modifier; } public Note createNote() { Note note = new Note(); note.setDocBookVersion(docBookVersion); return note; } public Olink createOlink(String label, String targetdoc, String targetptr) { Olink olink = new Olink(label, targetdoc, targetptr); olink.setDocBookVersion(docBookVersion); return olink; } public OoClass createOoClass() { OoClass ooClass = new OoClass(); ooClass.setDocBookVersion(docBookVersion); return ooClass; } public OoException createOoException() { OoException ooException = new OoException(); ooException.setDocBookVersion(docBookVersion); return ooException; } public OoInterface createOoInterface() { OoInterface ooInterface = new OoInterface(); ooInterface.setDocBookVersion(docBookVersion); return ooInterface; } public OrderedList createOrderedList() { OrderedList orderedList = new OrderedList(); orderedList.setDocBookVersion(docBookVersion); return orderedList; } public Para createPara() { Para para = new Para(); para.setDocBookVersion(docBookVersion); return para; } public Para createPara(String text) { Para para = new Para(text); para.setDocBookVersion(docBookVersion); return para; } public ParamDef createParamDef() { ParamDef paramDef = new ParamDef(); paramDef.setDocBookVersion(docBookVersion); return paramDef; } public Parameter createParameter(String name) { Parameter parameter = new Parameter(name); parameter.setDocBookVersion(docBookVersion); return parameter; } public Part createPart() { Part part = new Part(); part.setDocBookVersion(docBookVersion); return part; } public PartInfo createPartInfo() { PartInfo partInfo = new PartInfo(); partInfo.setDocBookVersion(docBookVersion); return partInfo; } public PartIntro createPartIntro() { PartIntro partIntro = new PartIntro(); partIntro.setDocBookVersion(docBookVersion); return partIntro; } public Personname createPersonname() { Personname personname = new Personname(); personname.setDocBookVersion(docBookVersion); return personname; } public Phrase createPhrase() { Phrase phrase = new Phrase(); phrase.setDocBookVersion(docBookVersion); return phrase; } public Primary createPrimary(String key) { Primary primary = new Primary(key); primary.setDocBookVersion(docBookVersion); return primary; } public ProgramListing createProgramListing() { ProgramListing programListing = new ProgramListing(); programListing.setDocBookVersion(docBookVersion); return programListing; } public ProgramListing createProgramListing(String str) { ProgramListing programListing = new ProgramListing(str); programListing.setDocBookVersion(docBookVersion); return programListing; } public Quote createQuote() { Quote quote = new Quote(); quote.setDocBookVersion(docBookVersion); return quote; } public RefEntry createRefEntry() { RefEntry refEntry = new RefEntry(); refEntry.setDocBookVersion(docBookVersion); return refEntry; } public RefEntryInfo createRefEntryInfo() { RefEntryInfo refEntryInfo = new RefEntryInfo(); refEntryInfo.setDocBookVersion(docBookVersion); return refEntryInfo; } public Reference createReference() { Reference reference = new Reference(); reference.setDocBookVersion(docBookVersion); return reference; } public RefMeta createRefMeta() { RefMeta refMeta = new RefMeta(); refMeta.setDocBookVersion(docBookVersion); return refMeta; } public RefMiscInfo createRefMiscInfo(String clazz, String info) { RefMiscInfo refMiscInfo = new RefMiscInfo(clazz, info); refMiscInfo.setDocBookVersion(docBookVersion); return refMiscInfo; } public RefName createRefName(String name) { RefName refName = new RefName(name); refName.setDocBookVersion(docBookVersion); return refName; } public RefNameDiv createRefNameDiv() { RefNameDiv refNameDiv = new RefNameDiv(); refNameDiv.setDocBookVersion(docBookVersion); return refNameDiv; } public RefPurpose createRefPurpose() { RefPurpose refPurpose = new RefPurpose(); refPurpose.setDocBookVersion(docBookVersion); return refPurpose; } public RefSect1 createRefSect1() { RefSect1 refSect1 = new RefSect1(); refSect1.setDocBookVersion(docBookVersion); return refSect1; } public RefSect1 createRefSect1(String title) { RefSect1 refSect1 = new RefSect1(title); refSect1.setDocBookVersion(docBookVersion); return refSect1; } public RefSect2 createRefSect2() { RefSect2 refSect2 = new RefSect2(); refSect2.setDocBookVersion(docBookVersion); return refSect2; } public RefSect2 createRefSect2(String title) { RefSect2 refSect2 = new RefSect2(title); refSect2.setDocBookVersion(docBookVersion); return refSect2; } public RefSect3 createRefSect3() { RefSect3 refSect3 = new RefSect3(); refSect3.setDocBookVersion(docBookVersion); return refSect3; } public RefSect4 createRefSect4() { RefSect4 refSect4 = new RefSect4(); refSect4.setDocBookVersion(docBookVersion); return refSect4; } public RefSect5 createRefSect5() { RefSect5 refSect5 = new RefSect5(); refSect5.setDocBookVersion(docBookVersion); return refSect5; } public RefSection createRefSection() { RefSection refSection = new RefSection(); refSection.setDocBookVersion(docBookVersion); return refSection; } public RefSection createRefSection(String title) { RefSection refSection = new RefSection(title); refSection.setDocBookVersion(docBookVersion); return refSection; } public RefSynopsisDiv createRefSynopsisDiv() { RefSynopsisDiv refSynopsisDiv = new RefSynopsisDiv(); refSynopsisDiv.setDocBookVersion(docBookVersion); return refSynopsisDiv; } public ReleaseInfo createReleaseInfo() { ReleaseInfo releaseInfo = new ReleaseInfo(); releaseInfo.setDocBookVersion(docBookVersion); return releaseInfo; } public ReleaseInfo createReleaseInfo(String text) { ReleaseInfo releaseInfo = new ReleaseInfo(); releaseInfo.appendChild(text); releaseInfo.setDocBookVersion(docBookVersion); return releaseInfo; } public Row createRow() { Row row = new Row(); row.setDocBookVersion(docBookVersion); return row; } public Screen createScreen() { Screen screen = new Screen(); screen.setDocBookVersion(docBookVersion); return screen; } public Secondary createSecondary(String key) { Secondary secondary = new Secondary(key); secondary.setDocBookVersion(docBookVersion); return secondary; } public Sect1 createSect1() { Sect1 sect1 = new Sect1(); sect1.setDocBookVersion(docBookVersion); return sect1; } public Sect1 createSect1(String title) { Sect1 sect1 = new Sect1(title); sect1.setDocBookVersion(docBookVersion); return sect1; } public Sect2 createSect2() { Sect2 sect2 = new Sect2(); sect2.setDocBookVersion(docBookVersion); return sect2; } public Sect2 createSect2(String str) { Sect2 sect2 = new Sect2(str); sect2.setDocBookVersion(docBookVersion); return sect2; } public Sect3 createSect3() { Sect3 sect3 = new Sect3(); sect3.setDocBookVersion(docBookVersion); return sect3; } public Sect3 createSect3(String str) { Sect3 sect3 = new Sect3(str); sect3.setDocBookVersion(docBookVersion); return sect3; } public Sect4 createSect4() { Sect4 sect4 = new Sect4(); sect4.setDocBookVersion(docBookVersion); return sect4; } public Sect5 createSect5() { Sect5 sect5 = new Sect5(); sect5.setDocBookVersion(docBookVersion); return sect5; } public Section createSection() { Section section = new Section(); section.setDocBookVersion(docBookVersion); return section; } public Section createSection(String title) { Section section = new Section(title); section.setDocBookVersion(docBookVersion); return section; } public SimPara createSimPara() { SimPara simPara = new SimPara(); simPara.setDocBookVersion(docBookVersion); return simPara; } public SimPara createSimPara(String text) { SimPara simPara = new SimPara(); simPara.appendChild(text); simPara.setDocBookVersion(docBookVersion); return simPara; } public SimpleList createSimpleList() { SimpleList simpleList = new SimpleList(); simpleList.setDocBookVersion(docBookVersion); return simpleList; } public SimpleList createSimpleList(int type) { SimpleList simpleList = createSimpleList(); simpleList.setType(type); return simpleList; } public SimpleSect createSimpleSect() { SimpleSect simpleSect = new SimpleSect(); simpleSect.setDocBookVersion(docBookVersion); return simpleSect; } public Spanspec createSpanspec() { Spanspec spanspec = new Spanspec(); spanspec.setDocBookVersion(docBookVersion); return spanspec; } public Subject createSubject() { Subject subject = new Subject(); subject.setDocBookVersion(docBookVersion); return subject; } public Subjectset createSubjectset() { Subjectset subjectset = new Subjectset(); subjectset.setDocBookVersion(docBookVersion); return subjectset; } public Subjectterm createSubjectterm() { Subjectterm subjectterm = new Subjectterm(); subjectterm.setDocBookVersion(docBookVersion); return subjectterm; } public Subscript createSubscript() { Subscript subscript = new Subscript(); subscript.setDocBookVersion(docBookVersion); return subscript; } public Superscript createSuperscript() { Superscript superscript = new Superscript(); superscript.setDocBookVersion(docBookVersion); return superscript; } public Surname createSurname() { Surname surname = new Surname(); surname.setDocBookVersion(docBookVersion); return surname; } public Surname createSurname(String name) { Surname surname = new Surname(); surname.appendChild(name); surname.setDocBookVersion(docBookVersion); return surname; } public Synopsis createSynopsis() { Synopsis synopsis = new Synopsis(); synopsis.setDocBookVersion(docBookVersion); return synopsis; } public Table createTable() { Table table = new Table(); table.setDocBookVersion(docBookVersion); return table; } public DocBookElement createTag(String name) throws DocBookTagFactoryException { DocBookElement docBookElement = new DocBookElement(name); docBookElement.setDocBookVersion(docBookVersion); return docBookElement; } public Tbody createTbody() { Tbody tbody = new Tbody(); tbody.setDocBookVersion(docBookVersion); return tbody; } public Term createTerm() { Term term = new Term(); term.setDocBookVersion(docBookVersion); return term; } public TextObject createTextObject() { TextObject textObject = new TextObject(); textObject.setDocBookVersion(docBookVersion); return textObject; } public Tfoot createTfoot() { Tfoot tfoot = new Tfoot(); tfoot.setDocBookVersion(docBookVersion); return tfoot; } public Tgroup createTgroup() { Tgroup tgroup = new Tgroup(); tgroup.setDocBookVersion(docBookVersion); return tgroup; } public Tgroup createTgroup(int cols) { Tgroup tgroup = new Tgroup(); tgroup.setDocBookVersion(docBookVersion); tgroup.setCols(2); tgroup.appendChild(new Colspec("c1", "1*")); tgroup.appendChild(new Colspec("c2", "1*")); return tgroup; } public Thead createThead() { Thead thead = new Thead(); thead.setDocBookVersion(docBookVersion); return thead; } public Tip createTip() { Tip tip = new Tip(); tip.setDocBookVersion(docBookVersion); return tip; } public Title createTitle() { Title title = new Title(); title.setDocBookVersion(docBookVersion); return title; } public Title createTitle(String str) { Title title = new Title(str); title.setDocBookVersion(docBookVersion); return title; } public Type createType() { Type type = new Type(); type.setDocBookVersion(docBookVersion); return type; } public ULink createULink() { ULink uLink = new ULink(); uLink.setDocBookVersion(docBookVersion); return uLink; } public VariableList createVariableList() { VariableList variableList = new VariableList(); variableList.setDocBookVersion(docBookVersion); return variableList; } public VarListEntry createVarListEntry() { VarListEntry varListEntry = new VarListEntry(); varListEntry.setDocBookVersion(docBookVersion); return varListEntry; } public VarName createVarName() { VarName varName = new VarName(); varName.setDocBookVersion(docBookVersion); return varName; } public VarName createVarName(String text) { VarName varName = new VarName(text); varName.setDocBookVersion(docBookVersion); return varName; } public Void createVoid() { Void _void = new Void(); _void.setDocBookVersion(docBookVersion); return _void; } public Warning createWarning() { Warning warning = new Warning(); warning.setDocBookVersion(docBookVersion); return warning; } public Warning createWarning(String text) { Warning warning = new Warning(text); warning.setDocBookVersion(docBookVersion); return warning; } public XRef createXRef(String linkend) { XRef xref = new XRef(linkend); xref.setDocBookVersion(docBookVersion); return xref; } public Year createYear() { Year year = new Year(); year.setDocBookVersion(docBookVersion); return year; } public Year createYear(String text) { Year year = new Year(); year.appendChild(text); year.setDocBookVersion(docBookVersion); return year; } public DocBookVersion getDocBookVersion() { return docBookVersion; } public boolean isDocBook5() { if (docBookVersion != null && docBookVersion == DocBookVersion.V5_0) { return true; } return false; } }src/java/org/dbdoclet/trafo/tag/docbook/Code.java0000644000000000000000000000111012124530526020647 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.XmlServices; public class Code extends DocBookElement { private static String tag = "code"; Code() { super(tag); setFormatType(FORMAT_INLINE); isMixedContentModel(true); } Code(String text) { this(); appendChild(XmlServices.textToXml(text)); } } src/java/org/dbdoclet/trafo/tag/docbook/Tgroup.java0000644000000000000000000000105312124530526021263 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Tgroup extends DocBookElement { Tgroup() { super("tgroup"); setFormatType(FORMAT_BLOCK); } Tgroup setAlign(String align) { setAttribute("align", align); return this; } public Tgroup setCols(int cols) { setAttribute("cols", new Integer(cols)); return this; } } src/java/org/dbdoclet/trafo/tag/docbook/Parameter.java0000644000000000000000000000066312124530526021731 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Parameter extends DocBookElement { Parameter(String parameter) { super("parameter"); setFormatType(FORMAT_INLINE); appendChild(parameter); } } src/java/org/dbdoclet/trafo/tag/docbook/Colspec.java0000644000000000000000000000103512124530526021373 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Colspec extends DocBookElement { Colspec() { super("colspec"); isEmpty(true); } Colspec(String name, String width) { super("colspec"); setAttribute("colname", name); setAttribute("colwidth", width); isEmpty(true); } } src/java/org/dbdoclet/trafo/tag/docbook/OoException.java0000644000000000000000000000067712124530526022252 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class OoException extends DocBookElement { private static String tagName = "ooexception"; OoException() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } } src/java/org/dbdoclet/trafo/tag/docbook/Para.java0000644000000000000000000000706612124530526020700 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Para extends DocBookElement { private static HashMap> validParentMap; private static String tag = "para"; static { validParentMap = new HashMap>(); validParentMap.put(Article.getTag(), Article.getAttributeMap()); // abstract // answer // appendix validParentMap.put(Article.getTag(), Article.getAttributeMap()); // authorblurb // bibliodiv // bibliography validParentMap.put(BlockQuote.getTag(), BlockQuote.getAttributeMap()); // callout validParentMap.put(Caption.getTag(), Caption.getAttributeMap()); validParentMap.put(Caution.getTag(), Caution.getAttributeMap()); validParentMap.put(Chapter.getTag(), Chapter.getAttributeMap()); // colophon, // constraintdef // dedication validParentMap.put(Entry.getTag(), Entry.getAttributeMap()); // epigraph validParentMap.put(Example.getTag(), Example.getAttributeMap()); // footnote validParentMap.put(FormalPara.getTag(), FormalPara.getAttributeMap()); // glossary // glossdef // glossdiv // highlights validParentMap.put(Important.getTag(), Important.getAttributeMap()); // index // indexdiv validParentMap.put(InformalExample.getTag(), InformalExample.getAttributeMap()); validParentMap.put(ItemizedList.getTag(), ItemizedList.getAttributeMap()); // legalnotice validParentMap.put(ListItem.getTag(), ListItem.getAttributeMap()); // msgexplan // msgtext validParentMap.put(Note.getTag(), Note.getAttributeMap()); validParentMap.put(OrderedList.getTag(), OrderedList.getAttributeMap()); validParentMap.put(PartIntro.getTag(), PartIntro.getAttributeMap()); // personblurb // preface // printhistory // procedure // qandadiv // qandaset // question validParentMap.put(RefSect1.getTag(), RefSect1.getAttributeMap()); validParentMap.put(RefSect2.getTag(), RefSect2.getAttributeMap()); validParentMap.put(RefSect3.getTag(), RefSect3.getAttributeMap()); // refsection, validParentMap.put(RefSynopsisDiv.getTag(), RefSynopsisDiv.getAttributeMap()); // revdescription validParentMap.put(Sect1.getTag(), Sect1.getAttributeMap()); validParentMap.put(Sect2.getTag(), Sect2.getAttributeMap()); validParentMap.put(Sect3.getTag(), Sect3.getAttributeMap()); validParentMap.put(Sect4.getTag(), Sect4.getAttributeMap()); validParentMap.put(Sect5.getTag(), Sect5.getAttributeMap()); validParentMap.put(Section.getTag(), Section.getAttributeMap()); // setindex // sidebar validParentMap.put(SimpleSect.getTag(), SimpleSect.getAttributeMap()); // step validParentMap.put(TextObject.getTag(), TextObject.getAttributeMap()); validParentMap.put(Tip.getTag(), Tip.getAttributeMap()); validParentMap.put(VariableList.getTag(), VariableList.getAttributeMap()); validParentMap.put(Warning.getTag(), Warning.getAttributeMap()); } public static String getTag() { return tag; } @Override public boolean isValidParent(DocBookElement parent) { if (parent == null) { return true; } boolean rc = validate2(validParentMap, new Para(), parent); return rc; } Para() { super(tag); setFormatType(FORMAT_CONTENT); } Para(String text) { this(); appendChild(text); } @Override public boolean validate() { if (getParentNode() == null) { return true; } boolean rc = validate2(validParentMap); return rc; } } src/java/org/dbdoclet/trafo/tag/docbook/Acronym.java0000644000000000000000000000220612124530526021414 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Acronym extends DocBookElement { private static final String tag = "acronym"; private static final HashMap> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); invalidParentMap.put(Subscript.getTag(), Subscript.getAttributeMap()); invalidParentMap.put(Superscript.getTag(), Superscript.getAttributeMap()); } Acronym() { super(tag); setFormatType(FORMAT_INLINE); } Acronym(String text) { super(tag); appendChild(text); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/Part.java0000644000000000000000000000100112124530526020702 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Part extends DocBookElement { private static String tagName = "part"; Part() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } public static String getTag() { return tagName; } } src/java/org/dbdoclet/trafo/tag/docbook/Abbrev.java0000644000000000000000000000231112124530526021202 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Abbrev extends DocBookElement { private static final String tag = "abbrev"; private static final HashMap> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Acronym.getTag(), Acronym.getAttributeMap()); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); invalidParentMap.put(Subscript.getTag(), Subscript.getAttributeMap()); invalidParentMap.put(Superscript.getTag(), Superscript.getAttributeMap()); } Abbrev() { super(tag); setFormatType(FORMAT_INLINE); } Abbrev(String text) { super(tag); appendChild(text); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/ComputerOutput.java0000644000000000000000000000077112124530526023030 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class ComputerOutput extends DocBookElement { ComputerOutput() { super("computeroutput"); setFormatType(FORMAT_INLINE); isLiteral(true); } ComputerOutput(String text) { this(); appendChild(text); } } src/java/org/dbdoclet/trafo/tag/docbook/FieldSynopsis.java0000644000000000000000000000126612124530526022604 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class FieldSynopsis extends DocBookElement { private static final String tagName = "fieldsynopsis"; FieldSynopsis() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); setAttribute("language", "java"); } public static String getTag() { return tagName; } public void setLanguage(String language) { setAttribute("language", language); } } src/java/org/dbdoclet/trafo/tag/docbook/ArticleInfo.java0000644000000000000000000000076212124530526022210 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class ArticleInfo extends DocBookElement { private static final String tag = "articleinfo"; ArticleInfo() { super(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Surname.java0000644000000000000000000000113412124530526021415 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.XmlServices; public class Surname extends DocBookElement { private static String tagName = "surname"; Surname() { super(tagName); setFormatType(FORMAT_INLINE); isMixedContentModel(true); } Surname(String text) { this(); appendChild(XmlServices.textToXml(text)); } } src/java/org/dbdoclet/trafo/tag/docbook/MethodName.java0000644000000000000000000000103012124530526022017 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class MethodName extends DocBookElement { private static final String tagName = "methodname"; public static String getTag() { return tagName; } MethodName() { super(tagName); } MethodName(String methodname) { this(); appendChild(methodname); } } src/java/org/dbdoclet/trafo/tag/docbook/ClassSynopsis.java0000644000000000000000000000153612124530526022626 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class ClassSynopsis extends DocBookElement { private static final String tag = "classsynopsis"; ClassSynopsis() { super(tag); setFormatType(FORMAT_BLOCK); isContentModel(true); setAttribute("class", "class"); setAttribute("language", "java"); } public void setLanguage(String language) { setAttribute("language", language); } public void setInterface(boolean value) { if (value == true) { setAttribute("class", "interface"); } else { setAttribute("class", "class"); } } } src/java/org/dbdoclet/trafo/tag/docbook/PartInfo.java0000644000000000000000000000075112124530526021531 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class PartInfo extends DocBookElement { private static final String tag = "partinfo"; PartInfo() { super(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Primary.java0000644000000000000000000000065012124530526021430 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Primary extends DocBookElement { Primary(String primary) { super("primary"); setFormatType(FORMAT_INLINE); appendChild(primary); } } src/java/org/dbdoclet/trafo/tag/docbook/ListItem.java0000644000000000000000000000124012124530526021533 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class ListItem extends DocBookElement { private static String tag = "listitem"; public static HashMap getAttributeMap() { return new HashMap(); } public static String getTag() { return tag; } ListItem() { super("listitem"); setFormatType(FORMAT_BLOCK); isContentModel(true); } ListItem(String text) { this(); appendChild(text); } } src/java/org/dbdoclet/trafo/tag/docbook/Void.java0000644000000000000000000000054512124530526020711 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Void extends DocBookElement { Void() { super("void"); isEmpty(true); } } src/java/org/dbdoclet/trafo/tag/docbook/Subjectterm.java0000644000000000000000000000071212124530526022273 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Subjectterm extends DocBookElement { private static String tag = "subjectterm"; Subjectterm() { super(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/FuncSynopsis.java0000644000000000000000000000054412124530526022452 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class FuncSynopsis extends DocBookElement { FuncSynopsis() { super("funcsynopsis"); } } src/java/org/dbdoclet/trafo/tag/docbook/RefSect3.java0000644000000000000000000000111612124530526021421 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class RefSect3 extends DocBookElement { private static String tag = "refsect3"; RefSect3() { super(tag); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/SimPara.java0000644000000000000000000000212612124530526021341 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class SimPara extends DocBookElement { private static final String tag = "simpara"; private static HashMap> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); invalidParentMap.put(Subscript.getTag(), Subscript.getAttributeMap()); invalidParentMap.put(Superscript.getTag(), Superscript.getAttributeMap()); } SimPara() { super(tag); setFormatType(FORMAT_BLOCK); } SimPara(String text) { this(); appendChild(text); } public static String getTag() { return tag; } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/Chapter.java0000644000000000000000000000113712124530526021374 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Chapter extends SectionElement { private static final String tag = "chapter"; Chapter() { super(tag); setFormatType(FORMAT_BLOCK); isContentModel(true); } Chapter(String title) { this(); appendChild(new Title(title)); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/OoClass.java0000644000000000000000000000066312124530526021354 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class OoClass extends DocBookElement { private static String tagName = "ooclass"; OoClass() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } } src/java/org/dbdoclet/trafo/tag/docbook/VarName.java0000644000000000000000000000066412124530526021343 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class VarName extends DocBookElement { VarName() { super("varname"); } VarName(String varname) { super("varname"); appendChild(varname); } } src/java/org/dbdoclet/trafo/tag/docbook/RefSect1.java0000644000000000000000000000137012124530526021421 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class RefSect1 extends DocBookElement { private static String tagName = "refsect1"; RefSect1() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } RefSect1(String title) { this(); appendChild(new Title(title)); } public static String getTag() { return tagName; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/DocBookFragment.java0000644000000000000000000000072612124530526023015 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class DocBookFragment extends DocumentFragmentImpl { public DocBookFragment() { super(); setNodeType(DOCUMENT_FRAGMENT_NODE); setParentNode(null); } } src/java/org/dbdoclet/trafo/tag/docbook/Year.java0000644000000000000000000000112012124530526020676 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.XmlServices; public class Year extends DocBookElement { private static String tagName = "year"; Year() { super(tagName); setFormatType(FORMAT_INLINE); isMixedContentModel(true); } Year(String text) { this(); appendChild(XmlServices.textToXml(text)); } } src/java/org/dbdoclet/trafo/tag/docbook/Email.java0000644000000000000000000000112312124530526021030 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.XmlServices; public class Email extends DocBookElement { private static String tagName = "email"; Email() { super(tagName); setFormatType(FORMAT_INLINE); isMixedContentModel(true); } Email(String text) { this(); appendChild(XmlServices.textToXml(text)); } }src/java/org/dbdoclet/trafo/tag/docbook/ParamDef.java0000644000000000000000000000072212124530526021464 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class ParamDef extends DocBookElement { private static final String tagName = "paramdef"; ParamDef() { super(tagName); } public static String getTag() { return tagName; } } src/java/org/dbdoclet/trafo/tag/docbook/FuncPrototype.java0000644000000000000000000000054712124530526022633 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class FuncPrototype extends DocBookElement { FuncPrototype() { super("funcprototype"); } } src/java/org/dbdoclet/trafo/tag/docbook/RefEntry.java0000644000000000000000000000057612124530526021552 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class RefEntry extends DocBookElement { RefEntry() { super("refentry"); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/DocBookDocument.java0000644000000000000000000000162412124530526023026 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.dom.DocumentImpl; public class DocBookDocument extends DocumentImpl { public void setDocumentElement(DocBookElement documentElement) { if (documentElement == null) { throw new IllegalArgumentException("The argument documentElement must not be null!"); } super.setDocumentElement(documentElement); if (documentElement.isDocBook5()) { documentElement.setAttribute("xmlns", DocBookElement.DOCBOOK_NAMESPACE); documentElement.setAttribute("xmlns:xl", DocBookElement.XLINK_NAMESPACE); documentElement.setAttribute("version", "5.0"); } } } src/java/org/dbdoclet/trafo/tag/docbook/RefEntryInfo.java0000644000000000000000000000061212124530526022355 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class RefEntryInfo extends DocBookElement { RefEntryInfo() { super("refentryinfo"); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/Info.java0000644000000000000000000000072712124530526020705 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Info extends DocBookElement { private static String tag = "info"; Info() { super(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Book.java0000644000000000000000000000112312124530526020673 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Book extends SectionElement { private static final String tag = "book"; Book() { super(tag); setFormatType(FORMAT_BLOCK); isContentModel(true); } Book(String title) { this(); appendChild(new Title(title)); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Caption.java0000644000000000000000000000132012124530526021375 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Caption extends DocBookElement { private static String tag = "caption"; Caption() { super("caption"); setFormatType(FORMAT_BLOCK); } Caption(String caption) { this(); appendChild(new Para(caption)); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/RefPurpose.java0000644000000000000000000000105612124530526022100 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class RefPurpose extends DocBookElement { private static String tagName = "refpurpose"; RefPurpose() { super(tagName); } RefPurpose(String refpurpose) { this(); appendChild(refpurpose); } public static String getTag() { return tagName; } } src/java/org/dbdoclet/trafo/tag/docbook/Modifier.java0000644000000000000000000000071112124530526021541 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Modifier extends DocBookElement { private static String tagName = "modifier"; Modifier() { super(tagName); } Modifier(String modifier) { this(); appendChild(modifier); } } src/java/org/dbdoclet/trafo/tag/docbook/Author.java0000644000000000000000000000074312124530526021252 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Author extends DocBookElement { private static final String tag = "author"; Author() { super(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Initializer.java0000644000000000000000000000223712124530526022273 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Initializer extends DocBookElement { private static final String tagName = "initializer"; private static final HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(FieldSynopsis.getTag(), FieldSynopsis.getAttributeMap()); validParentMap.put(MethodParam.getTag(), MethodParam.getAttributeMap()); validParentMap.put(ParamDef.getTag(), ParamDef.getAttributeMap()); } Initializer() { super(tagName); setFormatType(FORMAT_CONTENT); isMixedContentModel(true); } Initializer(String text) { this(); appendChild(hardenText(text)); } public static String getTag() { return tagName; } @Override public boolean validate() { return validate2(validParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/Affiliation.java0000644000000000000000000000072312124530526022233 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Affiliation extends DocBookElement { private static String tagName = "affiliation"; Affiliation() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } } src/java/org/dbdoclet/trafo/tag/docbook/RefMiscInfo.java0000644000000000000000000000071412124530526022152 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class RefMiscInfo extends DocBookElement { RefMiscInfo(String clazz, String refMiscInfo) { super("refmiscinfo"); setAttribute("class", clazz); appendChild(refMiscInfo); } } src/java/org/dbdoclet/trafo/tag/docbook/ConstructorSynopsis.java0000644000000000000000000000120112124530526024073 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class ConstructorSynopsis extends DocBookElement { private static final String tagName = "constructorsynopsis"; ConstructorSynopsis() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); setAttribute("language", "java"); } public void setLanguage(String language) { setAttribute("language", language); } } src/java/org/dbdoclet/trafo/tag/docbook/ExceptionName.java0000644000000000000000000000122412124530526022542 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.XmlServices; public class ExceptionName extends DocBookElement { private static String tagName = "exceptionname"; ExceptionName() { super(tagName); setFormatType(FORMAT_INLINE); } ExceptionName(String text) { this(); appendChild(XmlServices.textToXml(text)); } public static String getTag() { return tagName; } } src/java/org/dbdoclet/trafo/tag/docbook/OoInterface.java0000644000000000000000000000072712124530526022210 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class OoInterface extends DocBookElement { private static String tagName = "oointerface"; OoInterface() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } } src/java/org/dbdoclet/trafo/tag/docbook/SimpleList.java0000644000000000000000000000105512124530526022072 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class SimpleList extends DocBookElement { final static public int FORMAT_INLINE = 1; SimpleList() { super("simplelist"); } SimpleList setType(int type) { if (type == FORMAT_INLINE) { setAttribute("type", "inline"); } return this; } } src/java/org/dbdoclet/trafo/tag/docbook/Sect1.java0000644000000000000000000000114412124530526020763 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Sect1 extends SectionElement { private final static String tagName = "sect1"; Sect1() { super(tagName); setFormatType(FORMAT_BLOCK); isContentModel(true); } Sect1(String title) { this(); appendChild(new Title(title)); } public static String getTag() { return tagName; } } src/java/org/dbdoclet/trafo/tag/docbook/Personname.java0000644000000000000000000000075112124530526022116 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Personname extends DocBookElement { private static String tag = "personname"; Personname() { super(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Olink.java0000644000000000000000000000271212124530526021062 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; import org.dbdoclet.xiphias.XmlServices; public class Olink extends DocBookElement { private static final HashMap> invalidParentMap; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); } Olink() { super("olink"); } Olink(DocBookElement label, String targetdoc, String targetptr) { this(targetdoc, targetptr); appendChild(label); } Olink(String targetdoc, String targetptr) { this(); setAttribute("targetdoc", hardenId(targetdoc)); setAttribute("targetptr", hardenId(targetptr)); setFormatType(FORMAT_INLINE); } Olink(String label, String targetdoc, String targetptr) { this(targetdoc, targetptr); appendChild(XmlServices.textToXml(label)); } public void setTargetDoc(String targetdoc) { setAttribute("targetdoc", targetdoc); } public void setTargetPtr(String targetptr) { setAttribute("targetptr", targetptr); } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/Row.java0000644000000000000000000000056012124530526020554 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Row extends DocBookElement { Row() { super("row"); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/RefMeta.java0000644000000000000000000000057312124530526021334 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class RefMeta extends DocBookElement { RefMeta() { super("refmeta"); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/Subjectset.java0000644000000000000000000000070712124530526022123 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Subjectset extends DocBookElement { private static String tag = "subjectset"; Subjectset() { super(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Example.java0000644000000000000000000000135112124530526021377 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Example extends DocBookElement { private static String tag = "example"; Example(String strTitle) { super("example"); Title title = new Title(strTitle); title.setParentNode(this); appendChild(title); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/Anchor.java0000644000000000000000000000061712124530526021222 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Anchor extends DocBookElement { Anchor() { super("anchor"); isEmpty(true); setFormatType(FORMAT_INLINE); } } src/java/org/dbdoclet/trafo/tag/docbook/Keyword.java0000644000000000000000000000067712124530526021442 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Keyword extends DocBookElement { private static String tag = "keyword"; Keyword() { super(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/Thead.java0000644000000000000000000000055512124530526021036 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Thead extends Telem { Thead() { super("thead"); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/FuncDef.java0000644000000000000000000000057312124530526021323 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class FuncDef extends DocBookElement { FuncDef() { super("funcdef"); setFormatType(FORMAT_INLINE); } } src/java/org/dbdoclet/trafo/tag/docbook/Subscript.java0000644000000000000000000000203712124530526021764 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Subscript extends DocBookElement { private static HashMap> invalidParentMap; private static String tag = "subscript"; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Abbrev.getTag(), Abbrev.getAttributeMap()); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); } Subscript() { super(tag); setFormatType(FORMAT_INLINE); } Subscript(String text) { super(tag); appendChild(text); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/MethodParam.java0000644000000000000000000000074412124530526022212 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class MethodParam extends DocBookElement { private static String tagName = "methodparam"; public static String getTag() { return tagName; } MethodParam() { super(tagName); setFormatType(FORMAT_INLINE); } } src/java/org/dbdoclet/trafo/tag/docbook/AttributeAlign.java0000644000000000000000000000015512124530526022723 0ustar rootrootpackage org.dbdoclet.trafo.tag.docbook; public enum AttributeAlign { CENTER, CHAR, JUSTIFY, LEFT, RIGHT; } src/java/org/dbdoclet/trafo/tag/docbook/Important.java0000644000000000000000000000135012124530526021760 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Important extends DocBookElement { private static String tag = "important"; public static HashMap getAttributeMap() { return new HashMap(); } public static String getTag() { return tag; } Important() { super("important"); setFormatType(FORMAT_BLOCK); } Important(String strTitle) { this(); Title title = new Title(strTitle); title.setParentNode(this); appendChild(title); } } src/java/org/dbdoclet/trafo/tag/docbook/ManVolNum.java0000644000000000000000000000057612124530526021670 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class ManVolNum extends DocBookElement { ManVolNum(String manvolnum) { super("manvolnum"); appendChild(manvolnum); } } src/java/org/dbdoclet/trafo/tag/docbook/Superscript.java0000644000000000000000000000204712124530526022332 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Superscript extends DocBookElement { private static HashMap> invalidParentMap; private static String tag = "superscript"; static { invalidParentMap = new HashMap>(); invalidParentMap.put(Abbrev.getTag(), Abbrev.getAttributeMap()); invalidParentMap.put(Address.getTag(), Address.getAttributeMap()); } Superscript() { super(tag); setFormatType(FORMAT_INLINE); } Superscript(String text) { super(tag); appendChild(text); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/Warning.java0000644000000000000000000000207212124530526021412 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Warning extends DocBookElement { private static String tag = "warning"; Warning() { super(tag); setFormatType(FORMAT_BLOCK); } Warning(String strTitle) { super(tag); Title title = new Title(strTitle); title.setParentNode(this); appendChild(title); setFormatType(FORMAT_BLOCK); } Warning(String strTitle, String text) { super(tag); Title title = new Title(strTitle); title.setParentNode(this); appendChild(title); appendChild(new Para(text)); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/Member.java0000644000000000000000000000144112124530526021213 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class Member extends DocBookElement { private static HashMap> invalidParentMap; private static String tag = "member"; static { invalidParentMap = new HashMap>(); } public static String getTag() { return tag; } Member() { super(tag); setFormatType(FORMAT_CONTENT); } Member(String text) { this(); appendChild(text); } @Override public boolean validate() { return validate(invalidParentMap); } } src/java/org/dbdoclet/trafo/tag/docbook/OrderedList.java0000644000000000000000000000112712124530526022225 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class OrderedList extends DocBookElement { private static String tag = "orderedlist"; OrderedList() { super(tag); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/MediaObject.java0000644000000000000000000000057012124530526022154 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class MediaObject extends DocBookElement { MediaObject() { super("mediaobject"); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/docbook/EntryTbl.java0000644000000000000000000000067012124530526021552 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class EntryTbl extends DocBookElement { EntryTbl() { super("entrytbl"); } public EntryTbl setCols(int cols) { setAttribute("cols", new Integer(cols)); return this; } } src/java/org/dbdoclet/trafo/tag/docbook/RefSect4.java0000644000000000000000000000111412124530526021420 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import java.util.HashMap; public class RefSect4 extends DocBookElement { private static String tag = "refsect3"; RefSect4() { super(tag); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return new HashMap(); } } src/java/org/dbdoclet/trafo/tag/docbook/ProgramListing.java0000644000000000000000000000174212124530526022751 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class ProgramListing extends DocBookElement { private static final String tag = "programlisting"; ProgramListing() { super(tag); setFormatType(FORMAT_CONTENT); isLiteral(true); } ProgramListing(String text) { this(); appendChild(text); } ProgramListing setWidth(int width) { setAttribute("width", new Integer(width)); return this; } public static String getTag() { return tag; } public void setLinenumberingEnabled(boolean linenumbering) { if (linenumbering == true) { setAttribute("linenumbering", "numbered"); } else { setAttribute("linenumbering", "unnumbered"); } } } src/java/org/dbdoclet/trafo/tag/docbook/Keywordset.java0000644000000000000000000000071012124530526022142 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; public class Keywordset extends DocBookElement { private static String tag = "keywordset"; Keywordset() { super(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } } src/java/org/dbdoclet/trafo/tag/docbook/FirstName.java0000644000000000000000000000114412124530526021674 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.docbook; import org.dbdoclet.xiphias.XmlServices; public class FirstName extends DocBookElement { private static String tagName = "firstname"; FirstName() { super(tagName); setFormatType(FORMAT_INLINE); isMixedContentModel(true); } FirstName(String text) { this(); appendChild(XmlServices.textToXml(text)); } } src/java/org/dbdoclet/trafo/tag/javadoc/0000755000000000000000000000000012124530526017130 5ustar rootrootsrc/java/org/dbdoclet/trafo/tag/javadoc/Linkplain.java0000644000000000000000000000370512124530526021721 0ustar rootroot/* * ### Copyright (C) 2001-2003 Michael Fuchs ### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Michael Fuchs * E-Mail: mfuchs@unico-consulting.com * * RCS Information: * --------------- * Id.........: $Id: Linkplain.java,v 1.1.1.1 2004/12/21 14:01:00 mfuchs Exp $ * Author.....: $Author: mfuchs $ * Date.......: $Date: 2004/12/21 14:01:00 $ * Revision...: $Revision: 1.1.1.1 $ * State......: $State: Exp $ */ package org.dbdoclet.trafo.tag.javadoc; /** * The class Linkplain represents a javadoc linkplain tag. * *
This is an examples for an embedded * javadoc linkplain tag: The type of the return code is a * {@linkplain org.dbdoclet.xiphias.dom.NodeImpl Node}.
* * @author Michael Fuchs * @version 1.0 */ public class Linkplain extends JavaDocElement { public Linkplain() { super(); setNodeName("javadoc:linkplain"); setFormatType(FORMAT_INLINE); } public String getName() { return getAttribute("name"); } public String getRef() { return getAttribute("ref"); } @Override public void init() { } @Override public boolean validate() { nodeStack.removeAllElements(); nodeStack.push(this); return true; } } src/java/org/dbdoclet/trafo/tag/javadoc/Literal.java0000644000000000000000000000126412124530526021372 0ustar rootroot/* * ### Copyright (C) 2001-2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.javadoc; /** * The class Link represents a javadoc link tag. * * @author Michael Fuchs * @version 1.0 */ public class Literal extends JavaDocElement { public Literal() { super(); setNodeName("javadoc:literal"); setFormatType(FORMAT_INLINE); } @Override public boolean validate() { nodeStack.removeAllElements(); nodeStack.push(this); return true; } } src/java/org/dbdoclet/trafo/tag/javadoc/Link.java0000644000000000000000000000153412124530526020673 0ustar rootroot/* * ### Copyright (C) 2001-2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.javadoc; /** * The class Link represents a javadoc link tag. * * @author Michael Fuchs * @version 1.0 */ public class Link extends JavaDocElement { public Link() { super(); setNodeName("javadoc:link"); setFormatType(FORMAT_INLINE); } public String getName() { return getAttribute("name"); } public String getRef() { return getAttribute("ref"); } @Override public void init() { } @Override public boolean validate() { nodeStack.removeAllElements(); nodeStack.push(this); return true; } } src/java/org/dbdoclet/trafo/tag/javadoc/Code.java0000644000000000000000000000125312124530526020646 0ustar rootroot/* * ### Copyright (C) 2001-2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.javadoc; /** * The class Link represents a javadoc link tag. * * @author Michael Fuchs * @version 1.0 */ public class Code extends JavaDocElement { public Code() { super(); setNodeName("javadoc:code"); setFormatType(FORMAT_INLINE); } @Override public boolean validate() { nodeStack.removeAllElements(); nodeStack.push(this); return true; } } src/java/org/dbdoclet/trafo/tag/javadoc/JavaDocElement.java0000644000000000000000000000366112124530526022622 0ustar rootroot/* * ### Copyright (C) 2001-2003 Michael Fuchs ### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Michael Fuchs * E-Mail: mfuchs@unico-consulting.com * * RCS Information: * --------------- * Id.........: $Id: JavaDocElement.java,v 1.1.1.1 2004/12/21 14:01:00 mfuchs Exp $ * Author.....: $Author: mfuchs $ * Date.......: $Date: 2004/12/21 14:01:00 $ * Revision...: $Revision: 1.1.1.1 $ * State......: $State: Exp $ */ package org.dbdoclet.trafo.tag.javadoc; import org.dbdoclet.trafo.tag.html.HtmlElement; public abstract class JavaDocElement extends HtmlElement { } /* * $Log: JavaDocElement.java,v $ * Revision 1.1.1.1 2004/12/21 14:01:00 mfuchs * Reimport * * Revision 1.2 2004/10/05 13:13:18 mfuchs * Sicherung * * Revision 1.1.1.1 2004/02/17 22:50:30 mfuchs * dbdoclet * * Revision 1.1.1.1 2004/01/05 14:58:10 cvs * dbdoclet * * Revision 1.1.1.1 2003/08/01 13:17:29 cvs * DocBook Doclet * * Revision 1.1.1.1 2003/07/31 17:05:39 mfuchs * DocBook Doclet since 0.46 * * Revision 1.1.1.1 2003/05/30 11:09:40 mfuchs * dbdoclet * * Revision 1.2 2003/04/18 12:22:41 mfuchs * Changes for release 0.41. * * Revision 1.1.1.1 2003/03/18 07:41:37 mfuchs * DocBook Doclet 0.40 * * Revision 1.1.1.1 2003/03/17 20:49:55 cvs * dbdoclet * */ src/java/org/dbdoclet/trafo/tag/javadoc/Value.java0000644000000000000000000000135612124530526021054 0ustar rootroot/* * ### Copyright (C) 2001-2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.javadoc; /** * The class Link represents a javadoc link tag. * * @author Michael Fuchs * @version 1.0 */ public class Value extends JavaDocElement { public Value() { super(); setNodeName("javadoc:value"); setFormatType(FORMAT_INLINE); } public String getRef() { return getAttribute("ref"); } @Override public boolean validate() { nodeStack.removeAllElements(); nodeStack.push(this); return true; } } src/java/org/dbdoclet/trafo/tag/html/0000755000000000000000000000000012124530526016465 5ustar rootrootsrc/java/org/dbdoclet/trafo/tag/html/Base.java0000644000000000000000000000152112124530526020201 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Base extends ReplaceElement { private static final String tag = "base"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Head.getTag(), HtmlElement.getAttributeMap()); } public Base() { setNodeName(tag); setFormatType(FORMAT_INLINE); } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Sup.java0000644000000000000000000000220512124530526020076 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Sup extends InlineElement { private static String tag = "sup"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove(Pre.getTag()); } public static String getTag() { return tag; } public Sup() { setNodeName(tag); setFormatType(FORMAT_INLINE); } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Form.java0000644000000000000000000000525012124530526020235 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Form extends ReplaceElement { private static final String tag = "form"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); attributeMap = new HashMap(); } public Form() { setNodeName(tag); setFormatType(FORMAT_INLINE); setAttribute("action", "#"); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Blockquote.java0000644000000000000000000000446212124530526021446 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Blockquote extends Inline2Element { private static final String tag = "blockquote"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public Blockquote() { setNodeName(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/HtmlElement.java0000644000000000000000000002410412124530526021547 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import org.dbdoclet.trafo.tag.NodeStack; import org.dbdoclet.xiphias.dom.AttrImpl; import org.dbdoclet.xiphias.dom.ElementImpl; import org.dbdoclet.xiphias.dom.NodeImpl; public abstract class HtmlElement extends ElementImpl { protected static HashMap> blockElementMap = new HashMap>(); protected static HashMap> inlineElementMap = new HashMap>(); static { initBlockElementMap(); initInlineElementMap(); } public static HashMap getAttributeMap() { return new HashMap(); } public static String getTag() { return "HTMLElement"; } private static void initBlockElementMap() { HashMap attributes; attributes = new HashMap(); blockElementMap.put("address", attributes); attributes = new HashMap(); blockElementMap.put("blockquote", attributes); attributes = new HashMap(); blockElementMap.put("center", attributes); attributes = new HashMap(); blockElementMap.put("dd", attributes); attributes = new HashMap(); blockElementMap.put("del", attributes); attributes = new HashMap(); blockElementMap.put("div", attributes); attributes = new HashMap(); blockElementMap.put("dt", attributes); attributes = new HashMap(); blockElementMap.put("form", attributes); attributes = new HashMap(); blockElementMap.put("h1", attributes); attributes = new HashMap(); blockElementMap.put("h2", attributes); attributes = new HashMap(); blockElementMap.put("h3", attributes); attributes = new HashMap(); blockElementMap.put("h4", attributes); attributes = new HashMap(); blockElementMap.put("h5", attributes); attributes = new HashMap(); blockElementMap.put("h6", attributes); attributes = new HashMap(); blockElementMap.put("ins", attributes); attributes = new HashMap(); blockElementMap.put("isindex", attributes); attributes = new HashMap(); blockElementMap.put("li", attributes); attributes = new HashMap(); blockElementMap.put("noframes", attributes); attributes = new HashMap(); blockElementMap.put("noscript", attributes); attributes = new HashMap(); blockElementMap.put("p", attributes); attributes = new HashMap(); blockElementMap.put("pre", attributes); attributes = new HashMap(); blockElementMap.put("td", attributes); attributes = new HashMap(); blockElementMap.put("th", attributes); } private static void initInlineElementMap() { HashMap attributes; attributes = new HashMap(); inlineElementMap.put("a", attributes); attributes = new HashMap(); inlineElementMap.put("abbr", attributes); attributes = new HashMap(); inlineElementMap.put("acronym", attributes); attributes = new HashMap(); inlineElementMap.put("applet", attributes); attributes = new HashMap(); inlineElementMap.put("b", attributes); attributes = new HashMap(); inlineElementMap.put("basefont", attributes); attributes = new HashMap(); inlineElementMap.put("bdo", attributes); attributes = new HashMap(); inlineElementMap.put("big", attributes); attributes = new HashMap(); inlineElementMap.put("br", attributes); attributes = new HashMap(); inlineElementMap.put("button", attributes); attributes = new HashMap(); inlineElementMap.put("cite", attributes); attributes = new HashMap(); inlineElementMap.put("code", attributes); attributes = new HashMap(); inlineElementMap.put("dfn", attributes); attributes = new HashMap(); inlineElementMap.put("em", attributes); attributes = new HashMap(); inlineElementMap.put("font", attributes); attributes = new HashMap(); inlineElementMap.put("i", attributes); attributes = new HashMap(); inlineElementMap.put("img", attributes); attributes = new HashMap(); inlineElementMap.put("input", attributes); attributes = new HashMap(); inlineElementMap.put("iframe", attributes); attributes = new HashMap(); inlineElementMap.put("kbd", attributes); attributes = new HashMap(); inlineElementMap.put("label", attributes); attributes = new HashMap(); inlineElementMap.put("legend", attributes); attributes = new HashMap(); inlineElementMap.put("object", attributes); attributes = new HashMap(); inlineElementMap.put("q", attributes); attributes = new HashMap(); inlineElementMap.put("s", attributes); attributes = new HashMap(); inlineElementMap.put("samp", attributes); attributes = new HashMap(); inlineElementMap.put("small", attributes); attributes = new HashMap(); inlineElementMap.put("span", attributes); attributes = new HashMap(); inlineElementMap.put("strike", attributes); attributes = new HashMap(); inlineElementMap.put("strong", attributes); attributes = new HashMap(); inlineElementMap.put("sub", attributes); attributes = new HashMap(); inlineElementMap.put("sup", attributes); attributes = new HashMap(); inlineElementMap.put("tt", attributes); attributes = new HashMap(); inlineElementMap.put("u", attributes); attributes = new HashMap(); inlineElementMap.put("var", attributes); } protected NodeStack nodeStack = new NodeStack(); public HtmlElement() { super(); isCaseInsensitive(true); } public HtmlElement(String name, NodeImpl parent) { super(name, parent); isCaseInsensitive(true); } public void closed() { // closed() } public String getCssClass() { return getAttribute("class"); } public String getStyle() { return getAttribute("style"); } @Override public String getId() { return getAttribute("id"); } public String getTitle() { return getAttribute("title"); } public NodeStack getValidateStack() { return nodeStack; } public void init() { // initialize } abstract public boolean validate(); protected boolean validate(HashMap> validParentMap) { if (validParentMap == null) { throw new IllegalArgumentException("Parameter validParentMap is null!"); } if (getParentNode() == null) { throw new NullPointerException("parent is null!"); } if (nodeStack == null) { throw new NullPointerException("Variable nodeStack is null!"); } nodeStack.removeAllElements(); nodeStack.push(this); return true; } protected synchronized void validateAttributes(HashMap attributeMap) { if (attributeMap == null) { throw new IllegalArgumentException("Parameter attributeMap is null!"); } Map attributes = getTrafoAttributes(); if ((attributes != null) && (attributes.size() > 0)) { ArrayList removeList = new ArrayList(); for (String name : attributes.keySet()) { name = name.toLowerCase(); if (attributeMap.get(name.toLowerCase()) == null) { removeList.add(name); } else { String validValues = attributeMap.get(name.toLowerCase()); if (validValues == null || validValues.trim().length() == 0) { continue; } AttrImpl attr = attributes.get(name); if (attr == null) { continue; } String attrValue = attr.getValue(); boolean found = false; for (String validValue : validValues.split(",")) { validValue = validValue.trim(); if (attrValue != null && attrValue.equalsIgnoreCase(validValue)) { found = true; break; } } if (found == false) { removeList.add(name); } } } for (String name : removeList) { attributes.remove(name); } } } } src/java/org/dbdoclet/trafo/tag/html/P.java0000644000000000000000000000422112124530526017526 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class P extends Inline2Element { private static String tag = "p"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public static String getTag() { return tag; } public P() { setNodeName(tag); setFormatType(FORMAT_CONTENT); } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Th.java0000644000000000000000000000166112124530526017707 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Th extends TableColumnElement { private static String tag = "th"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Tr.getTag(), HtmlElement.getAttributeMap()); } public Th() { setNodeName(tag); setFormatType(FORMAT_CONTENT); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Meta.java0000644000000000000000000000171412124530526020221 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Meta extends ReplaceElement { private static final String tag = "meta"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Head.getTag(), HtmlElement.getAttributeMap()); } public Meta() { setNodeName("meta"); setFormatType(FORMAT_CONTENT); isEmpty(true); } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } public String getName() { return getAttribute("name"); } public String getContent() { return getAttribute("content"); } } src/java/org/dbdoclet/trafo/tag/html/Table.java0000644000000000000000000001432512124530526020364 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.ArrayList; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; import org.dbdoclet.xiphias.dom.NodeImpl; import org.dbdoclet.xiphias.dom.NodeListImpl; public class Table extends Inline2Element { private static String tag = "table"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public static String getTag() { return tag; } private boolean hasHead = false; private boolean hasFoot = false; private String caption = ""; private final ArrayList widthList = new ArrayList(); public Table() { setNodeName(tag); setFormatType(FORMAT_BLOCK); } @Override public void closed() { boolean hasRows = false; if (hasChildNodes() == true && getNumberOfChildNodes() > 0) { for (NodeImpl child : getTrafoChildNodes()) { if (child instanceof HtmlElement) { HtmlElement elem = (HtmlElement) child; if (elem instanceof Tr || elem instanceof Tbody) { hasRows = true; } } } } if (hasRows == false) { appendChild(new Tr().appendChild(new Td())); } } private String cmpWidth(String width1, String width2) { if (((width1 == null) || (width1.length() == 0)) && ((width2 == null) || (width2.length() == 0))) { return ""; } // end of if () if ((width1 == null) || (width1.length() == 0)) { return width2; } if ((width2 == null) || (width2.length() == 0)) { return width1; } if (width1.endsWith("%") && !width2.endsWith("%")) { return width1; } if (width2.endsWith("%") && !width1.endsWith("%")) { return width2; } int w1 = widthToNumber(width1); int w2 = widthToNumber(width2); if (w1 > w2) { return width1; } else { return width2; } } public String getCaption() { return caption; } public ArrayList getColWidths() { getNumOfCols(); return widthList; } public int getNumOfCols() { int n; int cols = 0; widthList.clear(); for (NodeImpl child : getTrafoChildNodes()) { if (child instanceof Caption) { caption = child.getTextContent(); } if (child instanceof Thead) { hasHead = true; for (NodeImpl row : child.getTrafoChildNodes()) { if (row instanceof Tr) { n = getNumOfColsInRow((Tr) row); if (n > cols) { cols = n; } } } } if (child instanceof Tfoot) { hasFoot = true; for (NodeImpl row : child.getTrafoChildNodes()) { if (row instanceof Tr) { n = getNumOfColsInRow((Tr) row); if (n > cols) { cols = n; } } } } if (child instanceof Tbody) { for (NodeImpl row : child.getTrafoChildNodes()) { if (row instanceof Tr) { n = getNumOfColsInRow((Tr) row); if (n > cols) { cols = n; } } } } if (child instanceof Tr) { n = getNumOfColsInRow((Tr) child); if (n > cols) { cols = n; } } } if (cols < 0) { return 0; } return cols; } private int getNumOfColsInRow(Tr row) { int index = 0; int colspans = 0; String width; String val; NodeListImpl cols = row.getTrafoChildNodes(); widthList.ensureCapacity(cols.size()); for (NodeImpl node : cols) { if (node instanceof TableColumnElement) { TableColumnElement col = (TableColumnElement) node; width = col.getWidth(); if (widthList.size() >= (index + 1)) { val = widthList.get(index); } else { val = ""; } if (widthList.size() <= index) { widthList.add(index, cmpWidth(val, width)); } else { widthList.set(index, cmpWidth(val, width)); } index++; col.setIndex(index + colspans); if (col.getColspan() > 1) { /* Eine Spalte wird standardmäßig hinzugefügt. Deshalb muß eine von colspan abgezogen werden. */ colspans += col.getColspan() - 1; } } } return index; } public boolean hasBorder() { String attr = getAttribute("border"); if ((attr == null) || (attr.length() == 0) || attr.equals("0")) { return false; } else { return true; } } public boolean hasFoot() { return hasFoot; } public boolean hasHead() { return hasHead; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return false; } private int widthToNumber(String width) { StringBuffer buffer = new StringBuffer(); char c; for (int i = 0; i < width.length(); i++) { c = width.charAt(i); if (Character.isDigit(c)) { buffer.append(c); } else { break; } } int w; try { w = Integer.parseInt(buffer.toString()); } catch (NumberFormatException oops) { w = 1; } return w; } } src/java/org/dbdoclet/trafo/tag/html/H3.java0000644000000000000000000000467112124530526017612 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class H3 extends HeaderElement { protected static final int level = 3; private static final String tag = "h3"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public H3() { setNodeName(tag); } public static String getTag() { return tag; } @Override public void init() { } @Override public int getLevel() { return level; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return super.validate(); } } src/java/org/dbdoclet/trafo/tag/html/Map.java0000644000000000000000000000316412124530526020051 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Map extends InlineElement { private static final String tag = "map"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); attributeMap = new HashMap(); } public Map() { setNodeName(tag); setFormatType(FORMAT_BLOCK); setAttribute("name", "map"); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } @Override public void closed() { if ((getChildNodes() == null) || (getChildNodes().getLength() == 0)) { appendChild(new Area()); } } } src/java/org/dbdoclet/trafo/tag/html/BlockElement.java0000644000000000000000000000527712124530526021707 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.TextImpl; abstract public class BlockElement extends HtmlElement { @Override protected boolean validate(HashMap> validParentMap) { if (validParentMap == null) { throw new IllegalArgumentException("Parameter validParentMap is null!"); } if (getParentNode() == null) { throw new NullPointerException("Variable getParent() is null!"); } if (nodeStack == null) { throw new NullPointerException("Variable nodeStack is null!"); } nodeStack.removeAllElements(); nodeStack.push(this); if (validParentMap.get(getParentNode().getNodeName()) != null) { return true; } if (getParentNode() instanceof Fieldset) { getParentNode().getFirstChild(); if (!(getParentNode() instanceof Legend)) { Legend legend = new Legend(); getParentNode().appendChild(legend); legend.appendChild(new TextImpl("Legend", legend)); } return true; } if (getParentNode() instanceof Select) { nodeStack.removeAllElements(); Option option = new Option(); nodeStack.push(option); return true; } if (getParentNode() instanceof Optgroup) { nodeStack.removeAllElements(); Option option = new Option(); nodeStack.push(option); return true; } if (getParentNode() instanceof Dl) { Dd dd = new Dd(); dd.appendChild(this); nodeStack.push(dd); return true; } if (getParentNode() instanceof Dir || getParentNode() instanceof Menu || getParentNode() instanceof Ol || getParentNode() instanceof Ul) { Li li = new Li(); li.appendChild(this); nodeStack.push(li); return true; } if (getParentNode() instanceof Table) { Tr tr = new Tr(); Td td = new Td(); tr.appendChild(td); td.appendChild(this); nodeStack.push(td); nodeStack.push(tr); return true; } if (getParentNode() instanceof Tbody || getParentNode() instanceof Tfoot || getParentNode() instanceof Thead) { Tr tr = new Tr(); Td td = new Td(); tr.appendChild(td); td.appendChild(this); nodeStack.push(td); nodeStack.push(tr); return true; } if (getParentNode() instanceof Tr) { Td td = new Td(); td.appendChild(this); nodeStack.push(td); return true; } if (getParentNode() instanceof Map) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Strike.java0000644000000000000000000000207012124530526020570 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Strike extends InlineElement { private static String tag = "strike"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); } public static String getTag() { return tag; } public Strike() { setNodeName(tag); setFormatType(FORMAT_INLINE); } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Big.java0000644000000000000000000000276312124530526020041 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Big extends InlineElement { private static final String tag = "big"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove(Pre.getTag()); attributeMap = new HashMap(); } public Big() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Tt.java0000644000000000000000000000227212124530526017722 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Tt extends InlineElement { private static String tag = "tt"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); } public Tt() { setNodeName(tag); } public static String getTag() { return tag; } @Override public void init() { super.init(); } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/H4.java0000644000000000000000000000467112124530526017613 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class H4 extends HeaderElement { protected static final int level = 4; private static final String tag = "h4"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public H4() { setNodeName(tag); } public static String getTag() { return tag; } @Override public void init() { } @Override public int getLevel() { return level; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return super.validate(); } } src/java/org/dbdoclet/trafo/tag/html/Small.java0000644000000000000000000000222412124530526020400 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Small extends InlineElement { private static String tag = "small"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove(Pre.getTag()); } public static String getTag() { return tag; } public Small() { super(); setNodeName(tag); setFormatType(FORMAT_INLINE); } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Menu.java0000644000000000000000000000477512124530526020251 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Menu extends Inline2Element { private static final String tag = "menu"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public Menu() { setNodeName("menu"); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return false; } @Override public void closed() { if (hasChildNodes() == false || getNumberOfChildNodes() == 0) { appendChild(new Li()); } // end of if () } } src/java/org/dbdoclet/trafo/tag/html/Em.java0000644000000000000000000000254312124530526017675 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Em extends InlineElement { private static final String tag = "em"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.put(Caption.getTag(), HtmlElement.getAttributeMap()); validParentMap.remove("var"); } public Em() { setNodeName(tag); setFormatType(FORMAT_INLINE); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Title.java0000644000000000000000000000167612124530526020423 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Title extends StrictElement { private static final String tag = "title"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Head.getTag(), HtmlElement.getAttributeMap()); } public Title() { setNodeName(tag); setFormatType(FORMAT_CONTENT); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Div.java0000644000000000000000000000455112124530526020057 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Div extends Inline2Element { private static final String tag = "div"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public Div() { setNodeName("div"); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Tfoot.java0000644000000000000000000000277712124530526020440 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.NodeImpl; public class Tfoot extends StrictElement { private static String tag = "tfoot"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Table.getTag(), HtmlElement.getAttributeMap()); } public static String getTag() { return tag; } public Tfoot() { setNodeName(tag); } @Override public void closed() { boolean hasRows = false; if (hasChildNodes() == true && getNumberOfChildNodes() > 0) { for (NodeImpl node : getTrafoChildNodes()) { if (node instanceof HtmlElement) { HtmlElement elem = (HtmlElement) node; if (elem instanceof Tr) { hasRows = true; } } } } if (hasRows == false) { appendChild(new Tr().appendChild(new Td())); } } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/StrictElement.java0000644000000000000000000000162112124530526022112 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public abstract class StrictElement extends HtmlElement { @Override protected boolean validate(HashMap> validParentMap) { if (validParentMap == null) { throw new IllegalArgumentException("Parameter validParentMap is null!"); } if (getParentNode() == null) { throw new NullPointerException("Variable getParent() is null!"); } if (nodeStack == null) { throw new NullPointerException("Variable nodeStack is null!"); } nodeStack.removeAllElements(); nodeStack.push(this); if (validParentMap.get(getParentNode().getNodeName()) != null) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Dd.java0000644000000000000000000000161612124530526017663 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Dd extends ReplaceElement { private static final String tag = "dd"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Dl.getTag(), HtmlElement.getAttributeMap()); } public Dd() { setNodeName("dd"); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Label.java0000644000000000000000000000277212124530526020357 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Label extends InlineElement { private static final String tag = "label"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove("button"); validParentMap.remove("label"); attributeMap = new HashMap(); } public Label() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Noscript.java0000644000000000000000000000470012124530526021132 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Noscript extends Inline2Element { private static final String tag = "noscript"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public Noscript() { setNodeName("noscript"); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/TableColumnElement.java0000644000000000000000000000463312124530526023055 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; public abstract class TableColumnElement extends StrictElement { private int index = -1; public String getWidth() { String width = getAttribute("width"); if ((width == null) || (width.length() == 0)) { return ""; } else { return width; } } public int getColspan() { String str = getAttribute("colspan"); if ((str == null) || (str.length() == 0)) { return 1; } int colspan; try { colspan = Integer.parseInt(str); } catch (NumberFormatException oops) { colspan = 1; } return colspan; } public int getRowspan() { String str = getAttribute("rowspan"); if ((str == null) || (str.length() == 0)) { return 0; } int rowspan; try { rowspan = Integer.parseInt(str); rowspan--; } catch (NumberFormatException oops) { rowspan = 0; } // end of catch if (rowspan < 0) { rowspan = 0; } return rowspan; } public String getAlign() { return getAttribute("align"); } public String getVAlign() { String valign = getAttribute("valign"); if ((valign == null) || (valign.length() == 0)) { return null; } if (valign.equalsIgnoreCase("top") || valign.equalsIgnoreCase("middle") || valign.equalsIgnoreCase("bottom") || valign.equalsIgnoreCase("baseline")) { return valign; } if (valign.equalsIgnoreCase("head")) { return "top"; } return "middle"; } public String getChar() { return getAttribute("char"); } public String getCharOff() { return getAttribute("charoff"); } public void setIndex(int i) { index = i; } public int getIndex() { return index; } @Override public boolean validateAttributes() { String valign = getVAlign(); if (valign != null) { setAttribute("valign", valign); } return true; } } src/java/org/dbdoclet/trafo/tag/html/Dfn.java0000644000000000000000000000270612124530526020044 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Dfn extends InlineElement { private static final String tag = "dfn"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); attributeMap = new HashMap(); } public Dfn() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/H6.java0000644000000000000000000000467112124530526017615 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class H6 extends HeaderElement { protected static final int level = 6; private static final String tag = "h6"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public H6() { setNodeName(tag); } public static String getTag() { return tag; } @Override public void init() { } @Override public int getLevel() { return level; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return super.validate(); } } src/java/org/dbdoclet/trafo/tag/html/U.java0000644000000000000000000000235012124530526017534 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class U extends InlineElement { private static String tag = "u"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove("var"); } public U() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Br.java0000644000000000000000000000245712124530526017703 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Br extends InlineElement { private static final String tag = "br"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.put(Caption.getTag(), HtmlElement.getAttributeMap()); } public Br() { setNodeName("br"); isEmpty(true); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Dl.java0000644000000000000000000000506312124530526017673 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Dl extends Inline2Element { private static final String tag = "dl"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public Dl() { setNodeName("dl"); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return false; } @Override public void closed() { if (hasChildNodes() == false || getNumberOfChildNodes() == 0) { appendChild(new Dt()); appendChild(new Dd()); } } } src/java/org/dbdoclet/trafo/tag/html/Frame.java0000644000000000000000000000170212124530526020362 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Frame extends StrictElement { private static final String tag = "frame"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Frameset.getTag(), HtmlElement.getAttributeMap()); } public Frame() { setNodeName(tag); setFormatType(FORMAT_CONTENT); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Tbody.java0000644000000000000000000000277712124530526020426 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.NodeImpl; public class Tbody extends StrictElement { private static String tag = "tbody"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Table.getTag(), HtmlElement.getAttributeMap()); } public static String getTag() { return tag; } public Tbody() { setNodeName(tag); } @Override public void closed() { boolean hasRows = false; if (hasChildNodes() == true && getNumberOfChildNodes() > 0) { for (NodeImpl node : getTrafoChildNodes()) { if (node instanceof HtmlElement) { HtmlElement elem = (HtmlElement) node; if (elem instanceof Tr) { hasRows = true; } } } } if (hasRows == false) { appendChild(new Tr().appendChild(new Td())); } } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Font.java0000644000000000000000000000234212124530526020237 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Font extends InlineElement { private static final String tag = "font"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove(Pre.getTag()); } public Font() { setNodeName(tag); setFormatType(FORMAT_INLINE); } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Li.java0000644000000000000000000000221712124530526017676 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Li extends StrictElement { private static final String tag = "li"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Dir.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Menu.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Ol.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Ul.getTag(), HtmlElement.getAttributeMap()); } public Li() { setNodeName("li"); setFormatType(FORMAT_CONTENT); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Img.java0000644000000000000000000000457012124530526020052 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Img extends InlineElement { private static final String tagName = "img"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove("var"); attributeMap = new HashMap(); attributeMap.put("align", "top, middle, bottom, left, center, right"); attributeMap.put("alt", ""); attributeMap.put("border", ""); attributeMap.put("height", ""); attributeMap.put("hspace", ""); attributeMap.put("ismap", ""); attributeMap.put("longdesc", ""); attributeMap.put("name", ""); attributeMap.put("src", ""); attributeMap.put("usemap", ""); attributeMap.put("vspace", ""); attributeMap.put("width", ""); } public Img() { setNodeName("img"); setFormatType(FORMAT_INLINE); isEmpty(true); setAttribute("alt", "image"); setAttribute("src", "image.png"); } public static String getTag() { return tagName; } @Override public void init() { } public String getSrc() { return getAttribute("src"); } public String getAlt() { return getAttribute("alt"); } public String getWidth() { return getAttribute("width"); } public String getHeight() { return getAttribute("height"); } public String getAlign() { return getAttribute("align"); } @Override public boolean validate() { validateAttributes(attributeMap); if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Iframe.java0000644000000000000000000000367312124530526020544 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Iframe extends InlineElement { private static final String tagName = "iframe"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove("button"); attributeMap = new HashMap(); attributeMap.put("align", "center"); attributeMap.put("frameborder", "1"); attributeMap.put("height", ""); attributeMap.put("longdesc", ""); attributeMap.put("marginwidth", ""); attributeMap.put("marginheight", ""); attributeMap.put("name", ""); attributeMap.put("scrolling", "auto"); attributeMap.put("src", ""); attributeMap.put("width", ""); } public Iframe() { setNodeName(tagName); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tagName; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { validateAttributes(attributeMap); if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Link.java0000644000000000000000000000172312124530526020230 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Link extends ReplaceElement { private static final String tag = "link"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Head.getTag(), HtmlElement.getAttributeMap()); } public Link() { setNodeName(tag); setFormatType(FORMAT_CONTENT); isEmpty(true); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Head.java0000644000000000000000000000167212124530526020177 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Head extends ReplaceElement { private static final String tag = "head"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Html.getTag(), HtmlElement.getAttributeMap()); } public Head() { setNodeName(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Address.java0000644000000000000000000000443712124530526020725 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Address extends Inline2Element { private static final String tag = "address"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public Address() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Optgroup.java0000644000000000000000000000347512124530526021160 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.NodeImpl; public class Optgroup extends StrictElement { private static final String tag = "optgroup"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.put(Select.getTag(), HtmlElement.getAttributeMap()); attributeMap = new HashMap(); } public static HashMap getAttributeMap() { return attributeMap; } public static String getTag() { return tag; } public Optgroup() { setNodeName(tag); setFormatType(FORMAT_BLOCK); setAttribute("label", "Optgroup"); } @Override public void closed() { boolean hasOptions = false; if (hasChildNodes() == true && getNumberOfChildNodes() > 0) { for (NodeImpl node : getTrafoChildNodes()) { if (node instanceof HtmlElement) { HtmlElement elem = (HtmlElement) node; if (elem instanceof Option) { hasOptions = true; } } } } if (hasOptions == false) { appendChild(new Option()); } } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Select.java0000644000000000000000000000312612124530526020551 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; import org.dbdoclet.xiphias.dom.NodeImpl; public class Select extends InlineElement { private static String tag = "select"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove(Button.getTag()); } public static String getTag() { return tag; } public Select() { setNodeName(tag); setFormatType(FORMAT_BLOCK); } @Override public void closed() { boolean hasOptions = false; if (hasChildNodes() == true && getNumberOfChildNodes() > 0) { for (NodeImpl node : getTrafoChildNodes()) { if (node instanceof HtmlElement) { HtmlElement elem = (HtmlElement) node; if (elem instanceof Option) { hasOptions = true; } } } } if (hasOptions == false) { appendChild(new Option()); } } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Q.java0000644000000000000000000000235512124530526017535 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Q extends InlineElement { private static final String tag = "q"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); } public Q() { setNodeName(tag); setFormatType(FORMAT_INLINE); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Textarea.java0000644000000000000000000000300412124530526021102 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Textarea extends InlineElement { private static final String tag = "textarea"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove(Button.getTag()); attributeMap = new HashMap(); } public Textarea() { setNodeName(tag); setAttribute("cols", "80"); setAttribute("rows", "25"); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Code.java0000644000000000000000000000236612124530526020211 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Code extends InlineElement { private static final String tag = "code"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); } public Code() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/A.java0000644000000000000000000000301112124530526017503 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class A extends InlineElement { private static final String tag = "a"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.put(Caption.getTag(), HtmlElement.getAttributeMap()); validParentMap.remove("a"); validParentMap.remove("button"); } public static String getTag() { return tag; } public A() { super(); setNodeName(tag); setFormatType(FORMAT_INLINE); } public String getHref() { return getAttribute("href"); } public String getName() { return getAttribute("name"); } @Override public boolean validate() { if (super.validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Body.java0000644000000000000000000000232412124530526020226 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Body extends ReplaceElement { private static final String tag = "body"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.put(Html.getTag(), HtmlElement.getAttributeMap()); attributeMap = new HashMap(); attributeMap.put("bgcolor", "white"); } public Body() { setNodeName(tag); setFormatType(FORMAT_BLOCK); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } @Override public boolean validateAttributes() { validateAttributes(attributeMap); return true; } } src/java/org/dbdoclet/trafo/tag/html/HtmlObject.java0000644000000000000000000000310712124530526021364 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class HtmlObject extends InlineElement { private static final String tag = "object"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.put(Head.getTag(), HtmlElement.getAttributeMap()); validParentMap.remove("pre"); attributeMap = new HashMap(); } public HtmlObject() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Kbd.java0000644000000000000000000000236312124530526020034 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Kbd extends InlineElement { private static final String tag = "kbd"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); } public Kbd() { setNodeName(tag); setFormatType(FORMAT_INLINE); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Bdo.java0000644000000000000000000000243012124530526020033 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Bdo extends InlineElement { private static final String tag = "bdo"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); } public Bdo() { setNodeName(tag); setFormatType(FORMAT_INLINE); setAttribute("dir", "ltr"); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Acronym.java0000644000000000000000000000251012124530526020736 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Acronym extends InlineElement { private static final String tag = "acronym"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.put(Caption.getTag(), HtmlElement.getAttributeMap()); validParentMap.remove("var"); } public static String getTag() { return tag; } public Acronym() { setNodeName(tag); setFormatType(FORMAT_INLINE); } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/I.java0000644000000000000000000000254012124530526017521 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class I extends InlineElement { private static final String tag = "i"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.put(Caption.getTag(), HtmlElement.getAttributeMap()); validParentMap.remove("var"); } public I() { setNodeName(tag); setFormatType(FORMAT_INLINE); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Samp.java0000644000000000000000000000264312124530526020235 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Samp extends InlineElement { private static final String tag = "samp"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); attributeMap = new HashMap(); } public Samp() { setNodeName(tag); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Cite.java0000644000000000000000000000236612124530526020223 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Cite extends InlineElement { private static final String tag = "cite"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); } public Cite() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Param.java0000644000000000000000000000236412124530526020375 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Param extends StrictElement { private static final String tag = "param"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); attributeMap = new HashMap(); } public Param() { setNodeName(tag); isEmpty(true); setAttribute("name", "param"); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Span.java0000644000000000000000000000260012124530526020227 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Span extends InlineElement { private static final String tag = "span"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); attributeMap = new HashMap(); } public Span() { setNodeName(tag); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Pre.java0000644000000000000000000000436012124530526020061 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Pre extends Inline2Element { private static final String tag = "pre"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); new HashMap(); } public static String getTag() { return tag; } public Pre() { setNodeName(tag); } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Html.java0000644000000000000000000000132412124530526020234 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import org.w3c.dom.Node; public class Html extends StrictElement { @Override public boolean validate() { Node parent = getParentNode(); if (parent instanceof HtmlDocument) { nodeStack.removeAllElements(); nodeStack.push(this); return true; } return false; } private static final String tag = "html"; public static String getTag() { return tag; } public Html() { setNodeName(tag); setFormatType(FORMAT_BLOCK); } } src/java/org/dbdoclet/trafo/tag/html/Abbr.java0000644000000000000000000000256212124530526020203 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Abbr extends InlineElement { private static final String tag = "abbr"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.put(Caption.getTag(), HtmlElement.getAttributeMap()); validParentMap.remove(Abbr.getTag()); validParentMap.remove(Var.getTag()); } public Abbr() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Ul.java0000644000000000000000000000476012124530526017717 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Ul extends Inline2Element { private static String tag = "ul"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public Ul() { super(); setNodeName(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return false; } @Override public void closed() { if (hasChildNodes() == false) { appendChild(new Li()); } } } src/java/org/dbdoclet/trafo/tag/html/Td.java0000644000000000000000000000166012124530526017702 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Td extends TableColumnElement { private static String tag = "td"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Tr.getTag(), HtmlElement.getAttributeMap()); } public Td() { setNodeName(tag); setFormatType(FORMAT_CONTENT); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/HtmlDocument.java0000644000000000000000000000203612124530526021734 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import org.dbdoclet.xiphias.dom.DocumentImpl; import org.dbdoclet.xiphias.dom.ElementImpl; public class HtmlDocument extends DocumentImpl { private HtmlElement documentElement; @Override public HtmlElement getDocumentElement() { return documentElement; } @Override public void setDocumentElement(ElementImpl documentElement) { setDocumentElement((HtmlElement) documentElement); } public void setDocumentElement(HtmlElement documentElement) { if (documentElement == null) { throw new IllegalArgumentException("The argument documentElement must not be null!"); } if (this.documentElement != null) { replaceChild(this.documentElement, documentElement); } else { appendChild(documentElement); } this.documentElement = documentElement; } } src/java/org/dbdoclet/trafo/tag/html/Isindex.java0000644000000000000000000000500312124530526020731 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Isindex extends Inline2Element { private static final String tag = "isindex"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public Isindex() { setNodeName("isindex"); isEmpty(true); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (getParentNode() instanceof Dir || getParentNode() instanceof Menu) { return false; } if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/H2.java0000644000000000000000000000467112124530526017611 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class H2 extends HeaderElement { protected static final int level = 2; private static final String tag = "h2"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public H2() { setNodeName(tag); } public static String getTag() { return tag; } @Override public void init() { } @Override public int getLevel() { return level; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return super.validate(); } } src/java/org/dbdoclet/trafo/tag/html/Ins.java0000644000000000000000000000275612124530526020073 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Ins extends InlineElement { private static final String tag = "ins"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove("button"); attributeMap = new HashMap(); } public Ins() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Legend.java0000644000000000000000000000170212124530526020526 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Legend extends StrictElement { private static final String tag = "legend"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); } public Legend() { setNodeName(tag); setFormatType(FORMAT_CONTENT); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Caption.java0000644000000000000000000000161412124530526020727 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Caption extends ReplaceElement { private static final String tag = "caption"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Table.getTag(), HtmlElement.getAttributeMap()); } public static String getTag() { return tag; } public Caption() { setNodeName(tag); setFormatType(FORMAT_CONTENT); } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Col.java0000644000000000000000000000203612124530526020046 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Col extends ReplaceElement { private static final String tag = "col"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Table.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Colgroup.getTag(), HtmlElement.getAttributeMap()); } public Col() { setNodeName(tag); setFormatType(FORMAT_INLINE); isEmpty(true); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/H5.java0000644000000000000000000000467112124530526017614 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class H5 extends HeaderElement { protected static final int level = 5; private static final String tag = "h5"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public H5() { setNodeName(tag); } public static String getTag() { return tag; } @Override public void init() { } @Override public int getLevel() { return level; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return super.validate(); } } src/java/org/dbdoclet/trafo/tag/html/Area.java0000644000000000000000000000207012124530526020177 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Area extends ReplaceElement { private static final String tag = "area"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.put(Map.getTag(), Map.getAttributeMap()); attributeMap = new HashMap(); } public static HashMap getAttributeMap() { return attributeMap; } public static String getTag() { return tag; } public Area() { setNodeName(tag); setFormatType(FORMAT_CONTENT); isEmpty(true); setAttribute("alt", "area"); } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/B.java0000644000000000000000000000246312124530526017516 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class B extends InlineElement { private static final String tag = "b"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.put(Caption.getTag(), HtmlElement.getAttributeMap()); validParentMap.remove("var"); } public B() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Option.java0000644000000000000000000000227212124530526020603 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Option extends StrictElement { private static final String tag = "option"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.put(Select.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Optgroup.getTag(), Optgroup.getAttributeMap()); attributeMap = new HashMap(); } public Option() { setNodeName(tag); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Hr.java0000644000000000000000000000557212124530526017712 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; import org.w3c.dom.Node; public class Hr extends Inline2Element { private static final String tag = "hr"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public Hr() { setNodeName("hr"); isEmpty(true); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { Node parent = getParentNode(); if (parent instanceof Dir || parent instanceof Menu) { return false; } if (validate(validParentMap)) { return true; } if (parent instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } if (parent instanceof Li) { Node node = parent.getParentNode(); if (node == null) { return false; } if (node instanceof Dir || node instanceof Menu) { return false; } } return false; } } src/java/org/dbdoclet/trafo/tag/html/Center.java0000644000000000000000000000473512124530526020561 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Center extends Inline2Element { private static final String tag = "center"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public Center() { setNodeName("center"); setFormatType(FORMAT_BLOCK); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Input.java0000644000000000000000000000517012124530526020432 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Input extends InlineElement { private static final String tag = "input"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove("button"); attributeMap = new HashMap(); attributeMap.put("accept", ""); attributeMap.put("accesskey", ""); attributeMap.put("align", "top, middle, bottom, left, center, right"); attributeMap.put("alt", ""); attributeMap.put("checked", ""); attributeMap.put("datafld", ""); attributeMap.put("datasrc", ""); attributeMap.put("dataformatas", ""); attributeMap.put("disabled", ""); attributeMap.put("id", ""); attributeMap.put("ismap", ""); attributeMap.put("maxlength", ""); attributeMap.put("name", ""); attributeMap.put("onblur", ""); attributeMap.put("onchange", ""); attributeMap.put("onfocus", ""); attributeMap.put("onselect", ""); attributeMap.put("readonly", ""); attributeMap.put("size", ""); attributeMap.put("src", ""); attributeMap.put("tabindex", ""); attributeMap.put("", ""); attributeMap.put("type", "text, password, checkbox, radio, submit, reset, file, hidden, image, button"); attributeMap.put("usemap", ""); attributeMap.put("value", ""); } public Input() { setNodeName(tag); setFormatType(FORMAT_INLINE); isEmpty(true); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { // validateAttributes(attributeMap); if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Tr.java0000644000000000000000000000443512124530526017723 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.NodeImpl; public class Tr extends StrictElement { private static String tagName = "tr"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Table.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Tbody.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Thead.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Tfoot.getTag(), HtmlElement.getAttributeMap()); } public static String getTag() { return tagName; } public Tr() { setNodeName(tagName); setFormatType(FORMAT_BLOCK); } @Override public void closed() { boolean hasColumns = false; if (hasChildNodes() == true && getNumberOfChildNodes() > 0) { for (NodeImpl node : getTrafoChildNodes()) { if (node instanceof HtmlElement) { HtmlElement elem = (HtmlElement) node; if (elem instanceof TableColumnElement) { hasColumns = true; } } } } if (hasColumns == false) { appendChild(new Td()); } } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } @Override public boolean validateAttributes() { String valign = getAttribute("valign"); if (valign != null) { if (valign.equalsIgnoreCase("top") == false && valign.equalsIgnoreCase("middle") == false && valign.equalsIgnoreCase("bottom") == false && valign.equalsIgnoreCase("baseline") == false) { setAttribute("valign", "middle"); } } return true; } public Integer getHeight() { return getIntAttribute("height"); } } src/java/org/dbdoclet/trafo/tag/html/Basefont.java0000644000000000000000000000302612124530526021072 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Basefont extends InlineElement { private static final String tag = "basefont"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove(Pre.getTag()); attributeMap = new HashMap(); } public static HashMap getAttributeMap() { return attributeMap; } public static String getTag() { return tag; } public Basefont() { setNodeName(tag); setFormatType(FORMAT_INLINE); isEmpty(true); setAttribute("size", "12px"); } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Frameset.java0000644000000000000000000000170512124530526021101 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Frameset extends StrictElement { private static final String tag = "frameset"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Html.getTag(), HtmlElement.getAttributeMap()); } public Frameset() { setNodeName(tag); setFormatType(FORMAT_BLOCK); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Del.java0000644000000000000000000000270612124530526020041 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Del extends InlineElement { private static final String tag = "del"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); attributeMap = new HashMap(); } public Del() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/S.java0000644000000000000000000000235512124530526017537 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class S extends InlineElement { private static final String tag = "s"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); } public S() { setNodeName(tag); setFormatType(FORMAT_INLINE); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Script.java0000644000000000000000000000304012124530526020571 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Script extends InlineElement { private static final String tag = "script"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.put(Head.getTag(), HtmlElement.getAttributeMap()); attributeMap = new HashMap(); } public Script() { setNodeName(tag); setAttribute("type", "javascript"); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Noframes.java0000644000000000000000000000456212124530526021111 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Noframes extends Inline2Element { private static final String tag = "noframes"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public Noframes() { setNodeName("noframes"); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Fieldset.java0000644000000000000000000000550312124530526021072 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; import org.dbdoclet.xiphias.dom.NodeImpl; import org.dbdoclet.xiphias.dom.TextImpl; public class Fieldset extends ReplaceElement { private static final String tag = "fieldset"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); attributeMap = new HashMap(); } public Fieldset() { setNodeName(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return false; } @Override public void closed() { NodeImpl child = getFirstChild(); if (!(child instanceof Legend)) { insertChild(0, new Legend().appendChild(new TextImpl("Legend"))); } // end of if () } } src/java/org/dbdoclet/trafo/tag/html/HeaderElement.java0000644000000000000000000000071112124530526022031 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; abstract public class HeaderElement extends StrictElement { abstract public int getLevel(); @Override public boolean validate() { if (getParentNode() instanceof A) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Style.java0000644000000000000000000000227212124530526020433 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Style extends ReplaceElement { private static final String tag = "style"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.put(Head.getTag(), HtmlElement.getAttributeMap()); attributeMap = new HashMap(); } public Style() { setNodeName(tag); setFormatType(FORMAT_BLOCK); setAttribute("type", "text/css"); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Dt.java0000644000000000000000000000166412124530526017706 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Dt extends ReplaceElement { private static final String tag = "dt"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Dl.getTag(), HtmlElement.getAttributeMap()); } public Dt() { setNodeName(tag); setFormatType(FORMAT_CONTENT); } @Override public void init() { } public static String getTag() { return tag; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Strong.java0000644000000000000000000000237012124530526020606 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Strong extends InlineElement { private static String tag = "strong"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove("var"); } public Strong() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Thead.java0000644000000000000000000000277712124530526020372 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.NodeImpl; public class Thead extends StrictElement { private static String tag = "thead"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Table.getTag(), HtmlElement.getAttributeMap()); } public static String getTag() { return tag; } public Thead() { setNodeName(tag); } @Override public void closed() { boolean hasRows = false; if (hasChildNodes() == true && getNumberOfChildNodes() > 0) { for (NodeImpl node : getTrafoChildNodes()) { if (node instanceof HtmlElement) { HtmlElement elem = (HtmlElement) node; if (elem instanceof Tr) { hasRows = true; } } } } if (hasRows == false) { appendChild(new Tr().appendChild(new Td())); } } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Applet.java0000644000000000000000000000304012124530526020552 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Applet extends InlineElement { private static final String tag = "applet"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove(Pre.getTag()); attributeMap = new HashMap(); } public Applet() { setNodeName(tag); setFormatType(FORMAT_INLINE); setAttribute("width", "400"); setAttribute("height", "300"); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/ReplaceElement.java0000644000000000000000000000452112124530526022217 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.TextImpl; import org.w3c.dom.Node; abstract public class ReplaceElement extends HtmlElement { @Override protected boolean validate(HashMap> validParentMap) { if (validParentMap == null) { throw new IllegalArgumentException("Parameter validParentMap is null!"); } if (getParentNode() == null) { throw new NullPointerException("Variable getParent() is null!"); } if (nodeStack == null) { throw new NullPointerException("Variable nodeStack is null!"); } nodeStack.removeAllElements(); if (validParentMap.get(getParentNode().getNodeName()) != null) { nodeStack.push(this); return true; } if (getParentNode() instanceof Dir || getParentNode() instanceof Menu || getParentNode() instanceof Ol || getParentNode() instanceof Ul) { nodeStack.push(new Li()); return true; } // end of if () if (getParentNode() instanceof Dl) { nodeStack.push(new Dt()); return true; } // end of if () if (getParentNode() instanceof Fieldset) { Node child = getParentNode().getFirstChild(); if ((child == null) || !(child instanceof Legend)) { Legend legend = new Legend(); getParentNode().appendChild(legend); legend.appendChild(new TextImpl("Legend", legend)); } return true; } if (getParentNode() instanceof Select) { Option option = new Option(); nodeStack.push(option); return true; } if (getParentNode() instanceof Optgroup) { Option option = new Option(); nodeStack.push(option); return true; } if (getParentNode() instanceof Tbody || getParentNode() instanceof Tfoot || getParentNode() instanceof Thead) { Tr tr = new Tr(); Td td = new Td(); tr.appendChild(td); nodeStack.push(td); nodeStack.push(tr); return true; } if (getParentNode() instanceof Tr) { Td td = new Td(); nodeStack.push(td); return true; } if (getParentNode() instanceof Map) { Area area = new Area(); nodeStack.push(area); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Var.java0000644000000000000000000000231112124530526020055 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Var extends InlineElement { private static String tag = "var"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); } public Var() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Dir.java0000644000000000000000000000501712124530526020051 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Dir extends Inline2Element { private static final String tag = "dir"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public Dir() { setNodeName(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return false; } @Override public void closed() { if ((hasChildNodes() == false) || (getNumberOfChildNodes() == 0)) { appendChild(new Li()); } } } src/java/org/dbdoclet/trafo/tag/html/InlineElement.java0000644000000000000000000000536212124530526022066 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.TextImpl; import org.w3c.dom.Node; abstract public class InlineElement extends HtmlElement { @Override protected boolean validate(HashMap> validParentMap) { if (validParentMap == null) { throw new IllegalArgumentException("Parameter validParentMap is null!"); } if (getParentNode() == null) { throw new NullPointerException("Variable getParent() is null!"); } if (nodeStack == null) { throw new NullPointerException("Variable nodeStack is null!"); } nodeStack.removeAllElements(); nodeStack.push(this); if (validParentMap.get(getParentNode().getNodeName()) != null) { return true; } if (getParentNode() instanceof Fieldset) { Node child = getParentNode().getFirstChild(); if ((child == null) || !(child instanceof Legend)) { Legend legend = new Legend(); getParentNode().appendChild(legend); legend.appendChild(new TextImpl("Legend", legend)); } return true; } if (getParentNode() instanceof Select) { nodeStack.removeAllElements(); Option option = new Option(); nodeStack.push(option); return true; } if (getParentNode() instanceof Optgroup) { nodeStack.removeAllElements(); Option option = new Option(); nodeStack.push(option); return true; } if (getParentNode() instanceof Dl) { Dd dd = new Dd(); dd.appendChild(this); nodeStack.push(dd); return true; } if (getParentNode() instanceof Dir || getParentNode() instanceof Menu || getParentNode() instanceof Ol || getParentNode() instanceof Ul) { Li li = new Li(); li.appendChild(this); nodeStack.push(li); return true; } if (getParentNode() instanceof Table) { Tr tr = new Tr(); Td td = new Td(); tr.appendChild(td); td.appendChild(this); nodeStack.push(td); nodeStack.push(tr); return true; } if (getParentNode() instanceof Tbody || getParentNode() instanceof Tfoot || getParentNode() instanceof Thead) { Tr tr = new Tr(); Td td = new Td(); tr.appendChild(td); td.appendChild(this); nodeStack.push(td); nodeStack.push(tr); return true; } if (getParentNode() instanceof Tr) { Td td = new Td(); td.appendChild(this); nodeStack.push(td); return true; } if (getParentNode() instanceof Map) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Colgroup.java0000644000000000000000000000170712124530526021127 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; public class Colgroup extends ReplaceElement { private static final String tag = "colgroup"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Table.getTag(), HtmlElement.getAttributeMap()); } public Colgroup() { setNodeName(tag); setFormatType(FORMAT_BLOCK); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/HtmlFragment.java0000644000000000000000000000074212124530526021723 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class HtmlFragment extends DocumentFragmentImpl { public HtmlFragment() { super(); setNodeType(DOCUMENT_FRAGMENT_NODE); setParentNode(null); } } src/java/org/dbdoclet/trafo/tag/html/Button.java0000644000000000000000000000277012124530526020611 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Button extends InlineElement { private static final String tag = "button"; private static HashMap> validParentMap; private static HashMap attributeMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove("button"); attributeMap = new HashMap(); } public Button() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } public static HashMap getAttributeMap() { return attributeMap; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof Body || getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/H1.java0000644000000000000000000000432012124530526017577 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class H1 extends HeaderElement { protected static final int level = 1; private static final String tag = "h1"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public H1() { setNodeName(tag); } public static String getTag() { return tag; } @Override public void init() { } @Override public int getLevel() { return level; } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return super.validate(); } } src/java/org/dbdoclet/trafo/tag/html/Sub.java0000644000000000000000000000236612124530526020070 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Sub extends InlineElement { private static String tag = "sub"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.putAll(blockElementMap); validParentMap.putAll(inlineElementMap); validParentMap.remove(Pre.getTag()); } public Sub() { setNodeName(tag); setFormatType(FORMAT_INLINE); } public static String getTag() { return tag; } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Ol.java0000644000000000000000000000447312124530526017712 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.DocumentFragmentImpl; public class Ol extends Inline2Element { private static String tag = "ol"; private static HashMap> validParentMap; static { validParentMap = new HashMap>(); validParentMap.put(Applet.getTag(), Applet.getAttributeMap()); validParentMap.put(Blockquote.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Body.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Button.getTag(), Button.getAttributeMap()); validParentMap.put(Center.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Dd.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Del.getTag(), Del.getAttributeMap()); validParentMap.put(Div.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Fieldset.getTag(), Fieldset.getAttributeMap()); validParentMap.put(Form.getTag(), Form.getAttributeMap()); validParentMap.put(Iframe.getTag(), Iframe.getAttributeMap()); validParentMap.put(Ins.getTag(), Ins.getAttributeMap()); validParentMap.put(Li.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Map.getTag(), Map.getAttributeMap()); validParentMap.put(Noframes.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Noscript.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(HtmlObject.getTag(), HtmlObject.getAttributeMap()); validParentMap.put(Td.getTag(), HtmlElement.getAttributeMap()); validParentMap.put(Th.getTag(), HtmlElement.getAttributeMap()); } public static String getTag() { return tag; } public Ol() { setNodeName(tag); setFormatType(FORMAT_BLOCK); } @Override public void closed() { if ((getChildNodes() == null) || (getChildNodes().getLength() == 0)) { appendChild(new Li()); } // end of if () } @Override public void init() { } @Override public boolean validate() { if (validate(validParentMap)) { return true; } if (getParentNode() instanceof DocumentFragmentImpl) { return true; } return false; } } src/java/org/dbdoclet/trafo/tag/html/Inline2Element.java0000644000000000000000000000553512124530526022152 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.tag.html; import java.util.HashMap; import org.dbdoclet.xiphias.dom.TextImpl; import org.w3c.dom.Node; public abstract class Inline2Element extends HtmlElement { @Override protected boolean validate(HashMap> validParentMap) { if (validParentMap == null) { throw new IllegalArgumentException("Parameter validParentMap is null!"); } if (getParentNode() == null) { throw new NullPointerException("Variable getParent() is null!"); } if (nodeStack == null) { throw new NullPointerException("Variable nodeStack is null!"); } nodeStack.removeAllElements(); nodeStack.push(this); if (validParentMap.get(getParentNode().getNodeName()) != null) { return true; } if (getParentNode() instanceof Fieldset) { Node child = getParentNode().getFirstChild(); if ((child == null) || !(child instanceof Legend)) { Legend legend = new Legend(); getParentNode().appendChild(legend); legend.appendChild(new TextImpl("Legend", legend)); } return true; } if (getParentNode() instanceof Select) { nodeStack.removeAllElements(); Option option = new Option(); nodeStack.push(option); return true; } if (getParentNode() instanceof Optgroup) { nodeStack.removeAllElements(); Option option = new Option(); nodeStack.push(option); return true; } if (getParentNode() instanceof Dl) { Dd dd = new Dd(); dd.appendChild(this); nodeStack.push(dd); return true; } if (getParentNode() instanceof Dir || getParentNode() instanceof Menu) { nodeStack.removeAllElements(); Li li = new Li(); nodeStack.push(li); return true; } if (getParentNode() instanceof Ol || getParentNode() instanceof Ul) { Li li = new Li(); nodeStack.push(li); setParentNode(li); return true; } if (getParentNode() instanceof Table) { Tr tr = new Tr(); Td td = new Td(); tr.appendChild(td); td.appendChild(this); nodeStack.push(td); nodeStack.push(tr); return true; } if (getParentNode() instanceof Tbody || getParentNode() instanceof Tfoot || getParentNode() instanceof Thead) { Tr tr = new Tr(); Td td = new Td(); tr.appendChild(td); td.appendChild(this); nodeStack.push(td); nodeStack.push(tr); return true; } if (getParentNode() instanceof Tr) { Td td = new Td(); td.appendChild(this); nodeStack.push(td); return true; } if (getParentNode() instanceof Map) { Div div = new Div(); div.appendChild(this); nodeStack.push(div); return true; } return false; } } src/java/org/dbdoclet/trafo/tag/NodeStack.java0000644000000000000000000000335412124530526020244 0ustar rootroot/* * ### Copyright (C) 2001-2003 Michael Fuchs ### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Michael Fuchs * E-Mail: mfuchs@unico-consulting.com * * RCS Information: * --------------- * Id.........: $Id: NodeStack.java,v 1.1.1.1 2004/12/21 14:00:23 mfuchs Exp $ * Author.....: $Author: mfuchs $ * Date.......: $Date: 2004/12/21 14:00:23 $ * Revision...: $Revision: 1.1.1.1 $ * State......: $State: Exp $ */ package org.dbdoclet.trafo.tag; import java.util.Stack; public class NodeStack extends Stack { private static final long serialVersionUID = 1L; public int searchNearest(String[] nodes) { if (nodes == null) { throw new IllegalArgumentException("Variable nodes is null!"); } int min = -1; int index; for (int i = 0; i < nodes.length; i++) { index = search(nodes[i]); if (index != -1) { if ((min == -1) || (index < min)) { min = index; } } // end of if () } // end of for () return min; } } src/java/org/dbdoclet/trafo/TrafoException.java0000644000000000000000000000115012124530526020540 0ustar rootroot/* * ### Copyright (C) 2005, 2009 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo; public class TrafoException extends Exception { private static final long serialVersionUID = 1L; public TrafoException() { super(); } public TrafoException(String message) { super(message); } public TrafoException(String message, Throwable cause) { super(message, cause); } public TrafoException(Throwable cause) { super(cause); } } src/java/org/dbdoclet/trafo/TrafoExceptionHandler.java0000644000000000000000000000035712124530526022046 0ustar rootrootpackage org.dbdoclet.trafo; public class TrafoExceptionHandler { public static Throwable getCause(Throwable oops) { Throwable cause = oops; while (cause.getCause() != null) { cause = cause.getCause(); } return cause; } } src/java/org/dbdoclet/trafo/SectionNumberRemover.java0000644000000000000000000000345712124530526021737 0ustar rootrootpackage org.dbdoclet.trafo; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.dbdoclet.service.StringServices; import org.dbdoclet.xiphias.dom.INodeVisitor; import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.Text; public class SectionNumberRemover implements INodeVisitor { private String regex = null; public String getRegex() { return regex; } public void setRegex(String regex) { this.regex = regex; } @Override public void accept(Node node) { if (regex == null) { return; } if (node instanceof Text) { Text textNode = (Text) node; String text = textNode.getData(); text = stripSectionNumber(text, regex); if (text != null) { textNode.setData(text); } } if (node instanceof Element) { Element elem = (Element) node; NamedNodeMap namedNodeMap = elem.getAttributes(); for (int i = 0; i < namedNodeMap.getLength(); i++) { Node attrNode = namedNodeMap.item(i); if (attrNode instanceof Attr) { Attr attr = (Attr) attrNode; String value = stripSectionNumber(attr.getValue(), regex); attr.setValue(value); } } } } public static String stripSectionNumber(String title, String regex) { if (title == null) { return null; } if (regex == null) { return title; } title = title.trim(); regex = "(" + regex + ").*"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(title); if (matcher.matches()) { String sectionNumber = matcher.group(1); title = StringServices.cutPrefix(title, sectionNumber); } return title; } @Override public void openTag(Node node) throws Exception { // } @Override public void closeTag(Node node) throws Exception { // } } src/java/org/dbdoclet/trafo/script/0000755000000000000000000000000012124530526016252 5ustar rootrootsrc/java/org/dbdoclet/trafo/script/parser/0000755000000000000000000000000012124530526017546 5ustar rootrootsrc/java/org/dbdoclet/trafo/script/parser/TrafoScriptLexer.java0000644000000000000000000012357412124530526023665 0ustar rootroot// $ANTLR 3.4 /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g 2012-12-12 17:48:44 package org.dbdoclet.trafo.script.parser; import org.antlr.runtime.*; import java.util.Stack; import java.util.List; import java.util.ArrayList; @SuppressWarnings({"all", "warnings", "unchecked"}) public class TrafoScriptLexer extends Lexer { public static final int EOF=-1; public static final int T__18=18; public static final int T__19=19; public static final int T__20=20; public static final int BC=4; public static final int BO=5; public static final int BOOL=6; public static final int COMMENT=7; public static final int EOS=8; public static final int EQ=9; public static final int ID=10; public static final int LINE_COMMENT=11; public static final int MULTILINE=12; public static final int NUMBER=13; public static final int SECTION=14; public static final int TEXT=15; public static final int TRAN=16; public static final int WS=17; // delegates // delegators public Lexer[] getDelegates() { return new Lexer[] {}; } public TrafoScriptLexer() {} public TrafoScriptLexer(CharStream input) { this(input, new RecognizerSharedState()); } public TrafoScriptLexer(CharStream input, RecognizerSharedState state) { super(input,state); } public String getGrammarFileName() { return "/home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g"; } // $ANTLR start "T__18" public final void mT__18() throws RecognitionException { try { int _type = T__18; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:6:7: ( ',' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:6:9: ',' { match(','); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "T__18" // $ANTLR start "T__19" public final void mT__19() throws RecognitionException { try { int _type = T__19; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:7:7: ( '[' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:7:9: '[' { match('['); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "T__19" // $ANTLR start "T__20" public final void mT__20() throws RecognitionException { try { int _type = T__20; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:8:7: ( ']' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:8:9: ']' { match(']'); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "T__20" // $ANTLR start "BO" public final void mBO() throws RecognitionException { try { int _type = BO; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:51:4: ( '{' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:51:6: '{' { match('{'); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "BO" // $ANTLR start "BC" public final void mBC() throws RecognitionException { try { int _type = BC; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:52:4: ( '}' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:52:6: '}' { match('}'); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "BC" // $ANTLR start "BOOL" public final void mBOOL() throws RecognitionException { try { int _type = BOOL; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:53:6: ( 'true' | 'false' ) int alt1=2; int LA1_0 = input.LA(1); if ( (LA1_0=='t') ) { alt1=1; } else if ( (LA1_0=='f') ) { alt1=2; } else { NoViableAltException nvae = new NoViableAltException("", 1, 0, input); throw nvae; } switch (alt1) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:53:8: 'true' { match("true"); } break; case 2 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:53:15: 'false' { match("false"); } break; } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "BOOL" // $ANTLR start "EQ" public final void mEQ() throws RecognitionException { try { int _type = EQ; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:54:4: ( '=' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:54:6: '=' { match('='); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "EQ" // $ANTLR start "EOS" public final void mEOS() throws RecognitionException { try { int _type = EOS; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:55:5: ( ';' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:55:7: ';' { match(';'); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "EOS" // $ANTLR start "NUMBER" public final void mNUMBER() throws RecognitionException { try { int _type = NUMBER; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:56:8: ( ( '0' .. '9' )+ ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:56:10: ( '0' .. '9' )+ { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:56:10: ( '0' .. '9' )+ int cnt2=0; loop2: do { int alt2=2; int LA2_0 = input.LA(1); if ( ((LA2_0 >= '0' && LA2_0 <= '9')) ) { alt2=1; } switch (alt2) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g: { if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) { input.consume(); } else { MismatchedSetException mse = new MismatchedSetException(null,input); recover(mse); throw mse; } } break; default : if ( cnt2 >= 1 ) break loop2; EarlyExitException eee = new EarlyExitException(2, input); throw eee; } cnt2++; } while (true); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "NUMBER" // $ANTLR start "SECTION" public final void mSECTION() throws RecognitionException { try { int _type = SECTION; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:57:9: ( 'section' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:57:11: 'section' { match("section"); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "SECTION" // $ANTLR start "TRAN" public final void mTRAN() throws RecognitionException { try { int _type = TRAN; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:58:7: ( 'transformation' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:58:9: 'transformation' { match("transformation"); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "TRAN" // $ANTLR start "ID" public final void mID() throws RecognitionException { try { int _type = ID; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:59:4: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '-' | '_' )+ ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:59:6: ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '-' | '_' )+ { if ( (input.LA(1) >= 'A' && input.LA(1) <= 'Z')||input.LA(1)=='_'||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) { input.consume(); } else { MismatchedSetException mse = new MismatchedSetException(null,input); recover(mse); throw mse; } // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:59:29: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '-' | '_' )+ int cnt3=0; loop3: do { int alt3=2; int LA3_0 = input.LA(1); if ( (LA3_0=='-'||(LA3_0 >= '0' && LA3_0 <= '9')||(LA3_0 >= 'A' && LA3_0 <= 'Z')||LA3_0=='_'||(LA3_0 >= 'a' && LA3_0 <= 'z')) ) { alt3=1; } switch (alt3) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g: { if ( input.LA(1)=='-'||(input.LA(1) >= '0' && input.LA(1) <= '9')||(input.LA(1) >= 'A' && input.LA(1) <= 'Z')||input.LA(1)=='_'||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) { input.consume(); } else { MismatchedSetException mse = new MismatchedSetException(null,input); recover(mse); throw mse; } } break; default : if ( cnt3 >= 1 ) break loop3; EarlyExitException eee = new EarlyExitException(3, input); throw eee; } cnt3++; } while (true); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "ID" // $ANTLR start "TEXT" public final void mTEXT() throws RecognitionException { try { int _type = TEXT; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:60:6: ( '\"' (~ ( '\"' | '\\r' | '\\n' ) )* '\"' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:60:8: '\"' (~ ( '\"' | '\\r' | '\\n' ) )* '\"' { match('\"'); // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:60:12: (~ ( '\"' | '\\r' | '\\n' ) )* loop4: do { int alt4=2; int LA4_0 = input.LA(1); if ( ((LA4_0 >= '\u0000' && LA4_0 <= '\t')||(LA4_0 >= '\u000B' && LA4_0 <= '\f')||(LA4_0 >= '\u000E' && LA4_0 <= '!')||(LA4_0 >= '#' && LA4_0 <= '\uFFFF')) ) { alt4=1; } switch (alt4) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g: { if ( (input.LA(1) >= '\u0000' && input.LA(1) <= '\t')||(input.LA(1) >= '\u000B' && input.LA(1) <= '\f')||(input.LA(1) >= '\u000E' && input.LA(1) <= '!')||(input.LA(1) >= '#' && input.LA(1) <= '\uFFFF') ) { input.consume(); } else { MismatchedSetException mse = new MismatchedSetException(null,input); recover(mse); throw mse; } } break; default : break loop4; } } while (true); match('\"'); setText(getText().substring(1, getText().length()-1)); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "TEXT" // $ANTLR start "MULTILINE" public final void mMULTILINE() throws RecognitionException { try { int _type = MULTILINE; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:62:2: ( '\"\"\"' ( options {greedy=false; } : ( . )* ) '\"\"\"' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:62:4: '\"\"\"' ( options {greedy=false; } : ( . )* ) '\"\"\"' { match("\"\"\""); // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:62:10: ( options {greedy=false; } : ( . )* ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:62:35: ( . )* { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:62:35: ( . )* loop5: do { int alt5=2; int LA5_0 = input.LA(1); if ( (LA5_0=='\"') ) { int LA5_1 = input.LA(2); if ( (LA5_1=='\"') ) { int LA5_3 = input.LA(3); if ( (LA5_3=='\"') ) { alt5=2; } else if ( ((LA5_3 >= '\u0000' && LA5_3 <= '!')||(LA5_3 >= '#' && LA5_3 <= '\uFFFF')) ) { alt5=1; } } else if ( ((LA5_1 >= '\u0000' && LA5_1 <= '!')||(LA5_1 >= '#' && LA5_1 <= '\uFFFF')) ) { alt5=1; } } else if ( ((LA5_0 >= '\u0000' && LA5_0 <= '!')||(LA5_0 >= '#' && LA5_0 <= '\uFFFF')) ) { alt5=1; } switch (alt5) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:62:35: . { matchAny(); } break; default : break loop5; } } while (true); } match("\"\"\""); setText(getText().substring(3, getText().length()-3)); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "MULTILINE" // $ANTLR start "WS" public final void mWS() throws RecognitionException { try { int _type = WS; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:63:4: ( ( ' ' | '\\t' | '\\r' | '\\n' )+ ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:63:6: ( ' ' | '\\t' | '\\r' | '\\n' )+ { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:63:6: ( ' ' | '\\t' | '\\r' | '\\n' )+ int cnt6=0; loop6: do { int alt6=2; int LA6_0 = input.LA(1); if ( ((LA6_0 >= '\t' && LA6_0 <= '\n')||LA6_0=='\r'||LA6_0==' ') ) { alt6=1; } switch (alt6) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g: { if ( (input.LA(1) >= '\t' && input.LA(1) <= '\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) { input.consume(); } else { MismatchedSetException mse = new MismatchedSetException(null,input); recover(mse); throw mse; } } break; default : if ( cnt6 >= 1 ) break loop6; EarlyExitException eee = new EarlyExitException(6, input); throw eee; } cnt6++; } while (true); skip(); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "WS" // $ANTLR start "COMMENT" public final void mCOMMENT() throws RecognitionException { try { int _type = COMMENT; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:69:17: ( '/*' ( options {greedy=false; } : ( . )* ) '*/' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:69:19: '/*' ( options {greedy=false; } : ( . )* ) '*/' { match("/*"); // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:69:24: ( options {greedy=false; } : ( . )* ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:69:54: ( . )* { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:69:54: ( . )* loop7: do { int alt7=2; int LA7_0 = input.LA(1); if ( (LA7_0=='*') ) { int LA7_1 = input.LA(2); if ( (LA7_1=='/') ) { alt7=2; } else if ( ((LA7_1 >= '\u0000' && LA7_1 <= '.')||(LA7_1 >= '0' && LA7_1 <= '\uFFFF')) ) { alt7=1; } } else if ( ((LA7_0 >= '\u0000' && LA7_0 <= ')')||(LA7_0 >= '+' && LA7_0 <= '\uFFFF')) ) { alt7=1; } switch (alt7) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:69:54: . { matchAny(); } break; default : break loop7; } } while (true); } match("*/"); _channel = 2; } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "COMMENT" // $ANTLR start "LINE_COMMENT" public final void mLINE_COMMENT() throws RecognitionException { try { int _type = LINE_COMMENT; int _channel = DEFAULT_TOKEN_CHANNEL; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:70:17: ( '//' ( . )* '\\n' ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:70:19: '//' ( . )* '\\n' { match("//"); // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:70:24: ( . )* loop8: do { int alt8=2; int LA8_0 = input.LA(1); if ( (LA8_0=='\n') ) { alt8=2; } else if ( ((LA8_0 >= '\u0000' && LA8_0 <= '\t')||(LA8_0 >= '\u000B' && LA8_0 <= '\uFFFF')) ) { alt8=1; } switch (alt8) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:70:24: . { matchAny(); } break; default : break loop8; } } while (true); match('\n'); _channel = 2; } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "LINE_COMMENT" public void mTokens() throws RecognitionException { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:8: ( T__18 | T__19 | T__20 | BO | BC | BOOL | EQ | EOS | NUMBER | SECTION | TRAN | ID | TEXT | MULTILINE | WS | COMMENT | LINE_COMMENT ) int alt9=17; switch ( input.LA(1) ) { case ',': { alt9=1; } break; case '[': { alt9=2; } break; case ']': { alt9=3; } break; case '{': { alt9=4; } break; case '}': { alt9=5; } break; case 't': { int LA9_6 = input.LA(2); if ( (LA9_6=='r') ) { switch ( input.LA(3) ) { case 'u': { int LA9_23 = input.LA(4); if ( (LA9_23=='e') ) { int LA9_28 = input.LA(5); if ( (LA9_28=='-'||(LA9_28 >= '0' && LA9_28 <= '9')||(LA9_28 >= 'A' && LA9_28 <= 'Z')||LA9_28=='_'||(LA9_28 >= 'a' && LA9_28 <= 'z')) ) { alt9=12; } else { alt9=6; } } else { alt9=12; } } break; case 'a': { int LA9_24 = input.LA(4); if ( (LA9_24=='n') ) { int LA9_29 = input.LA(5); if ( (LA9_29=='s') ) { int LA9_33 = input.LA(6); if ( (LA9_33=='f') ) { int LA9_36 = input.LA(7); if ( (LA9_36=='o') ) { int LA9_38 = input.LA(8); if ( (LA9_38=='r') ) { int LA9_40 = input.LA(9); if ( (LA9_40=='m') ) { int LA9_42 = input.LA(10); if ( (LA9_42=='a') ) { int LA9_43 = input.LA(11); if ( (LA9_43=='t') ) { int LA9_44 = input.LA(12); if ( (LA9_44=='i') ) { int LA9_45 = input.LA(13); if ( (LA9_45=='o') ) { int LA9_46 = input.LA(14); if ( (LA9_46=='n') ) { int LA9_47 = input.LA(15); if ( (LA9_47=='-'||(LA9_47 >= '0' && LA9_47 <= '9')||(LA9_47 >= 'A' && LA9_47 <= 'Z')||LA9_47=='_'||(LA9_47 >= 'a' && LA9_47 <= 'z')) ) { alt9=12; } else { alt9=11; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } break; default: alt9=12; } } else if ( (LA9_6=='-'||(LA9_6 >= '0' && LA9_6 <= '9')||(LA9_6 >= 'A' && LA9_6 <= 'Z')||LA9_6=='_'||(LA9_6 >= 'a' && LA9_6 <= 'q')||(LA9_6 >= 's' && LA9_6 <= 'z')) ) { alt9=12; } else { NoViableAltException nvae = new NoViableAltException("", 9, 6, input); throw nvae; } } break; case 'f': { int LA9_7 = input.LA(2); if ( (LA9_7=='a') ) { int LA9_17 = input.LA(3); if ( (LA9_17=='l') ) { int LA9_25 = input.LA(4); if ( (LA9_25=='s') ) { int LA9_30 = input.LA(5); if ( (LA9_30=='e') ) { int LA9_34 = input.LA(6); if ( (LA9_34=='-'||(LA9_34 >= '0' && LA9_34 <= '9')||(LA9_34 >= 'A' && LA9_34 <= 'Z')||LA9_34=='_'||(LA9_34 >= 'a' && LA9_34 <= 'z')) ) { alt9=12; } else { alt9=6; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } else if ( (LA9_7=='-'||(LA9_7 >= '0' && LA9_7 <= '9')||(LA9_7 >= 'A' && LA9_7 <= 'Z')||LA9_7=='_'||(LA9_7 >= 'b' && LA9_7 <= 'z')) ) { alt9=12; } else { NoViableAltException nvae = new NoViableAltException("", 9, 7, input); throw nvae; } } break; case '=': { alt9=7; } break; case ';': { alt9=8; } break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { alt9=9; } break; case 's': { int LA9_11 = input.LA(2); if ( (LA9_11=='e') ) { int LA9_18 = input.LA(3); if ( (LA9_18=='c') ) { int LA9_26 = input.LA(4); if ( (LA9_26=='t') ) { int LA9_31 = input.LA(5); if ( (LA9_31=='i') ) { int LA9_35 = input.LA(6); if ( (LA9_35=='o') ) { int LA9_37 = input.LA(7); if ( (LA9_37=='n') ) { int LA9_39 = input.LA(8); if ( (LA9_39=='-'||(LA9_39 >= '0' && LA9_39 <= '9')||(LA9_39 >= 'A' && LA9_39 <= 'Z')||LA9_39=='_'||(LA9_39 >= 'a' && LA9_39 <= 'z')) ) { alt9=12; } else { alt9=10; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } else { alt9=12; } } else if ( (LA9_11=='-'||(LA9_11 >= '0' && LA9_11 <= '9')||(LA9_11 >= 'A' && LA9_11 <= 'Z')||LA9_11=='_'||(LA9_11 >= 'a' && LA9_11 <= 'd')||(LA9_11 >= 'f' && LA9_11 <= 'z')) ) { alt9=12; } else { NoViableAltException nvae = new NoViableAltException("", 9, 11, input); throw nvae; } } break; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt9=12; } break; case '\"': { int LA9_13 = input.LA(2); if ( (LA9_13=='\"') ) { int LA9_19 = input.LA(3); if ( (LA9_19=='\"') ) { alt9=14; } else { alt9=13; } } else if ( ((LA9_13 >= '\u0000' && LA9_13 <= '\t')||(LA9_13 >= '\u000B' && LA9_13 <= '\f')||(LA9_13 >= '\u000E' && LA9_13 <= '!')||(LA9_13 >= '#' && LA9_13 <= '\uFFFF')) ) { alt9=13; } else { NoViableAltException nvae = new NoViableAltException("", 9, 13, input); throw nvae; } } break; case '\t': case '\n': case '\r': case ' ': { alt9=15; } break; case '/': { int LA9_15 = input.LA(2); if ( (LA9_15=='*') ) { alt9=16; } else if ( (LA9_15=='/') ) { alt9=17; } else { NoViableAltException nvae = new NoViableAltException("", 9, 15, input); throw nvae; } } break; default: NoViableAltException nvae = new NoViableAltException("", 9, 0, input); throw nvae; } switch (alt9) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:10: T__18 { mT__18(); } break; case 2 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:16: T__19 { mT__19(); } break; case 3 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:22: T__20 { mT__20(); } break; case 4 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:28: BO { mBO(); } break; case 5 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:31: BC { mBC(); } break; case 6 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:34: BOOL { mBOOL(); } break; case 7 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:39: EQ { mEQ(); } break; case 8 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:42: EOS { mEOS(); } break; case 9 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:46: NUMBER { mNUMBER(); } break; case 10 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:53: SECTION { mSECTION(); } break; case 11 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:61: TRAN { mTRAN(); } break; case 12 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:66: ID { mID(); } break; case 13 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:69: TEXT { mTEXT(); } break; case 14 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:74: MULTILINE { mMULTILINE(); } break; case 15 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:84: WS { mWS(); } break; case 16 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:87: COMMENT { mCOMMENT(); } break; case 17 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:1:95: LINE_COMMENT { mLINE_COMMENT(); } break; } } }src/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.java0000644000000000000000000004214112124530526024021 0ustar rootroot// $ANTLR 3.4 /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g 2012-10-19 13:08:51 package org.dbdoclet.trafo.script.parser; import org.dbdoclet.trafo.script.Script; import org.antlr.runtime.*; import org.antlr.runtime.tree.*; import java.util.Stack; import java.util.List; import java.util.ArrayList; @SuppressWarnings({"all", "warnings", "unchecked"}) public class TrafoScriptWalker extends TreeParser { public static final String[] tokenNames = new String[] { "", "", "", "", "BC", "BO", "BOOL", "COMMENT", "EOS", "EQ", "ID", "LINE_COMMENT", "MULTILINE", "NUMBER", "SECTION", "TEXT", "TRAN", "WS", "','", "'['", "']'" }; public static final int EOF=-1; public static final int T__18=18; public static final int T__19=19; public static final int T__20=20; public static final int BC=4; public static final int BO=5; public static final int BOOL=6; public static final int COMMENT=7; public static final int EOS=8; public static final int EQ=9; public static final int ID=10; public static final int LINE_COMMENT=11; public static final int MULTILINE=12; public static final int NUMBER=13; public static final int SECTION=14; public static final int TEXT=15; public static final int TRAN=16; public static final int WS=17; // delegates public TreeParser[] getDelegates() { return new TreeParser[] {}; } // delegators public TrafoScriptWalker(TreeNodeStream input) { this(input, new RecognizerSharedState()); } public TrafoScriptWalker(TreeNodeStream input, RecognizerSharedState state) { super(input, state); } public String[] getTokenNames() { return TrafoScriptWalker.tokenNames; } public String getGrammarFileName() { return "/home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g"; } Script script; String namespace; // $ANTLR start "parse" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:19:1: parse[Script script, String namespace] : transformation ( section )* ; public final void parse(Script script, String namespace) throws RecognitionException { this.script = script; this.namespace = namespace; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:24:3: ( transformation ( section )* ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:24:3: transformation ( section )* { pushFollow(FOLLOW_transformation_in_parse53); transformation(); state._fsp--; // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:24:18: ( section )* loop1: do { int alt1=2; int LA1_0 = input.LA(1); if ( (LA1_0==ID) ) { alt1=1; } switch (alt1) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:24:18: section { pushFollow(FOLLOW_section_in_parse55); section(); state._fsp--; } break; default : break loop1; } } while (true); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return ; } // $ANTLR end "parse" // $ANTLR start "transformation" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:26:1: transformation : ^( TRAN ID ) ; public final void transformation() throws RecognitionException { CommonTree ID1=null; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:26:16: ( ^( TRAN ID ) ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:26:18: ^( TRAN ID ) { match(input,TRAN,FOLLOW_TRAN_in_transformation65); match(input, Token.DOWN, null); ID1=(CommonTree)match(input,ID,FOLLOW_ID_in_transformation67); script.setSystemParameter(namespace, Script.SYSPARAM_TRANSFORMATION_NAME, (ID1!=null?ID1.getText():null)); match(input, Token.UP, null); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return ; } // $ANTLR end "transformation" // $ANTLR start "section" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:27:1: section : ^( ID ( expr )* ) ; public final void section() throws RecognitionException { CommonTree ID2=null; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:27:9: ( ^( ID ( expr )* ) ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:27:11: ^( ID ( expr )* ) { ID2=(CommonTree)match(input,ID,FOLLOW_ID_in_section78); script.selectSection(namespace, (ID2!=null?ID2.getText():null)); if ( input.LA(1)==Token.DOWN ) { match(input, Token.DOWN, null); // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:27:63: ( expr )* loop2: do { int alt2=2; int LA2_0 = input.LA(1); if ( (LA2_0==ID) ) { alt2=1; } switch (alt2) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:27:63: expr { pushFollow(FOLLOW_expr_in_section82); expr(); state._fsp--; } break; default : break loop2; } } while (true); match(input, Token.UP, null); } } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return ; } // $ANTLR end "section" // $ANTLR start "expr" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:28:1: expr : ^( ID ( bparam[$ID.text] | nparam[$ID.text] | tparam[$ID.text] | mtparam[$ID.text] )+ ) ; public final void expr() throws RecognitionException { CommonTree ID3=null; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:28:6: ( ^( ID ( bparam[$ID.text] | nparam[$ID.text] | tparam[$ID.text] | mtparam[$ID.text] )+ ) ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:28:8: ^( ID ( bparam[$ID.text] | nparam[$ID.text] | tparam[$ID.text] | mtparam[$ID.text] )+ ) { ID3=(CommonTree)match(input,ID,FOLLOW_ID_in_expr92); match(input, Token.DOWN, null); // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:28:13: ( bparam[$ID.text] | nparam[$ID.text] | tparam[$ID.text] | mtparam[$ID.text] )+ int cnt3=0; loop3: do { int alt3=5; switch ( input.LA(1) ) { case BOOL: { alt3=1; } break; case NUMBER: { alt3=2; } break; case TEXT: { alt3=3; } break; case MULTILINE: { alt3=4; } break; } switch (alt3) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:28:14: bparam[$ID.text] { pushFollow(FOLLOW_bparam_in_expr95); bparam((ID3!=null?ID3.getText():null)); state._fsp--; } break; case 2 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:28:33: nparam[$ID.text] { pushFollow(FOLLOW_nparam_in_expr100); nparam((ID3!=null?ID3.getText():null)); state._fsp--; } break; case 3 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:28:52: tparam[$ID.text] { pushFollow(FOLLOW_tparam_in_expr105); tparam((ID3!=null?ID3.getText():null)); state._fsp--; } break; case 4 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:28:71: mtparam[$ID.text] { pushFollow(FOLLOW_mtparam_in_expr110); mtparam((ID3!=null?ID3.getText():null)); state._fsp--; } break; default : if ( cnt3 >= 1 ) break loop3; EarlyExitException eee = new EarlyExitException(3, input); throw eee; } cnt3++; } while (true); match(input, Token.UP, null); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return ; } // $ANTLR end "expr" // $ANTLR start "bparam" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:29:1: bparam[String ID] : BOOL ; public final void bparam(String ID) throws RecognitionException { CommonTree BOOL4=null; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:29:18: ( BOOL ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:29:20: BOOL { BOOL4=(CommonTree)match(input,BOOL,FOLLOW_BOOL_in_bparam121); script.addBoolParam(ID, (BOOL4!=null?BOOL4.getText():null)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return ; } // $ANTLR end "bparam" // $ANTLR start "nparam" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:30:1: nparam[String ID] : NUMBER ; public final void nparam(String ID) throws RecognitionException { CommonTree NUMBER5=null; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:30:18: ( NUMBER ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:30:20: NUMBER { NUMBER5=(CommonTree)match(input,NUMBER,FOLLOW_NUMBER_in_nparam130); script.addNumberParam(ID, (NUMBER5!=null?NUMBER5.getText():null)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return ; } // $ANTLR end "nparam" // $ANTLR start "tparam" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:31:1: tparam[String ID] : TEXT ; public final void tparam(String ID) throws RecognitionException { CommonTree TEXT6=null; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:31:18: ( TEXT ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:31:20: TEXT { TEXT6=(CommonTree)match(input,TEXT,FOLLOW_TEXT_in_tparam139); script.addTextParam(ID, (TEXT6!=null?TEXT6.getText():null)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return ; } // $ANTLR end "tparam" // $ANTLR start "mtparam" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:32:1: mtparam[String ID] : MULTILINE ; public final void mtparam(String ID) throws RecognitionException { CommonTree MULTILINE7=null; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:32:19: ( MULTILINE ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScriptWalker.g:32:25: MULTILINE { MULTILINE7=(CommonTree)match(input,MULTILINE,FOLLOW_MULTILINE_in_mtparam152); script.addTextParam(ID, (MULTILINE7!=null?MULTILINE7.getText():null)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return ; } // $ANTLR end "mtparam" // Delegated rules public static final BitSet FOLLOW_transformation_in_parse53 = new BitSet(new long[]{0x0000000000000402L}); public static final BitSet FOLLOW_section_in_parse55 = new BitSet(new long[]{0x0000000000000402L}); public static final BitSet FOLLOW_TRAN_in_transformation65 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_ID_in_transformation67 = new BitSet(new long[]{0x0000000000000008L}); public static final BitSet FOLLOW_ID_in_section78 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_expr_in_section82 = new BitSet(new long[]{0x0000000000000408L}); public static final BitSet FOLLOW_ID_in_expr92 = new BitSet(new long[]{0x0000000000000004L}); public static final BitSet FOLLOW_bparam_in_expr95 = new BitSet(new long[]{0x000000000000B048L}); public static final BitSet FOLLOW_nparam_in_expr100 = new BitSet(new long[]{0x000000000000B048L}); public static final BitSet FOLLOW_tparam_in_expr105 = new BitSet(new long[]{0x000000000000B048L}); public static final BitSet FOLLOW_mtparam_in_expr110 = new BitSet(new long[]{0x000000000000B048L}); public static final BitSet FOLLOW_BOOL_in_bparam121 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_NUMBER_in_nparam130 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_TEXT_in_tparam139 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_MULTILINE_in_mtparam152 = new BitSet(new long[]{0x0000000000000002L}); }src/java/org/dbdoclet/trafo/script/parser/TrafoScriptParser.java0000644000000000000000000005734612124530526024045 0ustar rootroot// $ANTLR 3.4 /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g 2012-12-12 17:48:44 package org.dbdoclet.trafo.script.parser; import java.util.LinkedList; import org.antlr.runtime.*; import java.util.Stack; import java.util.List; import java.util.ArrayList; import org.antlr.runtime.tree.*; @SuppressWarnings({"all", "warnings", "unchecked"}) public class TrafoScriptParser extends Parser { public static final String[] tokenNames = new String[] { "", "", "", "", "BC", "BO", "BOOL", "COMMENT", "EOS", "EQ", "ID", "LINE_COMMENT", "MULTILINE", "NUMBER", "SECTION", "TEXT", "TRAN", "WS", "','", "'['", "']'" }; public static final int EOF=-1; public static final int T__18=18; public static final int T__19=19; public static final int T__20=20; public static final int BC=4; public static final int BO=5; public static final int BOOL=6; public static final int COMMENT=7; public static final int EOS=8; public static final int EQ=9; public static final int ID=10; public static final int LINE_COMMENT=11; public static final int MULTILINE=12; public static final int NUMBER=13; public static final int SECTION=14; public static final int TEXT=15; public static final int TRAN=16; public static final int WS=17; // delegates public Parser[] getDelegates() { return new Parser[] {}; } // delegators public TrafoScriptParser(TokenStream input) { this(input, new RecognizerSharedState()); } public TrafoScriptParser(TokenStream input, RecognizerSharedState state) { super(input, state); } protected TreeAdaptor adaptor = new CommonTreeAdaptor(); public void setTreeAdaptor(TreeAdaptor adaptor) { this.adaptor = adaptor; } public TreeAdaptor getTreeAdaptor() { return adaptor; } public String[] getTokenNames() { return TrafoScriptParser.tokenNames; } public String getGrammarFileName() { return "/home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g"; } private List errors = new LinkedList(); public void displayRecognitionError(String[] tokenNames, RecognitionException e) { String hdr = getErrorHeader(e); String msg = getErrorMessage(e, tokenNames); errors.add(hdr + " " + msg); } public List getErrors() { return errors; } public static class parse_return extends ParserRuleReturnScope { CommonTree tree; public Object getTree() { return tree; } }; // $ANTLR start "parse" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:35:1: parse : transformation ( section )* EOF ; public final TrafoScriptParser.parse_return parse() throws RecognitionException { TrafoScriptParser.parse_return retval = new TrafoScriptParser.parse_return(); retval.start = input.LT(1); CommonTree root_0 = null; Token EOF3=null; TrafoScriptParser.transformation_return transformation1 =null; TrafoScriptParser.section_return section2 =null; CommonTree EOF3_tree=null; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:35:7: ( transformation ( section )* EOF ) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:35:9: transformation ( section )* EOF { root_0 = (CommonTree)adaptor.nil(); pushFollow(FOLLOW_transformation_in_parse54); transformation1=transformation(); state._fsp--; adaptor.addChild(root_0, transformation1.getTree()); // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:35:24: ( section )* loop1: do { int alt1=2; int LA1_0 = input.LA(1); if ( (LA1_0==SECTION) ) { alt1=1; } switch (alt1) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:35:25: section { pushFollow(FOLLOW_section_in_parse57); section2=section(); state._fsp--; adaptor.addChild(root_0, section2.getTree()); } break; default : break loop1; } } while (true); EOF3=(Token)match(input,EOF,FOLLOW_EOF_in_parse61); EOF3_tree = (CommonTree)adaptor.create(EOF3) ; adaptor.addChild(root_0, EOF3_tree); } retval.stop = input.LT(-1); retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); } catch (RecognitionException re) { reportError(re); recover(input,re); retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); } finally { // do for sure before leaving } return retval; } // $ANTLR end "parse" public static class transformation_return extends ParserRuleReturnScope { CommonTree tree; public Object getTree() { return tree; } }; // $ANTLR start "transformation" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:37:1: transformation : TRAN ^ ID EOS !; public final TrafoScriptParser.transformation_return transformation() throws RecognitionException { TrafoScriptParser.transformation_return retval = new TrafoScriptParser.transformation_return(); retval.start = input.LT(1); CommonTree root_0 = null; Token TRAN4=null; Token ID5=null; Token EOS6=null; CommonTree TRAN4_tree=null; CommonTree ID5_tree=null; CommonTree EOS6_tree=null; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:38:2: ( TRAN ^ ID EOS !) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:38:4: TRAN ^ ID EOS ! { root_0 = (CommonTree)adaptor.nil(); TRAN4=(Token)match(input,TRAN,FOLLOW_TRAN_in_transformation70); TRAN4_tree = (CommonTree)adaptor.create(TRAN4) ; root_0 = (CommonTree)adaptor.becomeRoot(TRAN4_tree, root_0); ID5=(Token)match(input,ID,FOLLOW_ID_in_transformation73); ID5_tree = (CommonTree)adaptor.create(ID5) ; adaptor.addChild(root_0, ID5_tree); EOS6=(Token)match(input,EOS,FOLLOW_EOS_in_transformation75); } retval.stop = input.LT(-1); retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); } catch (RecognitionException re) { reportError(re); recover(input,re); retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); } finally { // do for sure before leaving } return retval; } // $ANTLR end "transformation" public static class section_return extends ParserRuleReturnScope { CommonTree tree; public Object getTree() { return tree; } }; // $ANTLR start "section" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:40:1: section : SECTION ! ID ^ BO ! ( param )* BC !; public final TrafoScriptParser.section_return section() throws RecognitionException { TrafoScriptParser.section_return retval = new TrafoScriptParser.section_return(); retval.start = input.LT(1); CommonTree root_0 = null; Token SECTION7=null; Token ID8=null; Token BO9=null; Token BC11=null; TrafoScriptParser.param_return param10 =null; CommonTree SECTION7_tree=null; CommonTree ID8_tree=null; CommonTree BO9_tree=null; CommonTree BC11_tree=null; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:40:9: ( SECTION ! ID ^ BO ! ( param )* BC !) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:40:11: SECTION ! ID ^ BO ! ( param )* BC ! { root_0 = (CommonTree)adaptor.nil(); SECTION7=(Token)match(input,SECTION,FOLLOW_SECTION_in_section85); ID8=(Token)match(input,ID,FOLLOW_ID_in_section88); ID8_tree = (CommonTree)adaptor.create(ID8) ; root_0 = (CommonTree)adaptor.becomeRoot(ID8_tree, root_0); BO9=(Token)match(input,BO,FOLLOW_BO_in_section91); // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:40:28: ( param )* loop2: do { int alt2=2; int LA2_0 = input.LA(1); if ( (LA2_0==ID) ) { alt2=1; } switch (alt2) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:40:29: param { pushFollow(FOLLOW_param_in_section95); param10=param(); state._fsp--; adaptor.addChild(root_0, param10.getTree()); } break; default : break loop2; } } while (true); BC11=(Token)match(input,BC,FOLLOW_BC_in_section99); } retval.stop = input.LT(-1); retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); } catch (RecognitionException re) { reportError(re); recover(input,re); retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); } finally { // do for sure before leaving } return retval; } // $ANTLR end "section" public static class param_return extends ParserRuleReturnScope { CommonTree tree; public Object getTree() { return tree; } }; // $ANTLR start "param" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:42:1: param : ID ^ EQ ! expr EOS !; public final TrafoScriptParser.param_return param() throws RecognitionException { TrafoScriptParser.param_return retval = new TrafoScriptParser.param_return(); retval.start = input.LT(1); CommonTree root_0 = null; Token ID12=null; Token EQ13=null; Token EOS15=null; TrafoScriptParser.expr_return expr14 =null; CommonTree ID12_tree=null; CommonTree EQ13_tree=null; CommonTree EOS15_tree=null; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:42:7: ( ID ^ EQ ! expr EOS !) // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:42:9: ID ^ EQ ! expr EOS ! { root_0 = (CommonTree)adaptor.nil(); ID12=(Token)match(input,ID,FOLLOW_ID_in_param108); ID12_tree = (CommonTree)adaptor.create(ID12) ; root_0 = (CommonTree)adaptor.becomeRoot(ID12_tree, root_0); EQ13=(Token)match(input,EQ,FOLLOW_EQ_in_param111); pushFollow(FOLLOW_expr_in_param114); expr14=expr(); state._fsp--; adaptor.addChild(root_0, expr14.getTree()); EOS15=(Token)match(input,EOS,FOLLOW_EOS_in_param116); } retval.stop = input.LT(-1); retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); } catch (RecognitionException re) { reportError(re); recover(input,re); retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); } finally { // do for sure before leaving } return retval; } // $ANTLR end "param" public static class expr_return extends ParserRuleReturnScope { CommonTree tree; public Object getTree() { return tree; } }; // $ANTLR start "expr" // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:44:1: expr : ( TEXT | MULTILINE | NUMBER | BOOL | '[' ! ']' !| '[' ! expr ( ',' ! expr )* ']' !); public final TrafoScriptParser.expr_return expr() throws RecognitionException { TrafoScriptParser.expr_return retval = new TrafoScriptParser.expr_return(); retval.start = input.LT(1); CommonTree root_0 = null; Token TEXT16=null; Token MULTILINE17=null; Token NUMBER18=null; Token BOOL19=null; Token char_literal20=null; Token char_literal21=null; Token char_literal22=null; Token char_literal24=null; Token char_literal26=null; TrafoScriptParser.expr_return expr23 =null; TrafoScriptParser.expr_return expr25 =null; CommonTree TEXT16_tree=null; CommonTree MULTILINE17_tree=null; CommonTree NUMBER18_tree=null; CommonTree BOOL19_tree=null; CommonTree char_literal20_tree=null; CommonTree char_literal21_tree=null; CommonTree char_literal22_tree=null; CommonTree char_literal24_tree=null; CommonTree char_literal26_tree=null; try { // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:44:7: ( TEXT | MULTILINE | NUMBER | BOOL | '[' ! ']' !| '[' ! expr ( ',' ! expr )* ']' !) int alt4=6; switch ( input.LA(1) ) { case TEXT: { alt4=1; } break; case MULTILINE: { alt4=2; } break; case NUMBER: { alt4=3; } break; case BOOL: { alt4=4; } break; case 19: { int LA4_5 = input.LA(2); if ( (LA4_5==20) ) { alt4=5; } else if ( (LA4_5==BOOL||(LA4_5 >= MULTILINE && LA4_5 <= NUMBER)||LA4_5==TEXT||LA4_5==19) ) { alt4=6; } else { NoViableAltException nvae = new NoViableAltException("", 4, 5, input); throw nvae; } } break; default: NoViableAltException nvae = new NoViableAltException("", 4, 0, input); throw nvae; } switch (alt4) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:44:9: TEXT { root_0 = (CommonTree)adaptor.nil(); TEXT16=(Token)match(input,TEXT,FOLLOW_TEXT_in_expr126); TEXT16_tree = (CommonTree)adaptor.create(TEXT16) ; adaptor.addChild(root_0, TEXT16_tree); } break; case 2 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:45:4: MULTILINE { root_0 = (CommonTree)adaptor.nil(); MULTILINE17=(Token)match(input,MULTILINE,FOLLOW_MULTILINE_in_expr132); MULTILINE17_tree = (CommonTree)adaptor.create(MULTILINE17) ; adaptor.addChild(root_0, MULTILINE17_tree); } break; case 3 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:46:8: NUMBER { root_0 = (CommonTree)adaptor.nil(); NUMBER18=(Token)match(input,NUMBER,FOLLOW_NUMBER_in_expr141); NUMBER18_tree = (CommonTree)adaptor.create(NUMBER18) ; adaptor.addChild(root_0, NUMBER18_tree); } break; case 4 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:47:8: BOOL { root_0 = (CommonTree)adaptor.nil(); BOOL19=(Token)match(input,BOOL,FOLLOW_BOOL_in_expr150); BOOL19_tree = (CommonTree)adaptor.create(BOOL19) ; adaptor.addChild(root_0, BOOL19_tree); } break; case 5 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:48:8: '[' ! ']' ! { root_0 = (CommonTree)adaptor.nil(); char_literal20=(Token)match(input,19,FOLLOW_19_in_expr159); char_literal21=(Token)match(input,20,FOLLOW_20_in_expr162); } break; case 6 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:49:8: '[' ! expr ( ',' ! expr )* ']' ! { root_0 = (CommonTree)adaptor.nil(); char_literal22=(Token)match(input,19,FOLLOW_19_in_expr172); pushFollow(FOLLOW_expr_in_expr175); expr23=expr(); state._fsp--; adaptor.addChild(root_0, expr23.getTree()); // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:49:18: ( ',' ! expr )* loop3: do { int alt3=2; int LA3_0 = input.LA(1); if ( (LA3_0==18) ) { alt3=1; } switch (alt3) { case 1 : // /home/michael/Java/workspaces/Development/org.dbdoclet.trafo/src/main/java/org/dbdoclet/trafo/script/parser/TrafoScript.g:49:19: ',' ! expr { char_literal24=(Token)match(input,18,FOLLOW_18_in_expr178); pushFollow(FOLLOW_expr_in_expr181); expr25=expr(); state._fsp--; adaptor.addChild(root_0, expr25.getTree()); } break; default : break loop3; } } while (true); char_literal26=(Token)match(input,20,FOLLOW_20_in_expr185); } break; } retval.stop = input.LT(-1); retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0); adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); } catch (RecognitionException re) { reportError(re); recover(input,re); retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); } finally { // do for sure before leaving } return retval; } // $ANTLR end "expr" // Delegated rules public static final BitSet FOLLOW_transformation_in_parse54 = new BitSet(new long[]{0x0000000000004000L}); public static final BitSet FOLLOW_section_in_parse57 = new BitSet(new long[]{0x0000000000004000L}); public static final BitSet FOLLOW_EOF_in_parse61 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_TRAN_in_transformation70 = new BitSet(new long[]{0x0000000000000400L}); public static final BitSet FOLLOW_ID_in_transformation73 = new BitSet(new long[]{0x0000000000000100L}); public static final BitSet FOLLOW_EOS_in_transformation75 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_SECTION_in_section85 = new BitSet(new long[]{0x0000000000000400L}); public static final BitSet FOLLOW_ID_in_section88 = new BitSet(new long[]{0x0000000000000020L}); public static final BitSet FOLLOW_BO_in_section91 = new BitSet(new long[]{0x0000000000000410L}); public static final BitSet FOLLOW_param_in_section95 = new BitSet(new long[]{0x0000000000000410L}); public static final BitSet FOLLOW_BC_in_section99 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_ID_in_param108 = new BitSet(new long[]{0x0000000000000200L}); public static final BitSet FOLLOW_EQ_in_param111 = new BitSet(new long[]{0x000000000008B040L}); public static final BitSet FOLLOW_expr_in_param114 = new BitSet(new long[]{0x0000000000000100L}); public static final BitSet FOLLOW_EOS_in_param116 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_TEXT_in_expr126 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_MULTILINE_in_expr132 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_NUMBER_in_expr141 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_BOOL_in_expr150 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_19_in_expr159 = new BitSet(new long[]{0x0000000000100000L}); public static final BitSet FOLLOW_20_in_expr162 = new BitSet(new long[]{0x0000000000000002L}); public static final BitSet FOLLOW_19_in_expr172 = new BitSet(new long[]{0x000000000008B040L}); public static final BitSet FOLLOW_expr_in_expr175 = new BitSet(new long[]{0x0000000000140000L}); public static final BitSet FOLLOW_18_in_expr178 = new BitSet(new long[]{0x000000000008B040L}); public static final BitSet FOLLOW_expr_in_expr181 = new BitSet(new long[]{0x0000000000140000L}); public static final BitSet FOLLOW_20_in_expr185 = new BitSet(new long[]{0x0000000000000002L}); }src/java/org/dbdoclet/trafo/script/ScriptEvent.java0000644000000000000000000000111212124530526021356 0ustar rootrootpackage org.dbdoclet.trafo.script; import java.io.Serializable; public class ScriptEvent implements Serializable { public enum Type { INPUT_FILE_CHANGED, OUTPUT_FILE_CHANGED } private static final long serialVersionUID = 1L; private final Type type; private final T value; private final Script script; public ScriptEvent(Script script, T value, Type type) { this.script = script; this.value = value; this.type = type; } public Type getType() { return type; } public T getValue() { return value; } public Script getScript() { return script; } } src/java/org/dbdoclet/trafo/script/ScriptListener.java0000644000000000000000000000017312124530526022070 0ustar rootrootpackage org.dbdoclet.trafo.script; public interface ScriptListener { public void scriptChanged(ScriptEvent event); } src/java/org/dbdoclet/trafo/script/Script.java0000644000000000000000000002701012124530526020361 0ustar rootrootpackage org.dbdoclet.trafo.script; import java.util.ArrayList; import java.util.LinkedHashMap; import org.dbdoclet.service.UnicodeServices; import org.dbdoclet.trafo.param.BooleanParam; import org.dbdoclet.trafo.param.NumberParam; import org.dbdoclet.trafo.param.Param; import org.dbdoclet.trafo.param.TextParam; public class Script { public static final String DEFAULT_NAMESPACE = ""; private static final String DEFAULT_SECTION = "main"; private static final String SECTION_SYSTEM = "SYS PARAMS"; public static final String SYSPARAM_TRANSFORMATION_NAME = "transformation.name"; private static final String SECTION_INPUT = "input"; private static final String SECTION_OUTPUT = "output"; private static final String PARAM_FORMAT = "format"; private final LinkedHashMap>>> namespaceMap; private LinkedHashMap> currentParamMap; private final LinkedHashMap> variableMap; private ArrayList listeners; public Script() { namespaceMap = new LinkedHashMap>>>(); variableMap = new LinkedHashMap>(); } public void addBoolParam(String name, boolean flag) { if (currentParamMap == null) { throw new IllegalStateException( "Field currentParamMap must not be null!"); } BooleanParam param = (BooleanParam) currentParamMap.get(name); if (param == null) { param = new BooleanParam(name, flag); currentParamMap.put(name, param); } else { param.addValue(flag); } } public void addBoolParam(String name, String bool) { addBoolParam(name, Boolean.valueOf(bool)); } public void addNumberParam(String name, int number) { if (currentParamMap == null) { throw new IllegalStateException( "Field currentParamMap must not be null!"); } NumberParam param = (NumberParam) currentParamMap.get(name); if (param == null) { param = new NumberParam(name, number); currentParamMap.put(name, param); } else { param.addValue(number); } } public void addNumberParam(String name, String number) { addNumberParam(name, Integer.valueOf(number)); } public void addScriptListener(ScriptListener listener) { if (listener == null) { return; } if (listeners == null) { listeners = new ArrayList(); } if (listeners.contains(listener) == false) { listeners.add(listener); } } public void addTextParam(String name, String text) { if (currentParamMap == null) { throw new IllegalStateException( "Field currentParamMap must not be null!"); } text = UnicodeServices.unescape(text); TextParam param = (TextParam) currentParamMap.get(name); if (param == null) { param = new TextParam(name, new String(text)); currentParamMap.put(name, param); } else { param.addValue(new String(text)); } } public String dump() { StringBuilder buffer = new StringBuilder(); for (String namespace : namespaceMap.keySet()) { System.out.println("\n+++ Namespace: " + namespace); LinkedHashMap>> sectionMap = namespaceMap .get(namespace); for (String section : sectionMap.keySet()) { System.out.println("> Section: " + section); LinkedHashMap> paramMap = sectionMap .get(section); for (String name : paramMap.keySet()) { Param param = paramMap.get(name); System.out.println(param.toString()); } } } return buffer.toString(); } private LinkedHashMap> findParamMap(String namespace, String section) { if (namespace == null) { namespace = DEFAULT_NAMESPACE; } if (section == null) { section = DEFAULT_SECTION; } LinkedHashMap>> sectionMap = namespaceMap .get(namespace); if (sectionMap == null) { sectionMap = new LinkedHashMap>>(); namespaceMap.put(namespace, sectionMap); } LinkedHashMap> paramMap = sectionMap.get(section); if (paramMap == null) { paramMap = new LinkedHashMap>(); sectionMap.put(section, paramMap); } return paramMap; } public void fireScriptEvent(ScriptEvent event) { if (listeners == null) { return; } for (ScriptListener listener : listeners) { listener.scriptChanged(event); } } public String getInputFormat() { return getInputFormat(DEFAULT_NAMESPACE); } public String getInputFormat(String namespace) { return getTextParameter(namespace, SECTION_INPUT, PARAM_FORMAT, null); } public int getIntParameter(String section, String name, int def) { return getIntParameter(DEFAULT_NAMESPACE, section, name, def); } public int getIntParameter(String namespace, String section, String name, int def) { Param param = getParameter(namespace, section, name); if (param == null) { return def; } return (Integer) param.getValue(); } public String getOutputFormat() { return getOutputFormat(DEFAULT_NAMESPACE); } public String getOutputFormat(String namespace) { return getTextParameter(namespace, SECTION_OUTPUT, PARAM_FORMAT, null); } public Param getParameter(String section, String name) { return getParameter(DEFAULT_NAMESPACE, section, name); } public Param getParameter(String namespace, String section, String name) { LinkedHashMap>> sectionMap = namespaceMap .get(namespace); if (sectionMap == null) { return null; } LinkedHashMap> paramMap = sectionMap.get(section); if (paramMap == null) { return null; } return paramMap.get(name); } @SuppressWarnings("unchecked") public T getParameterValue(String namespace, String section, String name, T def) { Param param = getParameter(namespace, section, name); if (param == null) { return def; } T value = def; try { Object paramValue = param.getValue(); if (paramValue != null) { value = ((T) paramValue); } } catch (Throwable oops) { oops.printStackTrace(); } return value; } public T getParameterValue(String section, String name, T def) { return getParameterValue(DEFAULT_NAMESPACE, section, name, def); } public LinkedHashMap>> getSectionMap( String namespace) { return namespaceMap.get(namespace); } public Param getSystemParameter(String namespace, String name) { LinkedHashMap> paramMap = findParamMap(namespace, SECTION_SYSTEM); return paramMap.get(name); } public String getTextParameter(String section, String name, String def) { return getTextParameter(DEFAULT_NAMESPACE, section, name, def); } public String getTextParameter(String namespace, String section, String name, String def) { Param param = getParameter(namespace, section, name); if (param == null) { return def; } return param.getValueAsText(); } public ArrayList getTextParameterList(String section, String name) { return getTextParameterList(DEFAULT_NAMESPACE, section, name, new ArrayList()); } public ArrayList getTextParameterList(String section, String name, ArrayList def) { return getTextParameterList(DEFAULT_NAMESPACE, section, name, def); } public ArrayList getTextParameterList(String namespace, String section, String name, ArrayList def) { Param param = getParameter(namespace, section, name); if (param == null) { return def; } ArrayList values = param.getValues(); ArrayList list = new ArrayList(values.size()); for (Object value : values) { list.add(value.toString()); } return list; } public Param getVariable(String param) { return variableMap.get(param); } public boolean isEnabled(String section, String name) { Param param = getParameter(section, name); if (param != null) { param.isEnabled(); } return false; } public boolean isParameterOn(String section, String name, boolean def) { return isParameterOn(DEFAULT_NAMESPACE, section, name, def); } public boolean isParameterOn(String namespace, String section, String name, boolean def) { Param param = getParameter(namespace, section, name); if (param == null) { return def; } Object value = param.getValue(); if (value == null) { return false; } if (value instanceof Boolean) { return (Boolean) value; } return Boolean.valueOf(value.toString()); } public void mergeNamespaces() { LinkedHashMap>> defSectionMap = namespaceMap .get(DEFAULT_NAMESPACE); if (defSectionMap == null) { defSectionMap = new LinkedHashMap>>(); } ArrayList removeList = new ArrayList(); for (String namespace : namespaceMap.keySet()) { if (namespace.equals(DEFAULT_NAMESPACE)) { continue; } LinkedHashMap>> sectionMap = namespaceMap .get(namespace); for (String section : sectionMap.keySet()) { LinkedHashMap> paramMap = sectionMap .get(section); LinkedHashMap> defParamMap = defSectionMap .get(section); if (defParamMap == null) { defParamMap = new LinkedHashMap>(); defSectionMap.put(section, defParamMap); } for (String name : paramMap.keySet()) { Param param = paramMap.get(name); defParamMap.put(name, param); } } removeList.add(namespace); } for (String namespace : removeList) { namespaceMap.remove(namespace); } } public void removeScriptListener(ScriptListener listener) { if (listeners == null || listener == null) { return; } if (listeners.contains(listener)) { listeners.remove(listener); } } public void selectSection(String section) { selectSection(DEFAULT_NAMESPACE, section); } public void selectSection(String namespace, String section) { LinkedHashMap> paramMap = findParamMap(namespace, section); currentParamMap = paramMap; } public void setBoolParameter(String name, boolean flag) { if (currentParamMap == null) { throw new IllegalStateException( "Field currentParamMap must not be null!"); } BooleanParam param = new BooleanParam(name, flag); currentParamMap.put(name, param); } public void setEnabled(String section, String name, boolean flag) { Param param = getParameter(section, name); if (param != null) { param.setEnabled(flag); } } public void setListParam(String name, ArrayList textList) { @SuppressWarnings("unchecked") Param> param = (Param>) currentParamMap .get(name); param = new Param>(name, textList); currentParamMap.put(name, param); } public void setSystemParameter(String name, String value) { setSystemParameter(DEFAULT_NAMESPACE, name, value); } public void setSystemParameter(String namespace, String name, String value) { LinkedHashMap> paramMap = findParamMap(namespace, SECTION_SYSTEM); paramMap.put(name, new TextParam(name, value)); } public void setTextParameter(String name, String text) { if (currentParamMap == null) { throw new IllegalStateException( "The field currentParamMap must not be null! Select a scetion first."); } TextParam param = (TextParam) currentParamMap.get(name); param = new TextParam(name, new String(text)); currentParamMap.put(name, param); } public void setVariable(Param param) { variableMap.put(param.getName(), param); } } src/java/org/dbdoclet/trafo/html/0000755000000000000000000000000012124530526015712 5ustar rootrootsrc/java/org/dbdoclet/trafo/html/parser/0000755000000000000000000000000012124530526017206 5ustar rootrootsrc/java/org/dbdoclet/trafo/html/parser/HtmlParser.java0000644000000000000000000004563212124530526022144 0ustar rootroot/* * * ### Copyright (C) 2001-2006 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.parser; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.progress.ProgressEvent; import org.dbdoclet.progress.ProgressListener; import org.dbdoclet.progress.ProgressManager; import org.dbdoclet.service.FileServices; import org.dbdoclet.service.ReplaceServices; import org.dbdoclet.service.StringServices; import org.dbdoclet.trafo.tag.NodeStack; import org.dbdoclet.trafo.tag.html.A; import org.dbdoclet.trafo.tag.html.Body; import org.dbdoclet.trafo.tag.html.Frameset; import org.dbdoclet.trafo.tag.html.Head; import org.dbdoclet.trafo.tag.html.HeaderElement; import org.dbdoclet.trafo.tag.html.Html; import org.dbdoclet.trafo.tag.html.HtmlDocument; import org.dbdoclet.trafo.tag.html.HtmlElement; import org.dbdoclet.trafo.tag.html.HtmlFragment; import org.dbdoclet.trafo.tag.html.Li; import org.dbdoclet.trafo.tag.html.P; import org.dbdoclet.trafo.tag.html.Pre; import org.dbdoclet.trafo.tag.html.Title; import org.dbdoclet.trafo.tokenizer.Token; import org.dbdoclet.trafo.tokenizer.Tokenizer; import org.dbdoclet.trafo.tokenizer.TokenizerException; import org.dbdoclet.xiphias.HtmlServices; import org.dbdoclet.xiphias.dom.CommentImpl; import org.dbdoclet.xiphias.dom.ElementImpl; import org.dbdoclet.xiphias.dom.NodeImpl; import org.dbdoclet.xiphias.dom.NodeListImpl; import org.dbdoclet.xiphias.dom.TextImpl; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** *

* The class HTMLParser parses HTML code and creates a tree of * HTMLElement nodes. *

* * @author Michael Fuchs */ public class HtmlParser { public final static int CONTEXT_HTML = 1; public final static int CONTEXT_BODY = 2; private static Log logger = LogFactory.getLog(HtmlParser.class); private int treeSize = 0; private final ArrayList listeners = new ArrayList(); private final HashMap unsupportedTags = new HashMap(); private final NodeStack openTags = new NodeStack(); private final NodeStack openElements = new NodeStack(); private int codeContext = CONTEXT_HTML; private final String title = ""; public static int computeSize(Node node) { NodeList childNodes = node.getChildNodes(); int elemCounter = 1; for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); elemCounter += computeSize(child); } return elemCounter; } /** * The method addProgressListener adds a progress listener. * * @param listener * a ProgressListener value */ public void addProgressListener(ProgressListener listener) { if (listener == null) { throw new IllegalArgumentException("Parameter listener is null!"); } listeners.add(listener); } public String getTitle() { return title; } public int getTreeSize() { return treeSize; } public HtmlDocument parseDocument(File file) throws IOException, ParserException, TokenizerException { String htmlCode = FileServices.readToString(file); HtmlDocument doc = new HtmlDocument(); parseInternal(htmlCode, doc, null); return doc; } public HtmlDocument parseDocument(String htmlCode) throws ParserException, TokenizerException { HtmlDocument doc = new HtmlDocument(); parseInternal(htmlCode, doc, null); return doc; } public HtmlFragment parseFragment(String htmlCode) throws ParserException, TokenizerException { HtmlFragment fragment = new HtmlFragment(); setCodeContext(CONTEXT_BODY); parseInternal(htmlCode, fragment, null); return fragment; } public HtmlFragment parseFragment(String htmlCode, String skipTo) throws ParserException, TokenizerException { HtmlFragment fragment = new HtmlFragment(); setCodeContext(CONTEXT_BODY); parseInternal(htmlCode, fragment, skipTo); return fragment; } /* ======================================================================== */ /* PRIVATE METHODS */ /* ======================================================================== */ public void postparse(NodeImpl root, NodeImpl node) { NodeListImpl childNodes = node.getTrafoChildNodes(); for (NodeImpl child : new ArrayList(childNodes)) { NodeImpl parent = child.getTrafoParentNode(); if (parent != null) { if (child instanceof HeaderElement && parent instanceof A) { /* * Falls ein Header Tag in einem A Tag enthalten ist, stellt * dies eine ungültige Schachtelung dar, die erst innerhalb * der Nachbearbeitung behoben werden kann. Der * Header-Knoten tauscht seinen Platz mit seinem * Vaterknoten. */ child.swapWithParent(); } } if (child.getNodeType() == NodeImpl.ELEMENT_NODE) { postparse(root, child); } } } /** * The method setCodeContext sets the context for the HTML code * to parse. * * The context can be CONTEXT_HTML, which means the code is a complete HTML * page, or CONTEXT_BODY, which means the code is a snippet inside a body * region. * * @param context * an int value */ public void setCodeContext(int context) { switch (context) { case CONTEXT_HTML: break; case CONTEXT_BODY: break; default: throw new IllegalArgumentException("Invalid code context '" + context + "'."); } codeContext = context; } private void addOpenTag(NodeImpl elem) { String tag = elem.getNodeName(); openElements.push(elem); openTags.push(tag.toLowerCase()); } /** * The method capFirstLetter lowers all letters of a string * except the first one, which is made an upper case letters. * * The code: * *
	 * s = s.toLowerCase();
	 * StringBuffer b = new StringBuffer(s);
	 * b.setCharAt(0, Character.toUpperCase(b.charAt(0)));
	 * 
* * * @param s * a String value * @return a String value */ private String capFirstLetter(String s) { if ((s != null) && (s.length() > 0)) { s = s.toLowerCase(); StringBuffer b = new StringBuffer(s); b.setCharAt(0, Character.toUpperCase(b.charAt(0))); return b.toString(); } else { return s; } // end of else } private boolean checkCodeContext(NodeImpl candidate) { if (codeContext == CONTEXT_BODY) { if (candidate instanceof Head || candidate instanceof Title || candidate instanceof Html || candidate instanceof Frameset) { return false; } } return true; } private int closeClosingTag(String tag, NodeImpl currentNode) { if (currentNode == null || currentNode instanceof HtmlElement == false) { return 0; } Node elem = currentNode; String tagName = elem.getNodeName(); if (tagName == null) { return 0; } // First of all. Look if there is a corresponding open tag at all! while ((elem != null) && !elem.getNodeName().equalsIgnoreCase(tag)) { elem = elem.getParentNode(); } if (elem == null) { logger.debug("Tag <" + tag + "> has no corresponding opening tag!"); return 0; } int nesting = 0; int depth = openTags.search(tag); logger.debug("Open tag stack = '" + openTags + "'"); for (int i = 0; i < depth; i++) { removeOpenTag(); nesting++; } // end of while () return nesting; } private int closeOpenTag(String tag, NodeImpl currentNode) { String search = ""; logger.debug("Testing tag \"" + tag + "\". The current node is " + currentNode + "."); // Close any open p tags, if the tag is a ol, ul, dl, address, // div, pre or table tag and no opening tag can be found. if (tag.equalsIgnoreCase("address") || tag.equalsIgnoreCase("div") || tag.equalsIgnoreCase("dl") || tag.equalsIgnoreCase("menu") || tag.equalsIgnoreCase("ol") || tag.equalsIgnoreCase("p") || tag.equalsIgnoreCase("pre") || tag.equalsIgnoreCase("table") || tag.equalsIgnoreCase("ul")) { if (openTags.search("p") != -1) { search = "p"; } } // end of if () if (tag.equalsIgnoreCase("h1") || tag.equalsIgnoreCase("h2") || tag.equalsIgnoreCase("h3") || tag.equalsIgnoreCase("h4") || tag.equalsIgnoreCase("h5") || tag.equalsIgnoreCase("h6")) { search = "p"; /* * String[] nodes = { "ul", "ol", "menu", "dl" }; index1 = * searchNearset(); * * if ( ( index1 != -1 ) { openTags.search("ul")) != -1 ) { * * index2 = openTags.search("li"); * * if ( index2 > index1 ) search = "ul"; * * } else if ( openTags.search("ol") != -1 && openTags.search("li") * == -1) search = "ol"; else if ( openTags.search("menu") != -1 ) * search = "menu"; else if ( openTags.search("dl") != -1 && * openTags.search("dd") == -1) search = "dl"; */ } if (tag.equalsIgnoreCase("td")) { int tdDepth = openTags.search("td"); if (tdDepth != -1) { int depth = openTags.search("tr"); if ((depth != -1) && (depth > tdDepth)) { search = "td"; } } } if (tag.equalsIgnoreCase("tr")) { int trDepth = openTags.search("tr"); if (trDepth != -1) { int depth = openTags.search("table"); if ((depth != -1) && (depth > trDepth)) { search = "tr"; } } } if (tag.equalsIgnoreCase("li")) { // if an open li tag is found, test first if it is in the // same list or not. int liDepth = openTags.search("li"); if (liDepth != -1) { int uldepth = openTags.search("ul"); int oldepth = openTags.search("ol"); int depth = -1; if ((oldepth == -1) && (uldepth != -1)) { depth = uldepth; } if ((oldepth != -1) && (uldepth == -1)) { depth = oldepth; } if ((oldepth != -1) && (uldepth != -1) && (oldepth < uldepth)) { depth = oldepth; } if ((oldepth != -1) && (uldepth != -1) && (uldepth < oldepth)) { depth = uldepth; } if ((depth != -1) && (depth > liDepth)) { search = "li"; } if ((depth != -1) && (depth > liDepth)) { search = "li"; } } } // Close any open dt tags if the tag is a dd. if (tag.equalsIgnoreCase("dd")) { int dtDepth = openTags.search("dt"); if (dtDepth != -1) { search = "dt"; } } // end of if () // Close any open dd tags if the tag is a dt. if (tag.equalsIgnoreCase("dt")) { int dddepth = openTags.search("dd"); int dldepth = openTags.search("dl"); // System.out.println("dddepth: " + dddepth + " dldepth: " + // dldepth); if ((dddepth != -1) && (dldepth > dddepth)) { search = "dd"; } if ((dddepth != -1) && (dldepth != -1) && (dldepth < dddepth)) { search = ""; } } // end of if () int depth = openTags.search(search); return depth; } private HtmlElement createElement(Token token, NodeImpl parent) { String className; HtmlElement node = null; String tagName = token.getTagName().toLowerCase(); logger.debug("tagName=" + tagName); if (token.isJavadoc()) { tagName = tagName.substring("javadoc:".length()); className = "org.dbdoclet.trafo.tag.javadoc." + capFirstLetter(tagName); logger.debug("Javadoc classname = '" + className + "'."); } else { className = "org.dbdoclet.trafo.tag.html." + capFirstLetter(tagName); } try { Class tagClass = Class.forName(className); node = (HtmlElement) tagClass.newInstance(); node.setParentNode(parent); node.setTrafoStringAttributes(token.getAttributes()); node.setLine(token.getLine()); node.setColumn(token.getColumn()); } catch (ClassNotFoundException oops) { if (unsupportedTags.get(tagName) == null) { logger.debug("Tag " + tagName + " is not supported! (" + className + ")"); unsupportedTags.put(tagName, className); } } catch (Exception oops) { logger.error("Exception: " + oops.getClass().getName() + " " + oops.getMessage()); } return node; } private void parseInternal(String htmlCode, NodeImpl root, String skipTo) throws ParserException, TokenizerException { ProgressManager pm = new ProgressManager(listeners); treeSize = 1; String errorBuffer = ""; boolean firstElement = true; int index = 0; int nesting = 0; if ((htmlCode == null) || htmlCode.equals("")) { return; } boolean skip = false; if (skipTo != null) { skip = true; } Tokenizer tokenizer = new Tokenizer(htmlCode); tokenizer.setProgressListeners(listeners); tokenizer.tokenize(); Token token = null; NodeImpl currentNode = root; HtmlElement candidate = null; String title = ""; while (tokenizer.hasNext()) { token = tokenizer.next(); ProgressEvent event = new ProgressEvent(tokenizer.size(), tokenizer.position()); event.setAction("HTML Parser: " + token.toString()); event.setStage(ProgressEvent.STAGE_PREPARE); pm.fireProgressEvent(event); logger.debug(String.format("++++++ PROCESSING NEXT TOKEN %s", token.getTagName())); logger.debug("token=" + token.toString()); logger.debug("currentNode=" + currentNode); if (token.isDoctype() && (currentNode == root)) { continue; } if ((codeContext == CONTEXT_HTML) && (firstElement == true)) { String tagName = token.getTagName(); if (tagName != null) { tagName = tagName.toLowerCase(); } if ((tagName != null) && tagName.equals("html")) { firstElement = false; } else if ((tagName != null) && tagName.equals("body")) { logger.debug("Missing html tag."); firstElement = false; } else { if (token.isTag()) { logger.debug("Found tag before html tag: " + token.toString()); if (errorBuffer.length() < 16832) { errorBuffer += "Found tag before html tag: " + token.toString() + ".\n"; } else { if (errorBuffer.endsWith("More...\n") == false) { errorBuffer += "More...\n"; } } } continue; } } if (token.isComment()) { currentNode.appendChild(new CommentImpl("\n" + token.getValue() + "\n", currentNode)); treeSize++; continue; } if (token.isText()) { /* * Falls der letzte Kandidat der Title-Tag des Dokumentes war, * wird er in dem Attribut title abgelegt. Der Titel des * Dokuments kann nach der Transformation, mit Hilfe der Methode * getTitle() vom Aufrufer ermittelt werden. */ if (candidate instanceof Title) { title += token.getValue(); title = StringServices.replace(title, "\n", " "); title = title.trim(); } if (skip == true) { continue; } if (((currentNode == root) || currentNode instanceof Body || currentNode instanceof Li) && (token.isWhitespace() == false)) { P para = new P(); para.setParentNode(currentNode); currentNode.appendChild(para); treeSize++; currentNode = para; addOpenTag(para); } if (currentNode instanceof Pre || (currentNode.findParent(Pre.class) != null)) { String value = token.getValue(); value = HtmlServices.textToHtml(value); logger.debug("Adding text to literal environment.\n'" + value + "'."); currentNode.appendChild(new TextImpl(value, currentNode)); treeSize++; } else { if (token.isWhitespace() == false) { String value = token.getValue(); value = ReplaceServices.replaceAll(value, "[\\t ]+", " "); value = ReplaceServices.replaceAll(value, "\\s+$", " "); currentNode.appendChild(new TextImpl(HtmlServices .textToHtml(value), currentNode)); treeSize++; } } } if (token.isOpeningTag()) { String tagName = token.getTagName(); if (tagName == null) { continue; } tagName = tagName.toLowerCase(); if ((skip == true) && skipTo.equals(tagName)) { logger.debug("Setting skip to false. Found tag " + tagName + "."); skip = false; } nesting = closeOpenTag(tagName, currentNode); NodeImpl node = currentNode; for (int i = 0; i < nesting; i++) { if (node != null) { NodeImpl parent = node.getTrafoParentNode(); if (parent != null) { logger.debug("Closing node = " + node); logger.debug("New current node = " + parent); node = parent; } } } candidate = createElement(token, node); if (candidate == null) { continue; } logger.debug("Created candidate = " + candidate); if (!checkCodeContext(candidate)) { logger.debug("Candidate is not allowed in this code context(" + codeContext + ") '" + candidate + "'!"); continue; } if ((candidate == null) || !candidate.validate()) { logger.debug("Candidate is invalid '" + candidate + "'!"); continue; } else { logger.debug("Candidate is valid: " + candidate); } // Commit changes if (skip == false) { for (int i = 0; i < nesting; i++) { removeOpenTag(); if (currentNode != null) { NodeImpl parent = currentNode.getTrafoParentNode(); if (parent != null) { currentNode = parent; } } } NodeStack nodeStack = candidate.getValidateStack(); index = 0; while ((currentNode != null) && !nodeStack.empty()) { node = (HtmlElement) nodeStack.pop(); if (index == 0) { if (currentNode instanceof HtmlDocument) { ((HtmlDocument) currentNode) .setDocumentElement((ElementImpl) node); } else { currentNode.appendChild(node); treeSize++; } } if (node.isEmpty() == false) { addOpenTag(node); currentNode = node; } logger.debug("Inserted tag <" + node.getNodeName() + ">."); index++; } } else { logger.debug("Skipped candidate."); } // end of else } // end of if () if (token.isClosingTag() && (skip == false)) { if (currentNode != null) { nesting = closeClosingTag(token.getTagName().toLowerCase(), currentNode); logger.debug("Nesting = " + nesting); for (int j = 0; j < nesting; j++) { if ((currentNode != null) && (currentNode.getParentNode() != null)) { currentNode = currentNode.getTrafoParentNode(); } } } } } postparse(root, root); /* * --------------------------------------------------------------- try { * * PrintWriter out = new PrintWriter(new FileWriter("dbdoclet-" + new * Date().getTime() + ".html")); out.println(root.toHTML()); * out.close(); * * } catch (Exception oops) { * * logger.error("Can't save intermediate HTML file: " + * oops.getMessage()); } * --------------------------------------------------------------- */ if ((errorBuffer != null) && (errorBuffer.length() > 0)) { root.appendChild(new CommentImpl("ERRORS:\n" + errorBuffer)); treeSize++; } } private HtmlElement removeOpenTag() { openTags.pop(); HtmlElement node = (HtmlElement) openElements.pop(); node.closed(); return node; } } src/java/org/dbdoclet/trafo/html/parser/ParserException.java0000644000000000000000000000327412124530526023172 0ustar rootroot/* * ### Copyright (C) 2001-2003 Michael Fuchs ### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Michael Fuchs * E-Mail: mfuchs@unico-consulting.com * * RCS Information: * --------------- * Id.........: $Id: ParserException.java,v 1.1.1.1 2004/12/21 14:01:33 mfuchs Exp $ * Author.....: $Author: mfuchs $ * Date.......: $Date: 2004/12/21 14:01:33 $ * Revision...: $Revision: 1.1.1.1 $ * State......: $State: Exp $ */ package org.dbdoclet.trafo.html.parser; public class ParserException extends Exception { private static final long serialVersionUID = 1L; public ParserException(String msg) { super(msg); } public ParserException(Throwable oops) { super(oops); } @Override public String getMessage() { String str; String msg; Throwable cause = getCause(); if (cause != null) { msg = "[" + cause.getClass().getName() + "] "; str = cause.getMessage(); if ((str != null) && (str.length() > 0)) { msg += str; } } else { msg = super.getMessage(); } return msg; } } src/java/org/dbdoclet/trafo/html/docbook/0000755000000000000000000000000012124530534017331 5ustar rootrootsrc/java/org/dbdoclet/trafo/html/docbook/DbtConstants.java0000644000000000000000000000744012124530526022610 0ustar rootrootpackage org.dbdoclet.trafo.html.docbook; public class DbtConstants { public static final String DEFAULT_DESTINATION_ENCODING = "UTF-8"; public static final String DEFAULT_EMPHASIS_ROLE_BOLD = "bold"; public static final String DEFAULT_EMPHASIS_ROLE_ITALIC = "italic"; public static final String DEFAULT_EMPHASIS_ROLE_UNDERLINE = "underline"; public static final String DEFAULT_IMAGE_PATH = "img"; public static final String DEFAULT_SOURCE_ENCODING = "UTF-8"; public static final String DEFAULT_TABLE_STYLE = "all"; public static final boolean DEFAULT_DECOMPOSE_TABLES = false; public static final int DEFAULT_MAX_LINE_WIDTH = 75; // public static final String DEFAULT_SECTION_NUMBERING_PATTERN = // "(((\\d\\.)+)?\\d*\\.?\\p{Z}*).*"; public static final String SECTION_DOCBOOK = "DocBook"; public static final String SECTION_HTML = "HTML"; public static final String SECTION_SECTION_DETECTION = "section-detection"; public static final String SECTION_LIST_DETECTION = "list-detection"; public static final String SECTION_INPUT = "input"; public static final String SECTION_IMPORT = "import"; public static final String SECTION_MAIN = "main"; public static final String SECTION_OUTPUT = "output"; public static final String PARAM_ABSTRACT = "abstract"; public static final String PARAM_ADD_INDEX = "add-index"; public static final String PARAM_ATTRIBUTE_CLASS = "attribute-class"; public static final String PARAM_AUTHOR_EMAIL = "author-email"; public static final String PARAM_AUTHOR_FIRSTNAME = "author-firstname"; public static final String PARAM_AUTHOR_SURNAME = "author-surname"; public static final String PARAM_COLLAPSE_PROTECTED_SPACE = "collapse-protected-space"; public static final String PARAM_COPYRIGHT_HOLDER = "copyright-holder"; public static final String PARAM_COPYRIGHT_YEAR = "copyright-year"; public static final String PARAM_CORPORATION = "corporation"; public static final String PARAM_CREATE_CONDITION_ATTRIBUTE = "create-condition-attribute"; public static final String PARAM_CREATE_PROLOG = "create-prolog"; public static final String PARAM_CREATE_REMAP_ATTRIBUTE = "create-remap-attribute"; public static final String PARAM_CREATE_XREF_LABEL = "create-xref-label"; public static final String PARAM_DECOMPOSE_TABLES = "decompose-tables"; public static final String PARAM_DETECT_TRAPPED_BR = "detect-trapped-br"; public static final String PARAM_DOCBOOK_VERSION = "docbook-version"; public static final String PARAM_DOCUMENTATION_ID = "documentation-id"; public static final String PARAM_DOCUMENT_ELEMENT = "document-element"; public static final String PARAM_ENCODING = "encoding"; public static final String PARAM_EXCLUDE = "exclude"; public static final String PARAM_FILE = "file"; public static final String PARAM_HTML_SOURCE_ENCODING = "encoding"; public static final String PARAM_HYPHENATION_CHAR = "hyphenation-char"; public static final String PARAM_IMAGEDATA_FORMATS = "image-data-formats"; public static final String PARAM_IMAGE_PATH = "image-path"; public static final String PARAM_ITEMIZED_ATTRIBUTE_CLASS = "itemized-attribute-class"; public static final String PARAM_ITEMIZED_STRIP_PREFIX = "itemized-strip-prefix"; public static final String PARAM_LANGUAGE = "language"; public static final String PARAM_ORDERED_ATTRIBUTE_CLASS = "ordered-attribute-class"; public static final String PARAM_ORDERED_STRIP_PREFIX = "ordered-strip-prefix"; public static final String PARAM_RELEASE_INFO = "release-info"; public static final String PARAM_SECTION_NUMBERING_PATTERN = "section-numbering-pattern"; public static final String PARAM_TABLE_STYLE = "table-style"; public static final String PARAM_TITLE = "title"; public static final String PARAM_TITLE_NORMALIZE_SPACE = "title-normalize-space"; public static final String PARAM_USE_ABSOLUTE_IMAGE_PATH = "use-absolute-image-path"; } src/java/org/dbdoclet/trafo/html/docbook/Resources.properties0000644000000000000000000000023412124530526023421 0ustar rootrootC_DOCUMENT_ELEMENT=Document Type C_ENCODING_SOURCE=Source File Encoding C_LANGUAGE=Language C_PROFILE=Profile C_USE_ABSOLUTE_IMAGE_PATH=Absolute Image Pathssrc/java/org/dbdoclet/trafo/html/docbook/DocBookTransformer.java0000644000000000000000000007251112124530526023746 0ustar rootroot/* * $Id$ * * ### Copybright (C) 2006 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StringReader; import java.io.StringWriter; import java.util.ArrayList; import java.util.Iterator; import java.util.Locale; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.CanceledException; import org.dbdoclet.Sfv; import org.dbdoclet.progress.ProgressEvent; import org.dbdoclet.progress.ProgressListener; import org.dbdoclet.progress.ProgressManager; import org.dbdoclet.service.FileServices; import org.dbdoclet.service.StringServices; import org.dbdoclet.trafo.TrafoException; import org.dbdoclet.trafo.TrafoResult; import org.dbdoclet.trafo.html.docbook.editor.Editor; import org.dbdoclet.trafo.html.docbook.editor.EditorException; import org.dbdoclet.trafo.html.docbook.editor.EditorFactory; import org.dbdoclet.trafo.html.docbook.editor.EditorFactoryException; import org.dbdoclet.trafo.html.docbook.editor.EditorInstruction; import org.dbdoclet.trafo.html.parser.HtmlParser; import org.dbdoclet.trafo.param.TextParam; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.Abstract; import org.dbdoclet.trafo.tag.docbook.DocBookDocument; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookFragment; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Info; import org.dbdoclet.trafo.tag.docbook.Section; import org.dbdoclet.trafo.tag.html.HtmlDocument; import org.dbdoclet.trafo.tag.html.HtmlElement; import org.dbdoclet.trafo.tag.html.HtmlFragment; import org.dbdoclet.xiphias.NodeSerializer; import org.dbdoclet.xiphias.XPathServices; import org.dbdoclet.xiphias.XmlServices; import org.dbdoclet.xiphias.dom.CommentImpl; import org.dbdoclet.xiphias.dom.ElementImpl; import org.dbdoclet.xiphias.dom.NodeCountVisitor; import org.dbdoclet.xiphias.dom.NodeImpl; import org.dbdoclet.xiphias.dom.NodeListImpl; import org.dbdoclet.xiphias.dom.TextImpl; import org.dbdoclet.xiphias.dom.TransformInstruction; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; import org.xml.sax.InputSource; public class DocBookTransformer { public enum DocumentElementType { ARTICLE, BOOK, CHAPTER, OVERVIEW, PARAGRAPH, PART, REFERENCE, SECTION; } private static Log logger = LogFactory.getLog(DocBookTransformer.class); private DocBookTagFactory dbfactory; private ListDetector listDetector; /** * Einrückung für Debugging-Ausgaben */ private String indent = ""; private final LinkManager linkManager; public final ArrayList listeners = new ArrayList(); private DocumentElementType documentType = DocumentElementType.ARTICLE; private Script script; private final ProgressManager pm; public DocBookTransformer() { linkManager = new LinkManager(); pm = new ProgressManager(listeners); } public void addLink(ElementImpl link) { linkManager.addLink(link); } public void addProgressListener(ProgressListener listener) { if (listener == null) { throw new IllegalArgumentException("Parameter listener is null!"); } listeners.add(listener); } public void convert(ArrayList inList) throws TrafoException { if (inList == null) { throw new IllegalArgumentException( "The argument inList must not be null!"); } for (File file : inList) { convert(file); } } public String convert(File file) throws TrafoException { if (file == null) { return null; } String htmlCode = null; try { htmlCode = FileServices.readToString(file, script.getTextParameter( DbtConstants.SECTION_HTML, DbtConstants.PARAM_HTML_SOURCE_ENCODING, DbtConstants.DEFAULT_SOURCE_ENCODING)); return convert(htmlCode); } catch (IOException oops) { throw new TrafoException(oops); } } public String convert(File inFile, File destinationFile) throws TrafoException { try { Script script = createDefaultScript(); String buffer = convert(inFile); FileServices.createParentDir(destinationFile); FileServices.writeFromString(destinationFile, buffer, script .getTextParameter(DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_ENCODING, "UTF-8")); return buffer; } catch (IOException oops) { throw new TrafoException(oops); } } public String convert(String htmlCode) throws TrafoException { String buffer; try { buffer = transformDocument(htmlCode, documentType, new TrafoResult()); } catch (TrafoException oops) { logger.fatal( "Failed to convert as document. I will try to convert as fragment.", oops); Throwable cause = oops; while (cause.getCause() != null) { cause = cause.getCause(); } if (cause != null && cause instanceof CanceledException == false) { buffer = transformFragment(htmlCode, new TrafoResult()); } else { throw oops; } } return buffer; } public String createUniqueId(String id) { return linkManager.createUniqueId(id); } public ArrayList getLinkList() { return linkManager.getLinkList(); } public Script getScript() { return script; } public DocBookTagFactory getTagFactory() { if (dbfactory == null) { dbfactory = new DocBookTagFactory(); } return dbfactory; } public String getUniqueId(String id) { return linkManager.getUniqueId(id); } public ArrayList getUnresolvedIds() { return linkManager.getUnresolvedIds(); } public ArrayList getUsedIdList() { return linkManager.getUsedIdList(); } public void setScript(Script script) { this.script = script; if (script != null) { String value = script.getTextParameter( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_DOCUMENT_ELEMENT, "article"); documentType = DocumentElementType.valueOf(value.toUpperCase()); } } public void setTagFactory(DocBookTagFactory dbfactory) { if (dbfactory == null) { throw new IllegalArgumentException( "The argument dbfactory must not be null!"); } this.dbfactory = dbfactory; } public NodeImpl transform(NodeImpl htmlRoot, NodeImpl parent, TrafoResult result) throws Exception { logger.debug("-> transform(NodeImpl, NodeImpl, TrafoResult) " + htmlRoot); if (htmlRoot == null) { throw new IllegalArgumentException("The htmlRoot must not be null!"); } if (parent == null) { throw new IllegalArgumentException( "The argument parent must not be null!"); } TextParam excludeParam = (TextParam) script.getParameter( DbtConstants.SECTION_HTML, DbtConstants.PARAM_EXCLUDE); if (excludeParam != null) { for (String excludeXpath : excludeParam.getValues()) { ArrayList nodeList = XPathServices.getNodes(htmlRoot, excludeXpath); for (Node node : nodeList) { if (node.getParentNode() != null) { node.getParentNode().removeChild(node); } } } } pm.nextStage(); NodeCountVisitor nodeCounter = new NodeCountVisitor(listeners); htmlRoot.traverse(nodeCounter); pm.setProgressMaximum(nodeCounter.getNumberOfNodes()); pm.fireProgressEvent(new ProgressEvent("Preprocess HTML tree...", false)); PreprocessStage1 preprocessStage1 = new PreprocessStage1(listeners); htmlRoot.traverse(preprocessStage1); preprocessStage1.finish(); NodeImpl root = null; pm.nextStage(); pm.fireProgressEvent(new ProgressEvent("Transformation...", false)); pm.setProgressMaximum(nodeCounter.getNumberOfNodes()); listDetector = new ListDetector(); if (parent instanceof DocBookElement) { root = edit(htmlRoot, (DocBookElement) parent); } if (parent instanceof DocBookFragment) { Section section = new DocBookTagFactory().createSection(); parent.appendChild(section); root = edit(htmlRoot, section); } // System.out.println("XML Tree =\n" + parent.treeView()); while (root.getParentNode() != null) { root = root.getTrafoParentNode(); } // logger.debug("Edit - DocBook XML Tree =\n" + root.treeView()); pm.nextStage(); nodeCounter = new NodeCountVisitor(listeners); pm.fireProgressEvent(new ProgressEvent("Postprocess stage 1...", false)); root.traverse(nodeCounter); pm.setProgressMaximum(nodeCounter.getNumberOfNodes()); PostprocessStage1 postprocessStage1 = new PostprocessStage1(dbfactory, script, listeners); root.traverse(postprocessStage1); postprocessStage1.finish(); pm.nextStage(); pm.fireProgressEvent(new ProgressEvent("Postprocess stage 2...", false)); root.traverse(nodeCounter.reset()); pm.setProgressMaximum(nodeCounter.getNumberOfNodes()); PostprocessStage2 postprocessStage2 = new PostprocessStage2(dbfactory, script, listeners); root.traverse(postprocessStage2); postprocessStage2.finish(); new PostprocessStage3(dbfactory, postprocessStage1.getSubtables()) .process(); boolean addIndex = script.isParameterOn(DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_ADD_INDEX, false); if (addIndex == true) { root.appendChild(dbfactory.createIndex()); } return root; } public String transform(String in, DocBookElement parent, TrafoResult result) throws TrafoException { if (in == null) { throw new IllegalArgumentException( "The argument in must not be null!"); } if (result == null) { throw new IllegalArgumentException( "The argument result must not be null!"); } String xml = ""; try { DocBookElement elem = (DocBookElement) transform(in, parent); xml = NodeSerializer.toXML(elem); result.append(xml); if (xml == null || xml.length() == 0) { throw new TrafoException("Transformation returned null!"); } logger.debug("Transformer out=" + xml); String destinationEncoding = script.getTextParameter( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_ENCODING, DbtConstants.DEFAULT_DESTINATION_ENCODING); byte[] data = XmlServices.validate(xml, destinationEncoding); result.setData(data); File file = result.getFile(); if (file != null) { FileOutputStream writer = new FileOutputStream(file); writer.write(data); writer.close(); } return xml; } catch (Exception oops) { throw new TrafoException(oops); } } public NodeImpl transform(String buffer, NodeImpl parent) throws Exception { return transform(buffer, parent, null); } public NodeImpl transform(String buffer, NodeImpl parent, HtmlElement skipTo) throws Exception { return transform(buffer, parent, skipTo, null); } public NodeImpl transform(String buffer, NodeImpl parent, HtmlElement skipTo, TrafoResult result) throws Exception { logger.debug("-> transform(String, NodeImpl, HtmlElement, TrafoResult)"); HtmlParser parser = new HtmlParser(); if (documentType == DocumentElementType.CHAPTER || documentType == DocumentElementType.SECTION || documentType == DocumentElementType.PARAGRAPH || documentType == DocumentElementType.OVERVIEW) { parser.setCodeContext(HtmlParser.CONTEXT_BODY); } HtmlFragment htmlRoot = null; if (skipTo != null) { htmlRoot = parser.parseFragment(buffer, skipTo.getNodeName()); } else { htmlRoot = parser.parseFragment(buffer); } // logger.debug(((HtmlFragment) htmlRoot).toXML()); // logger.debug("HTML Tree =\n" + ((TrafoNode) htmlRoot).treeView()); if (htmlRoot == null) { return null; } NodeImpl rc = transform(htmlRoot, parent, result); logger.debug("<- transform(String, NodeImpl, HtmlElement, TrafoResult)"); return rc; } public String transformDocument(String htmlCode, DocumentElementType documentType, TrafoResult result) throws TrafoException { if (script == null) { script = new Script(); } try { pm.setStageCount(8); pm.nextStage(); HtmlParser parser = new HtmlParser(); for (ProgressListener listener : listeners) { parser.addProgressListener(listener); } HtmlDocument htmlDoc = parser.parseDocument(htmlCode); if (logger.isTraceEnabled()) { NodeSerializer serializer = new NodeSerializer(); serializer.write(htmlDoc, new File("__trace__herold.html")); } HtmlElement documentElement = htmlDoc.getDocumentElement(); String lang = null; if (documentElement == null) { throw new TrafoException("Couldn't find a document element!"); } documentElement.removeAttribute("xmlns"); String language = script.getTextParameter( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_LANGUAGE, null); logger.debug("Profile: Parameter language = " + language); if (language == null) { lang = detectLanguage(documentElement); logger.debug("Detected language from HTML = " + lang); if (lang == null) { lang = Locale.getDefault().getLanguage().toLowerCase(); logger.debug("Using default language from JVM = " + lang); } } else { lang = language; } DocBookDocument doc = new DocBookDocument(); doc.setXmlEncoding(script.getTextParameter( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_ENCODING, DbtConstants.DEFAULT_DESTINATION_ENCODING)); DocBookTagFactory dbf = getTagFactory(); DocBookElement rootElement; this.documentType = documentType; if (documentType == DocumentElementType.BOOK) { rootElement = dbf.createBook(); } else if (documentType == DocumentElementType.REFERENCE) { rootElement = dbf.createReference(); } else if (documentType == DocumentElementType.PART) { rootElement = dbf.createPart(); } else if (documentType == DocumentElementType.CHAPTER) { rootElement = dbf.createChapter(); } else if (documentType == DocumentElementType.SECTION) { rootElement = dbf.createSection(); } else if (documentType == DocumentElementType.PARAGRAPH) { rootElement = dbf.createPara(); } else { rootElement = dbf.createArticle(); } if (lang != null) { logger.debug("Setting attribute xml:lang to " + lang); rootElement.setAttributeNS( "http://www.w3.org/XML/1998/namespace", "xml:lang", lang); } Info info = dbf.createInfo(); rootElement.appendChild(info); String title = script.getTextParameter( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_TITLE, null); if (title != null && title.trim().length() > 0) { info.appendChild(dbf.createTitle(title)); } else { generateTitle(htmlDoc, dbf, info); } String abstractText = script.getTextParameter( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_ABSTRACT, null); if (abstractText != null) { Abstract abstractElement = dbf.createAbstract(); info.appendChild(abstractElement); createAbstract(doc, abstractElement, abstractText); } doc.setDocumentElement(rootElement); // setImagePath("./"); transform(documentElement, rootElement, result); StringWriter buffer = serialize(doc); logger.debug("<- transformDocument"); return buffer.toString(); } catch (TrafoException oops) { throw oops; } catch (Exception oops) { throw new TrafoException(oops); } } private void createAbstract(Document doc, Abstract abstractElement, String abstractText) { if (abstractText.trim().startsWith("<")) { abstractText = "" + abstractText + ""; } else { abstractText = "" + abstractText + ""; } try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory .newDocumentBuilder(); Document docAbstract = documentBuilder.parse(new InputSource( new StringReader(abstractText))); Element documentElement = docAbstract.getDocumentElement(); documentElement = (Element) doc.importNode(documentElement, true); if (documentElement != null && documentElement.hasChildNodes()) { NodeList childList = documentElement.getChildNodes(); for (int i = 0; i < childList.getLength(); i++) { Node child = childList.item(i); abstractElement.appendChild(child); } } } catch (Exception oops) { logger.error("Parsing abstract failed!", oops); } } private void generateTitle(HtmlDocument htmlDoc, DocBookTagFactory dbf, Info info) { HtmlElement elem = (HtmlElement) XPathServices.getNode(htmlDoc, "/html/head/title"); if (elem == null) { for (int i = 1; i <= 6; i++) { if (elem == null) { elem = (HtmlElement) XPathServices.getNode(htmlDoc, "/html/body/h" + i + "[1]"); } } } if (elem != null) { info.appendChild(dbf.createTitle(elem.getTextContent())); } else { Text text = (Text) XPathServices.getNode(htmlDoc, "//text()[1]"); if (text != null) { info.appendChild(dbf.createTitle(text.getData())); } else { info.appendChild(dbf.createTitle("Herold")); } } } public String transformFragment(String htmlCode) throws TrafoException { return transformFragment(htmlCode, new TrafoResult()); } public String transformFragment(String htmlCode, TrafoResult result) throws TrafoException { logger.debug("-> transformFragment " + htmlCode); if (script == null) { script = new Script(); } script.setEnabled(DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_ADD_INDEX, false); try { HtmlParser parser = new HtmlParser(); for (ProgressListener listener : listeners) { parser.addProgressListener(listener); } HtmlFragment htmlRoot = parser.parseFragment(htmlCode); if (htmlRoot == null) { throw new TrafoException("Couldn't find a html fragment!"); } logger.debug("transform"); DocBookFragment parent = new DocBookFragment(); NodeImpl elem = transform(htmlRoot, parent, result); StringWriter buffer = serialize(elem); logger.debug("<- transformFragment"); return buffer.toString(); } catch (Exception oops) { throw new TrafoException(oops); } } /** * The method checkCodeContext. * * @param candidate * a HTMLElement value * @return a boolean value */ private boolean checkCodeContext(HtmlElement candidate) { if (candidate == null) { throw new IllegalArgumentException("Parameter candidate is null!"); } if (documentType == DocumentElementType.SECTION) { if (candidate instanceof org.dbdoclet.trafo.tag.html.Head || candidate instanceof org.dbdoclet.trafo.tag.html.Html || candidate instanceof org.dbdoclet.trafo.tag.html.Frameset) { return false; } } return true; } private Script createDefaultScript() { Script script = new Script(); return script; } private String detectLanguage(Element documentElement) { String lang = documentElement.getAttribute("xml:lang"); if (lang == null) { lang = documentElement.getAttribute("lang"); } if (lang == null) { HtmlElement elem = (HtmlElement) XPathServices.getNode( documentElement, "//meta[@http-equiv='Content-Language']"); if (elem != null) { lang = elem.getAttribute("content"); } } return lang; } /** * The method edit is reponsible for the transformation of the * HTML document tree into an DocBook document tree. * * @param htmlNode * a Node value * @param dbParent * a DocBookElement value * * @return a Element. The root node of the created DocBook * document tree. */ private DocBookElement edit(NodeImpl htmlNode, DocBookElement dbParent) { logger.debug("-> edit " + htmlNode); if (htmlNode == null) { logger.error("[DocBookDoclet.edit] - Parameter node is null!"); return null; } if (dbParent == null) { logger.error("[DocBookDoclet.edit] - Parameter dbParent is null!"); return null; } NodeListImpl htmlChildren = htmlNode.getTrafoChildNodes(); Iterator iterator = htmlChildren.iterator(); boolean doTraverse = true; boolean doIgnore = false; NodeImpl child = null; HtmlElement htmlElement; DocBookElement dbElement; DocBookElement dbOldParent = dbParent; DocBookElement dbChildParent = null; Object anything = null; Editor editor; DocBookElement dbelem; // for temporay use only! int index = 0; logger.debug(indent + "\n>>>=================================================="); logger.debug(indent + " HTML Vaterelement " + htmlNode + "."); logger.debug(indent + " DocBook Vaterelement " + dbParent + "."); indent += "."; while (iterator.hasNext()) { index++; child = iterator.next(); pm.fireProgressEvent(new ProgressEvent("Transforming " + child.toString())); logger.debug(indent + " HTML element is " + child + "."); dbElement = dbParent; doTraverse = true; if (child instanceof CommentImpl) { try { CommentImpl comment = (CommentImpl) child; if (isInstruction(comment)) { EditorInstruction values = new EditorInstruction(); values.setAnything(null); values.setChild(null); values.setCodeContext(documentType); values.setCurrent(dbParent); values.setParent(dbParent); values.setCharacterDataNode((CommentImpl) child); values.setTransformer(this); editor = EditorFactory.getCommentEditor(); logger.debug(indent + " Vor der Kommentarbearbeitung: " + child + ".\n"); values = editor.edit(values); logger.debug(indent + " Nach der Kommentarbearbeitung: " + child + ".\n"); dbParent = values.getParent(); if (dbParent == null) { throw new NullPointerException("[Node #" + index + "]" + "DocBook parent element for element '" + child + "' is null!"); } dbElement = values.getCurrent(); doTraverse = values.doTraverse(); } else { pm.fireProgressEvent(new ProgressEvent("Comment")); dbParent.appendChild(child); continue; } } catch (EditorException oops) { logger.debug(indent + " EditorException " + oops.getMessage()); } } if (child instanceof TextImpl) { logger.debug("Text='" + ((Text) child).toString() + "'"); try { EditorInstruction values = new EditorInstruction(); values.setAnything(null); values.setChild(null); values.setCodeContext(documentType); values.setCurrent(dbParent); values.setParent(dbParent); values.setCharacterDataNode((TextImpl) child); values.setTransformer(this); editor = EditorFactory.getTextEditor(); logger.debug(indent + " Vor der Textbearbeitung: " + child + ".\n"); values = editor.edit(values); logger.debug(indent + " Nach der Textbearbeitung: " + child + ".\n"); dbParent = values.getParent(); if (dbParent == null) { throw new NullPointerException("[Node #" + index + "]" + "DocBook parent element for element '" + child + "' is null!"); } dbElement = values.getCurrent(); doTraverse = values.doTraverse(); } catch (EditorException oops) { logger.debug(indent + "EditorException " + oops.getMessage()); } } if (child instanceof HtmlElement) { try { htmlElement = (HtmlElement) child; if (!checkCodeContext(htmlElement)) { logger.warn(indent + " Element is not allowed in this code context(" + documentType + ") '" + htmlElement + "'!"); continue; } editor = EditorFactory.getChildEditor(htmlElement); logger.debug("Setting editor values."); EditorInstruction values = new EditorInstruction(); values.setAnything(anything); values.setChild((HtmlElement) child); values.setCodeContext(documentType); values.setCurrent(dbParent); values.setParent(dbParent); values.setCharacterDataNode(null); values.setTransformer(this); logger.debug(indent + " Vor der Transformation: " + child + ".\n" + "Editor " + editor + "\n" + values); if (child.getTransformInstruction() != null) { TransformInstruction transformInstruction = child .getTransformInstruction(); DocBookElement parent = values.getParent(); parent.appendChild(transformInstruction .getReplacement()); Node replacement = transformInstruction .getReplacement(); Node newParent = transformInstruction.getNewParent(); if (replacement != null && replacement instanceof DocBookElement) { values.setCurrent((DocBookElement) replacement); } if (newParent != null && newParent instanceof DocBookElement) { values.setParent((DocBookElement) newParent); } } else { if (beforeEdit(values)) { values = editor.edit(values); afterEdit(values); } } dbElement = values.getCurrent(); // editor.copyCommonAttributes((HtmlElement) child, // dbElement); logger.debug(indent + " Nach der Transformation: " + child + ".\n" + "Editor " + editor + "\n" + values); doTraverse = values.doTraverse(); doIgnore = values.doIgnore(); dbParent = values.getParent(); if (dbParent == null) { throw new NullPointerException("[Node #" + index + "]" + "DocBook parent element for element " + child + " is null!"); } anything = values.getAnything(); } catch (EditorFactoryException oops) { logger.debug("EditorFactoryException " + oops.getMessage()); } catch (EditorException oops) { logger.debug("EditorException " + oops.getMessage()); } } if (doTraverse == true) { dbChildParent = edit(child, dbElement); logger.debug(indent + "\n<<<=================================================="); if (doIgnore == true) { dbParent = dbChildParent; } } else { int num = HtmlParser.computeSize(child); for (int i = 0; i < num; i++) { pm.fireProgressEvent(new ProgressEvent("Transforming node " + htmlNode.getNodeName())); } // System.out.println("doTraverse == false " + num + " "); } logger.debug(indent + "[Teilbaum bearbeitet] HTML: " + child + ", DocBook: " + dbElement + ", Vater: " + dbParent); dbElement.closed(); if (dbParent != dbOldParent) { logger.debug(indent + "Parent changed. Old parent was " + dbOldParent + ". New parent is " + dbParent + "."); dbelem = dbOldParent; logger.debug(indent + "Closing old parent " + dbelem + ". HTML Element is " + child + "."); dbelem.closed(); dbelem.isNew(false); dbOldParent = dbParent; } } if (indent.length() > 2) { indent = indent.substring(0, indent.length() - 2); } logger.debug(indent + "[Vaterknoten bearbeitet] HTML: " + child + ", Vaterknoten: " + dbParent); dbParent.closed(); dbParent.isNew(false); logger.debug("<- edit "); return dbParent; } private void afterEdit(EditorInstruction values) { } private boolean beforeEdit(EditorInstruction values) { listDetector.edit(values); SectionDetector sectionDetector = new SectionDetector(); HtmlElement htmlElement = values.getHtmlElement(); if (sectionDetector.isSection(htmlElement, getScript())) { sectionDetector.edit(values); return false; } return true; } private boolean isInstruction(CommentImpl comment) { if (comment == null) { return false; } String text = comment.getData(); if (text == null) { return false; } text = text.trim(); text = StringServices.cutPrefix(text, ""); text = text.trim(); if (text.startsWith("[:dbdoclet:]")) { return true; } return false; } private StringWriter serialize(NodeImpl elem) throws Exception { pm.nextStage(); pm.fireProgressEvent(new ProgressEvent("Serializing XML...", false)); NodeCountVisitor nodeCounter = new NodeCountVisitor(listeners); elem.traverse(nodeCounter.reset()); int nodeCount = nodeCounter.getNumberOfNodes(); if (elem instanceof Document) { nodeCount++; } pm.setProgressMaximum(nodeCount); NodeSerializer serializer = new NodeSerializer(); serializer.setProgressListeners(listeners); StringWriter buffer = new StringWriter(); serializer.write(elem, buffer); return buffer; } public void convert(InputStream in, OutputStream out) throws TrafoException { try { String encoding = script.getTextParameter( DbtConstants.SECTION_HTML, DbtConstants.PARAM_HTML_SOURCE_ENCODING, "UTF-8"); BufferedReader reader = new BufferedReader(new InputStreamReader( in, encoding)); StringWriter buffer = new StringWriter(); String line = reader.readLine(); while (line != null) { buffer.append(line); buffer.append(Sfv.LSEP); line = reader.readLine(); } reader.close(); String docBookCode = convert(buffer.toString()); encoding = script.getTextParameter(DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_ENCODING, "UTF-8"); PrintWriter writer = new PrintWriter(new OutputStreamWriter(out, encoding)); BufferedReader docBookReader = new BufferedReader(new StringReader( docBookCode)); line = docBookReader.readLine(); while (line != null) { writer.println(line); line = docBookReader.readLine(); } docBookReader.close(); writer.close(); } catch (IOException oops) { throw new TrafoException(oops); } } } src/java/org/dbdoclet/trafo/html/docbook/editor/0000755000000000000000000000000012124530526020620 5ustar rootrootsrc/java/org/dbdoclet/trafo/html/docbook/editor/BigEditor.java0000644000000000000000000000073412124530526023337 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class BigEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/CodeEditor.java0000644000000000000000000000222112124530526023501 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Literal; import org.dbdoclet.trafo.tag.html.Code; public class CodeEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Code code = (Code) getHtmlElement(); DocBookElement parent = getParent(); if (parent.isContentModel() == true) { setCurrent(dbfactory.createProgramListing()); parent.appendChild(getCurrent()); traverse(true); } else { Literal candidate = dbfactory.createLiteral(code.getTextContent()); candidate.setParentNode(parent); if (candidate.validate()) { parent.appendChild(candidate); } traverse(false); } return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/MapEditor.java0000644000000000000000000000073512124530526023354 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class MapEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/AbstractInlineEditor.java0000644000000000000000000000355612124530526025545 0ustar rootrootpackage org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Para; import org.dbdoclet.trafo.tag.docbook.Subscript; import org.dbdoclet.trafo.tag.docbook.Superscript; import org.dbdoclet.xiphias.dom.ElementImpl; import org.dbdoclet.xiphias.dom.NodeImpl; public abstract class AbstractInlineEditor extends Editor { private DocBookElement inlineElement; public DocBookElement getInlineElement() { return inlineElement; } public void setInlineElement(DocBookElement inlineElement) { this.inlineElement = inlineElement; } @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); setCurrent(inlineElement); copyCommonAttributes(getHtmlElement(), inlineElement); DocBookTagFactory dbfactory = values.getTagFactory(); traverse(true); DocBookElement parent = getParent(); if (parent.isContentModel()) { Para para = dbfactory.createPara(); para.setFormatType(ElementImpl.FORMAT_INLINE); parent.appendChild(para); setParent(para); parent = para; } if (parent instanceof Subscript || parent instanceof Superscript) { NodeImpl ancestor = parent.getTrafoParentNode(); if (ancestor != null) { ancestor.replaceChild(inlineElement, parent); inlineElement.appendChild(parent); setCurrent(parent); return finalizeValues(); } } if (inlineElement.isValidParent(parent) == false) { Para candidate = dbfactory.createPara(); candidate.setParentNode(parent); if (candidate.validate()) { setParent(candidate); parent.appendChild(candidate); candidate.appendChild(getCurrent()); } } else { getCurrent().setParentNode(parent); parent.appendChild(getCurrent()); } return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/ImgEditor.java0000644000000000000000000002155312124530526023354 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.service.FileServices; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.param.Param; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Emphasis; import org.dbdoclet.trafo.tag.docbook.Entry; import org.dbdoclet.trafo.tag.docbook.ImageData; import org.dbdoclet.trafo.tag.docbook.ImageObject; import org.dbdoclet.trafo.tag.docbook.Link; import org.dbdoclet.trafo.tag.docbook.Para; import org.dbdoclet.trafo.tag.docbook.Screen; import org.dbdoclet.trafo.tag.docbook.Term; import org.dbdoclet.trafo.tag.docbook.ULink; import org.dbdoclet.trafo.tag.html.Img; import org.dbdoclet.xiphias.ImageServices; public class ImgEditor extends Editor { private static Log logger = LogFactory.getLog(ImgEditor.class); private static HashMap validFormatMap; static { validFormatMap = new HashMap(); validFormatMap.put("BASE64", "BASE64"); validFormatMap.put("BMP", "BMP"); validFormatMap.put("CGM-BINARY", "CGM-BINARY"); validFormatMap.put("CGM-CHAR", "CGM-CHAR"); validFormatMap.put("CGM-CLEAR", "CGM-CLEAR"); validFormatMap.put("DITROFF", "DITROFF"); validFormatMap.put("DVI", "DVI"); validFormatMap.put("EPS", "EPS"); validFormatMap.put("EQN", "EQN"); validFormatMap.put("FAX", "FAX"); validFormatMap.put("GIF", "GIF"); validFormatMap.put("GIF87a", "GIF87a"); validFormatMap.put("GIF89a", "GIF89a"); validFormatMap.put("IGES", "IGES"); validFormatMap.put("JPEG", "JPEG"); validFormatMap.put("JPG", "JPG"); validFormatMap.put("linespecific", "linespecific"); validFormatMap.put("PCX", "PCX"); validFormatMap.put("PIC", "PIC"); validFormatMap.put("PNG", "PNG"); validFormatMap.put("PS", "PS"); validFormatMap.put("SGML", "SGML"); validFormatMap.put("SVG", "SVG"); validFormatMap.put("TBL", "TBL"); validFormatMap.put("TEX", "TEX"); validFormatMap.put("TIFF", "TIFF"); validFormatMap.put("WMF", "WMF"); validFormatMap.put("WPG", "WPG"); } public void createFoImageData(DocBookElement parent, DocBookTagFactory dbfactory, List imageDataFormats, Img img, File file) throws IOException { String fileRef = FileServices.normalizePath(file.getPath()); fileRef = FileServices.getFileBase(fileRef); if (FileServices.isAbsolutePath(fileRef)) { fileRef = FileServices.normalizePath(fileRef); if (fileRef.startsWith("/")) { fileRef = "file://" + fileRef; } else { fileRef = "file:///" + fileRef; } } int index = 0; for (String format : imageDataFormats) { ImageObject image = dbfactory.createImageObject(); if (index == 0) { image.setRole("fo"); } else { image.setRole("fo-" + format.toLowerCase()); } String align = img.getAlign(); ImageData data = dbfactory.createImageData(); data.setScaleFit(true); data.setWidth("100%"); data.setContentDepth("100%"); data.setFormat(format); if (align != null && align.length() > 0) { data.setAlign(validateAlign(align)); } data.setFileRef(fileRef + "." + format.toLowerCase()); image.appendChild(data); parent.appendChild(image); index++; } } public void createHtmlImageData(DocBookElement parent, DocBookTagFactory dbfactory, List imageDataFormats, Img img, File file) throws IOException { String fileRef = FileServices.normalizePath(file.getPath()); logger.debug("Parameter fileRef=" + fileRef); if (FileServices.isAbsolutePath(fileRef)) { fileRef = FileServices.normalizePath(fileRef); if (fileRef.startsWith("/")) { fileRef = "file://" + fileRef; } else { fileRef = "file:///" + fileRef; } } fileRef = FileServices.getFileBase(fileRef); int index = 0; for (String format : imageDataFormats) { String width = img.getWidth(); String height = img.getHeight(); String align = img.getAlign(); ImageObject image = dbfactory.createImageObject(); if (index == 0) { image.setRole("html"); } else { image.setRole("html-" + format.toLowerCase()); } ImageData data = dbfactory.createImageData(); data.setScaleFit(true); if (width != null && width.length() > 0) { data.setContentWidth(width); } if (height != null && height.length() > 0) { data.setContentDepth(height); } if (file.exists() && format.equalsIgnoreCase("BASE64")) { String fileName = FileServices.getFileBase(file) + ".base64"; FileServices.writeFromString(new File(fileName), ImageServices.toXml(file)); } data.setFormat(format); if (align != null && align.length() > 0) { data.setAlign(validateAlign(align)); } String attr = fileRef + "." + format.toLowerCase(); logger.debug("XML attribute fileRef=" + attr); data.setFileRef(attr); image.appendChild(data); parent.appendChild(image); index++; } } public ArrayList createImageDataFormatList( ArrayList paramList, String src) { ArrayList formatList = new ArrayList(); for (String param : paramList) { if (param == null) { continue; } if (formatList.contains(param.toUpperCase()) == false) { formatList.add(param.toUpperCase()); } } if (src != null) { String value = FileServices.getExtension(src); if (value != null && value.trim().length() > 0 && formatList.contains(value.toUpperCase()) == false) { formatList.add(0, value.toUpperCase()); } } return formatList; } @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Script script = getScript(); Img img = (Img) getHtmlElement(); Boolean useAbsoluteImagePath = script.isParameterOn( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_USE_ABSOLUTE_IMAGE_PATH, false); logger.debug("Parameter use-absolute-image-path is set to " + useAbsoluteImagePath); ArrayList imageDataFormats = createImageDataFormatList( script.getTextParameterList(DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_IMAGEDATA_FORMATS, new ArrayList()), img.getSrc()); String imagePath = "./img"; Param param = script .getVariable(DbtConstants.PARAM_IMAGE_PATH); if (param != null) { imagePath = param.getValueAsText(); } else { imagePath = script.getTextParameter(DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_IMAGE_PATH, ""); } logger.debug("Configuration property imagePath is set to " + imagePath); String src = img.getSrc(); logger.debug("Attribute src has a value of " + src); if ((src == null) || (src.length() == 0)) { return finalizeValues(); } if (imagePath != null && imagePath.length() > 0 && FileServices.isAbsolutePath(src) == false) { src = FileServices.appendFileName(imagePath, src); } validateSrc(src); DocBookElement media; DocBookElement parent = getParent(); if (parent instanceof Emphasis || parent instanceof Entry || parent instanceof Para || parent instanceof Screen || parent instanceof Term || parent instanceof ULink || parent instanceof Link) { media = dbfactory.createInlineMediaObject(); parent.appendChild(media); media.setParentNode(getCurrent()); setAnything(media.getParentNode()); } else { DocBookElement figure; String title = img.getTitle(); if ((title != null) && (title.length() > 0)) { figure = dbfactory.createFigure(title); } else { figure = dbfactory.createInformalFigure(); } figure.setParentNode(parent); if (figure.validate()) { parent.appendChild(figure); media = dbfactory.createMediaObject(); figure.appendChild(media); setAnything(figure); } else { traverse(true); return finalizeValues(); } } traverse(false); setCurrent(parent); File file = new File(src); if (useAbsoluteImagePath) { file = file.getAbsoluteFile(); } try { createHtmlImageData(media, dbfactory, imageDataFormats, img, file); createFoImageData(media, dbfactory, imageDataFormats, img, file); } catch (IOException oops) { throw new EditorException(oops); } return finalizeValues(); } public String validateFormat(String format) { if (format == null) { throw new IllegalArgumentException("Parameter format is null!"); } format = format.toUpperCase(); if (validFormatMap.get(format) != null) { return format; } else { return "JPG"; } } } src/java/org/dbdoclet/trafo/html/docbook/editor/EditorException.java0000644000000000000000000000233312124530526024571 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import java.io.PrintStream; import java.io.PrintWriter; public class EditorException extends Exception { private static final long serialVersionUID = 1L; private Exception cause; public EditorException(Exception oops) { super(oops.getClass().getName() + ": " + oops.getMessage()); cause = oops; } public EditorException(String msg) { super(msg); } @Override public void printStackTrace() { if (cause != null) { System.err.println("\nCause:"); cause.printStackTrace(); System.err.println("-------"); } super.printStackTrace(); } @Override public void printStackTrace(PrintStream stream) { printStackTrace(new PrintWriter(stream)); } @Override public void printStackTrace(PrintWriter writer) { if (writer == null) { return; } if (cause != null) { writer.println("\nCause:"); cause.printStackTrace(writer); writer.println("-------"); } super.printStackTrace(writer); } } src/java/org/dbdoclet/trafo/html/docbook/editor/DivEditor.java0000644000000000000000000001173312124530526023361 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.html.docbook.SectionDetector; import org.dbdoclet.trafo.tag.docbook.Anchor; import org.dbdoclet.trafo.tag.docbook.Book; import org.dbdoclet.trafo.tag.docbook.Chapter; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Para; import org.dbdoclet.trafo.tag.docbook.Part; import org.dbdoclet.trafo.tag.docbook.RefEntry; import org.dbdoclet.trafo.tag.docbook.RefNameDiv; import org.dbdoclet.trafo.tag.docbook.RefSection; import org.dbdoclet.trafo.tag.docbook.Reference; import org.dbdoclet.trafo.tag.html.Div; public class DivEditor extends Editor { private static final int TIP = 1; private static final int NOTE = 2; private static final int WARNING = 3; private static final int CAUTION = 4; private static final int IMPORTANT = 5; private void addAdmonition(DocBookTagFactory dbfactory, int type, String title) { DocBookElement admon; DocBookElement parent = getParent(); switch (type) { case CAUTION: admon = dbfactory.createCaution(); break; case IMPORTANT: admon = dbfactory.createImportant(); break; case NOTE: admon = dbfactory.createNote(); break; case TIP: admon = dbfactory.createTip(); break; case WARNING: admon = dbfactory.createWarning(); break; default: admon = null; break; } if (admon == null) { return; } if (title != null && title.length() > 0) { admon.appendChild(dbfactory.createTitle(title)); } Para para = dbfactory.createPara(); admon.appendChild(para); parent.appendChild(admon); setCurrent(para); } @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); Div div = (Div) getHtmlElement(); SectionDetector sectionDetector = new SectionDetector(); if (sectionDetector.isSection(div, getScript())) { sectionDetector.edit(values); setValues(values); return finalizeValues(); } DocBookTagFactory dbfactory = values.getTagFactory(); String type = null; String id = div.getId(); String clazz = div.getCssClass(); String title = div.getTitle(); DocBookElement parent = getParent(); traverse(true); ignore(false); if ((id != null) && (id.length() > 0)) { type = id.toLowerCase(); } if ((type == null) && (clazz != null) && (clazz.length() > 0)) { type = clazz.toLowerCase(); } if ((type != null) && (type.length() > 0)) { if (type.startsWith("example")) { if ((title != null) && (title.length() > 0)) { setCurrent(dbfactory.createExample(title)); } else { setCurrent(dbfactory.createInformalExample()); } parent.appendChild(getCurrent()); getCurrent().setParentNode(parent); return finalizeValues(); } if (type.startsWith("formalpara")) { if ((title != null) && (title.length() > 0)) { setCurrent(dbfactory.createFormalPara(title)); } else { setCurrent(dbfactory.createFormalPara()); } parent.appendChild(getCurrent()); return finalizeValues(); } if (type.startsWith("caution")) { addAdmonition(dbfactory, CAUTION, title); return finalizeValues(); } if (type.startsWith("important")) { addAdmonition(dbfactory, IMPORTANT, title); return finalizeValues(); } if (type.startsWith("note")) { addAdmonition(dbfactory, NOTE, title); return finalizeValues(); } if (type.startsWith("tip") || type.startsWith("hint")) { addAdmonition(dbfactory, TIP, title); return finalizeValues(); } if (type.startsWith("warning")) { addAdmonition(dbfactory, WARNING, title); return finalizeValues(); } } if (parent instanceof Book || parent instanceof Part) { Chapter chapter = dbfactory.createChapter(AUTOMATICALLY_INSERTED); parent.appendChild(chapter); Para para = dbfactory.createPara(); chapter.appendChild(para); parent = para; setCurrent(para); } if (parent instanceof Reference) { RefEntry refEntry = dbfactory.createRefEntry(); parent.appendChild(refEntry); RefNameDiv refNameDiv = dbfactory.createRefNameDiv(); refNameDiv.appendChild(dbfactory .createRefName(AUTOMATICALLY_INSERTED)); refNameDiv.appendChild(dbfactory.createRefPurpose()); refEntry.appendChild(refNameDiv); RefSection refSection = dbfactory .createRefSection(AUTOMATICALLY_INSERTED); refEntry.appendChild(refSection); Para para = dbfactory.createPara(); refSection.appendChild(para); parent = para; setCurrent(para); } if (id != null) { Anchor anchor = dbfactory.createAnchor(); anchor.validate(); copyCommonAttributes(getHtmlElement(), anchor); parent.appendChild(anchor); } traverse(true); ignore(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/TrEditor.java0000644000000000000000000000354012124530526023221 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Row; import org.dbdoclet.trafo.tag.html.Tr; public class TrEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Script script = getTransformer().getScript(); boolean decomposeTables = script.isParameterOn( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_DECOMPOSE_TABLES, DbtConstants.DEFAULT_DECOMPOSE_TABLES); if (decomposeTables || getHtmlElement().isMute()) { traverse(true); return finalizeValues(); } Tr tr = (Tr) values.getHtmlElement(); Integer height = tr.getHeight(); if (height != null && height == 0) { traverse(false); return finalizeValues(); } if (getParent() instanceof org.dbdoclet.trafo.tag.docbook.Tgroup || getParent() instanceof org.dbdoclet.trafo.tag.docbook.EntryTbl) { setCurrent(dbfactory.createTbody()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); setParent(getCurrent()); } Row row = dbfactory.createRow(); copyCommonAttributes(getHtmlElement(), row); setCurrent(row); getParent().appendChild(getCurrent()); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/TitleEditor.java0000644000000000000000000000073712124530526023722 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class TitleEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); traverse(false); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/IEditor.java0000644000000000000000000000136212124530526023024 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.tag.docbook.Emphasis; public class IEditor extends EmEditor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { EditorInstruction evo = super.edit(values); Emphasis emphasis = getEmphasis(); if (emphasis != null) { emphasis.setRole(DbtConstants.DEFAULT_EMPHASIS_ROLE_ITALIC); } return evo; } } src/java/org/dbdoclet/trafo/html/docbook/editor/StyleEditor.java0000644000000000000000000000073712124530526023741 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class StyleEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); traverse(false); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/DtEditor.java0000644000000000000000000000344612124530526023210 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Term; import org.dbdoclet.trafo.tag.docbook.VarListEntry; import org.dbdoclet.trafo.tag.docbook.VariableList; import org.dbdoclet.xiphias.dom.ElementImpl; public class DtEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { DocBookElement entry = null; setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); if (getParent() instanceof VariableList) { entry = dbfactory.createVarListEntry(); entry.setParentNode(getParent()); getParent().appendChild(entry); } else if (getParent() instanceof VarListEntry) { setParent((DocBookElement) getParent().getParentNode()); if ((getParent() != null) && getParent() instanceof VariableList) { getCurrent().appendChild( dbfactory.createListItem().appendChild( dbfactory.createPara().setFormatType( ElementImpl.FORMAT_INLINE))); entry = dbfactory.createVarListEntry(); entry.setParentNode(getParent()); getParent().appendChild(entry); } else { return finalizeValues(); } } else { return finalizeValues(); } Term term = dbfactory.createTerm(); copyCommonAttributes(getHtmlElement(), term); setCurrent(term); getCurrent().setParentNode(entry); entry.appendChild(getCurrent()); setParent(entry); setAnything(getCurrent()); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/DefaultEditor.java0000644000000000000000000000143412124530526024220 0ustar rootrootpackage org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.Anchor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.html.HtmlElement; public class DefaultEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { EditorInstruction evo = super.edit(values); HtmlElement html = getHtmlElement(); String htmlId = html.getId(); if (htmlId != null) { DocBookTagFactory dbf = evo.getTagFactory(); Anchor anchor = dbf.createAnchor(); copyCommonAttributes(html, anchor); getParent().appendChild(anchor); } return evo; } } src/java/org/dbdoclet/trafo/html/docbook/editor/AddressEditor.java0000644000000000000000000000131312124530526024215 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; public class AddressEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); setCurrent(dbfactory.createAddress()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/MenuEditor.java0000644000000000000000000000162712124530526023544 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; public class MenuEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); if (getParent().isList()) { setCurrent(dbfactory.createListItem()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); setParent(getCurrent()); } setCurrent(dbfactory.createItemizedList()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/StrongEditor.java0000644000000000000000000000213412124530526024106 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.html.HtmlElement; public class StrongEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); HtmlElement child = getHtmlElement(); DocBookElement parent = getParent(); DocBookElement candidate; candidate = dbfactory.createEmphasis(child.getTextContent()); candidate.setParentNode(parent); candidate.setRole(DbtConstants.DEFAULT_EMPHASIS_ROLE_BOLD); if (candidate.validate()) { parent.appendChild(candidate); setCurrent(candidate); } traverse(false); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/HrEditor.java0000644000000000000000000000073512124530526023210 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class HrEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); traverse(false); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/H5Editor.java0000644000000000000000000000046212124530526023110 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class H5Editor extends HeadingEditor { } src/java/org/dbdoclet/trafo/html/docbook/editor/UEditor.java0000644000000000000000000000137112124530526023040 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.tag.docbook.Emphasis; public class UEditor extends EmEditor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { EditorInstruction evo = super.edit(values); Emphasis emphasis = getEmphasis(); if (emphasis != null) { emphasis.setRole(DbtConstants.DEFAULT_EMPHASIS_ROLE_UNDERLINE); } return evo; } } src/java/org/dbdoclet/trafo/html/docbook/editor/PEditor.java0000644000000000000000000000561512124530526023040 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.Book; import org.dbdoclet.trafo.tag.docbook.Chapter; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Entry; import org.dbdoclet.trafo.tag.docbook.Para; import org.dbdoclet.trafo.tag.docbook.Part; import org.dbdoclet.trafo.tag.docbook.RefEntry; import org.dbdoclet.trafo.tag.docbook.RefNameDiv; import org.dbdoclet.trafo.tag.docbook.RefSection; import org.dbdoclet.trafo.tag.docbook.Reference; import org.dbdoclet.trafo.tag.docbook.SectionElement; import org.dbdoclet.trafo.tag.html.P; import org.dbdoclet.xiphias.dom.ElementImpl; import org.dbdoclet.xiphias.dom.TextImpl; public class PEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); P p = (P) getHtmlElement(); DocBookElement parent = getParent(); Para candidate = dbfactory.createPara(); copyCommonAttributes(p, candidate); candidate.setParentNode(parent); if (parent instanceof Entry) { candidate.setFormatType(ElementImpl.FORMAT_INLINE); } if (candidate.validate()) { setCurrent(candidate); parent.appendChild(getCurrent()); } else { setCurrent(parent); if (parent instanceof Para && (parent.getParentNode() != null)) { parent.appendChild(new TextImpl(" ")); setParent((DocBookElement) parent.getParentNode()); } if (parent.isSection()) { if (parent instanceof Book || parent instanceof Part) { Chapter chapter = dbfactory .createChapter("Automatically inserted chapter"); parent.appendChild(chapter); setCurrent(candidate); chapter.appendChild(getCurrent()); } else if (parent instanceof Reference) { setCurrent(candidate); RefEntry refEntry = dbfactory.createRefEntry(); parent.appendChild(refEntry); RefNameDiv refNameDiv = dbfactory.createRefNameDiv(); refNameDiv.appendChild(dbfactory .createRefName(AUTOMATICALLY_INSERTED)); refNameDiv.appendChild(dbfactory.createRefPurpose()); refEntry.appendChild(refNameDiv); RefSection refSection = dbfactory.createRefSection(); refEntry.appendChild(refSection); refSection.appendChild(getCurrent()); } else { SectionElement sect = (SectionElement) parent; SectionElement firstSectionChild = sect .getFirstSectionChild(); if (firstSectionChild != null) { setCurrent(candidate); parent.insertBefore(getCurrent(), firstSectionChild); } } } } traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/H4Editor.java0000644000000000000000000000046212124530526023107 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class H4Editor extends HeadingEditor { } src/java/org/dbdoclet/trafo/html/docbook/editor/HeadingEditor.java0000644000000000000000000000330012124530526024165 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import java.util.HashMap; import org.dbdoclet.option.OptionException; import org.dbdoclet.trafo.html.docbook.SectionDetector; import org.dbdoclet.trafo.tag.html.HtmlDocument; import org.dbdoclet.trafo.tag.html.HtmlElement; public class HeadingEditor extends Editor { public static HashMap> validHtmlParentPathMap; static { validHtmlParentPathMap = new HashMap>(); validHtmlParentPathMap.put(new HtmlDocument().getNodeName(), HtmlElement.getAttributeMap()); validHtmlParentPathMap.put(org.dbdoclet.trafo.tag.html.Html.getTag(), HtmlElement.getAttributeMap()); validHtmlParentPathMap.put(org.dbdoclet.trafo.tag.html.Body.getTag(), HtmlElement.getAttributeMap()); validHtmlParentPathMap.put(org.dbdoclet.trafo.tag.html.Center.getTag(), HtmlElement.getAttributeMap()); validHtmlParentPathMap.put(org.dbdoclet.trafo.tag.html.Div.getTag(), HtmlElement.getAttributeMap()); validHtmlParentPathMap.put(org.dbdoclet.trafo.tag.html.A.getTag(), HtmlElement.getAttributeMap()); } // private HeaderElement header; @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { try { SectionDetector sectionManager = new SectionDetector(); sectionManager.edit(values); setValues(super.edit(values)); return finalizeValues(); } catch (OptionException oops) { throw new EditorException(oops); } // end of try-catch } } src/java/org/dbdoclet/trafo/html/docbook/editor/HtmlEditor.java0000644000000000000000000000231212124530526023534 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.Article; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.html.HtmlElement; public class HtmlEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Article article = dbfactory.createArticle(); HtmlElement child = getHtmlElement(); String lang = child.getAttribute("lang"); if (lang == null) { lang = child.getAttribute("xml:lang"); } if (lang != null) { article.setAttribute("lang", lang.toLowerCase()); } setCurrent(article); traverse(true); article.setAttribute("xmlns", "http://docbook.org/ns/docbook"); article.setAttribute("version", "5.0"); if (lang != null) { article.setAttribute("xml:lang", lang.toLowerCase()); } getParent().appendChild(getCurrent()); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/DdEditor.java0000644000000000000000000000335512124530526023167 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.ListItem; import org.dbdoclet.trafo.tag.docbook.Para; import org.dbdoclet.trafo.tag.docbook.Term; import org.dbdoclet.trafo.tag.docbook.VarListEntry; import org.dbdoclet.trafo.tag.docbook.VariableList; public class DdEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { DocBookElement list = null; setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); // Try to detect two sequenced dd tags. if (getParent() instanceof VariableList) { if (getAnything() instanceof ListItem) { list = (ListItem) getAnything(); } else { VarListEntry entry = dbfactory.createVarListEntry(); getParent().appendChild(entry); Term term = dbfactory.createTerm(); entry.appendChild(term); list = dbfactory.createListItem(); entry.appendChild(list); } } else if (getParent() instanceof VarListEntry) { list = dbfactory.createListItem(); getParent().appendChild(list); setAnything(list); setParent((DocBookElement) getParent().getParentNode()); } // end of else if (list == null) { return finalizeValues(); } // end of else Para para = dbfactory.createPara(); copyCommonAttributes(getHtmlElement(), para); setCurrent(para); list.appendChild(getCurrent()); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/DirEditor.java0000644000000000000000000000210412124530526023345 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.xiphias.dom.NodeListImpl; public class DirEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); NodeListImpl children = getHtmlElement().getTrafoChildNodes(); if (children.size() == 0) { return finalizeValues(); } if (getParent().isList()) { setCurrent(dbfactory.createListItem()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); setParent(getCurrent()); } setCurrent(dbfactory.createItemizedList()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/DlEditor.java0000644000000000000000000000236512124530526023177 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.xiphias.dom.NodeListImpl; public class DlEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); org.dbdoclet.trafo.tag.html.Dl dl = (org.dbdoclet.trafo.tag.html.Dl) getHtmlElement(); String title = dl.getTitle(); NodeListImpl children = dl.getTrafoChildNodes(); if (children.size() == 0) { return finalizeValues(); } if (getParent().isList()) { setCurrent(dbfactory.createListItem()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); setParent(getCurrent()); } setCurrent(dbfactory.createVariableList()); if ((title != null) && (title.length() > 0)) { getCurrent().appendChild(dbfactory.createTitle(title)); } getParent().appendChild(getCurrent()); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/FontEditor.java0000644000000000000000000000260012124530526023536 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Emphasis; import org.dbdoclet.trafo.tag.docbook.SimPara; import org.dbdoclet.trafo.tag.html.Font; public class FontEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); traverse(true); Font font = (Font) values.getHtmlElement(); String color = font.getAttribute("color"); if (color == null || color.trim().length() == 0) { return finalizeValues(); } Emphasis emphasis = dbfactory.createEmphasis(); emphasis.setRole("color"); emphasis.setCondition(color); setCurrent(emphasis); if (emphasis.isValidParent(getParent()) == false) { SimPara candidate = dbfactory.createSimPara(); candidate.setParentNode(getParent()); if (candidate.validate()) { getParent().appendChild(candidate); candidate.appendChild(getCurrent()); } } else { getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); } return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/EmEditor.java0000644000000000000000000000145712124530526023202 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Emphasis; public class EmEditor extends AbstractInlineEditor { private Emphasis emphasis; @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { DocBookTagFactory dbfactory = values.getTagFactory(); emphasis = dbfactory.createEmphasis(); setInlineElement(emphasis); return super.edit(values); } public Emphasis getEmphasis() { return emphasis; } } src/java/org/dbdoclet/trafo/html/docbook/editor/Editor.java0000644000000000000000000002061212124530526022712 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.service.StringServices; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.html.docbook.DocBookTransformer; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.AttributeAlign; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.DocBookVersion; import org.dbdoclet.trafo.tag.docbook.Para; import org.dbdoclet.trafo.tag.docbook.Row; import org.dbdoclet.trafo.tag.html.HtmlElement; import org.dbdoclet.trafo.tag.html.Table; import org.dbdoclet.trafo.tag.html.Td; import org.dbdoclet.trafo.tag.html.Th; import org.dbdoclet.xiphias.dom.CharacterDataImpl; import org.dbdoclet.xiphias.dom.TextImpl; public class Editor { protected static final String FSEP = System.getProperty("file.separator"); protected static final Log logger = LogFactory.getLog(Editor.class); protected static final String AUTOMATICALLY_INSERTED = "Automatically inserted"; private DocBookElement current; private DocBookElement parent; private HtmlElement child; private Object anything; private DocBookTransformer transformer; private CharacterDataImpl characterDataNode; private boolean doIgnore; private boolean doTraverse; private DocBookTransformer.DocumentElementType codeContext; public void copyCommonAttributes(HtmlElement html, DocBookElement dbk) { logger.debug("Copy common attributes from " + html + " to " + dbk); if (html == null || dbk == null) { return; } String htmlId = html.getId(); if (htmlId != null) { dbk.setId(transformer.createUniqueId(htmlId)); } Script script = getScript(); if (script.isParameterOn(DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_CREATE_CONDITION_ATTRIBUTE, false)) { StringBuilder buffer = new StringBuilder(); String htmlClass = html.getCssClass(); if (htmlClass != null) { buffer.append(htmlClass); buffer.append(","); } String htmlTitle = html.getTitle(); if (htmlTitle != null) { buffer.append(htmlTitle); buffer.append(","); } String condition = buffer.toString(); if (condition.trim().length() > 0) { condition = StringServices.cutSuffix(condition, ","); dbk.setCondition(condition); } } if (script.isParameterOn(DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_CREATE_REMAP_ATTRIBUTE, false)) { createRemapAttribute(html, dbk); dbk.setLine(html.getLine()); dbk.setColumn(html.getColumn()); } dbk.setUserData("html", html, null); } private void createRemapAttribute(HtmlElement html, DocBookElement dbk) { String remap = String.format("%s:%d:%d", html.getTagName(), html.getLine(), html.getColumn()); dbk.setRemap(remap); } public EditorInstruction edit(EditorInstruction vo) throws EditorException { if (vo == null) { throw new IllegalArgumentException("Variable vo is null!"); } setValues(vo); DocBookTagFactory dbfactory = transformer.getTagFactory(); if (parent instanceof Row) { if ((child != null) && !(child instanceof Td) && !(child instanceof Th) && !(child instanceof Table)) { Para para = dbfactory.createPara(); parent.appendChild(dbfactory.createEntry().appendChild(para)); parent = para; current = parent; } if (characterDataNode != null && characterDataNode instanceof TextImpl) { Para para = dbfactory.createPara(); parent.appendChild(dbfactory.createEntry().appendChild(para)); parent = para; current = parent; } } return finalizeValues(); } public Object getAnything() { return anything; } public CharacterDataImpl getCharacterDataNode() { return characterDataNode; } public DocBookTransformer.DocumentElementType getCodeContext() { return codeContext; } public DocBookElement getCurrent() { return current; } public HtmlElement getHtmlElement() { return child; } public DocBookElement getParent() { return parent; } public DocBookTagFactory getTagFactory() { if (transformer == null) { throw new IllegalStateException( "The field \"transformer\" must not be null!"); } return transformer.getTagFactory(); } public Script getScript() { return transformer.getScript(); } public DocBookTransformer getTransformer() { return transformer; } public boolean ignore() { return doIgnore; } public void ignore(boolean newDoIgnore) { this.doIgnore = newDoIgnore; } public boolean isDocBook5() { DocBookVersion docBookVersion = getDocBookVersion(); if (docBookVersion == DocBookVersion.V5_0) { return true; } else { return false; } } public boolean isDocBookVersion(DocBookVersion version) { if (version == null) { throw new IllegalArgumentException( "The argument version must not be null!"); } DocBookVersion docBookVersion = getDocBookVersion(); if (docBookVersion.equals(version)) { return true; } else { return false; } } public void setAnything(Object newAnything) { this.anything = newAnything; } public void setChild(HtmlElement newChild) { this.child = newChild; } public void setCodeContext( DocBookTransformer.DocumentElementType newCodeContext) { this.codeContext = newCodeContext; } public void setCurrent(DocBookElement newCurrent) { this.current = newCurrent; } public void setParent(DocBookElement newParent) { this.parent = newParent; } public void setTextNode(TextImpl newTextNode) { this.characterDataNode = newTextNode; } public void setTransformer(DocBookTransformer transformer) { this.transformer = transformer; } @Override public String toString() { String buffer = ""; buffer += ("editor[" + getClass().getName() + "]"); return buffer; } public boolean traverse() { return doTraverse; } public void traverse(boolean newDoTraverse) { this.doTraverse = newDoTraverse; } private DocBookVersion getDocBookVersion() { if (transformer == null) { throw new IllegalStateException( "The field transformer must not be null!"); } DocBookTagFactory dbfactory = transformer.getTagFactory(); if (dbfactory == null) { throw new IllegalStateException( "The field dbfactory must not be null!"); } DocBookVersion docBookVersion = dbfactory.getDocBookVersion(); if (docBookVersion == null) { throw new IllegalStateException( "The field docBookVersion must not be null!"); } return docBookVersion; } protected EditorInstruction finalizeValues() { EditorInstruction values = new EditorInstruction(); values.doIgnore(doIgnore); values.doTraverse(doTraverse); values.setAnything(anything); values.setChild(child); values.setCodeContext(codeContext); values.setCurrent(current); values.setParent(parent); values.setCharacterDataNode(characterDataNode); values.setTransformer(transformer); return values; } public void setValues(EditorInstruction values) { anything = values.getAnything(); child = values.getHtmlElement(); codeContext = values.getCodeContext(); current = values.getCurrent(); doIgnore = values.doIgnore(); doTraverse = values.doTraverse(); parent = values.getParent(); characterDataNode = values.getCharacterDataNode(); transformer = values.getTransformer(); } protected void transferId(HtmlElement html, DocBookElement db) { if (html == null) { throw new IllegalArgumentException( "The argument html must not be null!"); } if (db == null) { throw new IllegalArgumentException( "The argument db must not be null!"); } String id = html.getId(); if (id != null && id.length() > 0) { db.setId(id); } } protected String validateAlign(String align) { if (align == null) { return align; } align = align.toLowerCase(); try { AttributeAlign.valueOf(align.toUpperCase()); } catch (IllegalArgumentException oops) { return AttributeAlign.CENTER.toString().toLowerCase(); } return align; } protected String validateSrc(String src) { if (src == null) { throw new IllegalArgumentException("Parameter src is null!"); } if (src.startsWith("http:") && (src.indexOf("?") > 0)) { src = src.substring(0, src.indexOf("?")); } return src; } } src/java/org/dbdoclet/trafo/html/docbook/editor/OlEditor.java0000644000000000000000000000203012124530526023177 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.xiphias.dom.NodeListImpl; public class OlEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); NodeListImpl children = getHtmlElement().getTrafoChildNodes(); if (children.size() == 0) { return finalizeValues(); } if (getParent().isList()) { setCurrent(dbfactory.createListItem()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); setParent(getCurrent()); } setCurrent(dbfactory.createOrderedList()); getParent().appendChild(getCurrent()); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/TtEditor.java0000644000000000000000000000130112124530526023214 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Literal; public class TtEditor extends AbstractInlineEditor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { DocBookTagFactory dbfactory = values.getTagFactory(); Literal literal = dbfactory.createLiteral(); setInlineElement(literal); return super.edit(values); } } src/java/org/dbdoclet/trafo/html/docbook/editor/BlockquoteEditor.java0000644000000000000000000000200512124530526024737 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.BlockQuote; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Para; public class BlockquoteEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); BlockQuote blockquote = dbfactory.createBlockQuote(); DocBookElement parent = getParent(); parent.appendChild(blockquote); blockquote.setParentNode(parent); Para para = dbfactory.createPara(); blockquote.appendChild(para); para.setParentNode(blockquote); setCurrent(para); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/SpanEditor.java0000644000000000000000000000541412124530526023537 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.service.StringServices; import org.dbdoclet.trafo.html.docbook.DocBookTransformer; import org.dbdoclet.trafo.tag.docbook.Anchor; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.IndexTerm; import org.dbdoclet.trafo.tag.docbook.Primary; import org.dbdoclet.trafo.tag.docbook.Secondary; import org.dbdoclet.trafo.tag.html.Span; public class SpanEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Span span = (Span) getHtmlElement(); DocBookElement parent = getParent(); String title = span.getTitle(); String border1 = ":primary="; String border2 = ":secondary="; if ((title != null) && title.startsWith("indexterm:")) { String buffer = StringServices.cutPrefix(title, "indexterm"); if (buffer.startsWith(border1)) { String primaryText = StringServices.cutPrefix(buffer, border1); String secondaryText = null; int indexSecondary = primaryText.indexOf(border2); if (indexSecondary != -1) { int index = indexSecondary + border2.length(); if (index < primaryText.length()) { secondaryText = primaryText.substring(indexSecondary + border2.length()); } primaryText = primaryText.substring(0, indexSecondary); } IndexTerm indexTerm = dbfactory.createIndexTerm(); indexTerm.setParentNode(getParent()); Primary primary = dbfactory.createPrimary(primaryText); indexTerm.appendChild(primary); if ((secondaryText != null) && (secondaryText.length() > 0)) { Secondary secondary = dbfactory.createSecondary(secondaryText); indexTerm.appendChild(secondary); } parent.appendChild(indexTerm); } } String id = span.getId(); if (id != null) { DocBookTransformer transformer = getTransformer(); Anchor anchor = dbfactory.createAnchor(); anchor.setId(transformer.createUniqueId(id)); parent.appendChild(anchor); } traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/CommentEditor.java0000644000000000000000000000331412124530526024235 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.service.StringServices; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.xiphias.XmlServices; import org.dbdoclet.xiphias.dom.CharacterDataImpl; import org.dbdoclet.xiphias.dom.CommentImpl; public class CommentEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { try { setValues(super.edit(values)); DocBookElement parent = getParent(); getCurrent(); CharacterDataImpl node = getCharacterDataNode(); if (node instanceof CommentImpl == false) { return finalizeValues(); } CommentImpl comment = (CommentImpl) node; String text = comment.getData(); if (text == null) { return finalizeValues(); } text = text.trim(); text = StringServices.cutPrefix(text, ""); text = text.trim(); text = StringServices.cutPrefix(text, "[:dbdoclet:]"); text = text.trim(); if (text.startsWith("insert ")) { text = StringServices.cutPrefix(text, "insert"); text = text.trim(); text = XmlServices.textToXml(text); text = StringServices.replace(text, "(", "<"); text = StringServices.replace(text, ")", ">"); text = StringServices.replace(text, "<<", "("); text = StringServices.replace(text, ">>", ")"); parent.appendChild(text, false); } return finalizeValues(); } catch (Exception oops) { throw new EditorException(oops); } } } src/java/org/dbdoclet/trafo/html/docbook/editor/BEditor.java0000644000000000000000000000135012124530526023012 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.tag.docbook.Emphasis; public class BEditor extends EmEditor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { EditorInstruction evo = super.edit(values); Emphasis emphasis = getEmphasis(); if (emphasis != null) { emphasis.setRole(DbtConstants.DEFAULT_EMPHASIS_ROLE_BOLD); } return evo; } } src/java/org/dbdoclet/trafo/html/docbook/editor/EditorFactoryException.java0000644000000000000000000000066012124530526026122 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class EditorFactoryException extends Exception { private static final long serialVersionUID = 1L; public EditorFactoryException(String msg) { super(msg); } } src/java/org/dbdoclet/trafo/html/docbook/editor/TfootEditor.java0000644000000000000000000000211712124530526023726 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; public class TfootEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Script script = getTransformer().getScript(); boolean decomposeTables = script.isParameterOn( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_DECOMPOSE_TABLES, DbtConstants.DEFAULT_DECOMPOSE_TABLES); if (decomposeTables) { traverse(true); return finalizeValues(); } setCurrent(dbfactory.createTfoot()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/StrikeEditor.java0000644000000000000000000000222112124530526024070 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Emphasis; import org.dbdoclet.trafo.tag.docbook.SimPara; public class StrikeEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); traverse(true); Emphasis emphasis = dbfactory.createEmphasis(); emphasis.setRole("strikethrough"); setCurrent(emphasis); if (emphasis.isValidParent(getParent()) == false) { SimPara candidate = dbfactory.createSimPara(); candidate.setParentNode(getParent()); if (candidate.validate()) { getParent().appendChild(candidate); candidate.appendChild(getCurrent()); } } else { getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); } return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/TextEditor.java0000644000000000000000000000301012124530526023550 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Para; import org.dbdoclet.xiphias.dom.NodeImpl; public class TextEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { try { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); DocBookElement parent = getParent(); DocBookElement current = getCurrent(); Script script = getTransformer().getScript(); if (parent.isContentModel()) { if (getCharacterDataNode().getNodeType() == NodeImpl.TEXT_NODE) { Para para = dbfactory.createPara(); parent.appendChild(para); setParent(para); parent = para; setCurrent(para); current = para; } } String text = getCharacterDataNode().getData(); if (script.isParameterOn(DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_COLLAPSE_PROTECTED_SPACE, false)) { text = text.replace('\u00a0', ' '); } current.appendChild(text); return finalizeValues(); } catch (Exception oops) { throw new EditorException(oops); } } } src/java/org/dbdoclet/trafo/html/docbook/editor/TbodyEditor.java0000644000000000000000000000271112124530526023714 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Tbody; import org.dbdoclet.trafo.tag.docbook.Tgroup; public class TbodyEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Script script = getTransformer().getScript(); boolean decomposeTables = script.isParameterOn(DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_DECOMPOSE_TABLES, DbtConstants.DEFAULT_DECOMPOSE_TABLES); if (decomposeTables) { traverse(true); return finalizeValues(); } DocBookElement parent = getParent(); if (parent != null && parent instanceof Tgroup) { Tbody tbody = (Tbody) parent.getLastChild(Tbody.class); if (tbody == null) { setCurrent(dbfactory.createTbody()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); } else { setCurrent(tbody); } } traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/VarEditor.java0000644000000000000000000000232212124530526023361 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.BlockQuote; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; public class VarEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); DocBookElement parent = getParent(); if (parent instanceof BlockQuote) { setCurrent(dbfactory.createProgramListing()); traverse(true); } else { DocBookElement ancestor = parent; if (parent.isContentModel()) { ancestor = dbfactory.createPara(); parent.appendChild(ancestor); } // end of if () DocBookElement candidate = dbfactory.createLiteral(); candidate.setParentNode(ancestor); if (candidate.validate()) { setCurrent(candidate); ancestor.appendChild(candidate); } traverse(true); } return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/AEditor.java0000644000000000000000000000662612124530526023024 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.service.StringServices; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.html.docbook.DocBookTransformer; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.Anchor; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Link; import org.dbdoclet.trafo.tag.docbook.Para; import org.dbdoclet.trafo.tag.docbook.SimPara; import org.dbdoclet.trafo.tag.docbook.ULink; import org.dbdoclet.trafo.tag.docbook.XRef; import org.dbdoclet.trafo.tag.html.A; public class AEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Script script = getTransformer().getScript(); DocBookElement ancestor; DocBookElement parent = getParent(); DocBookTransformer transformer = getTransformer(); traverse(true); // The referncen of attribute parent must not be changed. Because of // this we // need a temporary variable to store a new parent for // different situations. ancestor = parent; if (parent.isContentModel()) { Para para = dbfactory.createPara(); parent.appendChild(para); ancestor = para; } A htmlA = (A) getHtmlElement(); String name = htmlA.getName(); String href = htmlA.getHref(); if (name != null && name.length() > 0) { Anchor anchor = dbfactory.createAnchor(); anchor.setId(transformer.createUniqueId(name)); boolean createXrefLabel = script.isParameterOn( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_CREATE_XREF_LABEL, true); if (createXrefLabel == true) { anchor.setXrefLabel(StringServices.replace( htmlA.getTextContent(), "\"", """)); } ancestor.appendChild(anchor); } else if (href != null && href.equals("#") == false && href.startsWith("#")) { String label = htmlA.getTextContent(); if ((label != null) && (label.length() > 0)) { Link link = dbfactory.createLink(transformer.getUniqueId(href)); link.setParentNode(ancestor); ancestor.appendChild(link); setCurrent(link); } else { XRef xref = dbfactory.createXRef(transformer.getUniqueId(href)); xref.setParentNode(ancestor); ancestor.appendChild(xref); setCurrent(ancestor); } } else { DocBookElement linkElement; if (isDocBook5()) { Link link = dbfactory.createLink(); link.setParentNode(ancestor); if (href != null) { link.setHref(href); } else { link.setHref(""); } linkElement = link; } else { ULink ulink = dbfactory.createULink(); ulink.setParentNode(ancestor); ulink.setUrl(href); linkElement = ulink; } if (linkElement.validate()) { setCurrent(linkElement); ancestor.appendChild(getCurrent()); transformer.addLink(linkElement); } else { SimPara candidate = dbfactory.createSimPara(); candidate.setParentNode(ancestor); if (candidate.validate()) { ancestor.appendChild(candidate); candidate.appendChild(ancestor); } } } return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/H1Editor.java0000644000000000000000000000045412124530526023105 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class H1Editor extends HeadingEditor { } src/java/org/dbdoclet/trafo/html/docbook/editor/TableEditor.java0000644000000000000000000001272612124530526023671 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import java.util.ArrayList; import java.util.Iterator; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Entry; import org.dbdoclet.trafo.tag.docbook.EntryTbl; import org.dbdoclet.trafo.tag.html.Td; import org.dbdoclet.xiphias.dom.NodeImpl; import org.w3c.dom.Element; public class TableEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Script script = getTransformer().getScript(); boolean decomposeTables = script.isParameterOn( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_DECOMPOSE_TABLES, DbtConstants.DEFAULT_DECOMPOSE_TABLES); if (decomposeTables || getHtmlElement().isMute()) { traverse(true); return finalizeValues(); } org.dbdoclet.trafo.tag.html.Table htmlTable = (org.dbdoclet.trafo.tag.html.Table) getHtmlElement(); NodeImpl htmlTableParent = htmlTable.getTrafoParentNode(); ArrayList htmlParentChildList = htmlTableParent .getChildElementList(); /* * Falls sich die HTML-Tabelle innerhalb einer sie umgebenden * Tabellenzelle liegt und diese mehrere Kindelemente ent */ NodeImpl tdParent = htmlTable.findParent(Td.class); if (tdParent != null) { htmlParentChildList = tdParent.getChildElementList(); } NodeImpl parent = getParent(); NodeImpl grandParent = parent.getTrafoParentNode(); if (parent instanceof org.dbdoclet.trafo.tag.docbook.Row) { if (htmlParentChildList.size() > 1) { Entry entry = dbfactory.createEntry(); parent.appendChild(entry); parent = entry; setParent(entry); setCurrent(entry); addTable(dbfactory, htmlTable, parent); } else { addSubtable(dbfactory, htmlTable, parent); } } else if ((grandParent != null) && parent instanceof org.dbdoclet.trafo.tag.docbook.Entry) { if (htmlParentChildList.size() > 1) { addTable(dbfactory, htmlTable, parent); } else { addSubtable(dbfactory, htmlTable, grandParent); } } else { addTable(dbfactory, htmlTable, parent); } return finalizeValues(); } private void addSubtable(DocBookTagFactory dbfactory, org.dbdoclet.trafo.tag.html.Table htmlTable, NodeImpl parent) { ArrayList colWidthList = htmlTable.getColWidths(); EntryTbl entrytbl = dbfactory.createEntryTbl(); entrytbl.setCols(htmlTable.getNumOfCols()); Iterator iterator = colWidthList.iterator(); int index = 1; String width; while (iterator.hasNext()) { width = iterator.next(); entrytbl.appendChild(dbfactory.createColspec("c" + index, width)); index++; } entrytbl.setParentNode(parent); parent.appendChild(entrytbl); setCurrent(entrytbl); traverse(true); } private void addTable(DocBookTagFactory dbfactory, org.dbdoclet.trafo.tag.html.Table htmlTable, NodeImpl parent) { ArrayList colWidthList = htmlTable.getColWidths(); org.dbdoclet.trafo.tag.docbook.Table table = null; String caption = htmlTable.getCaption(); if ((caption != null) && (caption.length() > 0)) { table = dbfactory.createTable(); } else { table = dbfactory.createInformalTable(); } copyCommonAttributes(htmlTable, table); Script script = getTransformer().getScript(); String tableStyle = script.getTextParameter( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_TABLE_STYLE, DbtConstants.DEFAULT_TABLE_STYLE); table.setFrame(tableStyle); org.dbdoclet.trafo.tag.docbook.Tgroup tgroup = dbfactory.createTgroup(); colWidthList = editWidths(colWidthList); Iterator iterator = colWidthList.iterator(); int index = 1; String width; while (iterator.hasNext()) { width = iterator.next(); tgroup.appendChild(dbfactory.createColspec("c" + index, width)); index++; } if (htmlTable.hasBorder() == false) { table.setFrame("none"); } else { table.setFrame("all"); } transferId(htmlTable, table); tgroup.setCols(colWidthList.size()); table.appendChild(tgroup); parent.appendChild(table); setCurrent(tgroup); traverse(true); } private ArrayList editWidths(ArrayList list) { int percent = 0; int i; int withoutWidth = 0; String width; Iterator iterator; int index = 0; iterator = list.iterator(); while (iterator.hasNext()) { width = iterator.next(); if ((width == null) || (width.length() == 0)) { withoutWidth++; continue; } width = width.trim(); if (width.endsWith("%") || width.matches("\\d+")) { width = width.substring(0, width.length() - 1); try { i = Integer.parseInt(width); } catch (NumberFormatException oops) { continue; } percent += i; list.set(index, String.valueOf(i) + "*"); } index++; } index = 0; if ((percent < 100) && (withoutWidth > 0)) { percent = (100 - percent) / withoutWidth; } else { percent = 10; } iterator = list.iterator(); while (iterator.hasNext()) { width = iterator.next(); if ((width == null) || (width.length() == 0)) { list.set(index, String.valueOf(percent) + "*"); } index++; } return list; } } src/java/org/dbdoclet/trafo/html/docbook/editor/EditorFactory.java0000644000000000000000000000304712124530526024245 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.html.HtmlElement; import org.dbdoclet.trafo.tag.javadoc.JavaDocElement; public class EditorFactory { static public Editor getChildEditor(HtmlElement child) throws EditorFactoryException { if (child == null) { throw new EditorFactoryException("Can't create editor for child null!"); } String str = child.getClass().getName(); if (child instanceof JavaDocElement) { str = "org.dbdoclet.trafo.html.docbook.editor.javadoc" + str.substring(str.lastIndexOf('.'), str.length()) + "Editor"; } else { str = "org.dbdoclet.trafo.html.docbook.editor" + str.substring(str.lastIndexOf('.'), str.length()) + "Editor"; } Class c; Object o; try { c = Class.forName(str); o = c.newInstance(); } catch (ClassNotFoundException oops) { return new DefaultEditor(); } catch (InstantiationException oops) { throw new EditorFactoryException("Can't create editor for " + child.getNodeName()); } catch (IllegalAccessException oops) { throw new EditorFactoryException("No permission to create editor for " + child.getNodeName()); } return (Editor) o; } public static Editor getCommentEditor() { return new CommentEditor(); } public static Editor getTextEditor() { return new TextEditor(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/CaptionEditor.java0000644000000000000000000000136412124530526024233 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Title; public class CaptionEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Title title = dbfactory.createTitle(); getParent().getTrafoParentNode().insertChild(0, title); setCurrent(title); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/BrEditor.java0000644000000000000000000000521212124530526023175 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.service.StringServices; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Para; import org.dbdoclet.trafo.tag.html.Br; import org.dbdoclet.xiphias.dom.TextImpl; import org.w3c.dom.Node; import org.w3c.dom.Text; public class BrEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); traverse(false); Br brElement = (Br) values.getHtmlElement(); Script script = getScript(); boolean detectTrappedBrEnabled = script.isParameterOn( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_DETECT_TRAPPED_BR, true); if (detectTrappedBrEnabled && isTrapped(brElement, values.getCurrent())) { return finalizeValues(); } if (getCurrent() instanceof Para) { DocBookElement parent = (DocBookElement) getCurrent() .getParentNode(); if (parent != null) { Para para = dbfactory.createPara(); parent.appendChild(para); setParent(para); setCurrent(para); } } else { getCurrent().appendChild(new TextImpl("\n")); } return finalizeValues(); } private boolean isTrapped(Br brElement, DocBookElement current) { Node prevSibling = brElement.getPreviousSibling(); Node nextSibling = brElement.getNextSibling(); if (prevSibling == null || nextSibling == null) { return false; } if (prevSibling instanceof Text == false || nextSibling instanceof Text == false) { return false; } String prevText = prevSibling.getTextContent(); String nextText = nextSibling.getTextContent(); if (prevText == null || nextText == null) { return false; } if (nextText.matches("(?s)^[\\w\\u00A0].*$") == false) { return false; } if (prevText.matches("(?s)^.*[\\w\\u00A0-]$") == false) { return false; } if (prevText.endsWith("-")) { Node lastChild = current.getLastChild(); if (lastChild instanceof Text) { Text lastChildText = (Text) lastChild; String buffer = lastChildText.getTextContent(); if (buffer != null && buffer.endsWith("-")) { buffer = StringServices.cutSuffix(buffer, "-"); lastChildText.setTextContent(buffer); } } } return true; } } src/java/org/dbdoclet/trafo/html/docbook/editor/javadoc/0000755000000000000000000000000012124530526022227 5ustar rootrootsrc/java/org/dbdoclet/trafo/html/docbook/editor/javadoc/CodeEditor.java0000644000000000000000000000155412124530526025120 0ustar rootroot/* * ### Copyright (C) 2001-2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor.javadoc; import org.dbdoclet.trafo.html.docbook.editor.Editor; import org.dbdoclet.trafo.html.docbook.editor.EditorInstruction; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; public class CodeEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) { setValues(values); DocBookTagFactory dbfactory = values.getTagFactory(); org.dbdoclet.trafo.tag.javadoc.Code code = (org.dbdoclet.trafo.tag.javadoc.Code) getHtmlElement(); getCurrent().appendChild(dbfactory.createComputerOutput(code.getTextContent())); traverse(false); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/javadoc/LinkEditor.java0000644000000000000000000000377112124530526025146 0ustar rootroot/* * ### Copyright (C) 2001-2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor.javadoc; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.trafo.html.docbook.editor.Editor; import org.dbdoclet.trafo.html.docbook.editor.EditorInstruction; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Emphasis; import org.dbdoclet.trafo.tag.docbook.Literal; /** * The class LinkEditor is reponsible for transforming @link tags * into DocBook code. * * @author Michael Fuchs * @version $Revision$ */ public class LinkEditor extends Editor { private static Log logger = LogFactory.getLog(LinkEditor.class); @Override public EditorInstruction edit(EditorInstruction values) { setValues(values); DocBookTagFactory dbfactory = values.getTagFactory(); DocBookElement parent = getParent(); org.dbdoclet.trafo.tag.javadoc.Link link = (org.dbdoclet.trafo.tag.javadoc.Link) getHtmlElement(); String ref = link.getRef(); logger.debug("ref=" + ref); if ((ref != null) && (ref.length() > 0)) { String name = link.getName(); String label = link.getTextContent(); Literal elem; if (parent instanceof Literal) { elem = (Literal) parent; } else { elem = dbfactory.createLiteral(); setCurrent(elem); parent.appendChild(getCurrent()); } if ((label != null) && (label.length() > 0)) { elem.appendChild(dbfactory.createLink(label, ref)); } else { elem.appendChild(dbfactory.createLink(name, ref)); } } else { Emphasis elem = dbfactory.createEmphasis(link.getName()); setCurrent(elem); parent.appendChild(getCurrent()); } traverse(false); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/javadoc/ValueEditor.java0000644000000000000000000000166712124530526025327 0ustar rootroot/* * ### Copyright (C) 2001-2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor.javadoc; import org.dbdoclet.trafo.html.docbook.editor.Editor; import org.dbdoclet.trafo.html.docbook.editor.EditorInstruction; /** * The class ValueEditor is reponsible for transforming @value tags * into DocBook code. * * @author Michael Fuchs * @version $Revision$ */ public class ValueEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) { setValues(values); org.dbdoclet.trafo.tag.javadoc.Value value = (org.dbdoclet.trafo.tag.javadoc.Value) getHtmlElement(); getCurrent().appendChild(value.getTextContent()); traverse(false); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/javadoc/LiteralEditor.java0000644000000000000000000000170212124530526025635 0ustar rootroot/* * ### Copyright (C) 2001-2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor.javadoc; import org.dbdoclet.trafo.html.docbook.editor.Editor; import org.dbdoclet.trafo.html.docbook.editor.EditorInstruction; /** * The class CodeEditor is reponsible for transforming @literal * tags into DocBook code. * * @author Michael Fuchs * @version $Revision$ */ public class LiteralEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) { setValues(values); org.dbdoclet.trafo.tag.javadoc.Literal literal = (org.dbdoclet.trafo.tag.javadoc.Literal) getHtmlElement(); getCurrent().appendChild(literal.getTextContent()); traverse(false); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/javadoc/LinkplainEditor.java0000644000000000000000000000467412124530526026175 0ustar rootroot/* * ### Copyright (C) 2001-2003 Michael Fuchs ### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Michael Fuchs * E-Mail: mfuchs@unico-consulting.com * * RCS Information: * --------------- * Id.........: $Id: LinkplainEditor.java,v 1.1.1.1 2004/12/21 14:01:14 mfuchs Exp $ * Author.....: $Author: mfuchs $ * Date.......: $Date: 2004/12/21 14:01:14 $ * Revision...: $Revision: 1.1.1.1 $ * State......: $State: Exp $ */ package org.dbdoclet.trafo.html.docbook.editor.javadoc; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.trafo.html.docbook.editor.Editor; import org.dbdoclet.trafo.html.docbook.editor.EditorInstruction; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Emphasis; import org.dbdoclet.trafo.tag.docbook.Link; import org.dbdoclet.trafo.tag.docbook.XRef; import org.dbdoclet.trafo.tag.javadoc.Linkplain; public class LinkplainEditor extends Editor { private static Log logger = LogFactory.getLog(LinkplainEditor.class); @Override public EditorInstruction edit(EditorInstruction values) { setValues(values); DocBookTagFactory dbfactory = values.getTagFactory(); Linkplain linkplain = (Linkplain) getHtmlElement(); String ref = linkplain.getRef(); logger.debug("ref=" + ref); if ((ref != null) && (ref.length() > 0)) { String label = linkplain.getTextContent(); if ((label != null) && (label.length() > 0)) { Link elem = dbfactory.createLink(label, ref); setCurrent(elem); } else { XRef elem = dbfactory.createXRef(ref); setCurrent(elem); } } else { Emphasis elem = dbfactory.createEmphasis(linkplain.getName()); setCurrent(elem); } getParent().appendChild(getCurrent()); traverse(false); return finalizeValues(); } }src/java/org/dbdoclet/trafo/html/docbook/editor/TheadEditor.java0000644000000000000000000000211712124530526023660 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; public class TheadEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Script script = getTransformer().getScript(); boolean decomposeTables = script.isParameterOn( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_DECOMPOSE_TABLES, DbtConstants.DEFAULT_DECOMPOSE_TABLES); if (decomposeTables) { traverse(true); return finalizeValues(); } setCurrent(dbfactory.createThead()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/BodyEditor.java0000644000000000000000000000073612124530526023535 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class BodyEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/CenterEditor.java0000644000000000000000000000076012124530526024055 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class CenterEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); traverse(true); ignore(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/UlEditor.java0000644000000000000000000000210312124530526023206 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.xiphias.dom.NodeListImpl; public class UlEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); NodeListImpl children = getHtmlElement().getTrafoChildNodes(); if (children.size() == 0) { return finalizeValues(); } if (getParent().isList()) { setCurrent(dbfactory.createListItem()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); setParent(getCurrent()); } setCurrent(dbfactory.createItemizedList()); getCurrent().setParentNode(getParent()); getParent().appendChild(getCurrent()); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/LiEditor.java0000644000000000000000000000235612124530526023204 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.ListItem; public class LiEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); DocBookElement parent = getParent(); if (parent instanceof ListItem) { setParent((DocBookElement) getParent().getParentNode()); parent = getParent(); } DocBookElement item = dbfactory.createListItem(); copyCommonAttributes(getHtmlElement(), item); item.setParentNode(parent); parent.appendChild(item); setCurrent(dbfactory.createPara()); getCurrent().setParentNode(item); item.appendChild(getCurrent()); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/ThEditor.java0000644000000000000000000000366512124530526023217 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.xiphias.dom.ElementImpl; public class ThEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Script script = getTransformer().getScript(); boolean decomposeTables = script.isParameterOn( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_DECOMPOSE_TABLES, DbtConstants.DEFAULT_DECOMPOSE_TABLES); if (decomposeTables || getHtmlElement().isMute()) { traverse(true); return finalizeValues(); } org.dbdoclet.trafo.tag.html.Th th = (org.dbdoclet.trafo.tag.html.Th) getHtmlElement(); org.dbdoclet.trafo.tag.docbook.Entry entry = dbfactory.createEntry(); entry.setAlign(th.getAlign()); entry.setChar(th.getChar()); entry.setCharOff(th.getCharOff()); entry.setVAlign(th.getVAlign()); int colspan = th.getColspan(); if (colspan > 1) { entry.setNameSt("c" + th.getIndex()); entry.setNameEnd("c" + ((th.getIndex() + colspan) - 1)); } int rowspan = th.getRowspan(); if (rowspan > 0) { entry.setMorerows(rowspan); } org.dbdoclet.trafo.tag.docbook.Para para = dbfactory.createPara(); para.setFormatType(ElementImpl.FORMAT_INLINE); org.dbdoclet.trafo.tag.docbook.Emphasis emph = dbfactory .createEmphasis(); emph.setRole(DbtConstants.DEFAULT_EMPHASIS_ROLE_BOLD); entry.appendChild(para); para.appendChild(emph); getParent().appendChild(entry); setCurrent(emph); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/SmallEditor.java0000644000000000000000000000073712124530526023711 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class SmallEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/HeadEditor.java0000644000000000000000000000073312124530526023476 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class HeadEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/PreEditor.java0000644000000000000000000000346212124530526023365 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Entry; import org.dbdoclet.trafo.tag.docbook.Example; import org.dbdoclet.trafo.tag.docbook.InformalExample; import org.dbdoclet.trafo.tag.docbook.SectionElement; import org.dbdoclet.trafo.tag.html.HtmlElement; public class PreEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); HtmlElement pre = values.getHtmlElement(); DocBookElement candidate; DocBookElement parent = getParent(); if (getParent() instanceof Entry) { candidate = dbfactory.createScreen(); } else if (getParent() instanceof Example || getParent() instanceof InformalExample) { candidate = dbfactory.createProgramListing(); } else { candidate = dbfactory.createScreen(); } String attrLang = pre.getAttribute("lang"); if (attrLang != null) { candidate.setAttribute("language", attrLang); } candidate.setParentNode(parent); if (candidate.validate()) { setCurrent(candidate); parent.appendChild(candidate); } else { if (parent.isSection()) { SectionElement sect = (SectionElement) parent; SectionElement firstSectionChild = sect.getFirstSectionChild(); if (firstSectionChild != null) { setCurrent(candidate); parent.insertBefore(candidate, firstSectionChild); } } } traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/SubEditor.java0000644000000000000000000000152712124530526023370 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Subscript; public class SubEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Subscript candidate = dbfactory.createSubscript(); candidate.setParentNode(getParent()); if (candidate.validate()) { setCurrent(candidate); getParent().appendChild(getCurrent()); } // end of if () traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/ScriptEditor.java0000644000000000000000000000074112124530526024100 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class ScriptEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); traverse(false); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/H2Editor.java0000644000000000000000000000045412124530526023106 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class H2Editor extends HeadingEditor { } src/java/org/dbdoclet/trafo/html/docbook/editor/AbbrEditor.java0000644000000000000000000000147312124530526023505 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.Abbrev; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; public class AbbrEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Abbrev candidate = dbfactory.createAbbrev(); candidate.setParentNode(getParent()); if (candidate.validate()) { setCurrent(candidate); getParent().appendChild(getCurrent()); } traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/SupEditor.java0000644000000000000000000000160312124530526023401 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Superscript; public class SupEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Superscript candidate = dbfactory.createSuperscript(); candidate.setParentNode(getParent()); copyCommonAttributes(getHtmlElement(), candidate); if (candidate.validate()) { setCurrent(candidate); getParent().appendChild(getCurrent()); } traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/EditorProperties.java0000644000000000000000000000073212124530526024770 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import java.util.Properties; public class EditorProperties extends Properties { private static final long serialVersionUID = 1L; public String getEmphasisRoleBold() { // strong or bold return "bold"; } } src/java/org/dbdoclet/trafo/html/docbook/editor/MetaEditor.java0000644000000000000000000001154012124530526023521 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import java.util.List; import org.dbdoclet.trafo.tag.docbook.Abstract; import org.dbdoclet.trafo.tag.docbook.Author; import org.dbdoclet.trafo.tag.docbook.Date; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Info; import org.dbdoclet.trafo.tag.docbook.Keyword; import org.dbdoclet.trafo.tag.docbook.Keywordset; import org.dbdoclet.trafo.tag.docbook.Para; import org.dbdoclet.trafo.tag.docbook.Personname; import org.dbdoclet.trafo.tag.docbook.Subject; import org.dbdoclet.trafo.tag.docbook.Subjectset; import org.dbdoclet.trafo.tag.docbook.Subjectterm; import org.dbdoclet.trafo.tag.html.Meta; import org.dbdoclet.xiphias.dom.ElementImpl; import org.dbdoclet.xiphias.dom.NodeImpl; public class MetaEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); traverse(false); DocBookElement current = getCurrent(); NodeImpl root = current.getRoot(); ElementImpl info = (ElementImpl) root.getFirstElement(); if (info == null) { info = dbfactory.createInfo(); root.appendChild(info); } if (info instanceof Info == false) { info = dbfactory.createInfo(); root.insertChild(0, info); } Meta meta = (Meta) getHtmlElement(); String name = meta.getName(); String content = meta.getContent(); if (name != null && name.trim().equalsIgnoreCase("author")) { insertAuthor(dbfactory, info, content); } if (name != null && name.trim().equalsIgnoreCase("date")) { insertDate(dbfactory, info, content); } if (name != null && name.trim().equalsIgnoreCase("description")) { insertAbstract(dbfactory, info, content); } if (name != null && name.trim().equalsIgnoreCase("keywords")) { insertKeywordset(dbfactory, info, content); } if (name != null && name.trim().equalsIgnoreCase("subject")) { insertSubjectset(dbfactory, info, content); } return finalizeValues(); } private void insertAuthor(DocBookTagFactory dbfactory, ElementImpl info, String content) { Author author = dbfactory.createAuthor(); Personname personname = dbfactory.createPersonname(); author.appendChild(personname); personname.setTextContent(content); List authorList = info.findChildren(Author.class); if (authorList.size() == 0) { info.appendChild(author); } else { info.insertAfter(author, authorList.get(authorList.size() - 1)); } } private void insertDate(DocBookTagFactory dbfactory, ElementImpl info, String content) { Date date = dbfactory.createDate(); date.setTextContent(content); List dateList = info.findChildren(Date.class); if (dateList.size() == 0) { info.appendChild(date); } else { info.insertAfter(date, dateList.get(dateList.size() - 1)); } } private void insertAbstract(DocBookTagFactory dbfactory, ElementImpl info, String content) { Abstract description = dbfactory.createAbstract(); Para para = dbfactory.createPara(content); description.appendChild(para); List abstractList = info.findChildren(Abstract.class); if (abstractList.size() == 0) { info.appendChild(description); } else { info.insertAfter(description, abstractList.get(abstractList.size() - 1)); } } private void insertKeywordset(DocBookTagFactory dbfactory, ElementImpl info, String content) { if (content == null || content.trim().length() == 0) { return; } Keywordset keywordset = dbfactory.createKeywordset(); for (String token : content.split(",")) { Keyword keyword = dbfactory.createKeyword(); keyword.setTextContent(token.trim()); keywordset.appendChild(keyword); } List keywordsetList = info.findChildren(Keywordset.class); if (keywordsetList.size() == 0) { info.appendChild(keywordset); } else { info.insertAfter(keywordset, keywordsetList.get(keywordsetList.size() - 1)); } } private void insertSubjectset(DocBookTagFactory dbfactory, ElementImpl info, String content) { if (content == null || content.trim().length() == 0) { return; } List subjectsetList = info.findChildren(Subjectset.class); Subjectset subjectset = null; if (subjectsetList.size() == 0) { subjectset = dbfactory.createSubjectset(); } else { subjectset = subjectsetList.get(0); } Subject subject = dbfactory.createSubject(); subjectset.appendChild(subject); Subjectterm subjectterm = dbfactory.createSubjectterm(); subjectterm.setTextContent(content); subject.appendChild(subjectterm); info.appendChild(subjectset); } } src/java/org/dbdoclet/trafo/html/docbook/editor/EditorInstruction.java0000644000000000000000000000527612124530526025165 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.html.docbook.DocBookTransformer; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.html.HtmlElement; import org.dbdoclet.xiphias.dom.CharacterDataImpl; public class EditorInstruction { private DocBookElement current; private DocBookElement parent; private HtmlElement child; private Object anything; private DocBookTransformer transformer; private CharacterDataImpl characterDataNode; private boolean doIgnore = false; private boolean doTraverse = true; private DocBookTransformer.DocumentElementType codeContext; public boolean doIgnore() { return doIgnore; } public void doIgnore(boolean ignore) { this.doIgnore = ignore; } public boolean doTraverse() { return doTraverse; } public void doTraverse(boolean traverse) { this.doTraverse = traverse; } public Object getAnything() { return anything; } public HtmlElement getHtmlElement() { return child; } public DocBookTransformer.DocumentElementType getCodeContext() { return codeContext; } public DocBookElement getCurrent() { return current; } public DocBookElement getParent() { return parent; } public DocBookTagFactory getTagFactory() { return transformer.getTagFactory(); } public CharacterDataImpl getCharacterDataNode() { return characterDataNode; } public DocBookTransformer getTransformer() { return transformer; } public void setAnything(Object anything) { this.anything = anything; } public void setChild(HtmlElement child) { this.child = child; } public void setCodeContext(DocBookTransformer.DocumentElementType context) { this.codeContext = context; } public void setCurrent(DocBookElement current) { this.current = current; } public void setParent(DocBookElement parent) { this.parent = parent; } public void setCharacterDataNode(CharacterDataImpl characterDataNode) { this.characterDataNode = characterDataNode; } public void setTransformer(DocBookTransformer transformer) { this.transformer = transformer; } @Override public String toString() { String buffer = ""; buffer += ("\nEditor values:\n" + "current.........: " + current + "\n" + "parent..........: " + parent + "\n" + "child...........: " + child + "\n" + "code context....: " + codeContext + "\n" + "do ignore.......: " + doIgnore + "\n" + "do traverse.....: " + doTraverse + "\n"); return buffer; } } src/java/org/dbdoclet/trafo/html/docbook/editor/H3Editor.java0000644000000000000000000000046212124530526023106 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class H3Editor extends HeadingEditor { } src/java/org/dbdoclet/trafo/html/docbook/editor/TdEditor.java0000644000000000000000000000444112124530526023204 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import java.util.Iterator; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.xiphias.dom.ElementImpl; import org.dbdoclet.xiphias.dom.NodeImpl; import org.dbdoclet.xiphias.dom.NodeListImpl; public class TdEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Script script = getTransformer().getScript(); boolean decomposeTables = script.isParameterOn( DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_DECOMPOSE_TABLES, DbtConstants.DEFAULT_DECOMPOSE_TABLES); if (decomposeTables || getHtmlElement().isMute()) { traverse(true); return finalizeValues(); } org.dbdoclet.trafo.tag.html.Td td = (org.dbdoclet.trafo.tag.html.Td) getHtmlElement(); org.dbdoclet.trafo.tag.docbook.Entry entry = dbfactory.createEntry(); copyCommonAttributes(getHtmlElement(), entry); NodeListImpl children = td.getTrafoChildNodes(); Iterator iterator = children.iterator(); NodeImpl node; while (iterator.hasNext()) { node = iterator.next(); if (node instanceof org.dbdoclet.trafo.tag.html.Table) { traverse(true); return finalizeValues(); } } entry.setAlign(td.getAlign()); entry.setChar(td.getChar()); entry.setCharOff(td.getCharOff()); entry.setVAlign(td.getVAlign()); int colspan = td.getColspan(); if (colspan > 1) { entry.setNameSt("c" + td.getIndex()); entry.setNameEnd("c" + ((td.getIndex() + colspan) - 1)); } int rowspan = td.getRowspan(); if (rowspan > 0) { entry.setMorerows(rowspan); } org.dbdoclet.trafo.tag.docbook.Para para = dbfactory.createPara(); para.setFormatType(ElementImpl.FORMAT_INLINE); entry.appendChild(para); para.setParentNode(entry); getParent().appendChild(entry); entry.setParentNode(getParent()); setCurrent(para); traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/AcronymEditor.java0000644000000000000000000000152112124530526024241 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; import org.dbdoclet.trafo.tag.docbook.Acronym; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; public class AcronymEditor extends Editor { @Override public EditorInstruction edit(EditorInstruction values) throws EditorException { setValues(super.edit(values)); DocBookTagFactory dbfactory = values.getTagFactory(); Acronym candidate = dbfactory.createAcronym(); candidate.setParentNode(getParent()); if (candidate.validate()) { setCurrent(candidate); getParent().appendChild(getCurrent()); } // end of if () traverse(true); return finalizeValues(); } } src/java/org/dbdoclet/trafo/html/docbook/editor/H6Editor.java0000644000000000000000000000046212124530526023111 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.trafo.html.docbook.editor; public class H6Editor extends HeadingEditor { } src/java/org/dbdoclet/trafo/html/docbook/ListDetector.java0000644000000000000000000002237012124530526022606 0ustar rootrootpackage org.dbdoclet.trafo.html.docbook; import java.util.Stack; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.trafo.html.docbook.editor.EditorInstruction; import org.dbdoclet.trafo.param.TextParam; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.ItemizedList; import org.dbdoclet.trafo.tag.docbook.ListItem; import org.dbdoclet.trafo.tag.docbook.OrderedList; import org.dbdoclet.trafo.tag.html.HtmlElement; import org.dbdoclet.xiphias.XmlServices; import org.w3c.dom.Element; import org.w3c.dom.Node; public class ListDetector { private static final Log logger = LogFactory.getLog(ListDetector.class); private final Stack cssClassStack = new Stack(); public enum ListType { ITEMIZED, ORDERED }; public void closeList(EditorInstruction values) { HtmlElement child = values.getHtmlElement(); String cssClass = child.getCssClass(); logger.trace(String.format("Closing list %s, %s.", cssClass, child)); DocBookTransformer transformer = values.getTransformer(); DocBookElement parent = values.getParent(); Script script = transformer.getScript(); if (isItemizedListElement(child, script) || isOrderedListElement(child, script)) { return; } if (cssClassStack.size() > 1) { closeNestedList(cssClass, values); parent = values.getParent(); } Node previous = child.getPreviousSibling(); while (previous != null && previous instanceof Element == false) { previous = previous.getNextSibling(); } // Das Geschwisterelement vor dem aktuellen Element war ein // Listenelement. Die Liste wird abgeschlossen. // if (previous != null // && (isItemizedListElement((HtmlElement) previous, script) || // isOrderedListElement( // (HtmlElement) previous, script))) { if (parent instanceof ListItem) { parent = (DocBookElement) parent.getParentNode(); } if (parent instanceof ItemizedList || parent instanceof OrderedList) { values.setParent((DocBookElement) parent.getParentNode()); values.setCurrent((DocBookElement) parent.getParentNode()); } cssClassStack.clear(); // } } private void closeNestedList(String cssClass, EditorInstruction values) { logger.trace(String.format("closeNestedList %s %s", cssClass, values.getHtmlElement())); if (cssClassStack.empty() == true) { return; } String currentCssClass = cssClassStack.peek(); while (cssClassStack.size() > 1 && currentCssClass.equals(cssClass) == false) { cssClassStack.pop(); DocBookElement parent = values.getParent(); // Eingebettete Liste finden while (parent != null && parent instanceof ItemizedList == false && parent instanceof OrderedList == false) { Node parentNode = parent.getParentNode(); if (parentNode instanceof DocBookElement == false) { logger.warn("Couldn't find nested list element for HTML element " + values.getHtmlElement() + ". DocBookParent = " + XmlServices.printPath(values.getParent()) + ". Stack = " + cssClassStack); parent = null; break; } parent = (DocBookElement) parentNode; } if (parent != null) { // Übergeordnete Liste suchen parent = (DocBookElement) parent.getParentNode(); while (parent != null && parent instanceof ItemizedList == false && parent instanceof OrderedList == false) { Node parentNode = parent.getParentNode(); if (parentNode instanceof DocBookElement == false) { logger.warn("Couldn't find parent list for a nested list for HTML element " + values.getHtmlElement() + ". DocBookParent = " + XmlServices.printPath(values.getParent()) + ". Stack = " + cssClassStack); parent = null; break; } parent = (DocBookElement) parentNode; } // Falls eine übergeordnete Liste gefunden wurde, wird diese zum // neuen Vaterelement gemacht. if (parent != null) { values.setParent(parent); values.setCurrent(parent); } } } } public void edit(EditorInstruction values) { HtmlElement htmlElement = values.getHtmlElement(); Script script = values.getTransformer().getScript(); if (isItemizedListElement(htmlElement, script)) { edit(values, ListDetector.ListType.ITEMIZED); } else if (isOrderedListElement(htmlElement, script)) { edit(values, ListDetector.ListType.ORDERED); } else if (isEndOfList(values, script)) { closeList(values); } } private boolean isEndOfList(EditorInstruction values, Script script) { if (cssClassStack.size() == 0) { return false; } HtmlElement htmlElement = values.getHtmlElement(); while (htmlElement != null) { if (isItemizedListElement(htmlElement, script) || isOrderedListElement(htmlElement, script)) { return false; } Node node = htmlElement.getParentNode(); if (node instanceof HtmlElement) { htmlElement = (HtmlElement) node; } else { return true; } } return true; } public void edit(EditorInstruction values, ListType type) { HtmlElement htmlElement = values.getHtmlElement(); String cssClass = htmlElement.getCssClass(); logger.trace(String.format("Editing list element %s, %s.", cssClass, htmlElement)); DocBookTagFactory dbfactory = values.getTagFactory(); DocBookElement parent = values.getParent(); if (isNestedList(cssClass) == false && parent instanceof ListItem) { parent = (DocBookElement) parent.getParentNode(); } parent = createListElement(type, cssClass, dbfactory, parent); if (isParentList(cssClass)) { closeNestedList(cssClass, values); parent = values.getParent(); } ListItem listItem = dbfactory.createListItem(); parent.appendChild(listItem); values.setParent(listItem); values.setCurrent(listItem); } private DocBookElement createListElement(ListType type, String cssClass, DocBookTagFactory dbfactory, DocBookElement parent) { if (type == ListType.ITEMIZED && parent instanceof ItemizedList == false) { ItemizedList itemizedList = dbfactory.createItemizedList(); parent.appendChild(itemizedList); parent = itemizedList; cssClassStack.push(cssClass); } if (type == ListType.ORDERED && parent instanceof OrderedList == false) { OrderedList orderedList = dbfactory.createOrderedList(); parent.appendChild(orderedList); parent = orderedList; cssClassStack.push(cssClass); } return parent; } /** * Die Methode prüft, ob das übergebene HTML-Element eine CSS-Klasse * besitzt, die auf einen der regulären Ausdrücke aus der Liste des * Parameters itemized-attribute-class passt. Ist dies der Fall wird mit * Hilfe des Rückgabewerts true signalisiert, dass das Element eigentlich * ein Listenelement einer ungeordneten Liste ist. * * @param element * @param script * @return */ public boolean isItemizedListElement(HtmlElement element, Script script) { TextParam paramClasses = (TextParam) script.getParameter( DbtConstants.SECTION_LIST_DETECTION, DbtConstants.PARAM_ITEMIZED_ATTRIBUTE_CLASS); String cssClass = element.getCssClass(); if (cssClass == null || paramClasses == null) { return false; } for (String regex : paramClasses.getValues()) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(cssClass); if (matcher.matches()) { return true; } } return false; } /** * Die Methode prüft, ob das übergebene HTML-Element eine CSS-Klasse * besitzt, die auf einen der regulären Ausdrücke aus der Liste des * Parameters ordered-attribute-class passt. Ist dies der Fall wird mit * Hilfe des Rückgabewerts true signalisiert, dass das Element eigentlich * ein Listenelement einer geordneten Liste ist. * * @param element * @param script * @return */ public boolean isOrderedListElement(HtmlElement element, Script script) { TextParam paramClasses = (TextParam) script.getParameter( DbtConstants.SECTION_LIST_DETECTION, DbtConstants.PARAM_ORDERED_ATTRIBUTE_CLASS); String cssClass = element.getCssClass(); if (cssClass == null || paramClasses == null) { return false; } for (String regex : paramClasses.getValues()) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(cssClass); if (matcher.matches()) { return true; } } return false; } /** * Ermittelt, ob die CSS-Klasse zu einer neuen geschachtelten Liste gehört. * Dazu wird geprüft, ob sich die CSS-Klasse geändert hat und nicht einer * übergeordneten Liste zu geordnet ist. * * @param cssClass * @return */ private boolean isNestedList(String cssClass) { if (cssClass == null) { return false; } if (cssClassStack.size() == 0 || cssClass.equals(cssClassStack.peek()) == false) { for (String elem : cssClassStack) { if (elem.equals(cssClass)) { return false; } } return true; } return false; } private boolean isParentList(String cssClass) { if (cssClass == null) { return false; } if (cssClassStack.size() == 0 || cssClass.equals(cssClassStack.peek()) == false) { for (String elem : cssClassStack) { if (elem.equals(cssClass)) { return true; } } } return false; } } src/java/org/dbdoclet/trafo/html/docbook/SectionDetector.java0000644000000000000000000003307512124530526023303 0ustar rootrootpackage org.dbdoclet.trafo.html.docbook; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.dbdoclet.option.OptionException; import org.dbdoclet.service.StringServices; import org.dbdoclet.trafo.html.docbook.editor.Editor; import org.dbdoclet.trafo.html.docbook.editor.EditorInstruction; import org.dbdoclet.trafo.html.docbook.editor.HeadingEditor; import org.dbdoclet.trafo.param.TextParam; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.Article; import org.dbdoclet.trafo.tag.docbook.Book; import org.dbdoclet.trafo.tag.docbook.BridgeHead; import org.dbdoclet.trafo.tag.docbook.Chapter; import org.dbdoclet.trafo.tag.docbook.DocBookDocument; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookFragment; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.Para; import org.dbdoclet.trafo.tag.docbook.Part; import org.dbdoclet.trafo.tag.docbook.PartIntro; import org.dbdoclet.trafo.tag.docbook.RefEntry; import org.dbdoclet.trafo.tag.docbook.RefName; import org.dbdoclet.trafo.tag.docbook.RefNameDiv; import org.dbdoclet.trafo.tag.docbook.RefPurpose; import org.dbdoclet.trafo.tag.docbook.RefSect1; import org.dbdoclet.trafo.tag.docbook.RefSect2; import org.dbdoclet.trafo.tag.docbook.RefSect3; import org.dbdoclet.trafo.tag.docbook.RefSect4; import org.dbdoclet.trafo.tag.docbook.RefSect5; import org.dbdoclet.trafo.tag.docbook.Reference; import org.dbdoclet.trafo.tag.docbook.Sect1; import org.dbdoclet.trafo.tag.docbook.Sect2; import org.dbdoclet.trafo.tag.docbook.Sect3; import org.dbdoclet.trafo.tag.docbook.Sect4; import org.dbdoclet.trafo.tag.docbook.Sect5; import org.dbdoclet.trafo.tag.docbook.Section; import org.dbdoclet.trafo.tag.docbook.Title; import org.dbdoclet.trafo.tag.html.HeaderElement; import org.dbdoclet.trafo.tag.html.HtmlElement; import org.dbdoclet.xiphias.dom.NodeImpl; import org.w3c.dom.Element; import org.w3c.dom.Node; public class SectionDetector { private static Class[] bookMap = { Book.class, Chapter.class, Section.class, Section.class, Section.class, Section.class }; private static Class[] articleMap = { Article.class, Section.class, Section.class, Section.class, Section.class, Section.class }; private static Class[] partIntroMap = { PartIntro.class, Section.class, Section.class, Section.class, Section.class, Section.class }; private static Class[] chapterMap = { Chapter.class, Section.class, Section.class, Section.class, Section.class, Section.class }; private static Class[] sect1Map = { Sect1.class, Sect2.class, Sect3.class, Sect4.class, Sect5.class, Sect5.class }; private static Class[] sect2Map = { Sect2.class, Sect3.class, Sect4.class, Sect5.class, Sect5.class, Sect5.class }; private static Class[] sect3Map = { Sect3.class, Sect4.class, Sect5.class, Sect5.class, Sect5.class, Sect5.class }; private static Class[] referenceMap = { Reference.class, RefEntry.class, RefSect1.class, RefSect2.class, RefSect3.class, RefSect4.class }; private static Class[] refSect1Map = { RefSect1.class, RefSect2.class, RefSect3.class, RefSect4.class, RefSect5.class, RefSect5.class }; private static Class[] refSect2Map = { RefSect2.class, RefSect3.class, RefSect4.class, RefSect5.class, RefSect5.class, RefSect5.class }; private static Class[] refSect3Map = { RefSect3.class, RefSect4.class, RefSect5.class, RefSect5.class, RefSect5.class, RefSect5.class }; private static Class[] saveMap = { Para.class, Para.class, Para.class, Para.class, Para.class, Para.class }; private Class[] map; private EditorInstruction values; public boolean isSection(HtmlElement element, Script script) { return getSectionLevel(element, script) > 0 ? true : false; } public int getSectionLevel(HtmlElement element, Script script) { if (element == null) { return 0; } if (element instanceof HeaderElement) { return ((HeaderElement) element).getLevel(); } String tagName = element.getTagName(); tagName = tagName.trim().toLowerCase(); if (tagName.startsWith("h")) { tagName = StringServices.cutPrefix(tagName, "h"); int level = -1; try { level = Integer.parseInt(tagName); } catch (NumberFormatException oops) { return -1; } return level; } TextParam paramClasses = (TextParam) script.getParameter( DbtConstants.SECTION_SECTION_DETECTION, DbtConstants.PARAM_ATTRIBUTE_CLASS); String cssClass = element.getCssClass(); if (cssClass == null || paramClasses == null) { return 0; } for (String regex : paramClasses.getValues()) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(cssClass); if (matcher.matches()) { int level = 7; int groupCount = matcher.groupCount(); if (groupCount > 0) { String group = matcher.group(groupCount); try { level = Integer.parseInt(group); } catch (NumberFormatException oops) { level = 7; } } return level; } } return 0; } public void edit(EditorInstruction values) { this.values = values; DocBookTagFactory dbfactory = values.getTagFactory(); DocBookElement sect; DocBookTransformer transformer = values.getTransformer(); HtmlElement child = values.getHtmlElement(); DocBookElement parent = values.getParent(); if (parent != null) { values.setCurrent(parent); } values.doTraverse(true); Element levelParent = null; int level = 7; if (child instanceof HeaderElement) { level = ((HeaderElement) child).getLevel(); } else { level = getSectionLevel(child, transformer.getScript()); } Element root = initMap(); levelParent = findParentForLevel(child, level); if ((levelParent == null) && ((values.getCodeContext() == DocBookTransformer.DocumentElementType.OVERVIEW) || (values .getCodeContext() == DocBookTransformer.DocumentElementType.BOOK))) { sect = dbfactory.createChapter(); sect.setRemap(child.getNodeName()); levelParent = root; } else { sect = createSectionChild(child, levelParent); } if (sect != null) { if (sect instanceof Para) { values.doTraverse(false); // Try to force a new paragraph after the header. if (parent instanceof Para && (parent.getParentNode() != null)) { values.setParent((DocBookElement) parent.getParentNode()); } values.setCurrent(values.getParent()); } else { if (levelParent != null) { levelParent.appendChild(sect); if (sect instanceof RefEntry) { RefNameDiv refNameDiv = dbfactory.createRefNameDiv(); RefName refName = dbfactory.createRefName(""); RefPurpose refPurpose = dbfactory.createRefPurpose(); refNameDiv.appendChild(refName); refNameDiv.appendChild(refPurpose); RefSect1 refSect1 = dbfactory.createRefSect1(); sect.appendChild(refNameDiv); sect.appendChild(refSect1); sect = refSect1; } if (sect instanceof BridgeHead) { // setParent(sect); values.setCurrent(sect); } else { Title title = dbfactory.createTitle(); sect.appendChild(title); values.setParent(sect); values.setCurrent(title); } } } } else { sect = values.getCurrent(); } String id = child.getId(); if ((id != null) && (id.length() > 0)) { sect.setId(transformer.createUniqueId(id)); } if (root != null) { root.getClass().getName(); } } private Element initMap() { Element root = getDocumentElement(); if (map != null) { return root; } if (isRootBook() || isRoot(Part.getTag())) { map = bookMap; } if (isRootArticle()) { map = articleMap; } if (isRoot(Chapter.getTag())) { map = chapterMap; } if (isRoot(PartIntro.getTag())) { map = partIntroMap; } if (isRoot(Sect1.getTag())) { map = sect1Map; } if (isRoot(Sect2.getTag())) { map = sect2Map; } if (isRoot(Sect3.getTag())) { map = sect3Map; } if (isRoot(Reference.getTag())) { map = referenceMap; } if (isRoot(RefSect1.getTag())) { map = refSect1Map; } if (isRoot(RefSect2.getTag())) { map = refSect2Map; } if (isRoot(RefSect3.getTag())) { map = refSect3Map; } if (map == null) { map = saveMap; } return root; } public boolean isRoot(String tagName) { Node root = getDocumentElement(); if (root instanceof DocBookFragment) { Node firstChild = ((DocBookFragment) root).getFirstElement(); if (firstChild != null) { root = firstChild; } } if (root == null) { throw new IllegalStateException("The field root must not be null!"); } if (tagName.equalsIgnoreCase(root.getNodeName())) { return true; } else { return false; } } public boolean isRootArticle() { Node root = getDocumentElement(); if (root instanceof DocBookFragment) { root = ((DocBookFragment) root).getFirstElement(); } if (root instanceof Article) { return true; } else { return false; } } public boolean isRootBook() { Element root = getDocumentElement(); if (root instanceof DocBookFragment) { root = ((DocBookFragment) root).getFirstElement(); } if (root instanceof Book || (values.getCodeContext() == DocBookTransformer.DocumentElementType.BOOK) || (values.getCodeContext() == DocBookTransformer.DocumentElementType.OVERVIEW)) { return true; } else { return false; } } private Element getDocumentElement() { NodeImpl rootNode = values.getCurrent().getRoot(); Element root = null; if (rootNode instanceof DocBookDocument) { DocBookDocument doc = (DocBookDocument) rootNode; root = doc.getDocumentElement(); } else if (rootNode instanceof Element) { root = (Element) rootNode; } else { throw new IllegalStateException( "Root node must be of type DocBookDocument or Element." + "Found root node of type " + rootNode.getClass().getName() + "!"); } return root; } public DocBookElement findParentForLevel(HtmlElement header, int level) { DocBookElement parent = null; Class parentClass = null; Script script = values.getTransformer().getScript(); if (level < 0) { level = 0; } if (level > map.length) { level = map.length - 1; } for (int i = (level - 1); i >= 0; i--) { parentClass = map[i]; parent = values.getCurrent(); if (parent != null) { int tagLevel = getSectionLevel(header, script); int parentLevel = getSectionLevel( (HtmlElement) parent.getUserData("html"), script); while (tagLevel != -1 && parentLevel != -1 && parentLevel >= tagLevel) { DocBookElement ancestor = (DocBookElement) NodeImpl .findParent(parent, parentClass); if (ancestor == null) { break; } parent = ancestor; parentLevel = getSectionLevel( (HtmlElement) parent.getUserData("html"), script); } break; } } return parent; } public DocBookElement createSectionChild(HtmlElement header, Element parent) throws OptionException { DocBookTagFactory dbfactory = values.getTagFactory(); DocBookElement section = null; if (parent == null || parent instanceof Para || isValidHeader(header) == false) { section = dbfactory.createBridgeHead(); } if (parent instanceof Book || parent instanceof Part) { section = dbfactory.createChapter(); } if (parent instanceof Chapter || parent instanceof PartIntro) { section = dbfactory.createSection(); } if (parent instanceof Article) { section = dbfactory.createSection(); } if (parent instanceof Section) { section = dbfactory.createSection(); } if (parent instanceof Sect1) { section = dbfactory.createSect2(); } if (parent instanceof Sect2) { section = dbfactory.createSect3(); } if (parent instanceof Sect3) { section = dbfactory.createSect4(); } if (parent instanceof Sect4) { section = dbfactory.createSect5(); } if (parent instanceof Sect5) { section = dbfactory.createSimpleSect(); } if (parent instanceof Reference) { section = dbfactory.createRefEntry(); } if (parent instanceof RefEntry) { section = dbfactory.createRefSect1(); } if (parent instanceof RefSect1) { section = dbfactory.createRefSect2(); } if (parent instanceof RefSect2) { section = dbfactory.createRefSect3(); } if (parent instanceof RefSect3) { section = dbfactory.createRefSect4(); } if (parent instanceof RefSect4) { section = dbfactory.createRefSect5(); } if (parent instanceof RefSect5) { section = dbfactory.createSimpleSect(); } if (section != null) { Editor editor = new Editor(); editor.setValues(values); editor.copyCommonAttributes(header, section); } return section; } public DocBookElement createSectionPara(Element parent) throws OptionException { DocBookElement para; DocBookTagFactory dbfactory = values.getTagFactory(); if ((parent != null) && parent instanceof Para) { para = (DocBookElement) parent; } else { para = dbfactory.createPara(); if (((Para) para).isValidParent(values.getParent())) { values.getParent().appendChild(para); } else { para = values.getParent(); } } BridgeHead bridgeHead = dbfactory.createBridgeHead(); bridgeHead.appendChild(values.getHtmlElement().getTextContent()); para.appendChild(bridgeHead); // Emphasis emph = dbfactory.createEmphasis(); // emph.setRole(getOptions().getEmphasisBoldRole()); // emph.setParentNode(para); // emph.setRemap(header.getNodeName()); // emph.appendChild(getChild().getText()); // para.appendChild(emph); return para; } private boolean isValidHeader(HtmlElement header) { boolean rc = header .validateParentPath(HeadingEditor.validHtmlParentPathMap); return rc; } } src/java/org/dbdoclet/trafo/html/docbook/PreprocessStage1.java0000644000000000000000000000163012124530526023367 0ustar rootrootpackage org.dbdoclet.trafo.html.docbook; import java.util.ArrayList; import org.dbdoclet.progress.ProgressEvent; import org.dbdoclet.progress.ProgressListener; import org.dbdoclet.trafo.tag.html.HtmlElement; import org.dbdoclet.xiphias.dom.AbstractNodeVisitor; import org.w3c.dom.Node; public class PreprocessStage1 extends AbstractNodeVisitor { private ArrayList removeList; public PreprocessStage1(ArrayList listeners) { super(listeners); removeList = new ArrayList(); } public void accept(Node node) { fireProgressEvent(node.toString(), ProgressEvent.STAGE_ACTION); if (node instanceof HtmlElement) { HtmlElement htmlElement = (HtmlElement) node; htmlElement.init(); } } public void finish() { removeNodes(removeList); } public void openTag(Node node) throws Exception { // } public void closeTag(Node node) throws Exception { // } } src/java/org/dbdoclet/trafo/html/docbook/PostprocessStage1.java0000644000000000000000000000763512124530526023601 0ustar rootrootpackage org.dbdoclet.trafo.html.docbook; import java.util.ArrayList; import java.util.HashMap; import org.dbdoclet.progress.ProgressEvent; import org.dbdoclet.progress.ProgressListener; import org.dbdoclet.service.StringServices; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.EntryTbl; import org.dbdoclet.trafo.tag.docbook.InformalTable; import org.dbdoclet.trafo.tag.docbook.ItemizedList; import org.dbdoclet.trafo.tag.docbook.ListItem; import org.dbdoclet.trafo.tag.docbook.OrderedList; import org.dbdoclet.trafo.tag.docbook.Para; import org.dbdoclet.trafo.tag.docbook.Table; import org.dbdoclet.xiphias.HtmlServices; import org.dbdoclet.xiphias.dom.AbstractNodeVisitor; import org.dbdoclet.xiphias.dom.ElementImpl; import org.dbdoclet.xiphias.dom.NodeImpl; import org.w3c.dom.Node; import org.w3c.dom.Text; public class PostprocessStage1 extends AbstractNodeVisitor { private final ArrayList removeList; private final HashMap subtables; private final Script script; public PostprocessStage1(DocBookTagFactory dbfactory, Script script, ArrayList listeners) { super(listeners); this.script = script; removeList = new ArrayList(); subtables = new HashMap(); } @Override public void accept(Node node) { fireProgressEvent(node.toString(), ProgressEvent.STAGE_ACTION); if (node instanceof Text) { replaceHtmlEntities((Text) node); } if (node instanceof ElementImpl) { NodeImpl elem = (NodeImpl) node; processPara(elem); processEntryTbl(elem); processListItem(elem); } } private void processListItem(NodeImpl elem) { if (elem == null || elem.getParentNode() == null) { return; } ArrayList stripPrefixesList = new ArrayList(); String text = elem.getTextContent(); if (elem instanceof ListItem && elem.getParentNode() instanceof ItemizedList) { stripPrefixesList = script.getTextParameterList( DbtConstants.SECTION_LIST_DETECTION, DbtConstants.PARAM_ITEMIZED_STRIP_PREFIX); } if (elem instanceof ListItem && elem.getParentNode() instanceof OrderedList) { stripPrefixesList = script.getTextParameterList( DbtConstants.SECTION_LIST_DETECTION, DbtConstants.PARAM_ORDERED_STRIP_PREFIX); } for (String stripPrefix : stripPrefixesList) { if (text.startsWith(stripPrefix)) { Text firstText = elem.findFirstText(); String firstContent = firstText.getData(); firstText.setData(StringServices.cutPrefix(firstContent, stripPrefix)); } } } private void processEntryTbl(NodeImpl elem) { Node node; if (elem instanceof EntryTbl) { node = NodeImpl.findParent(elem.getParentNode(), EntryTbl.class); if (node != null) { DocBookElement parentTable = (DocBookElement) NodeImpl .findParent(elem, Table.class); if (parentTable == null) { parentTable = (DocBookElement) NodeImpl.findParent(elem, InformalTable.class); } if (parentTable != null) { subtables.put((EntryTbl) elem, parentTable); } } } } private void processPara(NodeImpl elem) { if (elem instanceof Para && elem.hasSiblingElements() == true && elem.hasElementChildren() == false) { String text = elem.getTextContent(); text = text.replace((char) 160, ' '); text = text.trim(); if (text.length() == 0) { removeList.add(elem); } } } public void finish() { removeNodes(removeList); } public HashMap getSubtables() { return subtables; } private void replaceHtmlEntities(Text child) { String buffer = HtmlServices.replaceEntities(child.getTextContent()); child.setTextContent(buffer); } @Override public void openTag(Node node) throws Exception { // } @Override public void closeTag(Node node) throws Exception { // } } src/java/org/dbdoclet/trafo/html/docbook/Resources_de.properties0000644000000000000000000000024112124530526024067 0ustar rootrootC_DOCUMENT_ELEMENT=Dokumenttyp C_ENCODING_SOURCE=Zeichencodierung der Quelldatei C_LANGUAGE=Sprache C_PROFILE=Profil C_USE_ABSOLUTE_IMAGE_PATH=Absolute Bildpfadesrc/java/org/dbdoclet/trafo/html/docbook/PostprocessStage3.java0000644000000000000000000000314112124530526023567 0ustar rootrootpackage org.dbdoclet.trafo.html.docbook; import java.util.HashMap; import org.dbdoclet.trafo.tag.docbook.DocBookElement; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.EntryTbl; import org.dbdoclet.trafo.tag.docbook.InformalTable; import org.dbdoclet.trafo.tag.docbook.Tgroup; import org.dbdoclet.trafo.tag.docbook.XRef; public class PostprocessStage3 { private final DocBookTagFactory dbfactory; private final HashMap subtables; public PostprocessStage3(DocBookTagFactory dbfactory, HashMap subtables) { this.dbfactory = dbfactory; this.subtables = subtables; } public void process() { if ((subtables != null) && (subtables.size() > 0)) { int index = 1; for (EntryTbl entrytbl : subtables.keySet()) { String id = "subtable." + index; XRef xref = dbfactory.createXRef(id); DocBookElement table = subtables.get(entrytbl); DocBookElement entryTblParent = (DocBookElement) entrytbl .getParentNode(); entryTblParent.replaceChild(dbfactory.createEntry() .appendChild(xref), entrytbl); InformalTable it = dbfactory.createInformalTable(); it.setId(id); it.setXrefLabel("#" + index); Tgroup tgroup = dbfactory.createTgroup(); tgroup.setChildNodes(entrytbl.getChildNodes()); tgroup.setTrafoAttributes(entrytbl.getTrafoAttributes()); it.appendChild(tgroup); DocBookElement tableParent = (DocBookElement) table .getParentNode(); if (tableParent != null) { tableParent.insertAfter(it, table); } index++; } } } } src/java/org/dbdoclet/trafo/html/docbook/PostprocessStage2.java0000644000000000000000000000453012124530526023571 0ustar rootrootpackage org.dbdoclet.trafo.html.docbook; import java.util.ArrayList; import org.dbdoclet.progress.ProgressEvent; import org.dbdoclet.progress.ProgressListener; import org.dbdoclet.trafo.SectionNumberRemover; import org.dbdoclet.trafo.SpaceNormalizer; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.tag.docbook.DocBookTagFactory; import org.dbdoclet.trafo.tag.docbook.SectionElement; import org.dbdoclet.xiphias.dom.AbstractNodeVisitor; import org.dbdoclet.xiphias.dom.ElementImpl; import org.dbdoclet.xiphias.dom.NodeImpl; import org.w3c.dom.Node; public class PostprocessStage2 extends AbstractNodeVisitor { private final DocBookTagFactory dbfactory; private final ArrayList removeList; private final Script script; public PostprocessStage2(DocBookTagFactory dbfactory, Script script, ArrayList listeners) { super(listeners); this.dbfactory = dbfactory; this.script = script; removeList = new ArrayList(); } public void finish() { removeNodes(removeList); } @Override public void accept(Node node) throws Exception { fireProgressEvent(node.toString(), ProgressEvent.STAGE_ACTION); if (node instanceof ElementImpl) { NodeImpl elem = (NodeImpl) node; if (elem instanceof SectionElement) { SectionElement sect = (SectionElement) elem; NodeImpl title = sect.findChildElement("title"); if (title != null) { SectionNumberRemover snr = new SectionNumberRemover(); snr.setRegex(script.getTextParameter( DbtConstants.SECTION_SECTION_DETECTION, DbtConstants.PARAM_SECTION_NUMBERING_PATTERN, null)); title.traverse(snr); if (script.isParameterOn(DbtConstants.SECTION_DOCBOOK, DbtConstants.PARAM_TITLE_NORMALIZE_SPACE, false)) { SpaceNormalizer sn = new SpaceNormalizer(); title.traverse(sn); } } String titleText = sect.getTitle(); if (titleText.length() == 0 && sect.hasContentChildren() == false) { removeList.add(sect); return; } if (titleText.length() > 0 && sect.hasContentChildren() == false) { sect.appendChild(dbfactory.createPara("")); return; } } } } @Override public void openTag(Node node) throws Exception { // Auto-generated method stub } @Override public void closeTag(Node node) throws Exception { // Auto-generated method stub } } src/java/org/dbdoclet/trafo/html/docbook/LinkManager.java0000644000000000000000000000403112124530526022363 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet.trafo.html.docbook; import java.util.ArrayList; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.service.StringServices; import org.dbdoclet.xiphias.dom.ElementImpl; public class LinkManager { private static Log logger = LogFactory.getLog(LinkManager.class); private final ArrayList anchorIdList; private final ArrayList linkList; private final ArrayList usedIdList; public LinkManager() { linkList = new ArrayList(); anchorIdList = new ArrayList(); usedIdList = new ArrayList(); } public void addLink(ElementImpl link) { linkList.add(link); } public String createUniqueId(String str) { String id = str; id = ElementImpl.hardenId(id); String key = id; int counter = 1; while (anchorIdList.contains(key)) { key = id + "." + counter; counter++; } anchorIdList.add(key); logger.debug("Added reference " + key + "."); return key; } public ArrayList getLinkList() { return linkList; } public String getUniqueId(String str) { String id = str; logger.debug("#1 id=" + id); id = StringServices.cutPrefix(id, "#"); id = ElementImpl.hardenId(id); logger.debug("#2 id=" + id); if (id == null || id.length() == 0) { id = "dbdoclet.id"; } if (usedIdList.contains(id) == false) { usedIdList.add(id); } logger.debug("#3 id=" + id); return id; } public ArrayList getUnresolvedIds() { ArrayList list = new ArrayList(usedIdList); list.removeAll(anchorIdList); return list; } public ArrayList getUsedIdList() { return anchorIdList; } } src/java/org/dbdoclet/trafo/param/0000755000000000000000000000000012124530526016046 5ustar rootrootsrc/java/org/dbdoclet/trafo/param/NumberParam.java0000644000000000000000000000024412124530526021122 0ustar rootrootpackage org.dbdoclet.trafo.param; public class NumberParam extends Param { public NumberParam(String name, Integer value) { super(name, value); } } src/java/org/dbdoclet/trafo/param/TextParam.java0000644000000000000000000000023612124530526020617 0ustar rootrootpackage org.dbdoclet.trafo.param; public class TextParam extends Param { public TextParam(String name, String value) { super(name, value); } } src/java/org/dbdoclet/trafo/param/Param.java0000644000000000000000000000524512124530526017757 0ustar rootrootpackage org.dbdoclet.trafo.param; import java.util.ArrayList; import org.dbdoclet.service.StringServices; public class Param { private String name; private final ArrayList valueList; private boolean enabled = true; public Param(String name, T value) { this.name = name; valueList = new ArrayList(); valueList.add(value); } public String getName() { return name; } public void setName(String name) { this.name = name; } public T getValue() { if (valueList.size() == 0) { return null; } return valueList.get(0); } public T getValue(int index) { if (index < 0 && index >= valueList.size()) { return null; } return valueList.get(index); } public ArrayList getValues() { return valueList; } public void addValue(T value) { valueList.add(value); } public void setValue(T value) { valueList.clear(); valueList.add(value); } public boolean isArray() { return valueList.size() > 1; } // public boolean isEnabled() { // // T value = getValue(); // // if (value instanceof Boolean) { // return ((Boolean) value).booleanValue(); // } // // if (value instanceof String) { // return Boolean.valueOf((String) value); // } // // if (value instanceof Number) { // return ((Number) value).doubleValue() != 0; // } // // return false; // } public String getValueAsText() { if (valueList == null || valueList.size() == 0) { return null; } if (valueList.size() == 1) { return getValue().toString(); } StringBuilder buffer = new StringBuilder(); for (T value : valueList) { if (value == null) { continue; } buffer.append(value.toString()); buffer.append(", "); } String ret = buffer.toString().trim(); return StringServices.cutSuffix(ret, ","); } @Override public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append(name); buffer.append(" = "); if (valueList != null) { if (valueList.size() == 1) { Object valueObject = valueList.get(0); appendValueObject(buffer, valueObject); } if (valueList.size() > 1) { buffer.append("[ "); for (Object valueObject : valueList) { appendValueObject(buffer, valueObject); buffer.append(", "); } buffer.replace(buffer.length() - 2, buffer.length(), " ]"); } } return buffer.toString(); } private void appendValueObject(StringBuilder buffer, Object valueObject) { if (valueObject instanceof String) { buffer.append('"'); buffer.append(valueObject); buffer.append('"'); } else { buffer.append(valueObject); } } public void setEnabled(boolean enabled) { this.enabled = enabled; } public boolean isEnabled() { return enabled; } } src/java/org/dbdoclet/trafo/param/BooleanParam.java0000644000000000000000000000035412124530526021253 0ustar rootrootpackage org.dbdoclet.trafo.param; /** * Parameter mit boolschem Wert. * * @author Michael Fuchs */ public class BooleanParam extends Param { public BooleanParam(String name, Boolean value) { super(name, value); } } src/java/org/dbdoclet/trafo/TrafoResult.java0000644000000000000000000000517012124530526020066 0ustar rootroot/* * ### Copyright (C) 2001-2009 Michael Fuchs ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org */ package org.dbdoclet.trafo; import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.io.StringWriter; import javax.xml.transform.ErrorListener; import javax.xml.transform.TransformerException; import org.dbdoclet.service.StringServices; /** * Die Klasse TrafoResult speichert das Protokoll einer * Transformation. * * @author michael * */ public class TrafoResult implements ErrorListener { private File file; private StringBuffer buffer; private byte[] data; private Throwable throwable; public TrafoResult() { super(); buffer = new StringBuffer(); } public TrafoResult(File file) { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } this.file = file; buffer = new StringBuffer(); } public String getBuffer() { return buffer.toString(); } public byte[] getData() { return data; } public File getFile() { return file; } public void append(String line) { buffer.append(line); } public void setData(byte[] data) { this.data = data; } public void setThrowable(Throwable throwable) { this.throwable = throwable; } public Throwable getThrowable() { return throwable; } /** * Generiert eine Zusammenfassung des Protokolls */ @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append('\n'); builder.append(StringServices.createBox("TRANSFORMATION PROTOCOL")); if (buffer != null) { builder.append("=== STDOUT/STDERR ===\n"); builder.append(buffer); } if (throwable != null) { if (throwable instanceof FileNotFoundException) { builder.append("[ERROR] File not found: " + throwable.getMessage()); } else { builder.append("\n=== EXCEPTION ===\n"); StringWriter strBuffer = new StringWriter(); throwable.printStackTrace(new PrintWriter(strBuffer)); builder.append(strBuffer.toString()); } } builder.append(">>TRANSFORMATION FINISHED.\n\n"); return builder.toString(); } public void warning(TransformerException exception) throws TransformerException { buffer.append(exception.getMessage()); buffer.append('\n'); } public void error(TransformerException exception) throws TransformerException { buffer.append("[error] " + exception.getMessage()); buffer.append('\n'); } public void fatalError(TransformerException exception) throws TransformerException { buffer.append("[fatal] " + exception.getMessage()); buffer.append('\n'); } } src/java/org/dbdoclet/trafo/TrafoScriptManager.java0000644000000000000000000001144412124530526021350 0ustar rootrootpackage org.dbdoclet.trafo; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.LinkedHashMap; import java.util.List; import org.antlr.runtime.ANTLRFileStream; import org.antlr.runtime.ANTLRInputStream; import org.antlr.runtime.ANTLRStringStream; import org.antlr.runtime.CommonTokenStream; import org.antlr.runtime.RecognitionException; import org.antlr.runtime.tree.CommonTreeNodeStream; import org.dbdoclet.trafo.param.Param; import org.dbdoclet.trafo.script.Script; import org.dbdoclet.trafo.script.parser.TrafoScriptLexer; import org.dbdoclet.trafo.script.parser.TrafoScriptParser; import org.dbdoclet.trafo.script.parser.TrafoScriptWalker; public class TrafoScriptManager { /** * Parsen einer Skript-Datei. * * @param scriptFile * @return Script * @throws TrafoException */ public Script parseScript(File scriptFile) throws TrafoException { Script script = new Script(); parseScript(script, scriptFile, ""); return script; } public void parseScript(Script script, File scriptFile) throws TrafoException { parseScript(script, scriptFile, ""); } public void parseScript(Script script, File scriptFile, String namespace) throws TrafoException { try { TrafoScriptLexer lex = new TrafoScriptLexer(new ANTLRFileStream( scriptFile.getAbsolutePath(), "UTF8")); parseScript(script, lex, namespace); } catch (Exception oops) { throw new TrafoException(oops); } } public void parseScript(Script script, InputStream instr, String namespace) throws TrafoException { try { TrafoScriptLexer lex = new TrafoScriptLexer(new ANTLRInputStream( instr, "UTF8")); parseScript(script, lex, namespace); } catch (Exception oops) { throw new TrafoException(oops); } } /** * Parsen eines Skript-Puffers. * * @param scriptBuffer * @return Script * @throws IOException * @throws RecognitionException * @throws TrafoException */ public Script parseScript(String scriptBuffer) throws IOException, RecognitionException, TrafoException { TrafoScriptLexer lex = new TrafoScriptLexer(new ANTLRStringStream( scriptBuffer)); Script script = new Script(); parseScript(script, lex, ""); return script; } private Script parseScript(Script script, TrafoScriptLexer lex, String namespace) throws RecognitionException, TrafoException { CommonTokenStream tokens = new CommonTokenStream(lex); TrafoScriptParser parser = new TrafoScriptParser(tokens); TrafoScriptParser.parse_return r = parser.parse(); List errors = parser.getErrors(); if (errors != null && errors.size() > 0) { throw new TrafoException(errors.get(0)); } CommonTreeNodeStream nodes = new CommonTreeNodeStream(r.getTree()); TrafoScriptWalker walker = new TrafoScriptWalker(nodes); walker.parse(script, namespace); return script; } public void parseScript(Script script, String scriptBuffer) throws TrafoException { try { TrafoScriptLexer lex = new TrafoScriptLexer(new ANTLRStringStream( scriptBuffer)); parseScript(script, lex, ""); } catch (Exception oops) { throw new TrafoException(oops); } } public void writeScript(Script script, File file) throws IOException { writeScript(Script.DEFAULT_NAMESPACE, script, file); } public void writeScript(String namespace, Script script, File file) throws IOException { writeScript(namespace, script, new FileWriter(file)); } public void writeScript(Script script, Writer writer) throws IOException { writeScript(Script.DEFAULT_NAMESPACE, script, writer); } public void writeScript(String namespace, Script script, Writer writer) throws IOException { PrintWriter printWriter = null; try { printWriter = new PrintWriter(writer); String transformationName = "trafo"; Param sysparam = script.getSystemParameter(namespace, Script.SYSPARAM_TRANSFORMATION_NAME); if (sysparam != null) { transformationName = (String) sysparam.getValue(); } printWriter.println(String.format("transformation %s;", transformationName)); LinkedHashMap>> sectionMap = script .getSectionMap(namespace); if (sectionMap != null) { for (String sectionName : sectionMap.keySet()) { if (sectionName.startsWith("SYS ")) { continue; } printWriter.println(String.format("%nsection %s {", sectionName)); LinkedHashMap> paramMap = sectionMap .get(sectionName); for (Param param : paramMap.values()) { printWriter.println(String.format("\t%s;", param.toString())); } printWriter.println("}"); } } } finally { printWriter.close(); } } public void mergeNamespaces(Script script) { script.mergeNamespaces(); } } src/java/org/dbdoclet/trafo/tokenizer/0000755000000000000000000000000012124530526016760 5ustar rootrootsrc/java/org/dbdoclet/trafo/tokenizer/Token.java0000644000000000000000000002114412124530526020705 0ustar rootrootpackage org.dbdoclet.trafo.tokenizer; import java.util.HashMap; import org.dbdoclet.service.StringServices; /** * Die Klasse MLToken repräsentiert einen einzelnen Token. * * Ein Token entsteht bei der Zerlegung der Eingabedaten in Teilstücke. * * @author Michael Fuchs * @version 1.0 */ public class Token { /** Der Inhalt des Token. */ private String value; /** Der Name des Tags, falls der Token einen Tag repräsentiert.*/ private String tagName; /** Die Attributes des Tags, falls der Token einen Tag repräsentiert.*/ private HashMap tagAttributes; /** Der Typ des Tokens. */ private String type; /** Die Zeilenummer, in der der Token gefunden wurde. */ private int line; /** Die Spaltennummer, in der der Token gefunden wurde. */ private int column; public Token() { this(""); } /** * Erzeugt eine neue Instanz der Klasse MLToken. * * @param token String */ public Token(String token) { if (token == null) { throw new IllegalArgumentException( "The argument token may not be null!"); } type = "__UNKNOWN__"; tagAttributes = new HashMap(); this.value = parse(token); } /** * Die Methode getAttribute liefert ein bestimmtes Attribut des Tags. * * Ist der Token kein Tag, wird null zurückgegeben. * * @return HashMap */ public String getAttribute(String attrName) { if (attrName == null) { throw new IllegalArgumentException("The argument attrName must not be null!"); } if (tagAttributes != null) { return (String) tagAttributes.get(attrName); } return null; } /** * Die Methode getAttributes liefert die Attribute des Tags. * * Ist der Token kein Tag, wird null zurückgegeben. * * @return HashMap */ public HashMap getAttributes() { return tagAttributes; } /** * Die Methode getColumn liefert die Spaltennummer. * * @return int */ public int getColumn() { return column; } /** * Die Methode getLine liefert die Zeilennummer. * * @return int */ public int getLine() { return line; } /** * Die Methode getTagName liefert den Namen des Tags. * * Ist der Token kein Tag, wird null zurückgegeben. * * @return String */ public String getTagName() { return tagName; } /** * Die Methode getToken liefert den Token als Ganzes. * * @return String */ public String getValue() { if (isComment() && value != null) { String buffer = value.trim(); buffer = StringServices.cutPrefix(buffer, ""); buffer = buffer.trim(); return buffer; } return value; } /** * Wahr, falls der Token ein schließender Tag ist. * * @return boolean */ public boolean isClosingTag() { if (type.endsWith(".Closing") || type.endsWith(".Empty")) { return true; } return false; } /** * Wahr, falls der Token ein Kommentar ist. * * @return boolean */ public boolean isComment() { if (type.equals("Text.Comment")) { return true; } return false; } /** * Wahr, falls der Token eine Doctype-Anweisung ist. * * @return boolean */ public boolean isDoctype() { if (type.equals("Doctype")) { return true; } return false; } /** * Wahr, falls der Token ein leerer Tag ist. * * @return boolean */ public boolean isEmptyTag() { if (type.equals("Tag.Empty")) { return true; } return false; } /** * Wahr, falls der Token ein JavaDoc-Tag ist. * * @return boolean */ public boolean isJavadoc() { if (type.startsWith("Tag.Javadoc.")) { return true; } return false; } /** * Wahr, falls der Token ein öffnender Tag ist. * * @return boolean */ public boolean isOpeningTag() { if (type.endsWith(".Opening") || type.endsWith(".Empty")) { return true; } return false; } /** * Wahr, falls der Token ein Tag ist. * * @return boolean */ public boolean isTag() { if (type.startsWith("Tag.")) { return true; } return false; } /** * Wahr, falls der Token nur Text enthält ist. * * @return boolean */ public boolean isText() { if (type.startsWith("Text.")) { return true; } return false; } /** * Wahr, falls der Token nur Trennzeichen enthält. * * @return boolean */ public boolean isWhitespace() { if (type.equals("Text.Whitespace")) { return true; } return false; } /** * Die Methode setAttributes setzt die Attribute des Tags. * * @param attributes HashMap */ public void setAttributes(HashMap attributes) { this.tagAttributes = attributes; } /** * Die Methode setColumn setzt die Spaltennummer. * * @param column int */ public void setColumn(int column) { this.column = column; } /** * Die Methode setLine setzt die Zeilennummer. * * @param line int */ public void setLine(int line) { this.line = line; } /** * Die Methode setTagName setzt den Namen des Tags. * * @param tagName String */ public void setTagName(String tagName) { if (tagName == null) { throw new IllegalArgumentException("Parameter tagName is null!"); } this.tagName = tagName; } public void setValue(String value) { this.value = value; parse(value); } public void appendValue(String value) { this.value += value; } /** * Die Methode toString liefert eine textuelle Darstellung des * Tokens. * * @return String */ @Override public String toString() { StringBuilder buffer = new StringBuilder(); if (tagName != null) { buffer.append(tagName); buffer.append(", "); } if (type != null) { buffer.append(type); buffer.append(", "); } if (value != null) { buffer.append(value); } if (buffer.length() > 42) { buffer.delete(39, buffer.length()); buffer.append("..."); } return buffer.toString(); } /** * Die Methode parse wertet den Inhalt des Tokens aus und setzt * danach den Wert des Attributes type. * * @param token String * @return String */ private String parse(String token) { if (token == null) { return null; } String value = token.trim(); if (value.startsWith("")) { type = "Text.Comment"; } else if (value.startsWith("")) { type = "Doctype"; } else if (value.startsWith("")) { type = "Declaration"; } else if (value.startsWith("<") && value.endsWith("/>")) { type = "Tag.Empty"; } else if (value.startsWith("")) { type = "Tag.Javadoc.Opening"; } else if (value.startsWith("")) { type = "Tag.Javadoc.Closing"; } else if (value.startsWith("")) { type = "Tag.Closing"; } else if (value.startsWith("<") && value.endsWith(">")) { type = "Tag.Opening"; } else if (value.trim().equals("")) { type = "Text.Whitespace"; } else { type = "Text."; } return token; } } src/java/org/dbdoclet/trafo/tokenizer/Tokenizer.java0000644000000000000000000000745412124530526021607 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet.trafo.tokenizer; import java.text.ParseException; import java.util.ArrayList; import org.dbdoclet.progress.ProgressListener; import org.dbdoclet.trafo.xml.tokenizer.parser.TokenMgrError; import org.dbdoclet.trafo.xml.tokenizer.parser.XmlTokenizer; /** * Die Klasse MLTokenizer implementiert einen Tokenizer für * Datenformate wie SGML, XML or HTML. * * @author Michael Fuchs * @version 1.0 */ public class Tokenizer { private ArrayList tokens; private Token currentToken; private StringBuffer buffer = null; private int tokenPosition = 0; private ArrayList listeners; /** * Creates a new MLTokenizer instance. * * @param data * {@link String (String)} */ public Tokenizer(String data) { buffer = new StringBuffer(data); } public void tokenize() throws TokenizerException { tokenPosition = 0; tokens = parse(); } /* ======================================================================== */ /* PUBLIC METHODS */ /* ======================================================================== */ /** * The method hasNext returns true if there are still tokens to * be fetched. * * @return True if another token exists. */ public boolean hasNext() { if (tokenPosition < tokens.size()) { return true; } else { return false; } } /** * The method next returns the next token. * * If there are no more tokens left, a null value is returned. * * @return The next token or null {@link Token (MLToken)}. */ public Token next() { if (tokenPosition >= tokens.size()) { return null; } currentToken = (Token) tokens.get(tokenPosition); tokenPosition++; return currentToken; } public int size() { if (tokens == null) { throw new IllegalStateException("Variable tokens is null!"); } return tokens.size(); } public int position() { return tokenPosition; } /* ======================================================================== */ /* PRIVATE METHODS */ /* ======================================================================== */ /** * The method parse parses the buffer and adds all tokens into * an object of the type ArrayList, which is returned in the * end. * * @return {@link java.util.ArrayList (ArrayList)} * @exception TokenizerException * if an error occurs */ private ArrayList parse() throws TokenizerException { XmlTokenizer parser; try { parser = new XmlTokenizer(buffer.toString(), "UTF-8"); parser.setProgressListeners(listeners); return parser.parse(); } catch (Throwable oops) { String msg = "Tokenizer Error"; if (oops instanceof TokenMgrError || oops instanceof ParseException) { msg = "Parse error " + oops.getMessage() + " while parsing \"" + buffer.toString() + "\"."; } throw new TokenizerException(msg, oops); } } public void setProgressListeners(ArrayList listeners) { this.listeners = listeners; } } src/java/org/dbdoclet/trafo/tokenizer/TokenizerException.java0000644000000000000000000000516712124530526023465 0ustar rootroot/* * ### Copyright (C) 2001-2003 Michael Fuchs ### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Michael Fuchs * E-Mail: mfuchs@unico-consulting.com * * RCS Information: * --------------- * Id.........: $Id: TokenizerException.java,v 1.1.1.1 2004/12/21 13:57:02 mfuchs Exp $ * Author.....: $Author: mfuchs $ * Date.......: $Date: 2004/12/21 13:57:02 $ * Revision...: $Revision: 1.1.1.1 $ * State......: $State: Exp $ */ package org.dbdoclet.trafo.tokenizer; public class TokenizerException extends Exception { private static final long serialVersionUID = 1L; public TokenizerException(String msg) { super(msg); } public TokenizerException(String message, Throwable cause) { super(message, cause); } public TokenizerException(Throwable oops) { super(oops); } @Override public String getMessage() { String str; String msg; Throwable cause = getCause(); if (cause != null) { msg = "[" + cause.getClass().getName() + "] "; str = cause.getMessage(); if ((str != null) && (str.length() > 0)) { msg += str; } } else { msg = super.getMessage(); } return msg; } } /* * $Log: TokenizerException.java,v $ * Revision 1.1.1.1 2004/12/21 13:57:02 mfuchs * Reimport * * Revision 1.2 2004/10/05 13:11:21 mfuchs * Koorektur in der Behandlung von Entitäten * * Revision 1.1.1.1 2004/07/29 14:49:43 mfuchs * Tagspender * * Revision 1.1.1.1 2004/02/17 22:51:06 mfuchs * dbdoclet * * Revision 1.1.1.1 2004/01/05 14:58:45 cvs * dbdoclet * * Revision 1.1.1.1 2003/08/01 13:17:52 cvs * DocBook Doclet * * Revision 1.1.1.1 2003/07/31 17:05:39 mfuchs * DocBook Doclet since 0.46 * * Revision 1.1.1.1 2003/05/30 11:09:40 mfuchs * dbdoclet * * Revision 1.1.1.1 2003/03/18 07:41:37 mfuchs * DocBook Doclet 0.40 * * Revision 1.1.1.1 2003/03/17 20:50:12 cvs * dbdoclet * */ src/java/org/dbdoclet/service/0000755000000000000000000000000012124530534015272 5ustar rootrootsrc/java/org/dbdoclet/service/ReplaceServices.java0000644000000000000000000001153512124530526021222 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet.service; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.io.StringReader; import java.io.StringWriter; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.dbdoclet.ServiceException; public class ReplaceServices { public static String replaceAll(String buffer, String regexp, String subst) { if (buffer == null) { throw new IllegalArgumentException("The argument buffer must not be null!"); } if (regexp == null) { throw new IllegalArgumentException("The argument regexp must not be null!"); } if (subst == null) { throw new IllegalArgumentException("The argument subst must not be null!"); } Pattern pattern = Pattern.compile(regexp); Matcher matcher = pattern.matcher(buffer); return matcher.replaceAll(subst); } public static String replaceLines(String buffer, String regexp, String subst) throws IOException, ServiceException { if (buffer == null) { throw new IllegalArgumentException("The argument buffer must not be null!"); } if (regexp == null) { throw new IllegalArgumentException("The argument regexp must not be null!"); } if (subst == null) { throw new IllegalArgumentException("The argument subst must not be null!"); } BufferedReader reader = null; PrintWriter writer = null; StringWriter out = new StringWriter(); try { Pattern pattern = Pattern.compile(regexp); Matcher matcher; reader = new BufferedReader(new StringReader(buffer)); writer = new PrintWriter(out); String line; while ((line = reader.readLine()) != null) { matcher = pattern.matcher(line); if (matcher.find()) { writer.println(subst); } else { writer.println(line); } } reader.close(); writer.close(); return out.toString(); } catch (Exception oops) { throw new ServiceException(oops); } finally { try { if (reader != null) { reader.close(); } if (writer != null) { writer.close(); } } catch (IOException ioe) { ioe.printStackTrace(); } } } public static void replaceLines(File file, String regexp, String subst) throws IOException, ServiceException { if (file == null) { throw new IllegalArgumentException("The argument file must not be null!"); } if (regexp == null) { throw new IllegalArgumentException("The argument regexp must not be null!"); } if (subst == null) { throw new IllegalArgumentException("The argument subst must not be null!"); } PrintWriter writer = null; BufferedReader reader = null; try { Pattern pattern = Pattern.compile(regexp); Matcher matcher; File tmpFile = File.createTempFile("rsrl",".tmp"); writer = new PrintWriter(new FileWriter(tmpFile)); reader = new BufferedReader(new FileReader(file)); String line; while ((line = reader.readLine()) != null) { matcher = pattern.matcher(line); if (matcher.find()) { writer.println(subst); } else { writer.println(line); } } reader.close(); writer.close(); if (file.exists()) { file.delete(); } FileServices.copyFileToFile(tmpFile, file); } catch (Exception oops) { throw new ServiceException(oops); } finally { try { if (reader != null) { reader.close(); } if (writer != null) { writer.close(); } } catch (IOException ioe) { ioe.printStackTrace(); } } } } src/java/org/dbdoclet/service/ArrayServices.java0000644000000000000000000001046012124530526020721 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2006 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.service; import java.io.File; import java.util.ArrayList; import java.util.Arrays; /** * Die Klasse ArrayServices bietet Methoden für die Bearbeitung von Arrays. * */ public class ArrayServices { /** * Die Methode concat verknüpft 2 Arrays des Typs * String[] zu einem neuen String[] Array. * * @see java.lang.System#arraycopy */ public static String[] concat(String[] array1, String[] array2) { if (array1 == null) { throw new IllegalArgumentException("The argument array1 must not be null!"); } if (array2 == null) { throw new IllegalArgumentException("The argument array2 must not be null!"); } String[] array = new String[array1.length + array2.length]; System.arraycopy(array1, 0, array, 0, array1.length); System.arraycopy(array2, 0, array, array1.length, array2.length); return array; } public static File[] concat(File[] array1, File[] array2) { if (array1 == null) { throw new IllegalArgumentException("The argument array1 must not be null!"); } if (array2 == null) { throw new IllegalArgumentException("The argument array2 must not be null!"); } File[] array = new File[array1.length + array2.length]; System.arraycopy(array1, 0, array, 0, array1.length); System.arraycopy(array2, 0, array, array1.length, array2.length); return array; } /** * Die Methode concat verknüpft 2 Arrays des Typs Object[] zu einem neuen Array. */ public static Object[] concat(Object[] array1, Object[] array2) { if (array1 == null) { throw new IllegalArgumentException("The argument array1 must not be null!"); } if (array2 == null) { throw new IllegalArgumentException("The argument array2 must not be null!"); } Object[] array = new Object[array1.length + array2.length]; System.arraycopy(array1, 0, array, 0, array1.length); System.arraycopy(array2, 0, array, array1.length, array2.length); return array; } public static String[] listToSortedStringArray(ArrayList list) { if (list == null) { throw new IllegalArgumentException("The argument list must not be null!"); } Object[] objArray = list.toArray(); Arrays.sort(objArray); String[] strArray = new String[objArray.length]; for (int i = 0; i < objArray.length; i++) { if (objArray[i] == null) { strArray[i] = null; continue; } if (objArray[i] instanceof String) { strArray[i] = (String) objArray[i]; } else { strArray[i] = objArray.toString(); } } return strArray; } public static String[] listToStringArray(ArrayList list) { if (list == null) { throw new IllegalArgumentException("The argument list must not be null!"); } Object[] objArray = list.toArray(); String[] strArray = new String[objArray.length]; for (int i = 0; i < objArray.length; i++) { if (objArray[i] == null) { strArray[i] = null; continue; } if (objArray[i] instanceof String) { strArray[i] = (String) objArray[i]; } else { strArray[i] = objArray.toString(); } } return strArray; } public static String listToString(ArrayList list) { if (list == null) { throw new IllegalArgumentException("The argument list must not be null!"); } Object[] objArray = list.toArray(); StringBuffer buffer = new StringBuffer(); for (int i = 0; i < objArray.length; i++) { if (objArray[i] == null) { continue; } buffer.append(objArray[i].toString()); buffer.append(' '); } return buffer.toString(); } } src/java/org/dbdoclet/service/StringServices.java0000644000000000000000000005207512124530526021121 0ustar rootroot/* * ### Copyright (C) 2001-2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.service; import java.io.File; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.Sfv; /** * Die Klasse StringServices stellt eine Sammlung statischer * Methoden zur Bearbeitung von Zeichenketten und/oder deren * Internationalisierung zur Verfügung. * * @author Michael Fuchs * */ public class StringServices { public static final Log logger = LogFactory.getLog(StringServices.class); public static final String ZERO_WIDTH_SPACE = "\u200b"; public static final String SIX_PER_EM_SPACE = "\u2006"; public static final String SOFT_HYPHEN = "\u00ad"; /** * Die Methode replace ersetzt alle Vorkomnisse eines * bestimmten Musters durch eine Zeichenkette. * * Die orginale Zeichenkette bleibt unverändert. * * Das Muster kann in der Zeichenkette durch geschweifte Klammern begrenzt * sein, um Anfang und Ende einer Ersetzung zu kennzeichnen. * * @param str * Die Zeichenkette * @param pattern * Das Suchmuster * @param subst * Die Ersetzung * @return Die bearbeitete Zeichenkette */ public static String replace(String str, String pattern, String subst) { if (str == null) { return null; } if (pattern == null) { return str; } if (subst == null) { subst = ""; } if (pattern.equals(subst)) { return str; } int fromIndex = 0; int toIndex = 0; String pattern2 = "{" + pattern + "}"; if (str.indexOf(pattern) == -1 && str.indexOf(pattern2) == -1) { return str; } StringBuffer buffer = new StringBuffer(); while ((toIndex = str.indexOf(pattern2, toIndex)) != -1) { buffer.append(str.substring(fromIndex, toIndex)); buffer.append(subst); fromIndex = toIndex + pattern2.length(); toIndex = fromIndex; } // end of while () buffer.append(str.substring(fromIndex)); fromIndex = 0; toIndex = 0; str = buffer.toString(); buffer = new StringBuffer(); while ((toIndex = str.indexOf(pattern, toIndex)) != -1) { buffer.append(str.substring(fromIndex, toIndex)); buffer.append(subst); fromIndex = toIndex + pattern.length(); toIndex = fromIndex; } // end of while () buffer.append(str.substring(fromIndex)); return buffer.toString(); } /** * Die Methode replace ersetzt alle Vorkomnisse eines * bestimmten Musters durch eine Zeichenkette ohne die Groß/Kleinscrebung zu * beachten. * * Die orginale Zeichenkette bleibt unverändert. * * Das Muster kann in der Zeichenkette durch geschweifte Klammern begrenzt * sein, um Anfang und Ende einer Ersetzung zu kennzeichnen. * * @param str * Die Zeichenkette * @param pattern * Das Suchmuster * @param subst * Die Ersetzung * @return Die bearbeitete Zeichenkette */ public static String replaceIgnoreCase(String str, String pattern, String subst) { if (str == null) { return null; } if (pattern == null) { return str; } if (subst == null) { subst = ""; } int fromIndex = 0; int toIndex = 0; String buffer = ""; String lowerStr = str.toLowerCase(); String lowerPattern = pattern.toLowerCase(); String pattern2 = "{" + lowerPattern + "}"; while ((toIndex = lowerStr.indexOf(pattern2, toIndex)) != -1) { buffer += str.substring(fromIndex, toIndex); buffer += subst; fromIndex = toIndex + pattern2.length(); toIndex = fromIndex; } // end of while () buffer += str.substring(fromIndex); fromIndex = 0; toIndex = 0; str = buffer; buffer = ""; while ((toIndex = lowerStr.indexOf(lowerPattern, toIndex)) != -1) { buffer += str.substring(fromIndex, toIndex); buffer += subst; fromIndex = toIndex + lowerPattern.length(); toIndex = fromIndex; } // end of while () buffer += str.substring(fromIndex); return buffer; } /** * Die Methode createIndent erzeugt eine Einrückung aus * Leerzeichen der Länge len. * * @param len * int * @return String */ public static String createIndent(int len) { StringBuffer indent = new StringBuffer(); for (int i = 0; i < len; i++) { indent.append(' '); } return indent.toString(); } /** * Die Methode capFirstLetter wandelt den ersten Buchstaben * einer Zeichenkette in einen Großbuchstaben um. * * Die orginale Zeichenkette bleibt unverändert. * * @param str * Die Zeichenkette * @return Die bearbeitete Zeichenkette */ public static String capFirstLetter(String str) { if (str == null || str.length() == 0) { return str; } char[] chars = str.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); return new String(chars); } /** * Liefert den ersten Buchstaben einer Zeichenkette. */ public static String getFirstLetter(String str) { if (str == null || str.length() == 0) { return str; } char fc = str.toCharArray()[0]; char[] chars = new char[1]; chars[0] = fc; return new String(chars); } /** * Die Methode lowerFirstLetter wandelt den ersten Buchstaben * einer Zeichenkette in einen Kleinbuchstaben um. * * Die orginale Zeichenkette bleibt unverändert. * * @param str * Die Zeichenkette * @return Die bearbeitete Zeichenkette */ public static String lowerFirstLetter(String str) { if (str == null || str.length() == 0) { return str; } char[] chars = str.toCharArray(); chars[0] = Character.toLowerCase(chars[0]); return new String(chars); } /** * Die Methode createJavaIdentifier erzeugt aus einer * Zeichenkette einen gültiges Java Schlüsselwort. * * Falls der Parameter mangleUnderscores auf wahr gesetzt ist, * werden auch Unterstriche entfernt. Dies ist notwendig, um * jspc.sh konforme Klassennamen zu erzeugen. * jspc.sh ist der JSP-Compiler aus der Tomcat-Distribution. * * @param str * Die Zeichenkette * @param mangleUnderscores * boolean * @return Die bearbeitete Zeichenkette */ public static String createJavaIdentifier(String str, boolean mangleUnderscores) { if (str == null || str.length() == 0) { return str; } StringBuffer identifier = new StringBuffer(); if (Character.isJavaIdentifierStart(str.charAt(0)) == false) { identifier.append("i"); } for (int i = 0; i < str.length(); i++) { if (Character.isJavaIdentifierPart(str.charAt(i)) == false) { if (mangleUnderscores == true) { identifier.append(mangleChar(str.charAt(i), "0x")); } else { identifier.append(mangleChar(str.charAt(i), "_")); } } else { char c = str.charAt(i); if (c == '_' && mangleUnderscores == true) { identifier.append(mangleChar(str.charAt(i), "0x")); } else { identifier.append(str.charAt(i)); } } } // end of for () return identifier.toString(); } /** * Die Methode createJavaIdentifier erzeugt aus einer * Zeichenkette einen gültiges Java Schlüsselwort. * * @param str * Die Zeichenkette * @return Die bearbeitete Zeichenkette */ public static String createJavaIdentifier(String str) { return createJavaIdentifier(str, false); } /** * Die Methode mangleChar übersetzt ein Schriftzeichen in eine * numerische Darstellung. * * Die resultierende Zeichenkette startet mit einem Vorspann dem ein 5 * Spalten breiter, hexadezimaler Wert folgt. starts with a prefix, the * * Beispiel: _0002f * * @param c * a char value * @param prefix * a String value * @return String */ public static String mangleChar(char c, String prefix) { String s = Integer.toHexString(c); int nzeros = 5 - s.length(); char[] result = new char[5]; for (int i = 0; i < nzeros; i++) { result[i] = '0'; } for (int i = nzeros, j = 0; i < 5; i++, j++) { result[i] = s.charAt(j); } return (prefix + new String(result)); } /** * Die Methode createHeadline erzeugt eine Überschrift der Form * **** title ****. * * @param title * String * @return String */ public static String createHeadline(String title) { if (title == null) { throw new IllegalArgumentException( "The argument title may not be null!"); } StringBuffer sep = new StringBuffer(); for (int i = 0; i < title.length() + 4; i++) { sep.append('*'); } String buffer = sep + "\n" + "* " + title + " *\n" + sep + "\n\n"; return buffer; } /** * Die Methode info erzeugt eine Informationszeile der Form * info.... ..: . * * Die Länge der erzeugten Zeichenkette beträgt 50 Zeichen. * * @param line * String * @return String */ public static String info(String line) { return align(line, 50, '.') + ": "; } /** * Die Methode info erzeugt eine Informationszeile der Form * info.... ... * * Die Länge der erzeugten Zeichenkette beträgt 50 Zeichen. * * @param line * String * @return String */ public static String align(String line) { return align(line, 50, '.'); } /** * Die Methode info erzeugt eine Informationszeile der Form * info.... ... * * Die Länge der erzeugten Zeichenkette beträgt width Zeichen. * * @param line * String * @param width * int * @return String */ public static String align(String line, int width) { return align(line, width, '.'); } /** * Die Methode info erzeugt eine Informationszeile der Form * info... ... * * Die Länge der erzeugten Zeichenkette beträgt width Zeichen. * Das verwendete Trennzeichen kann mit Hilfe des Parameters * fill angegeben werden. * * @param line * String * @param width * int * @param fill * char * @return String */ public static String align(String line, int width, char fill) { if (line == null || line.length() == 0) { throw new IllegalArgumentException( "The argument line may not be null!"); } StringBuffer buffer = new StringBuffer(line); if (line.length() >= width) { buffer.append(fill); buffer.append(fill); buffer.append(fill); return buffer.toString(); } for (int i = line.length(); i < width; i++) { buffer.append(fill); } return buffer.toString(); } /** * The method align returns a string prefix for the output of a * double. If the double is greater than 100 the method returns an empty * string. If the double is between 100 and 10 the method returns one space, * and if the double is less than 10 it returns two spaces. * * @param d * a double value * @return String * */ public static String align(double d) { return align((int) d); } /** * The method align returns a string prefix for the output of * an integer. If the integer is greater than 100 the method returns an * empty string. If the integer is between 100 and 10 the method returns one * space, and if the integer is less than 10 it returns two spaces. * * @param i * an int value * @return String * */ public static String align(int i) { if (i >= 1000) { return ""; } // end of if () if (i >= 100) { return " "; } // end of if () if (i >= 10) { return " "; } // end of if () return " "; } /** * Die Methode chop bzw. cutSuffix schneidet die * mit suffix angegebene Zeichenkette vom Ende der Zeichenkette * suffix ab. * * @param text * String * @param suffix * String * @return String */ public static String cutSuffix(String text, String suffix) { if (suffix == null) { logger.warn(String .format("Can't cut off a null suffix (%s)!", text)); return text; } if (text == null) { return null; } if (text.length() == 0) { return text; } int index; if (text.endsWith(suffix)) { index = text.lastIndexOf(suffix); if (index != -1) { text = text.substring(0, index); } } return text; } /** * Ein Alias für cutSuffix. */ public static String chop(String text, String suffix) { return cutSuffix(text, suffix); } /** * Löscht den Buchstaben c vom Anfang und Ende der Zeichenkette * text. */ public static String trim(String text, char c) { StringBuffer buffer = new StringBuffer(); buffer.append(c); return trim(text, buffer.toString()); } /** * Löscht das Muster pattern vom Anfang und Ende der * Zeichenkette text. */ public static String trim(String text, String pattern) { if (text == null) { return null; } if (text.length() == 0) { return text; } while (text.startsWith(pattern)) { text = cutPrefix(text, pattern); } while (text.endsWith(pattern)) { text = cutSuffix(text, pattern); } return text; } /** * Die Methode cut schneidet die erste mit pattern * angegebene Zeichenkette aus der Zeichenkette text aus. * * @param text * String * @param pattern * String * @return String */ public static String cut(String text, String pattern) { if (text == null) { throw new IllegalArgumentException("Parameter text is null!"); } if (pattern == null) { throw new IllegalArgumentException("Parameter pattern is null!"); } String buffer; int start; int end; buffer = text; start = text.indexOf(pattern); if (start != -1) { buffer = text.substring(0, start); end = start + pattern.length(); if (end < text.length()) { buffer += text.substring(end, text.length()); } } return buffer; } /** * Die Methode cutPrefix entfernt die Zeichenkette * prefix vom Anfang der Zeichenkette text. * * @param text * String * @param prefix * String * @return String */ public static String cutPrefix(String text, String prefix) { if (text == null) { throw new IllegalArgumentException("Parameter text is null!"); } if (prefix == null) { throw new IllegalArgumentException("Parameter prefix is null!"); } if (text.length() < prefix.length()) { return text; } if (text.equals(prefix)) { return ""; } String buffer = text; if (text.startsWith(prefix)) { if (text.length() == prefix.length()) { buffer = ""; } else { buffer = text.substring(prefix.length()); } } return buffer; } /** * Kürzt die Zeichenkette text auf die maximale Länge von * cols. * * Ist die Zeichenkette text länger als cols * werden die letzten 3 Zeichen durch Punkte ersetzt. */ public static String shorten(String text, int cols) { if (text == null || text.length() == 0) { return ""; } if (cols < 5) { return text; } if (text.length() <= cols) { return text; } String msg = new String(text); msg = text.substring(0, (cols / 2) - 3); msg += "..."; msg += text.substring(text.length() - (cols / 2)); return msg; } public static String splitAt(String text) { return splitAt(text, File.separator, 71, Sfv.LSEP); } /** * Fügt das Trennzeichen Sfv.LSEP an Positionen des Muster * breakable ein, falls die Position innerhalb der Teilkette * größer als 71 ist. */ public static String splitAt(String text, String breakable) { return splitAt(text, breakable, 71, Sfv.LSEP); } /** * Fügt in eine Zeichenkette Trennzeichen ein. * * Die Zeichenkette text daraufhin untersucht ob an bestimmten * Stellen Trennzeichen eingefügt werden können. Der Parameter * breakPos bestimmt die minimale Länge einer Teilkette bevor * deas nächste Trennzeichen eingfügt werden kann. Der Parameter * breakable definiert das Muster an dem das Einfügen von * Trennzeichen möglich ist. */ public static String splitAt(String text, String breakable, int breakPos, String splitter) { if (text == null || text.length() == 0) { return ""; } if (text.length() <= 3) { return text; } if (breakable == null || breakable.length() == 0) { return text; } if (breakPos <= 0 || breakPos >= text.length()) { return text; } if (splitter == null || splitter.length() == 0) { return text; } boolean doSplit = true; StringBuffer buffer = new StringBuffer(); while (doSplit == true) { int lessIndex = 0; int greaterIndex = 0; int index = text.indexOf(breakable); while (index != -1) { if (index <= breakPos) { lessIndex = index; } if (index >= breakPos && greaterIndex == 0) { greaterIndex = index; } index = text.indexOf(breakable, index + 1); } if (greaterIndex == 0) { greaterIndex = text.length(); } if (lessIndex == 0) { lessIndex = breakPos; } int lessDistance = breakPos - lessIndex; int greaterDistance = greaterIndex - breakPos; // StringBuffer buffer = new StringBuffer(text); if (lessDistance <= greaterDistance || greaterIndex >= text.length()) { buffer.append(text.substring(0, lessIndex)); buffer.append(splitter); text = text.substring(lessIndex); } if (greaterDistance < lessDistance && greaterIndex < text.length()) { buffer.append(text.substring(0, greaterIndex)); buffer.append(splitter); text = text.substring(greaterIndex); } if (text.length() <= breakPos) { buffer.append(text); doSplit = false; } /* * logger.debug("text=" + text); logger.debug("text.length=" + * text.length()); logger.debug("breakPos " + breakPos); * logger.debug("lessIndex " + lessIndex); * logger.debug("greaterIndex " + greaterIndex); * logger.debug("lessDistance " + lessDistance); * logger.debug("greaterDistance " + greaterDistance); */ } return buffer.toString(); } public static String fillInt(int num, int width) { if (num < 1) { num *= -1; } String buffer = String.valueOf(num); while (width > buffer.length()) { buffer = "0" + buffer; } return buffer; } public static String fillLeadingZero(String num, int width) { String buffer = String.valueOf(num); boolean negative = false; if (buffer.startsWith("-")) { buffer = buffer.substring(1); negative = true; } while (width > buffer.length()) { buffer = "0" + buffer; } if (negative == true) { buffer = "-" + buffer; } return buffer; } public static String makeWrapable(String str) { if (str == null || str.length() == 0) { return str; } String[] tokens = { "/", "\\", "-" }; String wrapable = new String(str); for (String token : tokens) { if (token == null || token.length() == 0) { continue; } // zero width space wrapable = StringServices.replace(wrapable, token, token + ZERO_WIDTH_SPACE); } return wrapable; } public static String arrayToString(String[] array) { return arrayToString(array, " "); } public static String arrayToString(String[] array, String sep) { if (array == null || array.length == 0) { return ""; } StringBuffer buffer = new StringBuffer(); for (int i = 0; i < array.length; i++) { buffer.append(array[i]); buffer.append(sep); } return buffer.toString(); } public static String listToString(List list) { return listToString(list, Sfv.LSEP); } public static String listToString(List list, String sep) { if (list == null || list.size() == 0) { return ""; } StringBuffer buffer = new StringBuffer(); for (int i = 0; i < list.size(); i++) { buffer.append(list.get(i)); buffer.append(sep); } return buffer.toString(); } /** * Erstellt einen Rahmen aus Linienzeichen um den angegebenen Text. * * @param text * @return */ public static String createBox(String text) { StringBuilder buffer = new StringBuilder(); buffer.append('\u2554'); for (int i = 0; i < text.length() + 2; i++) { buffer.append('\u2550'); } buffer.append('\u2557'); buffer.append('\n'); buffer.append("\u2551 "); buffer.append(text); buffer.append(" \u2551\n"); buffer.append('\u255A'); for (int i = 0; i < text.length() + 2; i++) { buffer.append('\u2550'); } buffer.append('\u255D'); buffer.append('\n'); return buffer.toString(); } } src/java/org/dbdoclet/service/FindServices.java0000644000000000000000000002007412124530526020525 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2006 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.service; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.dbdoclet.comparator.PathTokenCountComparator; import org.dbdoclet.progress.ProgressEvent; import org.dbdoclet.progress.ProgressListener; public class FindServices { /** * Die Methode findFileInDirectory durchsucht ein Verzeichnis rekursiv nach * Unterverzeichnissen und Dateien. * * Die gefundenen Dateien werden als java.io.File-Objekte in * der übergebenen Liste abgelegt. * * @param dir Das Verzeichnis * @param dpattern Der reguläre Ausdruck für die Auswahl der Verzeichnisse. * @param fpattern Der reguläre Ausdruck für die Auswahl der Dateien. * @param list Die Liste der gefundenen Dateien als File-Objekte. * * @see java.io.File */ public static void findFileInDirectory(File dir, String dpattern, String fpattern, List list) { findFileInDirectory(dir, dpattern, fpattern, null, list); } public static void findFileInDirectory(File dir, String dpattern, String fpattern, ProgressListener listener, List list) { if (dir == null) { throw new IllegalArgumentException("The argument dir must not be null!"); } if (dpattern == null) { throw new IllegalArgumentException("The argument dpattern must not be null!"); } if (fpattern == null) { throw new IllegalArgumentException("The argument fpattern must not be null!"); } if (list == null) { throw new IllegalArgumentException("The argument list must not be null!"); } File[] files1 = dir.listFiles(); File[] files2; File file1; File file2; Pattern red = Pattern.compile(dpattern, Pattern.CASE_INSENSITIVE); Pattern ref = Pattern.compile(fpattern, Pattern.CASE_INSENSITIVE); Matcher dirMatcher; Matcher fileMatcher; if (files1 == null) { return; } for (int i = 0; i < files1.length; i++) { file1 = files1[i]; dirMatcher = red.matcher(file1.getName()); if (file1.isDirectory() && dirMatcher.matches()) { if (listener != null) { listener.progress(new ProgressEvent().setStage(ProgressEvent.STAGE_PREPARE).setUserObject(file1)); } files2 = file1.listFiles(); if (files2 != null && files2.length > 0) { for (int j = 0; j < files2.length; j++) { file2 = files2[j]; fileMatcher = ref.matcher(file2.getName()); if (file2.isFile() && fileMatcher.matches()) { list.add(file2); } } } findFileInDirectory(file1, dpattern, fpattern, listener, list); continue; } if (file1.isDirectory()) { if (listener != null) { listener.progress(new ProgressEvent().setStage(ProgressEvent.STAGE_PREPARE).setUserObject(file1)); } findFileInDirectory(file1, dpattern, fpattern, listener, list); } } } public static void findFile(String path, ArrayList list) { if (path == null) { throw new IllegalArgumentException("The argument path must not be null!"); } findFile(new File(path), null, list); } public static void findFile(File dir, ArrayList list) { findFile(dir, null, list); } public static void findFile(File dir, String fpattern, ArrayList list) { findFile(dir, fpattern, true, list); } /** * Die Methode findFile sucht nach Dateien im Verzeichnis * dir die auf den regulären Ausdruck fpattern * passen. * * @param dir Das Verzeichnis. * @param fpattern Der reguläre Ausdruck. * @param list Die Liste der gefundenen Dateien */ public static void findFile(File dir, String fpattern, boolean recursive, ArrayList list) { if (dir == null) { throw new IllegalArgumentException("The argument dir must not be null!"); } if (list == null) { throw new IllegalArgumentException("The argument list must not be null!"); } File[] files = dir.listFiles(); File file; Pattern ref = null; Matcher fileMatcher = null; if (fpattern != null) { ref = Pattern.compile(fpattern, Pattern.CASE_INSENSITIVE); } if (files == null) { return; } for (int i = 0; i < files.length; i++) { file = files[i]; if (file.isDirectory()) { if (recursive == true) { findFile(file, fpattern, list); } } else { if (ref != null) { fileMatcher = ref.matcher(file.getName()); if (fileMatcher.matches()) { list.add(file); } } else { list.add(file); } } } } /** * Die Methode findDirectory sucht nach Unterverzeichnissen im * Verzeichnis dir die auf den regulären Ausdruck * dpattern passen. Die Liste wird, bevor sie an die aufrufende * Methode zurückgegeben wird, nach der Anzahl der Pfadelemente * sortiert. Und zwar so, daß die längsten Pfade am Anfang der Liste * stehen. Dies ermöglicht eine Verarbeitung, z.B. Umbenennung, der Pfade * vom Ende her, in der Art, daß möglichst alle Pfade ihre Gültigkeit * behalten. Würde ein Pfad zuerst am Anfang manipuliert, z.B. durch * Umbennenung, wären alle Pfadnamen der Unterverzeichnisse auf einen Schlag * ungültig. * * @param dir Das Verzeichnis * @param dpattern Der reguläre Ausdruck. * @param list Die Liste der gefundenen Dateien */ public static void findDirectory(File dir, String dpattern, ArrayList list) { if (dir == null) { throw new IllegalArgumentException("The argument dir must not be null!"); } if (dpattern == null) { throw new IllegalArgumentException("The argument dpattern must not be null!"); } if (list == null) { throw new IllegalArgumentException("The argument list must not be null!"); } File[] files = dir.listFiles(); File file; Pattern red = Pattern.compile(dpattern, Pattern.CASE_INSENSITIVE); Matcher dirMatcher; if (files == null) { return; } for (int i = 0; i < files.length; i++) { file = files[i]; if (file.isDirectory()) { dirMatcher = red.matcher(file.getName()); if (dirMatcher.matches()) { list.add(file); } findDirectory(file, dpattern, list); } } Collections.sort(list, new PathTokenCountComparator()); } } src/java/org/dbdoclet/service/ExecServices.java0000644000000000000000000002175112124530526020534 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2006 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.service; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.Sfv; import org.dbdoclet.progress.InfoListener; public class ExecServices { private static Log logger = LogFactory.getLog(ExecServices.class); public static void sleep(int secs) { try { Thread.sleep(secs * 1000); } catch (InterruptedException oops) { oops.printStackTrace(); } } /** * Ausführen eines externen Programmes im aktuellen Arbeitsverzeichnis. * * @param cmd * @return */ public static ExecResult exec(String cmd) { return exec(cmd, new File("."), false, null); } public static ExecResult exec(String cmd, InfoListener listener) { return exec(cmd, new File("."), false, listener); } public static ExecResult exec(String cmd, File workDir, InfoListener listener) { return exec(cmd, workDir, false, listener); } public static ExecResult exec(String cmd, boolean background) { return exec(cmd, new File("."), background, null); } public static ExecResult exec(String cmd, File workDir, boolean background) { return exec(cmd, workDir, background, null); } public static ExecResult exec(String cmd, File workDir, boolean background, InfoListener listener) { if (cmd == null) { throw new IllegalArgumentException( "The argument cmd may not be null!"); } if (workDir == null) { workDir = new File("."); } StringTokenizer stz = new StringTokenizer(cmd); ArrayList cmdList = new ArrayList(); String token; while (stz.hasMoreTokens()) { token = stz.nextToken(); if (token.startsWith("-") && token.endsWith("\"")) { token = StringServices.cut(token, "\""); token = StringServices.cutSuffix(token, "\""); } if (token.startsWith("\"")) { while (stz.hasMoreTokens()) { token += " " + stz.nextToken(); if (token.endsWith("\"")) { break; } } } token = StringServices.trim(token, '"'); cmdList.add(token); } String[] cmdArray = ArrayServices.listToStringArray(cmdList); for (int i = 0; i < cmdArray.length; i++) { logger.debug("cmdArray[" + i + "]=" + cmdArray[i]); } return exec(cmdArray, null, workDir, background, listener); } public static ExecResult exec(String[] cmd) { if (cmd == null) { throw new IllegalArgumentException( "The argument cmd may not be null!"); } return exec(cmd, null, null, false); } public static ExecResult exec(String[] cmd, boolean background) { if (cmd == null) { throw new IllegalArgumentException( "The argument cmd may not be null!"); } return exec(cmd, null, null, background); } public static ExecResult exec(String[] cmd, String path) { if (cmd == null) { throw new IllegalArgumentException( "The argument cmd may not be null!"); } if (path == null) { throw new IllegalArgumentException( "The argument path may not be null!"); } return exec(cmd, null, new File(path), false); } public static ExecResult exec(String[] cmd, String[] envp, File dir) { return exec(cmd, envp, dir, false); } public static ExecResult exec(String[] cmd, String[] envp, File dir, boolean background) { return exec(cmd, envp, dir, background, null); } public static ExecResult exec(String[] cmd, String[] envp, File dir, boolean background, InfoListener listener) { if (cmd == null) { throw new IllegalArgumentException( "The argument cmd may not be null!"); } StringBuilder buffer = new StringBuilder(); buffer.append("Executing \""); for (int i = 0; i < cmd.length; i++) { buffer.append("'"); buffer.append(cmd[i]); buffer.append("' "); } buffer.append("\""); logger.info(buffer.toString()); Process process = null; int exitCode = 0; ExecResult result = new ExecResult(); result.setCommand(StringServices.arrayToString(cmd)); StdInput stdout = null; StdInput stderr = null; try { Runtime runtime = Runtime.getRuntime(); if (envp == null && dir == null) { process = runtime.exec(cmd); } if (envp == null && dir != null) { // envp = new String[0]; process = runtime.exec(cmd, envp, dir); } if (envp != null && dir == null) { dir = new File("."); process = runtime.exec(cmd, envp, dir); } if (envp != null && dir != null) { process = runtime.exec(cmd, envp, dir); } result.setProcess(process); stdout = new StdInput(process.getInputStream(), listener, result); stderr = new StdInput(process.getErrorStream(), listener, result); stdout.start(); stderr.start(); if (background == false) { process.waitFor(); stdout.join(10000); stderr.join(10000); } } catch (Throwable oops) { result.setThrowable(oops); result.setExitCode(-1); } finally { if (background == false) { try { logger.info("Closing Stdout and Stderr..."); if (stdout != null) { stdout.close(); } if (stderr != null) { stderr.close(); } if (process != null) { exitCode = process.exitValue(); result.setExitCode(exitCode); } else { result.setExitCode(-1); } } catch (IllegalThreadStateException itse) { process.destroy(); } } } return result; } public static ExecResult open(File file) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } String[] cmd; ExecResult result = null; String path = file.getCanonicalPath(); if (JvmServices.isWindows()) { if (file.isDirectory()) { cmd = new String[2]; cmd[0] = "explorer"; cmd[1] = path; } else { cmd = new String[3]; cmd[0] = "cmd"; cmd[1] = "/c"; cmd[2] = path; } result = ExecServices.exec(cmd); } if (JvmServices.isUnix()) { String desktopSession = System.getProperty("desktop.session"); if (desktopSession != null && desktopSession.equalsIgnoreCase("gnome")) { cmd = new String[2]; cmd[0] = "gnome-open"; cmd[1] = path; result = ExecServices.exec(cmd); } else if (desktopSession != null && desktopSession.equalsIgnoreCase("kde")) { cmd = new String[3]; cmd[0] = "kfmclient"; cmd[1] = "newTab"; cmd[2] = path; result = ExecServices.exec(cmd); } else { cmd = new String[2]; cmd[0] = "gnome-open"; cmd[1] = path; result = ExecServices.exec(cmd); if (result.failed()) { cmd = new String[3]; cmd[0] = "kfmclient"; cmd[1] = "newTab"; cmd[2] = path; result = ExecServices.exec(cmd); } } } return result; } public static void invokeInfoViewer(final InfoListener viewer, final InputStream instr) { if (viewer == null) { throw new IllegalArgumentException( "The argument viewer must not be null!"); } if (instr == null) { throw new IllegalArgumentException( "The argument instr must not be null!"); } Thread t = new Thread() { @Override public void run() { BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(instr)); String line = reader.readLine(); while (line != null) { viewer.info(line); line = reader.readLine(); } } catch (Exception oops) { oops.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException ioe) { ioe.printStackTrace(); } } } } }; t.start(); } } class StdInput extends Thread { private BufferedReader reader; private InfoListener listener; private ExecResult result; private boolean doClose = false; public StdInput(InputStream instr, InfoListener listener, ExecResult result) { if (instr == null) { throw new IllegalArgumentException( "The argument instr must not be null!"); } if (result == null) { throw new IllegalArgumentException( "The argument result may not be null!"); } this.result = result; this.listener = listener; reader = new BufferedReader(new InputStreamReader(instr)); } public void close() { doClose = true; try { reader.close(); } catch (IOException ioe) { ioe.printStackTrace(); } } @Override public void run() { try { String line = reader.readLine(); while (line != null && doClose == false) { if (listener != null) { listener.info(line); } result.appendOutput(line + Sfv.LSEP); line = reader.readLine(); } } catch (Exception oops) { oops.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException ioe) { ioe.printStackTrace(); } } } } } src/java/org/dbdoclet/service/ExecResult.java0000644000000000000000000000432612124530526020226 0ustar rootrootpackage org.dbdoclet.service; import java.io.PrintWriter; import java.io.StringWriter; public class ExecResult { private Process process; private String command; private StringBuffer output; private Throwable oops; private int exitCode = -1; public ExecResult() { output = new StringBuffer(); oops = null; } public void setCommand(String command) { this.command = command; } public String getCommand() { return command; } public void setOutput(StringBuffer output) { this.output = output; } public void appendOutput(StringBuffer buffer) { this.output.append(buffer); } public void appendOutput(String buffer) { this.output.append(buffer); } public String getOutput() { return output.toString(); } public void setProcess(Process process) { this.process = process; } public Process getProcess() { return process; } public void setThrowable(Throwable oops) { this.oops = oops; } public Throwable getThrowable() { return oops; } public String getStackTrace() { if (oops == null) { return ""; } StringWriter buffer = new StringWriter(); oops.printStackTrace(new PrintWriter(buffer)); return buffer.toString(); } public void setExitCode(int exitCode) { this.exitCode = exitCode; } public int getExitCode() { return exitCode; } public boolean failed() { if (exitCode == 0) { return false; } return true; } @Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("Command '" + command + "' failed!\n"); buffer.append("Exit Code: "); buffer.append(exitCode); buffer.append('\n'); buffer.append("Console Output: "); buffer.append(output); buffer.append('\n'); if (oops != null) { buffer.append("Stacktrace: "); buffer.append(getStackTrace()); buffer.append('\n'); } return buffer.toString(); } } src/java/org/dbdoclet/service/UnicodeServices.java0000644000000000000000000000615712124530526021241 0ustar rootrootpackage org.dbdoclet.service; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Die Klasse UnicodeServices stellt eine Sammlung statischer * Methoden zur Bearbeitung von Unicode zur Verfügung. * * @author Michael Fuchs * @version 1.0 */ public class UnicodeServices { private static Pattern pattern = Pattern.compile("\\\\u[0-9a-fA-F]{4}"); public static String escape(char c) { char[] v = new char[1]; v[0] = c; return escape(new String(v)); } /** * Die Methode escape wandelt die Zeichenkette * str in eine 7-bit ASCII Darstellung um. * * @param str String * @return String */ public static String escape(String str) { if (str == null) { return ""; } StringBuffer buffer = new StringBuffer(); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); int n = c; if (c == '\r') { continue; } if (n >= 0 && n < 128 && c != '\n' && c != '\\') { buffer.append(c); } else { buffer.append("\\u"); String hex = Integer.toHexString(n); for (int j = 0; j < 4 - hex.length(); j++) { buffer.append("0"); } buffer.append(hex); } } return buffer.toString(); } public static String unescape(String str) { Matcher matcher = pattern.matcher(str); char[] c = new char[1]; String escape; String buffer; String part1; String part2; while (matcher.find()) { escape = matcher.group(); c[0] = (char) Integer.parseInt(escape.substring(2), 16); buffer = new String(c); // System.out.println("buffer = " + buffer); part1 = str.substring(0, matcher.start()); // System.out.println("part1 = " + part1); part2 = str.substring(matcher.end()); // System.out.println("part2 = " + part2); str = part1 + buffer + part2; // System.out.println("str = " + str); matcher.reset(str); } return str; } public static String removeUndefinedCharacters(String text) { if (text == null || text.length() == 0) { return ""; } StringBuffer textBuffer = new StringBuffer(text); StringBuffer buffer = new StringBuffer(); char c; for (int i = 0; i < textBuffer.length(); i++) { c = textBuffer.charAt(i); if (c == '\n' || c == '\t') { buffer.append(c); continue; } if (Character.isISOControl(c) == false && Character.isDefined(c) == true) { buffer.append(c); } } return buffer.toString(); } } src/java/org/dbdoclet/service/FileVisitor.java0000644000000000000000000000017612124530526020401 0ustar rootrootpackage org.dbdoclet.service; import java.io.File; public interface FileVisitor { public void visit(File file); } src/java/org/dbdoclet/service/FileServices.java0000644000000000000000000020406112124530526020524 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2003-2006 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.service; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.FileNameMap; import java.net.URLConnection; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.CreatePathException; import org.dbdoclet.DeleteFileException; import org.dbdoclet.FileAccessDeniedException; import org.dbdoclet.RenameFileException; import org.dbdoclet.ServiceException; import org.dbdoclet.Sfv; import org.dbdoclet.io.DirectoryFilter; import org.dbdoclet.io.EndsWithFilter; import org.dbdoclet.io.MimeType; import org.dbdoclet.io.StartsWithFilter; import org.dbdoclet.progress.ProgressEvent; import org.dbdoclet.progress.ProgressListener; import org.dbdoclet.template.TemplateTransformException; import org.dbdoclet.template.TemplateTransformer; /** * Die Klasse FileServices stellt Dienste rund um die * Dateiverwaltung bereit. * * @author Michael Fuchs * @version 1.0 */ public class FileServices { /** Alle Dateien */ public static final int ALL = 2; /** Verwende den EndsWith-Filter */ public static final int ENDS_WITH = 1; public static final String FSEP = System.getProperty("file.separator"); private static Log logger = LogFactory.getLog(FileServices.class); /** Verwende den StartsWith-Filter */ public static final int STARTS_WITH = 0; public static final Pattern PATTERN_ABSOLUTE_WINDOWS_PATH = Pattern .compile("^([a-z,A-Z]:|/)/.*$"); /** * @see #appendFileName(String dir, String filename) */ public static String appendFileName(File dir, String filename) { if (dir == null) { throw new IllegalArgumentException( "The argument dir must not be null!"); } return appendFileName(dir.getAbsolutePath(), filename); } /** * Die Methode appendFileName hängt den Dateinamen and das * Verzeichnis an. * * Falls der Dateinamen mit dem betriebsspezifischen Pfadtrennzeichen endet * wird eine IllegalArgumentException ausgelöst. * *
* *
	 * 
	 * String path = System.getProperty("user.home");
	 * 
	 * path = FileServices.appendPath(path, "logs");
	 * FileServices.createPath(path);
	 * 
	 * path = FileServices.appendFileName(path, "Errors.log");
	 * File file = new File(path);
	 * 
	 * 
* *
* * */ public static String appendFileName(String path1, String filename) { if (path1 == null || path1.length() == 0) { throw new IllegalArgumentException( "The argument path1 must not be null!"); } if (filename == null) { throw new IllegalArgumentException( "The argument filename must not be null!"); } if (filename.trim().length() == 0) { throw new IllegalArgumentException( "The argument filename must not be empty!"); } if (path1.endsWith(File.separator) == false) { path1 += File.separator; } if (filename.startsWith(File.separator) == true && filename.length() > 1) { filename = filename.substring(1); } if (filename.endsWith(File.separator) == true) { throw new IllegalArgumentException("The name of file '" + filename + "' must not end with '" + File.separator + "'!"); } if (filename.length() == 0) { throw new IllegalArgumentException( "The filename must not be of length 0!"); } return path1 + filename; } public static String appendPath(File dir1, File dir2) { if (dir1 == null) { throw new IllegalArgumentException( "The argument dir1 must not be null!"); } if (dir2 == null) { throw new IllegalArgumentException( "The argument dir2 must not be null!"); } return appendPath(dir1.getPath(), dir2.getPath()); } public static String appendPath(File dir1, String path2) { if (dir1 == null) { throw new IllegalArgumentException( "The argument dir1 must not be null!"); } if (path2 == null) { throw new IllegalArgumentException( "The argument path2 must not be null!"); } return appendPath(dir1.getPath(), path2); } /** * Die Methode appendPath hängt das Verzeichnis path2 an das * Verzeichnis path1. * * Der erstellte Verzeichnispfad endet in jedem Fall mit dem * betriebsspezifischen Trennzeichen für Verzeichnisse. */ public static String appendPath(String path1, String path2) { if (path1 == null || path1.length() == 0) { throw new IllegalArgumentException( "The argument path1 must not be null!"); } if (path2 == null || path2.length() == 0) { throw new IllegalStateException("The field path2 must not be null!"); } path1 = path1.replace("/", File.separator); path2 = path2.replace("/", File.separator); if (path1.endsWith(File.separator) == false) { path1 += File.separator; } if (path2.startsWith(File.separator) == true) { if (path2.length() > File.separator.length()) { path2 = path2.substring(File.separator.length()); } } if (path2.endsWith(File.separator) == false) { path2 += File.separator; } return path1 + path2; } /** * Die Methode cleanRelatedFiles löscht eine Datei oder ein * Verzeichnis und alle "verwandten" Dateien und Verzeichnisse. * * Als verwandte Dateiobjekte werden alle Dateien und Verzeichnisse * betrachtet, deren Dateinname aus dem Dateinamen der Referenzdatei mit * angehängtem Bindestrich und einer Ziffer besteht. Falls eine * Dateinamenserweiterung vorhanden ist, wird diese am Ende des Dateinamens * erwartet, z.B. Addressen-12.txt ist verwand mit * Addressen.txt. * * @param file * File * @exception IOException */ public static void cleanRelatedFiles(File file) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } int index = 1; String fileBase; String fileExt; String path; fileBase = getFileBase(file.getCanonicalPath()); fileExt = getExtension(file.getCanonicalPath()); logger.debug("Verzeichnis aufräumen: " + file.getCanonicalPath()); while (file.exists() == true) { try { setWritable(file); delete(file); } catch (Exception oops) { logger.fatal("FileServices.cleanRelatedFiles", oops); } path = fileBase + "-" + String.valueOf(index++); if (fileExt != null && fileExt.trim().length() > 0) { path += "." + fileExt; } file = new File(path); logger.debug("Verzeichnis aufräumen: " + file.getCanonicalPath()); } } public static boolean contains(File file, String regex) throws ServiceException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } if (regex == null) { throw new IllegalArgumentException( "The argument regex must not be null!"); } BufferedReader reader = null; try { Pattern pattern = Pattern.compile(regex); Matcher matcher; reader = new BufferedReader(new FileReader(file)); String line; while ((line = reader.readLine()) != null) { matcher = pattern.matcher(line); if (matcher.find()) { return true; } } return false; } catch (IOException oops) { throw new ServiceException(oops); } finally { try { if (reader != null) { reader.close(); } } catch (IOException ioe) { ioe.printStackTrace(); } } } public static boolean copyDir(File src, File dest) throws IOException { if (src == null) { throw new IllegalArgumentException( "The argument src must not be null!"); } if (dest == null) { throw new IllegalArgumentException( "The argument dest must not be null!"); } return copyDir(src.getCanonicalPath(), dest.getCanonicalPath(), null, null); } public static boolean copyDir(File src, File dest, Map filterSet) throws IOException { if (src == null) { throw new IllegalArgumentException( "The argument src must not be null!"); } if (dest == null) { throw new IllegalArgumentException( "The argument dest must not be null!"); } return copyDir(src.getCanonicalPath(), dest.getCanonicalPath(), null, filterSet, null, null); } public static boolean copyDir(File src, File dest, Pattern includePattern) throws IOException { if (src == null) { throw new IllegalArgumentException( "The argument src must not be null!"); } if (dest == null) { throw new IllegalArgumentException( "The argument dest must not be null!"); } if (includePattern == null) { throw new IllegalArgumentException( "The argument includePattern must not be null!"); } Pattern[] patterns = new Pattern[1]; patterns[0] = includePattern; return copyDir(src.getPath(), dest.getPath(), patterns, null, null, null); } public static boolean copyDir(File src, String dest, int index) throws IOException { if (src == null) { throw new IllegalArgumentException( "The argument src must not be null!"); } return copyDir(src.getCanonicalPath(), dest, index); } public static boolean copyDir(File src, String dest, int index, ProgressListener listener, String resourceString) throws IOException { if (src == null) { throw new IllegalArgumentException( "The argument src must not be null!"); } return copyDir(src.getCanonicalPath(), dest, index, listener, resourceString); } public static boolean copyDir(String src, String dest) throws IOException { return copyDir(src, dest, null, null, null, null); } public static boolean copyDir(String src, String dest, int index) throws IOException { return copyDir(src, dest, index, null, null); } /** * Die Methode copyDir kopiert das Verzeichnis mit einem Teil * seines übergeordneten Pfades in das angegebene Zielverzeichnis. * * @param src * String * @param dest * String * @param index * int * @exception IOException */ public static boolean copyDir(String src, String dest, int index, ProgressListener listener, String resourceString) throws IOException { String path = normalizePath(src); path = StringServices.chop(path, "/"); String name = getPathToken(path, index); if (name == null) { throw new FileNotFoundException(src); } for (int i = index; i > 0; i--) { name = getPathToken(path, i); dest = appendPath(dest, name); logger.debug("Anlegen des Verzeichnisses " + dest + "."); dest = normalizePath(dest); FileServices.createPath(dest); } return copyDir(src, dest, null, null, listener, resourceString); } public static boolean copyDir(String src, String dest, Map filterSet) throws IOException { return copyDir(src, dest, null, filterSet, null, null); } public static boolean copyDir(String src, String dest, Pattern[] includePatterns) throws IOException { return copyDir(src, dest, includePatterns, null, null, null); } /** * Die Methode copyDir kopiert ein Verzeichnis und seinen * Inhalt einschließlich aller Unterverzeichnissen. * * @param src * Der Parameter src enthält das Quellverzeichnis, * welches kopiert werden soll. Wird als Wert null * übergeben existiert das Verzeichnis nicht oder der angegebene * Pfad ist kein Verzeichnis, wird eine * IllegalArgumentException ausglöst. * * @param dest * Der Parameter dest enthält das Zielverzeichnis in * das kopiert werden soll. Wird als Wert null * übergeben oder ist der angegebene Pfad kein Verzeichnis, wird * eine IllegalArgumentException ausglöst. Falls das * Zielverzeichnis nicht existiert wird es angelegt. * * @exception IOException * Falls beim Kopieren ein Ein/Ausgabefehler auftritt. */ public static boolean copyDir(String src, String dest, Pattern[] includePatterns, Map filterSet, ProgressListener listener, String resourceString) throws IOException { String msg; src = normalizePath(src); dest = normalizePath(dest); logger.debug(src + " -> " + dest); if (src == null) { throw new IllegalArgumentException("Parameter src is null!"); } if (dest == null) { throw new IllegalArgumentException("Parameter dest is null!"); } File srcDir = new File(src); if (srcDir.exists() == false) { throw new FileNotFoundException("Source path '" + srcDir.getAbsolutePath() + "' dosen't exist!"); } if (srcDir.isDirectory() == false) { throw new IllegalArgumentException("Source path '" + srcDir.getAbsolutePath() + "' is not a directory!"); } File destDir = FileServices.createPath(dest); if (destDir.isDirectory() == false) { throw new IllegalArgumentException("Destination path '" + destDir.getAbsolutePath() + "' is not a directory!"); } src = normalizePath(srcDir.getCanonicalPath()); dest = normalizePath(destDir.getCanonicalPath()); File[] files = srcDir.listFiles(); File destFile; String destFileName; for (int i = 0; i < files.length; i++) { destFileName = appendFileName(dest, files[i].getName()); destFile = new File(destFileName); if (files[i].isDirectory()) { String newSrc = files[i].getCanonicalPath(); newSrc = normalizePath(newSrc); String newDest = StringServices.replace(newSrc, src, dest); copyDir(newSrc, newDest, includePatterns, filterSet, listener, resourceString); if (includePatterns != null) { File newDestDir = new File(newDest); if (newDestDir.list().length == 0) { delete(newDestDir); } } } if (includePatterns != null) { boolean doCopy = false; for (int p = 0; p < includePatterns.length; p++) { Matcher matcher = includePatterns[p].matcher(destFileName); if (matcher.matches() == true) { doCopy = true; break; } } if (doCopy == false) { continue; } } if (files[i].isFile()) { if (listener != null) { logger.debug("Firing progress event."); if (resourceString != null) { msg = MessageFormat.format(resourceString, files[i].getPath(), destFile.getPath()); } else { msg = files[i].getName(); } if (listener.progress(new ProgressEvent(msg, false)) == false) { return false; } } logger.debug(files[i].getAbsolutePath() + " -> " + destFile.getAbsolutePath()); if (filterSet == null || isBinary(files[i])) { FileInputStream in; FileOutputStream out; in = new FileInputStream(files[i]); out = new FileOutputStream(destFile); int n = 0; byte[] buffer = new byte[4096]; while ((n = in.read(buffer, 0, 4096)) != -1) { out.write(buffer, 0, n); } in.close(); out.flush(); out.close(); if (destFile.exists() == false) { throw new IOException("Couldn't create file " + destFileName + "!"); } if (destFile.length() != files[i].length()) { throw new IOException("Files differ after copy: " + destFileName + "!"); } } else { try { TemplateTransformer trafo = TemplateTransformer .newInstance(files[i]); trafo.transform(filterSet, destFile); } catch (TemplateTransformException oops) { IOException ioe = new IOException( "TemplateTransformException: " + oops.getMessage()); ioe.initCause(oops); ioe.fillInStackTrace(); throw ioe; } if (destFile.exists() == false) { throw new IOException("Couldn't create file " + destFileName + "!"); } } } } return true; } public static boolean copyDir(String src, String dest, ProgressListener listener, String resourceString) throws IOException { return copyDir(src, dest, null, null, listener, resourceString); } public static void copyFileToDir(File src, File destdir) throws IOException { copyFileToDir(src.getPath(), destdir.getPath()); } /** * Die Methode copyFileToDir kopiert eine einzelne Datei in das * angegebene Zielverzeichnis. * * Falls das Zielverzeichnis nicht existiert, wird es angelegt. * * Die Datei wird nur kopiert, falls die Quelldatei neuer als die Zieldatei * ist. * * @exception IOException * falls ein Fehler beim Kopieren auftritt. */ public static void copyFileToDir(String src, String destdir) throws IOException { File file; if (src == null) { throw new IllegalArgumentException("Parameter src is null!"); } file = new File(src); if (file.exists() == false) { throw new IllegalArgumentException("Parameter src (" + file.getAbsolutePath() + ") can not be found!"); } if (file.isFile() == false) { throw new IllegalArgumentException("Parameter src (" + file.getAbsolutePath() + ") is not a normal file!"); } if (destdir == null) { throw new IllegalArgumentException("Parameter destdir is null!"); } file = new File(destdir); if (file.exists() && file.isDirectory() == false) { throw new IllegalArgumentException("Parameter destdir (" + file.getAbsolutePath() + ") is not a directory!"); } File srcFile = new File(src); String path = appendFileName(destdir, srcFile.getName()); File destFile = new File(path); FileInputStream in; FileOutputStream out; in = new FileInputStream(srcFile); out = new FileOutputStream(destFile); int n = 0; byte[] buffer = new byte[4096]; while ((n = in.read(buffer, 0, 4096)) != -1) { out.write(buffer, 0, n); } in.close(); out.close(); } /** * Die Methode copyFileToFile kopiert eine einzelne Datei, * falls die Quelldatei neuer als die Zieldatei ist. * * Falls das Zielverzeichnis nicht existiert, wird es angelegt. * * @throws IOException * falls ein Fehler beim Kopieren auftritt. */ public static void copyFileToFile(File src, File dest) throws IOException { copyFileToFile(src.getAbsolutePath(), dest.getAbsolutePath(), null); } public static void copyFileToFile(File srcFile, File destFile, Map filterSet) throws IOException { if (srcFile == null) { throw new IllegalArgumentException("Parameter srcFile is null!"); } if (srcFile.exists() == false) { throw new IllegalArgumentException( "Parameter srcFile doesn't exist! '" + srcFile.getAbsolutePath() + "'"); } if (srcFile.isFile() == false) { throw new IllegalArgumentException( "Parameter srcFile is not a normal file! '" + srcFile.getAbsolutePath() + "'"); } if (destFile == null) { throw new IllegalArgumentException("Parameter destFile is null!"); } if (srcFile.exists() && srcFile.isFile() == false) { throw new IllegalArgumentException( "Parameter destFile is not a normal file! '" + srcFile.getAbsolutePath() + "'"); } if (srcFile.equals(destFile)) { return; } if (destFile.exists() == true && destFile.canWrite() == false) { throw new FileAccessDeniedException(destFile); } String srcPath = srcFile.getCanonicalPath(); srcPath = normalizePath(srcPath); String destPath = destFile.getCanonicalPath(); destPath = normalizePath(destPath); if (destPath.equals(srcPath)) { logger.warn("Copy: Files " + srcPath + " and " + destPath + " are identical!"); return; } String destParentDir = destFile.getParent(); if (destParentDir != null && destParentDir.length() > 0) { createPath(destParentDir); } if (filterSet == null || isBinary(srcFile)) { FileInputStream in; FileOutputStream out; in = new FileInputStream(srcFile); out = new FileOutputStream(destFile); int n = 0; byte[] buffer = new byte[4096]; while ((n = in.read(buffer, 0, 4096)) != -1) { out.write(buffer, 0, n); } in.close(); out.flush(); out.close(); } else { try { TemplateTransformer trafo = TemplateTransformer .newInstance(srcFile); trafo.transform(filterSet, destFile); } catch (TemplateTransformException oops) { IOException ioe = new IOException( "TemplateTransformException: " + oops.getMessage()); ioe.initCause(oops); ioe.fillInStackTrace(); throw ioe; } } } public static void copyFileToFile(String src, String dest) throws IOException { copyFileToFile(new File(src), new File(dest), null); } /** * Die Methode copyFileToFile kopiert eine einzelne Datei. * Falls das Zielverzeichnis nicht existiert, wird es angelegt. * * @throws IOException * falls ein Fehler beim Kopieren auftritt. */ public static void copyFileToFile(String src, String dest, Map filterSet) throws IOException { copyFileToFile(new File(src), new File(dest), filterSet); } public static File createParentDir(File dir) throws IOException { if (dir == null) { throw new IllegalArgumentException( "The argument dir must not be null!"); } File parentDir = dir.getParentFile(); if (parentDir == null) { return null; } return createPath(parentDir); } /** * Legt ein neues Verzeichnis an. * * Falls das Verzeichnis bereits existiert, wird dieses ohne Fehlermeldung * zurückgeliefert. Existiert das Verzeichnis nicht und das Anlegen schlägt * fehl wird eine Ausnahme erzeugt. * * Vorbedingung: Wird als dir-Parameter * null Übergeben, so wird eine * IllegalArgumentException ausgelöst. * * @exception IOException * falls das Anlegen des Verzeichnisses fehlschlägt. */ public static File createPath(File dir) throws IOException { if (dir == null) { throw new IllegalArgumentException( "The argument dir must not be null!"); } String dirName = dir.getCanonicalPath(); if (JvmServices.isWindows()) { if (dirName != null && dirName.length() > 255) { throw new CreatePathException(dirName, CreatePathException.PATH_TOO_LONG); } } if (dir.exists() == false) { if (dir.mkdirs() == false && dir.exists() == false) { ArrayList pathList = new ArrayList(); pathList.add(0, dir); File parent = dir.getParentFile(); File next = dir; while (parent != null && parent.exists() == false) { pathList.add(0, parent); next = parent; parent = parent.getParentFile(); } if (parent != null && parent.exists() == true) { if (parent.isDirectory() == false) { throw new CreatePathException(next.getCanonicalPath(), CreatePathException.FILE_PARENT); } if (parent.canWrite() == false || parent.canRead() == false) { throw new CreatePathException(next.getCanonicalPath(), CreatePathException.PERMISSION_DENIED); } } throw new CreatePathException(dir.getCanonicalPath()); } } return dir; } /** * Legt ein neues Verzeichnis an. * * Falls das Verzeichnis bereits existiert, wird dieses ohne Fehlermeldung * zurückgeliefert. Existiert das Verzeichnis nicht und das Anlegen schlägt * fehl wird eine Ausnahme erzeugt. * * Vorbedingung:Wird als path-Parameter * null übergeben, so wird eine * IllegalArgumentException ausgelöst. * * @throws IOException * falls das Anlegen des Verzeichnisses fehlschlägt. */ public static File createPath(String path) throws IOException { if (path == null) { throw new IllegalArgumentException("Parameter path is null!"); } return createPath(new File(path)); } public static File createUniqueFile(File file) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } int index = 1; String fileBase; String fileExt; String path; fileBase = getFileBase(file.getCanonicalPath()); fileExt = getExtension(file.getCanonicalPath()); while (file.exists() == true) { path = fileBase + "-" + String.valueOf(index++); if (fileExt != null && fileExt.trim().length() > 0) { path += "." + fileExt; } file = new File(path); } return file; } public static String cutPrefixPathItems(String path, int length) { if (path == null) { throw new IllegalArgumentException( "The argument path must not be null!"); } if (length < 0) { throw new IllegalArgumentException( "The argument length must not be < 0!"); } String buffer = normalizePath(path); buffer = StringServices.cutPrefix(buffer, "/"); while (buffer.endsWith("/")) { buffer = StringServices.cutSuffix(buffer, "/"); } int index = buffer.indexOf("/"); int counter = 1; while (index > 0 && counter < length) { index = buffer.indexOf("/", index + 1); counter++; } return buffer.substring(index + 1); } public static int delete(File file) throws IOException { if (file == null) { return 0; } return delete(file.getPath(), null); } public static int delete(File file, ProgressListener listener) throws IOException { return delete(file.getPath(), listener, null); } /** * Die Methode delete löscht alle regulären Dateien aus dem * Verzeichnis, die auf den regulären Asudruck passen. * * @param dir * a File value * @param regexp * a String value * @return an int value * @exception IOException * if an error occurs */ public static int delete(File dir, String regexp) throws IOException { if (dir == null) { return 0; } ArrayList fileList = new ArrayList(); FindServices.findFile(dir, regexp, false, fileList); for (File file : fileList) { delete(file); } return fileList.size(); } /** * Die Methode delete löscht eine Datei oder ein Verzeichnis * und alle darin enthaltenen Dateien und Unterverzeichnisse. */ public static int delete(String path) throws IOException { return delete(path, null); } public static int delete(String path, ProgressListener listener) throws IOException { return delete(path, listener, null); } /** * Die Methode delete löscht eine Datei oder ein Verzeichnis * und alle darin enthaltenen Dateien und Unterverzeichnisse. */ public static int delete(String path, ProgressListener listener, String resourceString) throws IOException { return delete(new File(path), listener, resourceString); } /** * Die Methode delete löscht eine Datei oder ein * Verzeichnis und alle darin enthaltenen Dateien und Unterverzeichnisse. */ public static int delete(File node, ProgressListener listener, String resourceString) throws IOException { String msg; logger.debug("Lösche Pfad " + node + "."); if (node == null) { return 0; } boolean rc; int counter = 0; if (node.exists() == false) { logger.debug("Der Pfad " + node.getAbsolutePath() + " existiert nicht!"); return 0; } if (node.isFile() == true) { rc = node.delete(); if (rc == false) { throw new DeleteFileException(node); /* * if (JvmServices.isWindows()) { * * String[] cmd = new String[4]; cmd[0] = "del"; cmd[1] = "/F"; * cmd[2] = "/Q"; cmd[3] = node.getCanonicalPath(); * * ExecResult result = ExecServices.exec(cmd); * * if (result.getFailed()) { throw new * DeleteFileException(node); } * * } else if (JvmServices.isUnix()) { * * String[] cmd = new String[3]; cmd[0] = "rm"; cmd[1] = "-f"; * cmd[2] = node.getCanonicalPath(); * * ExecResult result = ExecServices.exec(cmd); * * if (result.getFailed()) { throw new * DeleteFileException(node); } * * } else { * * } */ } } if (node.isDirectory() == true) { File[] list = node.listFiles(); if (list != null) { for (int i = 0; i < list.length; i++) { if (list[i].isDirectory()) { counter += delete(list[i].getAbsolutePath(), listener, resourceString); } else { rc = list[i].delete(); if (rc == false) { throw new DeleteFileException(node); } } } } counter++; if (listener != null) { logger.debug("Firing progress event."); if (resourceString != null) { msg = MessageFormat.format(resourceString, node.getPath()); } else { msg = node.getName(); } listener.progress(new ProgressEvent(msg, false)); } rc = node.delete(); if (rc == false) { throw new DeleteFileException(node); } } if (node.exists() == true) { throw new DeleteFileException(node); } return counter; } /** * Die Methode delete löscht alle Dateien aus dem Verzeichnis * path die auf den Filter filter passen. * * Die Art des Filters wird durch den Filtertyp bestimmt. Der Typ kann den * Anfang oder das Ende eines Dateinamens überpüfen. * * Folgende Type können verwendet werden: *
    *
  • STARTS_WITH - Testet den Anfang des Dateinamens
  • *
  • ENDS_WITH - Testet das Ende des Dateinamens
  • *
  • ALL - Trifft auf alle Dateien zu
  • *
*/ public static void delete(String path, String filter, int type) { if (path == null) { return; } File dir = new File(path); if (dir.exists() == false) { return; } File[] list; switch (type) { case STARTS_WITH: list = dir.listFiles(new StartsWithFilter(filter)); break; case ENDS_WITH: list = dir.listFiles(new EndsWithFilter(filter)); break; case ALL: list = dir.listFiles(); break; default: return; } for (int i = 0; i < list.length; i++) { list[i].delete(); } } public static void deleteEmptyDirs(File dir) throws IOException { if (dir == null) { throw new IllegalArgumentException( "The argument dir must not be null!"); } File[] list = dir.listFiles(); for (int i = 0; i < list.length; i++) { if (list[i].isDirectory()) { deleteEmptyDirs(list[i]); if (list[i].list().length == 0) { delete(list[i]); } } } } public static void deleteEmptyDirs(String path) throws IOException { deleteEmptyDirs(new File(path)); } /** * Die Methode getAbsoluteDirName liefert das übergeordnete * Verzeichnis des angegebenen Pfades als absoluten Pfad. */ public static String getAbsoluteDirName(String filename) { if (filename == null) { throw new IllegalArgumentException("Parameter filename is null!"); } if (filename.length() == 0) { throw new IllegalArgumentException("Parameter filename is null!"); } File file = new File(filename); String path = file.getAbsolutePath(); int index = path.lastIndexOf(File.separator); if (index == -1) { return "."; } path = path.substring(0, index); return path; } /** * Die Methode getDirName liefert das übergeordnete Verzeichnis * des angegebenen Pfades. */ public static String getDirName(String fileName) { if (fileName == null) { throw new IllegalArgumentException("Parameter fileName is null!"); } if (fileName.length() == 0) { throw new IllegalArgumentException("Parameter fileName is null!"); } fileName = StringServices.chop(fileName, File.separator); int index = fileName.lastIndexOf(File.separator); if (index == -1) { return "."; } String path = fileName.substring(0, index); return path; } /** * Die Methode getExtension liefert die Dateinamenerweiterung * des angegebenen Pfadnamens. * * Die Dateinamenerweiterung muß mit einem Punkt vom Rest getrennt sein. Der * Punkt wird nicht mit zurückgeliefert. */ public static String getExtension(String filename) { if (filename == null) { throw new IllegalArgumentException("Parameter filename is null!"); } // strip any directory information filename = getFileName(filename); int index = filename.lastIndexOf("."); if (index == -1) { return ""; } filename = filename.substring(index + 1); return filename; } public static String getFileBase(File file) { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } return getFileBase(file.getPath()); } /** * Die Methode getFileBase liefert den Pfadnamen ohne * Dateinamenerweiterung. * * Als Dateinamenerweiterung wird der letzte Teil eines Pfadnamens * angesehen, der mit einem Punkt vom Rest abgetrennt ist. * * Falls der Pfad Verzeichnisse enthält werden diese nicht entfernt. Um den * letzten Teil der Pfadangabe zu erhalten kann die Methode * getFileName verwendet werden. * *
*

* Der Pfad /tmp/file.txt wird zu /tmp/file. *

* */ public static String getFileBase(String fileName) { if (fileName == null) { throw new IllegalArgumentException("Parameter fileName is null!"); } int index = fileName.lastIndexOf("."); if (index == -1) { return fileName; } fileName = fileName.substring(0, index); return fileName; } /** * Die Methode getFileName liefert den letzten Teil einer * Pfadangabe, üblicherweise einen Dateinamen. */ public static String getFileName(String path) { if (path == null) { throw new IllegalArgumentException("Parameter path is null!"); } path = normalizePath(path); path = StringServices.chop(path, "/"); File file = new File(path); return file.getName(); } public static String getMimeType(String fileName) { if (fileName == null) { throw new IllegalArgumentException( "The argument fileName must not be null!"); } String type = null; String[] cmd = new String[5]; cmd[0] = "file"; cmd[1] = "-b"; cmd[2] = "-p"; cmd[3] = "-i"; cmd[4] = fileName; ExecResult result = ExecServices.exec(cmd); type = result.getOutput(); type = StringServices.trim(type, Sfv.LSEP); type = StringServices.trim(type, ' '); if (result.failed() == false && type != null && type.length() > 0) { logger.debug("(file -b -pi -i " + fileName + ") -e type=" + type); return type; } String name = FileServices.getFileName(fileName.toLowerCase()); name = StringServices.cutSuffix(name, ",v"); FileNameMap fnm = URLConnection.getFileNameMap(); type = fnm.getContentTypeFor(name); if (type != null && type.trim().length() > 0) { logger.debug("(FileNameMap " + name + ") type=" + type); return type; } String ext = FileServices.getExtension(name); MimeType mimeType = MimeType.findByExtension(ext); if (mimeType != null) { logger.debug("(MimeType " + name + ") type=" + mimeType.getMimeType()); return mimeType.getMimeType(); } File file = new File(fileName); boolean nullByte = false; if (file.exists() && file.canRead()) { FileReader reader = null; try { reader = new FileReader(file); int c = reader.read(); while (c != -1) { c = reader.read(); if (c == 0) { nullByte = true; break; } } } catch (Throwable oops) { logger.fatal("FileServices.isBinary", oops); } finally { try { if (reader != null) { reader.close(); } } catch (IOException oops) { logger.fatal("FileServices.isBinary reader.close() ", oops); } } } if (nullByte == true) { logger.debug("(No MimeType Found, Null Byte) " + name + ") type=application/octet-stream"); return "application/octet-stream"; } else { logger.debug("(No MimeType Found " + name + ") type=text/plain"); return "text/plain"; } } public static String getPathHead(String path, int length) { if (path == null) { throw new IllegalArgumentException( "The argument path must not be null!"); } if (length < 0) { throw new IllegalArgumentException( "The argument length must not be < 0!"); } path = normalizePath(path); String subPath = path; int index = path.indexOf("/"); int counter = 0; while (index > 0 && counter < length) { index = path.indexOf("/", index + 1); counter++; } if (index > 0) { subPath = path.substring(0, index); } return subPath; } public static String getPathTail(String path, int length) { if (path == null) { throw new IllegalArgumentException( "The argument path must not be null!"); } if (length < 0) { throw new IllegalArgumentException( "The argument length must not be < 0!"); } path = StringServices.replace(path, FSEP, "/"); String subPath = path; int index = path.lastIndexOf("/"); int counter = 1; while (index > 0 && counter < length) { index = path.lastIndexOf("/", index - 1); counter++; } if (index > 0) { subPath = path.substring(index + 1); } return subPath; } /** * Die Methode getPathToken liefert einen bestimmenten Teil * eines Pfades. * * Der Pfad wird von hinten nach vorne beginnend mit der Ziffer 1 * durchnummeriert. * * @param path * String * @param index * int * @return String */ public static String getPathToken(String path, int index) { if (index == 0) return ""; if (path == null) { throw new IllegalArgumentException( "The argument path must not be null!"); } if (index < 0) { throw new IllegalArgumentException( "The argument index must not be < 0!"); } String buffer = normalizePath(path); buffer = StringServices.chop(buffer, "/"); logger.debug("buffer = " + buffer); int indexStart = buffer.length(); int indexEnd = indexStart; for (int i = 0; i < index; i++) { indexEnd = indexStart; indexStart = buffer.lastIndexOf('/', indexStart - 1); logger.debug("start = " + indexStart + ", end = " + indexEnd); if (indexStart == -1) { return null; } } String token = buffer.substring(indexStart + 1, indexEnd); logger.debug("path token [" + index + "] = '" + token + "'."); return token; } public static int getPathTokenCount(String path) { logger.debug("#1 path=" + path); if (path == null || path.trim().length() == 0) { return 0; } path = normalizePath(path); path = StringServices.trim(path, '/'); logger.debug("#2 path=" + path); int index = path.indexOf("/"); logger.debug("index=" + index); int counter = 1; while (index > 0) { index = path.indexOf("/", index + 1); logger.debug("index=" + index); counter++; } logger.debug("counter=" + counter); return counter; } public static String getValueOfKey(File file, String key) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } if (key == null) { throw new IllegalArgumentException( "The argument key must not be null!"); } key = key.trim(); if (key.endsWith("=") == false) { key += "="; } BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String line; while ((line = reader.readLine()) != null) { if (line.startsWith(key) == true) { if (line.length() <= key.length()) { return ""; } else { return line.substring(key.length() + 1); } } } return ""; } finally { try { if (reader != null) { reader.close(); } } catch (IOException ioe) { ioe.printStackTrace(); } } } public static boolean hasSubdirectory(File dir, String name) { if (dir == null) { return false; } if (name == null || name.length() == 0) { return false; } String[] listing = dir.list(); if (listing == null) { return false; } for (int i = 0; i < listing.length; i++) { if (name.equals(listing[i])) { return true; } } return false; } public static String info(File file) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } StringBuffer buffer = new StringBuffer(); buffer.append("path=" + file.getCanonicalPath()); if (file.exists() == false) { buffer.append(",exists=false"); return buffer.toString(); } buffer.append(",size=" + file.length()); return buffer.toString(); } /** * Liefert true, falls die Zeichenkette einen absoluten Pfad * repräsentiert. */ public static boolean isAbsolutePath(String path) { if (path == null) { throw new IllegalArgumentException( "The argument path must not be null!"); } String buffer = new String(path); buffer = StringServices.replace(buffer, File.separator, "/"); buffer = buffer.toLowerCase(); if (buffer.startsWith("/")) { return true; } if (JvmServices.isWindows()) { if (PATTERN_ABSOLUTE_WINDOWS_PATH.matcher(buffer).matches()) { return true; } } return false; } public static boolean isBinary(File file) { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } return isBinary(file.getAbsolutePath()); } public static boolean isBinary(String fileName) { if (fileName == null) { throw new IllegalArgumentException( "The argument fileName must not be null!"); } String mimeType = getMimeType(fileName); logger.debug("mimeType=" + mimeType); if (mimeType.startsWith("image/")) { return true; } if (mimeType.startsWith("video/")) { return true; } if (mimeType.startsWith("audio/")) { return true; } if (mimeType.equals("application/octet-stream") || mimeType.equals("application/pdf") || mimeType.equals("application/postscript") || mimeType.equals("application/x-cpio") || mimeType.equals("application/x-dvi") || mimeType.equals("application/x-gtar") || mimeType.equals("application/x-tar") || mimeType.equals("application/x-ustar") || mimeType.equals("application/x-troff-msvideo") || mimeType.equals("application/zip")) { return true; } File file = new File(fileName); boolean nullByte = false; if (file.exists() && file.canRead()) { FileReader reader = null; try { reader = new FileReader(file); int c = reader.read(); while (c != -1) { c = reader.read(); if (c == 0) { nullByte = true; break; } } } catch (Throwable oops) { logger.fatal("FileServices.isBinary", oops); } finally { try { if (reader != null) { reader.close(); } } catch (IOException oops) { logger.fatal("FileServices.isBinary reader.close() ", oops); } } } if (nullByte == true) { return true; } return false; } public static boolean isEmptyDirectory(File file) { if (file.isDirectory() == false) { return false; } File[] list = file.listFiles(); if (list.length == 0) { return true; } else { return false; } } /** * Die Methode move verschiebt eine Datei in ein anderes * Verzeichnis. */ public static void move(String src, String destdir) throws IOException { if (src == null) { throw new IllegalArgumentException( "The argument src must not be null!"); } if (destdir == null) { throw new IllegalArgumentException( "The argument destdir must not be null!"); } File srcFile = new File(src); File destFile = new File(destdir + File.separator + srcFile.getName()); if (srcFile.equals(destFile)) { return; } boolean rc = srcFile.renameTo(destFile); if (rc == false) { throw new RenameFileException(srcFile, destFile); } } /** * Die Methode newer vergleicht ob die 1. Datei neuer als die * 2, Datei ist. Falls die 2. Datei nicht existiert wird true zurückgegeben. */ public static boolean newer(File f1, File f2) { if (f1 == null || f1.exists() == false) { return false; } if (f2 == null || f2.exists() == false) { return true; } if (f1.lastModified() >= f2.lastModified()) { return true; } else { return false; } } /** * Die Methode newer vergleicht 2 Dateien oder Verzeichnisse * bezüglich des Datums ihrer letzten Änderung. * * Requires: Beide Dateien/Verzeichnisse müssen existieren. */ public static boolean newer(String f1, String f2) { return newer(new File(f1), new File(f2)); } /** * Die Methode normalizePath konvertiert den angegegebenen Pfad * in ein Standardformat. * *
    *
  1. Weißraum am Anfang oder Ende der Zeichenkette wird entfernt.
  2. *
  3. Alle betriebssystemspezifischen Trennzeichen werden in einen * Schrägstrich umgewandelt.
  4. *
  5. Falls der Pfad einen absoluten Pfad repäsentiert, werden redundante * Angaben bereinigt, z.B. /C:/temp wird zu * C:/temp.
  6. *
      * * @param path * String * @return String */ public static String normalizePath(String path) { if (path == null) { throw new IllegalArgumentException( "The argument path must not be null!"); } path = new String(path); File file = new File(path); path = path.trim(); path = StringServices.replace(path, File.separator, "/"); while (isAbsolutePath(path) && path.length() > 1) { String buffer = path.substring(1); if (isAbsolutePath(buffer)) { path = buffer; } else { break; } } if (isAbsolutePath(path)) { path = StringServices.lowerFirstLetter(path); } if (file.exists() && file.isDirectory() && path.endsWith("/") == false) { path += "/"; } return path; } /** * Die Methode pkgToPath wandelt den Namen eines Java Packages * in einen Verzeichnispfad um. */ public static String pkgToPath(String pkg) { if (pkg == null) { throw new IllegalArgumentException( "The argument pkg must not be null!"); } String path = StringServices.replace(pkg, ".", File.separator); return path; } public static String readLine(File file, int lineIndex) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } if (lineIndex < 0) { throw new IllegalArgumentException( "The argument lineIndex must not be < 0!"); } int count = 0; if (file != null && file.exists()) { BufferedReader reader = new BufferedReader(new FileReader(file)); String line = reader.readLine(); while (line != null) { if (count == lineIndex) { reader.close(); return line; } line = reader.readLine(); count++; } reader.close(); } return null; } public static Object[] readToArray(File file) throws IOException { return readToArray(file, "UTF-8"); } public static Object[] readToArray(File file, String encoding) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } if (encoding == null) { throw new IllegalArgumentException( "The argument encoding must not be null!"); } BufferedReader reader = new BufferedReader(new InputStreamReader( new FileInputStream(file), encoding)); Object[] array = null; try { ArrayList list = new ArrayList(); String line = reader.readLine(); while (line != null) { list.add(line); line = reader.readLine(); } int index = 0; array = new Object[list.size()]; Iterator iterator = list.iterator(); while (iterator.hasNext()) { line = iterator.next(); array[index++] = line; } } finally { reader.close(); } return array; } public static byte[] readToByteArray(File file) throws IOException { if (file == null) { return null; } if (file.exists() == false) { return null; } FileInputStream fis = new FileInputStream(file); int off = 0; long fileLength = file.length(); if (fileLength > Integer.MAX_VALUE) { logger.error("The file is too big (>" + Integer.MAX_VALUE + ")!"); fis.close(); return null; } int length = (int) fileLength; int size = length; byte[] buffer = new byte[length]; int count; try { while ((count = fis.read(buffer, off, size)) != -1) { off += count; if ((length - off) < size) { size = length - off; if (size < 1) { break; } } if (off < 0) { logger.error("Argument off must not be negative: off=" + off + ", count=" + count + ", len=" + size + ", b.length=" + length); } if (size < 0) { logger.error("Argument len must not be negative: off=" + off + ", count=" + count + ", len=" + size + ", b.length=" + length); } if (size > (length - off)) { logger.error("Argument len must not be negative: off=" + off + ", count=" + count + ", len=" + size + ", b.length=" + length); } } } finally { fis.close(); } return buffer; } public static String readToString(File file) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } return readToString(file, "UTF-8"); } public static String readToString(File file, String encoding) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } FileInputStream fis = new FileInputStream(file); String buffer = readToString(fis, encoding); fis.close(); return buffer; } public static String readToString(InputStream is) throws IOException { return readToString(is, "UTF-8"); } public static String readToString(InputStream is, String encoding) throws IOException { if (is == null) { throw new IllegalArgumentException( "The argument is must not be null!"); } if (encoding == null) { throw new IllegalArgumentException( "The argument encoding must not be null!"); } BufferedReader reader = new BufferedReader(new InputStreamReader(is, encoding)); StringBuffer buffer = new StringBuffer(); char[] data = new char[4096]; int count; try { while ((count = reader.read(data)) > 0) { buffer.append(data, 0, count); } } finally { reader.close(); } return buffer.toString(); } public static String readToString(String fileName) throws IOException { if (fileName == null) { throw new IllegalArgumentException( "The argument fileName must not be null!"); } return readToString(new File(fileName), "UTF-8"); } public static String readToString(String fileName, String encoding) throws IOException { if (fileName == null) { throw new IllegalArgumentException( "The argument fileName must not be null!"); } return readToString(new File(fileName), encoding); } /** * Die Methode relativePath ermittelt den relativen Pfad um vom * Verzeichnis start zum Verzeichnis dest zu * gelangen. Falls kein relativer Pfad ermittelt werden kann wird der * absolute Pfad von dest zurückgeliefert. * * Werden relative Pfade übergeben, so werden diese mit Hilfe der Methode * {@link File#getCanonicalFile()} in absolute PFade umgewandelt. Diese * Methode ermittelt Pfad anscheinend anhand des Rückgabewertes von * System.getProperty("user.dir"). Der Wert ist also nicht * vohersagbar und ist abhängig vom aktuellen Arbeitsverzeichnis. * * @throws IOException */ public static String relativePath(File start, File dest) throws IOException { if (start == null) { throw new IllegalArgumentException( "The argument start must not be null!"); } if (dest == null) { throw new IllegalArgumentException( "The argument dest must not be null!"); } File from = new File(start.getCanonicalPath()); File to = new File(dest.getCanonicalPath()); logger.debug("Berechne relativen Pfad von " + from + " zu " + to + ".\n"); if (from.equals(to)) { return "."; } File file = to; String downPath = ""; String upPath = ""; String relativePath; String path1; String path2; String str; File fromParent = from; if (fromParent.isFile() == true) { fromParent = fromParent.getParentFile(); } while (fromParent != null) { path1 = fromParent.getCanonicalPath() + File.separator; path2 = to.getCanonicalPath(); logger.debug("path1 = " + path1); logger.debug("path2 = " + path2); if (path2.startsWith(path1)) { str = StringServices.cutPrefix(path2, path1); if (downPath.length() == 0) { downPath = "." + File.separator; } str = appendPath(downPath, str); relativePath = StringServices.chop(str, File.separator); return relativePath; } downPath += ".." + File.separator; if (file != null) { upPath = file.getName() + File.separator + upPath; } fromParent = fromParent.getParentFile(); if (fromParent.getParent() == null) { break; } if (file != null) { file = file.getParentFile(); } } return dest.getCanonicalPath(); } public static String removeParentPath(File dir, File parentDir) throws IOException { if (dir == null) { throw new IllegalArgumentException( "The argument dir must not be null!"); } if (parentDir == null) { throw new IllegalArgumentException( "The argument parentDir must not be null!"); } String parentPath = parentDir.getCanonicalPath(); if (parentPath.endsWith(Sfv.FSEP) == false) { parentPath += Sfv.FSEP; } return removeParentPath(dir.getCanonicalPath(), parentPath); } public static String removeParentPath(String path, String parentPath) { if (path == null) { throw new IllegalArgumentException( "The argument path must not be null!"); } if (parentPath == null) { throw new IllegalArgumentException( "The argument parentPath must not be null!"); } path = normalizePath(path); parentPath = normalizePath(parentPath); logger.debug("path=" + path); logger.debug("parentPath=" + parentPath); path = StringServices.cutPrefix(path, parentPath); return path; } public static void rename(File srcFile, File destFile) throws IOException { if (srcFile == null) { throw new IllegalArgumentException( "The argument srcFile must not be null!"); } if (destFile == null) { throw new IllegalArgumentException( "The argument destFile must not be null!"); } if (srcFile.equals(destFile)) { logger.warn("Source file " + srcFile + " is identical to destination file."); return; } boolean rc = srcFile.renameTo(destFile); if (rc == true) { return; } if (srcFile.isDirectory() == true) { copyDir(srcFile, destFile); delete(srcFile); return; } throw new RenameFileException(srcFile, destFile); } /** * Die Methode replaceExtension ersetzt die * Dateinamenserweiterung. */ public static String replaceExtension(File file, String extension) { return replaceExtension(file.getPath(), extension); } /** * Die Methode replaceExtension ersetzt die * Dateinamenserweiterung. */ public static String replaceExtension(String fileName, String extension) { if (fileName == null) { throw new IllegalArgumentException( "The argument fileName must not be null!"); } if (extension == null) { throw new IllegalArgumentException( "The argument extension must not be null!"); } String base = getFileBase(fileName); return base + extension; } public static boolean setReadOnly(File file) { if (file == null || file.exists() == false) { return false; } String[] cmd = null; ExecResult result = null; try { if (JvmServices.isUnix()) { if (file.isDirectory()) { cmd = new String[7]; cmd[0] = "find"; cmd[1] = file.getCanonicalPath(); cmd[2] = "-exec"; cmd[3] = "chmod"; cmd[4] = "a-w"; cmd[5] = "{}"; cmd[6] = ";"; } else { cmd = new String[3]; cmd[0] = "chmod"; cmd[1] = "a-w"; cmd[2] = file.getCanonicalPath(); } } if (JvmServices.isWindows()) { cmd = new String[4]; cmd[0] = "attrib"; cmd[1] = "+r"; cmd[2] = "+h"; cmd[3] = file.getCanonicalPath(); if (file.isDirectory()) { result = ExecServices.exec(cmd); if (result.failed() == true) { IOException oops = new IOException(result.toString()); throw oops; } cmd = new String[6]; cmd[0] = "attrib"; cmd[1] = "+r"; cmd[2] = "+h"; cmd[3] = file.getCanonicalPath() + "\\*.*"; cmd[4] = "/S"; cmd[5] = "/D"; } } if (cmd == null) { logger.error("Operating System '" + JvmServices.getOperatingSystem() + "' is not supported!"); return false; } logger.debug("Executing command '" + StringServices.arrayToString(cmd) + "'..."); result = ExecServices.exec(cmd); if (result.failed() == true) { logger.error(result.toString()); return false; } } catch (IOException oops) { logger.fatal( "setReadOnly failed! (" + StringServices.arrayToString(cmd) + ")", oops); return false; } return true; } public static boolean setReadOnly(String path) { if (path == null) { return false; } return setReadOnly(new File(path)); } /** * Die Methode setWritable setzt die Berechtigung Datei oder * das Verzeichnis auf schreibbar. Falls eine Verzeichnis angegeben wurde, * werden auch alle darin enthaltenen Dateien und Unterverzeichnisse * bearbeitet. * * setWritable verwendet Kommandos des Betriebssystems um die * Berechtigungen zu ändern. Unter Windows wird das Kommando * attrib aufgerufen und zusätzlich das Attribut * hidden zurückgesetzt. * * @param file * File */ public static boolean setWritable(File file) { if (file == null || file.exists() == false) { return false; } String[] cmd = null; ExecResult result = null; try { if (JvmServices.isUnix()) { if (file.isDirectory()) { cmd = new String[7]; cmd[0] = "find"; cmd[1] = file.getCanonicalPath(); cmd[2] = "-exec"; cmd[3] = "chmod"; cmd[4] = "a+w"; cmd[5] = "{}"; cmd[6] = ";"; } else { cmd = new String[3]; cmd[0] = "chmod"; cmd[1] = "a+w"; cmd[2] = file.getCanonicalPath(); } } if (JvmServices.isWindows()) { cmd = new String[4]; cmd[0] = "attrib"; cmd[1] = "-r"; cmd[2] = "-h"; cmd[3] = file.getCanonicalPath(); if (file.isDirectory()) { result = ExecServices.exec(cmd); if (result.failed() == true) { IOException oops = new IOException(result.toString()); throw oops; } cmd = new String[6]; cmd[0] = "attrib"; cmd[1] = "-r"; cmd[2] = "-h"; cmd[3] = file.getCanonicalPath() + "\\*.*"; cmd[4] = "/S"; cmd[5] = "/D"; } } if (cmd == null) { logger.error("Operating System '" + JvmServices.getOperatingSystem() + "' is not supported!"); return false; } logger.debug("Executing command '" + StringServices.arrayToString(cmd) + "'..."); result = ExecServices.exec(cmd); if (result.failed() == true) { logger.error(result.toString()); return false; } } catch (IOException oops) { logger.fatal( "setWritable failed! (" + StringServices.arrayToString(cmd) + ")", oops); return false; } return true; } public static boolean setWritable(File file, String caller) { logger.debug("Caller of setWritable is '" + caller + "'."); return setWritable(file); } public static boolean setWritable(String path) { if (path == null) { return false; } return setWritable(new File(path)); } public static boolean setWritable(String path, String caller) { logger.debug("Caller of setWritable is '" + caller + "'."); return setWritable(path); } public static void sort(File file) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } Object[] array = readToArray(file); Arrays.sort(array); writeFromArray(file, array); } public static void touch(File file) throws IOException { writeFromString(file, String.valueOf(System.currentTimeMillis())); } public static void touch(String fileName) throws IOException { if (fileName == null) { throw new IllegalArgumentException( "The argument fileName must not be null!"); } touch(new File(fileName)); } public static String toWindowsPath(String path) { if (path == null) { throw new IllegalArgumentException( "The argument path must not be null!"); } String winPath = path; Pattern winDrivePattern = Pattern.compile("^/[a-cA-Z]:/"); Matcher matcher = winDrivePattern.matcher(winPath); if (matcher.lookingAt()) { winPath = winPath.substring(1); } winPath = winPath.trim(); winPath = StringServices.replace(winPath, "/", "\\"); return winPath; } /** * This method corrects the path regarding the used operating system. * Windows "\" and Linux "/" * * @param in * the string representing the path * @return out the corrected string representing the path */ public static String correctPathSeperator(String in) { String os = System.getProperty("os.name"); in = FileServices.normalizePath(in); if (os.toLowerCase().contains("windows")) { in = toWindowsPath(in); return in; } return in; } public static void traverse(File dir, FileVisitor visitor) { if (dir == null || dir.exists() == false || visitor == null) { return; } for (File file : dir.listFiles()) { visitor.visit(file); } File[] subdirs = dir.listFiles(new DirectoryFilter()); if (subdirs != null) { for (File subdir : subdirs) { traverse(subdir, visitor); } } } public static void write(File file, InputStream instr) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } if (instr == null) { throw new IllegalArgumentException( "The argument instr must not be null!"); } File parent = file.getParentFile(); if (parent != null) { createPath(parent); } FileOutputStream out = new FileOutputStream(file); int n = 0; byte[] buffer = new byte[4096]; while ((n = instr.read(buffer, 0, 4096)) != -1) { out.write(buffer, 0, n); } out.flush(); out.close(); } public static void writeFromArray(File file, Object[] array) throws IOException { writeFromArray(file, array, "UTF-8"); } public static void writeFromArray(File file, Object[] array, String encoding) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } if (array == null) { throw new IllegalArgumentException( "The argument array must not be null!"); } if (encoding == null) { throw new IllegalArgumentException( "The argument encoding must not be null!"); } PrintWriter writer = new PrintWriter(new OutputStreamWriter( new FileOutputStream(file), encoding)); try { for (int i = 0; i < array.length; i++) { writer.println(array[i]); } } finally { writer.close(); } } public static void writeFromByteArray(File file, byte[] buffer) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } if (buffer == null) { throw new IllegalArgumentException( "The argument buffer must not be null!"); } FileOutputStream out = new FileOutputStream(file); out.write(buffer); out.close(); } public static void writeFromStream(String fileName, InputStream instr) throws IOException { if (fileName == null) { throw new IllegalArgumentException( "The argument fileName must not be null!"); } if (instr == null) { throw new IllegalArgumentException( "The argument instr must not be null!"); } FileOutputStream out = new FileOutputStream(fileName); int n = 0; byte[] buffer = new byte[4096]; while ((n = instr.read(buffer, 0, 4096)) != -1) { out.write(buffer, 0, n); } out.close(); } public static void writeFromString(File file, String str) throws IOException { writeFromString(file, str, "UTF-8"); } /* * Die Methode schreibt einen String in eine Datei * * @param File die Datei in die geschrieben wird * * @param String der zu schreibende String * * @param String die zu benutzende Zeichenkodierung (Standard UTF-8) */ public static void writeFromString(File file, String str, String encoding) throws IOException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } File parent = file.getParentFile(); if (parent != null && parent.exists() == false) { createPath(parent); } FileOutputStream fos = new FileOutputStream(file); writeFromString(fos, str, encoding); fos.close(); } public static void writeFromString(OutputStream os, String str) throws IOException { writeFromString(os, str, "UTF-8"); } public static void writeFromString(OutputStream os, String str, String encoding) throws IOException { if (os == null) { throw new IllegalArgumentException( "The argument os must not be null!"); } if (str == null) { throw new IllegalArgumentException( "The argument str must not be null!"); } if (encoding == null) { throw new IllegalArgumentException( "The argument encoding must not be null!"); } PrintWriter writer = new PrintWriter(new OutputStreamWriter(os, encoding)); try { writer.print(str); } finally { writer.close(); } } public static void writeFromString(String fileName, String str) throws IOException { if (fileName == null) { throw new IllegalArgumentException( "The argument fileName must not be null!"); } writeFromString(new File(fileName), str); } public static void writeFromString(String fileName, String str, String encoding) throws IOException { if (fileName == null) { throw new IllegalArgumentException( "The argument fileName must not be null!"); } writeFromString(new File(fileName), str, encoding); } } src/java/org/dbdoclet/service/ResourceServices.java0000644000000000000000000003322212124530526021433 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2006 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.service; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.StringReader; import java.io.UnsupportedEncodingException; import java.net.URL; import java.util.ArrayList; import java.util.Iterator; import java.util.MissingResourceException; import java.util.ResourceBundle; import javax.swing.ImageIcon; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Die Klasse ResourceServices bietet Methoden zur Bearbeitung von * Resourcen die vom Classloader geldaen werden. * * @author Michael Fuchs * @version 1.0 */ public class ResourceServices { private static Log logger = LogFactory.getLog(ResourceServices.class); public static ImageIcon getButtonIcon(String name) { if (name == null) { throw new IllegalArgumentException("The argument name must not be null!"); } ClassLoader loader = ClassLoader.getSystemClassLoader(); URL iconUrl = loader.getResource(name); if (iconUrl == null) { iconUrl = ResourceServices.class.getResource(name); } if (iconUrl == null) { return null; } ImageIcon icon = new ImageIcon(iconUrl, name); return icon; } public static String getXmlTemplate(String name) throws IOException { return getXmlTemplate(null, name); } public static String getXmlTemplate(String language, String name) throws IOException { String path; URL url = null; ClassLoader loader = ClassLoader.getSystemClassLoader(); if (language != null && language.length() > 0) { path = "/templates/xml/" + language.toLowerCase() + "/" + name; url = loader.getResource(path); if (url == null) { url = ResourceServices.class.getResource(path); } } if (url == null) { path = "/templates/xml/default/" + name; url = loader.getResource(path); if (url == null) { url = ResourceServices.class.getResource(path); } } if (url == null) { return null; } return readUrl(url); } /** * Die Methode getResourceAsString liefert die Resource als * Zeichenkette zurück. Die Eingabestrom wird dabei mit der Kodierung UTF-8 * eingelesen. * * @param name String * @return String * @exception IOException */ public static String getResourceAsString(String name) throws IOException { return getResourceAsString(name, null); } public static String getResourceAsString(String name, ClassLoader classLoader) throws IOException { if (name == null) { throw new IllegalArgumentException("The argument name must not be null!"); } InputStream is = getResourceAsStream(name, classLoader); if (is == null) { return null; } return readStream(is); } /** * @param is * @return String * @throws UnsupportedEncodingException * @throws IOException */ public static String readStream(InputStream is) throws UnsupportedEncodingException, IOException { if (is == null) { throw new IllegalArgumentException("The argument is must not be null!"); } InputStreamReader isr = new InputStreamReader(is, "UTF-8"); BufferedReader reader = new BufferedReader(isr); StringBuffer buffer = new StringBuffer(); String lsep = System.getProperty("line.separator"); String line = reader.readLine(); while (line != null) { buffer.append(line + lsep); line = reader.readLine(); } reader.close(); isr.close(); is.close(); return buffer.toString(); } public static URL getResourceAsUrl(String name) { URL url = null; ClassLoader loader = ClassLoader.getSystemClassLoader(); url = loader.getResource(name); if (url == null) { url = ResourceServices.class.getResource(name); } return url; } public static URL getResourceAsUrl(String name, ClassLoader classLoader) { if (name == null) { throw new IllegalArgumentException("The argument name must not be null!"); } if (classLoader == null) { throw new IllegalArgumentException("The argument classLoader must not be null!"); } URL url = null; url = classLoader.getResource(name); if (url == null) { return getResourceAsUrl(name); } return url; } public static InputStream getResourceAsStream(String name) throws IOException { return getResourceAsStream(name, null); } public static InputStream getResourceAsStream(String name, ClassLoader classLoader) throws IOException { URL url; if (classLoader != null) { url = getResourceAsUrl(name, classLoader); } else { url = getResourceAsUrl(name); } if (url == null) { return null; } return url.openStream(); } public static ImageIcon getIcon(String path) { return getIcon(path, null); } public static ImageIcon getIcon(String path, ClassLoader loader) { URL iconUrl = null; if (loader != null) { iconUrl = loader.getResource(path); } if (iconUrl == null) { iconUrl = ClassLoader.getSystemClassLoader().getResource(path); } if (iconUrl == null) { iconUrl = ResourceServices.class.getResource(path); } if (iconUrl == null) { return null; } ImageIcon icon = new ImageIcon(iconUrl, path); return icon; } public static boolean isDirectory(String name) { if (name == null) { throw new IllegalArgumentException("The argument name must not be null!"); } String buffer; String entry; String str; BufferedReader reader = null; if (name.endsWith("/") == false) { name += "/"; } try { buffer = getResourceAsString(name); if (buffer == null) { throw new IOException("Can't find resource " + name); } reader = new BufferedReader(new StringReader(buffer)); entry = reader.readLine(); while (entry != null) { entry = name + entry; logger.debug("entry=" + entry); str = getResourceAsString(entry); if (str == null) { return false; } break; // entry = reader.readLine(); } return true; } catch (IOException oops) { logger.error(oops); return false; } finally { if (reader != null) { try { reader.close(); } catch (IOException oops) { logger.error(oops); } } } } public static String[] list(String name) { logger.debug("list " + name); if (isDirectory(name) == false) { logger.error("Resource " + name + " is not a directory!"); return new String[0]; } String buffer; String entry; BufferedReader reader = null; try { ArrayList list = new ArrayList(); buffer = getResourceAsString(name); reader = new BufferedReader(new StringReader(buffer)); entry = reader.readLine(); while (entry != null) { list.add(entry); entry = reader.readLine(); } String[] listing = new String[list.size()]; Iterator iterator = list.iterator(); int i = 0; while (iterator.hasNext()) { entry = iterator.next(); listing[i++] = entry; } return listing; } catch (IOException oops) { logger.error(oops); return null; } finally { if (reader != null) { try { reader.close(); } catch (IOException oops) { logger.error(oops); } } } } public static void copyToDir(String name, String path) throws IOException { if (path == null) { throw new IllegalArgumentException("The argument path must not be null!"); } copyToDir(name, new File(path)); } public static void copyToDir(String name, File dir) throws IOException { if (name == null) { throw new IllegalArgumentException("The argument name must not be null!"); } if (dir == null) { throw new IllegalArgumentException("The argument dir must not be null!"); } logger.debug("Resource: " + name + ", Directory: " + dir.getPath()); FileServices.createPath(dir); String resourceName = name; resourceName = StringServices.chop(resourceName, "/"); int index = resourceName.lastIndexOf('/'); if (index != -1) { resourceName = resourceName.substring(index + 1); } if (isDirectory(name)) { if (name.endsWith("/") == false) { name += "/"; } logger.debug("Examination of directory " + name + "..."); String[] listing = list(name); for (int i = 0; i < listing.length; i++) { logger.debug("listing[" + i + "] = " + listing[i]); copyToDir(name + listing[i], FileServices.appendFileName(dir, resourceName)); } } else { InputStream instr = getResourceAsStream(name); if (instr == null) { throw new IOException("Can't find resource " + name); } String fileName = FileServices.appendFileName(dir, resourceName); logger.debug("Writing resource " + fileName + "..."); FileOutputStream outstr = new FileOutputStream(fileName); int n = 0; byte[] buffer = new byte[4096]; while ((n = instr.read(buffer, 0, 4096)) != -1) { outstr.write(buffer, 0, n); } instr.close(); outstr.close(); } } public static void copyToFile(String name, String fileName) throws IOException { if (fileName == null) { throw new IllegalArgumentException("The argument fileName must not be null!"); } copyToFile(name, new File(fileName)); } public static void copyToFile(String name, File file) throws IOException { if (name == null) { throw new IllegalArgumentException("The argument name must not be null!"); } if (file == null) { throw new IllegalArgumentException("The argument file must not be null!"); } if (file.exists() == true && file.isFile() == false) { throw new IllegalArgumentException("The argument file must be a regular file!"); } if (isDirectory(name)) { throw new IllegalArgumentException("The resource must not be a directory!"); } logger.debug("Resource: " + name + ", Datei: " + file.getPath()); File dir = file.getParentFile(); if (dir != null && dir.exists() == false) { FileServices.createPath(dir); } String resourceName = name; resourceName = StringServices.chop(resourceName, "/"); int index = resourceName.lastIndexOf('/'); if (index != -1) { resourceName = resourceName.substring(index + 1); } InputStream instr = getResourceAsStream(name); if (instr == null) { throw new IOException("Can't find resource " + name); } String fileName = FileServices.appendFileName(dir, file.getName()); logger.debug("Writing resource " + fileName + "..."); FileOutputStream outstr = new FileOutputStream(fileName); int n = 0; byte[] buffer = new byte[4096]; while ((n = instr.read(buffer, 0, 4096)) != -1) { outstr.write(buffer, 0, n); } instr.close(); outstr.close(); } public static String getString(ResourceBundle res, String key) { if (res == null && key == null) { return "(null)"; } if (res == null) { return key; } if (key == null) { return ""; } try { return res.getString(key); } catch (MissingResourceException oops) { logger.error("Missing resource '" + key + "'.", oops); return key; } } public static String readUrl(URL resourceUrl) throws UnsupportedEncodingException, IOException { if (resourceUrl == null) { throw new IllegalArgumentException("The argument resourceUrl must not be null!"); } return readStream(resourceUrl.openStream()); } } src/java/org/dbdoclet/service/JvmServices.java0000644000000000000000000000771512124530526020410 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet.service; import java.io.File; import java.io.IOException; import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class JvmServices { public static Log logger = LogFactory.getLog(JvmServices.class); public static void listSystemProperties() { Properties props = System.getProperties(); props.list(System.out); } public static String getOperatingSystem() { String os = System.getProperty("os.name"); return os; } public static String getLinuxDistribution() throws IOException { File file; file = new File("/etc/lsb-release"); if (file.exists() == true) { String value = FileServices.getValueOfKey(file, "DISTRIB_ID"); if (value != null && value.length() > 0) { return value; } } file = new File("/etc/redhat-release"); if (file.exists() == true) { return "RedHat"; } file = new File("/etc/SuSE-release"); if (file.exists() == true) { return "SUSE"; } return null; } public static boolean isUnix() { String os = System.getProperty("os.name"); if (os.equalsIgnoreCase("Linux")) { return true; } return false; } public static boolean isWindows() { String os = System.getProperty("os.name"); if (os.startsWith("Windows")) { return true; } return false; } public static boolean isJdk() { File binDir; File libDir; File jreDir; File srcFile; String path; String jreHome = System.getProperty("java.home"); File jreHomeDir = new File(jreHome); File jdkHomeDir = jreHomeDir.getParentFile(); if (jdkHomeDir == null) { return false; } path = FileServices.appendPath(jdkHomeDir, "bin"); logger.debug("binPath=" + path); binDir = new File(path); path = FileServices.appendPath(jdkHomeDir, "lib"); libDir = new File(path); path = FileServices.appendPath(jdkHomeDir, "jre"); jreDir = new File(path); path = FileServices.appendFileName(jdkHomeDir, "src.zip"); srcFile = new File(path); if (binDir.exists() == false || libDir.exists() == false || jreDir.exists() == false || srcFile.exists() == false) { return false; } return true; } public static File getTmpDirectory() { return new File(System.getProperty("java.io.tmpdir", "/tmp")); } public static File getJavaHomeDirectory() { return new File(System.getProperty("java.home")); } public static File getJdkHomeDirectory() { File jreHomeDir = getJavaHomeDirectory(); return jreHomeDir.getParentFile(); } public static File getHomeDirectory() { return new File(System.getProperty("user.home", "/tmp")); } public static void checkMemory() { Runtime runtime = Runtime.getRuntime(); long free = runtime.freeMemory(); if (free < (1048576 * 24)) { logger.debug("Running out of memory: " + ((free / 1048576)) + "MB left."); runtime.gc(); logger.debug("Running garbage collection: " + ((runtime.freeMemory() / 1048576)) + " MB available."); } } } src/java/org/dbdoclet/ServiceException.java0000644000000000000000000000111012124530526017746 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet; public class ServiceException extends Exception { private static final long serialVersionUID = 1L; public ServiceException(Throwable oops) { super(oops.getMessage()); } } src/java/org/dbdoclet/DeleteFileException.java0000644000000000000000000000151112124530526020355 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet; import java.io.File; import java.io.IOException; public class DeleteFileException extends IOException { /** * */ private static final long serialVersionUID = 1L; private String path; public DeleteFileException(File file) { this(file.getAbsolutePath()); } public DeleteFileException(String path) { super(path); this.path = path; } public String getPath() { return path; } } src/java/org/dbdoclet/option/0000755000000000000000000000000012124530534015142 5ustar rootrootsrc/java/org/dbdoclet/option/Resources.properties0000644000000000000000000000271312124530526021236 0ustar rootroot#Created by JInto - www.guh-software.de #Wed Feb 18 12:53:36 CET 2009 C_ERROR_INVALID_NUMBER=Ung\u00FCltiger Parameter {1} f\u00FCr die Option {0}\! C_ERROR_INVALID_OPTION=Ung\u00FCltige Option\: C_ERROR_OPTION_ALREADY_IN_USE=Die Option {0} konnte nicht zur Optionsliste hinzugef\u00FCgt werden. Sie kollidiert mit {1}\! C_ERROR_OPTION_INVALID_DIRECTORY=Ung\u00FCltiges Verzeichnis {1} f\u00FCr die Option {0}\! Das Verzeichnis existiert nicht. C_ERROR_OPTION_INVALID_FILE=Ung\u00FCltige Datei {1} f\u00FCr die Option {0}\! Die Datei existiert nicht. C_ERROR_OPTION_INVALID_PATH=Ung\u00FCltiger Pfad {1} f\u00FCr die Option {0}\! Das Pfadelement {2} existiert nicht. C_ERROR_OPTION_INVALID_SHORT_NAME=Ung\u00FCltiger kurzer Optionsname\: {0}. C_ERROR_OPTION_INVALID_TYPE=Die Option {0} ist nicht vom Typ {1}, sondern vom Typ {2}. C_ERROR_OPTION_INVALID_VALUE=Ung\u00FCltiger Parameter {1} f\u00FCr die Option "{0}". M\u00F6gliche Parameter sind\: {2}. C_ERROR_OPTION_NEEDS_ARG=Die Option "{0}" ben\u00F6tigt ein Argument. C_ERROR_OPTION_REQUIRED=Die Option "{0}" ist zwingend erforderlich. C_ERROR_OPTION_UNKNOWN=Unbekannte Option(en)\: {0}. C_ERROR_OPTION_WAS_FOUND_MORE_THAN_ONCE=Die Option "{0}" trat mehr als einmal auf. C_ERROR_PROPERTY_UNKNOWN=Unbekannte Eigenschaft (Property)\: "{0}" C_ERROR_WRONG_OPTIONS=FEHLER Ung\u00FCltige Optionen\: C_WARN_PROPERTY_DEPRECATED=Die Eigenschaft (Property) "{0}" ist \u00FCberholt. Bitte verwenden Sie statt dessen die Eigenschaft "{1}". src/java/org/dbdoclet/option/StringOption.java0000644000000000000000000000110012124530526020435 0ustar rootrootpackage org.dbdoclet.option; public class StringOption extends Option { public StringOption() { super(); hasArgument(true); } public StringOption(String longName) { super(longName); hasArgument(true); } public StringOption(String longName, String shortName) { super(longName, shortName); hasArgument(true); } @Override public void addValueFromString(String value) { addValue(value); } @Override public void setValueFromString(String value) { setValue(value); } @Override public OptionType getType() { return OptionType.TEXT; } } src/java/org/dbdoclet/option/OptionException.java0000644000000000000000000000321712124530526021140 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet.option; import java.io.PrintWriter; import java.io.StringWriter; /** * Describe class OptionException here. * * @author Michael Fuchs * @version 1.0 */ public class OptionException extends RuntimeException { private static final long serialVersionUID = 1L; private Exception cause; private String msg; /** * Creates a new OptionException instance. * * @param msg a String value */ public OptionException(String msg) { super(msg); this.msg = msg; this.cause = null; } /** * Creates a new OptionException instance. * * @param oops an Exception value */ public OptionException(Exception oops) { super(oops.getMessage()); this.msg = ""; this.cause = oops; } /** * Describe getMessage method here. * * @return an Exception value */ public String getMessage() { if (cause == null) { return msg; } StringWriter buffer = new StringWriter(); cause.printStackTrace(new PrintWriter(buffer)); return buffer.toString(); } } /* * $Log$ */ src/java/org/dbdoclet/option/PathOption.java0000644000000000000000000000432312124530526020075 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet.option; import java.io.File; import java.util.StringTokenizer; public class PathOption extends Option { private String invalidPathElement = ""; public PathOption() { super(); hasArgument(true); } public PathOption(String longName) { super(longName); hasArgument(true); } public PathOption(String longName, String shortName) { super(longName, shortName); hasArgument(true); } @Override public void addValueFromString(String value) { addValue(value); } public String getInvalidPathElement() { return invalidPathElement; } @Override public void setValueFromString(String value) { setValue(value); } protected boolean checkArgument(String arg) { if (arg == null) { throw new IllegalArgumentException("The argument arg may not be null!"); } StringTokenizer stz = new StringTokenizer(arg, System.getProperty("path.separator")); String token; File path; String pathElement; while (stz.hasMoreTokens()) { token = stz.nextToken(); pathElement = token; if (pathElement.startsWith("~")) { if (pathElement.equals("~")) { pathElement = System.getProperty("user.home"); } else { pathElement = System.getProperty("user.home") + pathElement.substring(1); } } path = new File(pathElement); if (path.exists() == false) { invalidPathElement = pathElement; return false; } } return true; } @Override public OptionType getType() { return OptionType.TEXT; } } /* * $Log$ */ src/java/org/dbdoclet/option/SelectOption.java0000644000000000000000000000553312124530526020424 0ustar rootroot/* * ### Copyright (C) 2001-2003 Michael Fuchs ### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Michael Fuchs * E-Mail: mfuchs@unico-consulting.com * * RCS Information: * --------------- * Id.........: $Id: SelectOption.java,v 1.1.1.1 2004/12/21 14:06:09 mfuchs Exp $ * Author.....: $Author: mfuchs $ * Date.......: $Date: 2004/12/21 14:06:09 $ * Revision...: $Revision: 1.1.1.1 $ * State......: $State: Exp $ */ package org.dbdoclet.option; /** * Die Klasse SelectOption definiert eine Option, die einen Wert * aus einer Menge vorbestimmter Werte annehmen kann. * * Das folgende Beispiel zeigt die Definition der Option "cmd", die die Werte * list, extract und create annehmen kann. * *
      *
        SelectOption optCmd = new SelectOption("cmd", "c");
       *  optCmd.isRequired(true);
       *  String[] optCmdList = { "list", "extract", "create" };
       *  optCmd.setList(optCmdList);
       *  options.add(optCmd);
      *
      * * @author Michael Fuchs * @version 1.0 */ public class SelectOption extends Option { private String[] list; public SelectOption() { super(); hasArgument(true); } public SelectOption(String longName, String shortName) { super(longName, shortName); hasArgument(true); } public void setList(String[] list) { this.list = list; } public String getListAsString() { String buffer = ""; for (int i = 0; iDirectoryOption verarbeitet ein Argument auf der * Kommandozeile, das ein Verzeichnis angibt. * * @author michael * */ public class DirectoryOption extends Option { private boolean isExisting = false; private boolean createPath = false; public DirectoryOption() { super(); hasArgument(true); } public DirectoryOption(String longName) { super(longName); hasArgument(true); } public DirectoryOption(String longName, String shortName) { super(longName, shortName); hasArgument(true); } public void isExisting(boolean value) { isExisting = value; } public void setCreatePath(boolean createPath) { this.createPath = createPath; } protected boolean checkArgument(String arg) { arg = expandPath(arg); File file = new File(arg); if (file.exists() == false && createPath == true) { file.mkdirs(); } if (isExisting == true && file.exists() == false) { return false; } if (file.exists() == true && file.isDirectory() == false) { return false; } return true; } @Override public void addValueFromString(String value) { addValue(new File(expandPath(value))); } @Override public void setValueFromString(String value) { setValue(new File(expandPath(value))); } @Override public OptionType getType() { return OptionType.FILE; } } src/java/org/dbdoclet/option/BooleanOption.java0000644000000000000000000000453412124530526020564 0ustar rootrootpackage org.dbdoclet.option; /** *
      * The class BooleanOption implements a flag option with no * argument. * * If the flag is present on the command line, the value of the option will be * true, otherwise it will be false. * *
      * *
      Die Klasse BooleanOption realisiert die * Standardoption ohne Argument. * * Wird die Option auf der Kommandozeile gesetzt, so erhält die Option den Wert * "wahr". Andernfalls den Wert "falsch". Der Standardwert kann bei Aufruf der * Methode getFlag() überschrieben werden. * *
      * *
      *
       OptionList options = new OptionList(args);
      
       Option option = new BooleanOption("help","h");
       options.add(option);
      
       if ( options.getFlag("help",false) ) {
           printUsage();
           return;
       } 
      
       * 
      *
      * * @author Michael Fuchs * @version 1.0 */ public class BooleanOption extends Option { /** * Creates a new BooleanOption instance. */ public BooleanOption() { super(); setDefault(false); } public BooleanOption(String longName) { super(longName); setDefault(false); } /** *
      * Creates a new BooleanOption instance. *
      * *
      * Erzeugt eine neue Instanz der Klasse BooleanOption. *
      * * @param longName a String value * @param shortName a String value */ public BooleanOption(String longName, String shortName) { super(longName, shortName); setDefault(false); } @Override public void addValueFromString(String value) { addValue(Boolean.valueOf(value)); } @Override public void setValueFromString(String value) { boolean flag = false; if (value.equals("1") || value.equalsIgnoreCase("on") || value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("true") || value.equalsIgnoreCase("ja") || value.equalsIgnoreCase("wahr")) { flag = true; } setValue(flag); } @Override public OptionType getType() { return OptionType.BOOLEAN; } } src/java/org/dbdoclet/option/FileOption.java0000644000000000000000000000254712124530526020066 0ustar rootroot/* * * ### Copyright (C) 2005,2010 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.option; import java.io.File; /** * Die Klasse FileOption verarbeitet ein Argument der * Kommandozeile, das eine Datei spezifiziert. * * @author michael * */ public class FileOption extends Option { private boolean isExisting = false; public FileOption() { super(); hasArgument(true); } public FileOption(String longName) { super(longName); hasArgument(true); } public FileOption(String longName, String shortName) { super(longName, shortName); hasArgument(true); } @Override public void addValueFromString(String value) { addValue(new File(expandPath(value))); } public void isExisting(boolean value) { isExisting = value; } @Override public void setValueFromString(String value) { setValue(new File(expandPath(value))); } protected boolean checkArgument(String arg) { arg = expandPath(arg); File file = new File(arg); if (isExisting == true && file.exists() == false) { return false; } if (file.exists() == true && file.isFile() == false) { return false; } return true; } @Override public OptionType getType() { return OptionType.FILE; } } src/java/org/dbdoclet/option/OptionList.java0000644000000000000000000005573612124530526020132 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet.option; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Properties; import java.util.ResourceBundle; import org.dbdoclet.service.ResourceServices; /** * Die Klasse OptionList verwaltet die bekannten Optionen und * wertet die Kommandozeile aus. * *
      * *
       * 
       * OptionList options = new OptionList(args);
       * StringOption opt = new StringOption("program-name", "n");
       * opt.setMediumName("name");
       * opt.setPropertyName("program.name");
       * opt.setDefault("PROGRAM");
       * options.add(opt);
       * 
       * if (options.validate() == false) {
       * 	fail(options.getError());
       * }
       * 
       * options.setProperties(properties);
       * println("Optionen:");
       * println(options.list());
       * 
       * 
      * *
      * * @author Michael Fuchs * @version 1.0 */ public class OptionList implements Iterable> { private static ResourceBundle res = Option.getResourceBundle(); private ArrayList remainingArgs; private ArrayList args; private ArrayList> optList; private HashMap> optMap; private HashMap> deprecatedPropertiesMap; private String error = ""; /** * Erzeugt eine neue Instanz der Klasse OptionList ohne * Argumente. */ public OptionList() { String[] args = new String[0]; init(args, 0); } /** * Erzeugt eine neue Instanz der Klasse OptionList. * * @param cmdline * String[][] */ public OptionList(String[][] cmdline) { ArrayList list = new ArrayList(); for (int i = 0; i < cmdline.length; i++) { for (int j = 0; j < cmdline[i].length; j++) { list.add(cmdline[i][j]); } } String[] args = new String[list.size()]; int index = 0; for (Iterator i = list.iterator(); i.hasNext();) { args[index++] = i.next(); } init(args, 0); } /** * Erzeugt eine neue Instanz der Klasse OptionList. * * @param cmdline * a String[] value */ public OptionList(String[] cmdline) { if (cmdline == null) throw new IllegalArgumentException("Variable args is null!"); init(cmdline, 0); } /** * Erzeugt eine neue Instanz der Klasse OptionList. * * Der Parameter offset gibt an ab welchem Element der * Kommandozeile die Argumente ausgewertet werden sollen. Damit ist möglich * den Parametern Unterbefehle voranzustellen, z.B. wie in cocs update * --force. * * @param cmdline * a String[] value */ public OptionList(String[] cmdline, int offset) { if (cmdline == null) { throw new IllegalArgumentException( "The argument cmdline may not be null!"); } if (offset < 0) { throw new IllegalArgumentException( "The argument offset must be greater than 0!"); } if (offset > cmdline.length) { throw new IllegalArgumentException( "The argument offset is greater than the lehgth of the command line!"); } init(cmdline, offset); } /** * Die Methode getError liefert die letzte Fehlermeldung an den * Aufrufer zurück. * * @return String */ public String getError() { if (error == null) { error = ""; } return error; } /** * Die Methode findOption sucht nach der angegebenen Option in * der aktuellen Liste von Optionen. * * Falls die Option nicht gefunden werden kann, wird null * zurückgegeben. * * @param option * Die Option nach der gesucht wird. * @return Die gefundene Option oder null. */ public Option findOption(Option option) { Object obj; int index = optList.indexOf(option); if (index != -1) { obj = optList.get(index); if (obj != null && obj instanceof Option) { return (Option) obj; } } return null; } /** * The method findOption tries to find the given option by * name. If the option can not be found, null is returned. * * @param name * a String value * @return The option or null if no option can be found. */ public Option findOption(String name) { if (name == null) { throw new IllegalArgumentException( " The argument name may not be null!"); } return optMap.get(name); } public Option findExistingOption(Option option) { if (option == null) { throw new IllegalArgumentException( " The argument option may not be null!"); } Option existing; existing = optMap.get(option.getLongName()); if (existing != null) { return existing; } existing = optMap.get(option.getMediumName()); if (existing != null) { return existing; } existing = optMap.get(option.getShortName()); if (existing != null) { return existing; } existing = optMap.get(option.getPropertyName()); if (existing != null) { return existing; } throw new OptionException("Can't find existing option!"); } /** * The method getOption tries to find the given option by name. * If the option can not be found, an OptionException is thrown. * * @param name * a String value * @return The option. */ public Option getOption(String name) throws OptionException { if (name == null) { throw new IllegalArgumentException( "The argument name may not be null!"); } Option option = optMap.get(name); if (option == null) { String msg = MessageFormat.format( ResourceServices.getString(res, "C_ERROR_OPTION_UNKNOWN"), name); throw new OptionException(msg); } return option; } public BooleanOption getBooleanOption(String name) { if (name == null) { throw new IllegalArgumentException( "The argument name may not be null!"); } Option option = getOption(name); if (option instanceof BooleanOption) { return (BooleanOption) option; } else { String msg = MessageFormat.format(ResourceServices.getString(res, "C_ERROR_OPTION_INVALID_TYPE"), name, "boolean", option .getClass().getName()); throw new OptionException(msg); } // end of else } public void add(Option option) throws OptionException { if (option == null) { throw new IllegalArgumentException( " The argument option may not be null!"); } if (option.isValid() == false) { throw new OptionException(ResourceServices.getString(res, "C_ERROR_INVALID_OPTION") + option.getUniqueName()); } if (exists(option)) { Option existing = findExistingOption(option); throw new OptionException(MessageFormat.format(ResourceServices .getString(res, "C_ERROR_OPTION_ALREADY_IN_USE"), option .getFQName(), existing.getFQName())); } optList.add(option); String[] names = option.getNames(); for (int i = 0; i < names.length; i++) { optMap.put(names[i], option); } } /** * Die Methode getRemainingArgs liefert die nach der * Validierung überzähligen Argumente. Also diejenigen Argumente, die nicht * definiert waren. * * @return String[] */ public String[] getRemainingArgs() { if (remainingArgs == null) { return new String[0]; } String[] array = new String[remainingArgs.size()]; for (int i = 0; i < remainingArgs.size(); i++) { array[i] = remainingArgs.get(i); } return array; } /** * Describe getString method here. * * @param name * a String value * @return a String value */ public String getString(String name) { if (name == null) throw new IllegalArgumentException("Variable name is null!"); Option option = optMap.get(name); if (option == null) { return ""; } if (option.getValue() == null) { return null; } return option.getValue().toString(); } /** * Describe getString method here. * * @param name * a String value * @param deflt * a String value * @return a String value */ public String getString(String name, String deflt) { if (name == null) throw new IllegalArgumentException("Variable name is null!"); Option option = optMap.get(name); if (option == null || option.isUnset()) return deflt; if (option.getValue() == null) { return deflt; } else { return option.getValue().toString(); } } public void addDeprecatedPropertyAlias(Option option, String alias) throws OptionException { if (option == null) { throw new IllegalArgumentException( "The argument option may not be null!"); } if (alias == null || alias.length() == 0 || alias.equals("!")) { throw new IllegalArgumentException( "The argument alias is invalid: " + alias); } if (deprecatedPropertiesMap == null) { throw new IllegalStateException( " The field deprecatedPropertiesMap may not be null!"); } String name = alias; if (name.startsWith("!")) { name = name.substring(1); } // end of if (name.startsWith("!")) Option opt = optMap.get(name); if (opt != null && opt.equals(option) == false) { throw new OptionException(MessageFormat.format(ResourceServices .getString(res, "C_ERROR_OPTION_ALREADY_IN_USE"), name)); } deprecatedPropertiesMap.put(alias, option); } public boolean setProperties(String fname) throws FileNotFoundException, IOException { if (fname == null) { throw new IllegalArgumentException( " The argument fname may not be null!"); } Properties props = new Properties(); props.load(new FileInputStream(fname)); return setProperties(props); } public boolean setProperties(Properties props) throws OptionException { if (props == null) { throw new IllegalArgumentException( " The argument props may not be null!"); } Object obj; Option option; String name; String value; String buffer = ""; for (Iterator i = props.keySet().iterator(); i.hasNext();) { obj = i.next(); if (obj instanceof String) { name = (String) obj; value = props.getProperty(name); if (value == null) { continue; } option = optMap.get(name); if (option == null) { option = deprecatedPropertiesMap.get(name); if (option != null) { buffer += MessageFormat.format(ResourceServices .getString(res, "C_WARN_PROPERTY_DEPRECATED"), name, option.getPropertyName()) + "\n"; } else { option = deprecatedPropertiesMap.get("!" + name); if (option != null && (option instanceof BooleanOption)) { value = value.trim(); boolean flag = false; if (value.equals("1") || value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("true") || value.equalsIgnoreCase("ja") || value.equalsIgnoreCase("wahr")) { flag = true; } ((BooleanOption) option).setValue(flag); continue; } } } if (option == null) { buffer += MessageFormat.format(ResourceServices .getString(res, "C_ERROR_PROPERTY_UNKNOWN"), name) + "\n"; continue; } if (option != null && option.isUnset()) { option.setValueFromString(value); } } } if (buffer != null && buffer.length() > 0) { error = buffer; return false; } else { return true; } } public boolean validate() { return validate(false); } /** * Die Methode validate validiert die Argumente. * * Das Validieren prüft die Argumente auf ihre syntaktische Korrektheit. * Zusätzlich werden die Optionen selbst bearbeitet. Gefundene Optionen * werden als vorhanden markiert und mit den Werten aus den Argumenten * initialisert. Überzählige Argumente werden in einem Container namens * remainingArgs gespeichert. Je nach Wert des Parameters * ignoreUnknownOptions führen überzählige Argumente zu einer * Fehlermeldung oder sie können mit Hilfe der Methode * getRemainingArgs ermittelt werden. Zusätzliche Argumente * sind sinnvoll, wenn den Optionen z.B. eine URL- oder Pfadangabe folgt, * welche nicht von einer Option eingeleitet wird. * *
      * *
      	 * cocs checkout --verbose file:///repository
      	 * 
      *

      * In diesem Beispiel wird die URL nicht von einer Option begleitet. Sie * gilt als "überzähliges Argument". *

      *
      * * @param ignoreUnknownOptions * boolean * @return boolean * @exception OptionException */ public boolean validate(boolean ignoreUnknownOptions) throws OptionException { Iterator> iterator = optList.iterator(); Option option; String arg; String str; String buffer = ""; int index = -1; int counter = 0; ArrayList argList = new ArrayList(args); while (iterator.hasNext()) { option = iterator.next(); option.isUnset(true); index = searchArgs(argList, option); if (index == -1 && option.isRequired()) { buffer += MessageFormat .format(ResourceServices.getString(res, "C_ERROR_OPTION_REQUIRED"), option .getUniqueName()) + "\n"; continue; } counter = 0; while (index != -1) { if (option.hasArgument()) { if (index == argList.size() - 1) { buffer += MessageFormat.format(ResourceServices .getString(res, "C_ERROR_OPTION_NEEDS_ARG"), option.getUniqueName()) + "\n"; argList.remove(index); index = searchArgs(argList, option); continue; } arg = argList.get(index + 1); if (arg.startsWith("-")) { buffer += MessageFormat.format(ResourceServices .getString(res, "C_ERROR_OPTION_NEEDS_ARG"), option.getUniqueName()) + "\n"; argList.remove(index); index = searchArgs(argList, option); continue; } if (option instanceof SelectOption) { SelectOption selopt = (SelectOption) option; if (selopt.checkArgument(arg) == false) { buffer += MessageFormat.format(ResourceServices .getString(res, "C_ERROR_OPTION_INVALID_VALUE"), option.getUniqueName(), arg, selopt .getListAsString()) + "\n"; argList.remove(index + 1); argList.remove(index); index = searchArgs(argList, option); continue; } } if (option instanceof PathOption) { PathOption pathopt = (PathOption) option; if (pathopt.checkArgument(arg) == false) { buffer += MessageFormat.format(ResourceServices .getString(res, "C_ERROR_OPTION_INVALID_PATH"), option.getUniqueName(), arg, pathopt .getInvalidPathElement()) + "\n"; argList.remove(index + 1); argList.remove(index); index = searchArgs(argList, option); continue; } } if (option instanceof FileOption) { FileOption fileopt = (FileOption) option; if (fileopt.checkArgument(arg) == false) { buffer += MessageFormat.format(ResourceServices .getString(res, "C_ERROR_OPTION_INVALID_FILE"), option.getUniqueName(), arg) + "\n"; argList.remove(index + 1); argList.remove(index); index = searchArgs(argList, option); continue; } } if (option instanceof DirectoryOption) { DirectoryOption diropt = (DirectoryOption) option; if (diropt.checkArgument(arg) == false) { buffer += MessageFormat .format(ResourceServices.getString(res, "C_ERROR_OPTION_INVALID_DIRECTORY"), option.getUniqueName(), arg) + "\n"; argList.remove(index + 1); argList.remove(index); index = searchArgs(argList, option); continue; } } if (option.isLowerCase()) { arg = arg.toLowerCase(); } if (option.isUnset() || option.isUnique()) { option.setValueFromString(arg); } else { option.addValueFromString(arg); } option.isPresent(true); argList.remove(index + 1); argList.remove(index); /* This option can have multiple arguments */ if (option.isUnique() == false) { int i; for (i = 0; i < argList.size(); i++) { arg = argList.get(i); if (arg.startsWith("-") == false) { option.addValueFromString(arg); } else { break; } } for (int j = 0; j < i; j++) { argList.remove(0); } } } else { String value = "true"; if (index + 1 < argList.size()) { String next = argList.get(index + 1); if (next.startsWith("-") == false) { value = next; argList.remove(index + 1); } } option.setValueFromString(value); option.isPresent(true); argList.remove(index); } // look for more appearances of this option. index = searchArgs(argList, option); if (option.isUnique() && index != -1 && counter == 0) { buffer += MessageFormat.format(ResourceServices .getString(res, "C_ERROR_OPTION_WAS_FOUND_MORE_THAN_ONCE"), option.getUniqueName()) + "\n"; } counter++; } } if (argList.size() > 0 && ignoreUnknownOptions == false) { str = ""; for (int i = 0; i < argList.size(); i++) { str += argList.get(i) + " "; } buffer += MessageFormat.format( ResourceServices.getString(res, "C_ERROR_OPTION_UNKNOWN"), str) + "\n"; } remainingArgs = new ArrayList(argList); if (buffer != null && buffer.length() > 0) { error = buffer; return false; } else { return true; } } public void write(PrintWriter writer) { Option option; String name; Object[] options = optList.toArray(); Arrays.sort(options); for (int i = 0; i < options.length; i++) { option = (Option) options[i]; name = option.getPropertyName(); if (option.getValue() != null) { if (name != null && name.length() > 0) { writer.println(option.getPropertyName() + "=" + escape(option.getValue().toString())); } } } } public Iterator> iterator() { return optList.iterator(); } /** * Describe list method here. * * @return a String value */ public String list() { StringBuffer buffer = new StringBuffer(); Object[] options = optList.toArray(); Arrays.sort(options); for (int i = 0; i < options.length; i++) { buffer.append(((Option) options[i]).toString() + "\n"); } return buffer.toString(); } /** * Describe init method here. * * @param cmdline * a String[] value */ private void init(String[] cmdline, int offset) { if (cmdline == null) { throw new IllegalArgumentException( "The argument cmdline may not be null!"); } if (offset < 0) { throw new IllegalArgumentException( "The argument offset must be greater than 0!"); } if (offset > cmdline.length) { throw new IllegalArgumentException( "The argument offset is greater than the length of the command line!"); } args = new ArrayList(); String arg; int pos; for (int i = offset; i < cmdline.length; i++) { arg = cmdline[i]; pos = arg.indexOf('='); if (arg.startsWith("--") && pos > 0) { args.add(arg.substring(0, pos)); if (pos + 1 < arg.length()) args.add(arg.substring(pos + 1)); else args.add(""); } else { args.add(cmdline[i]); } } optList = new ArrayList>(); optMap = new HashMap>(); deprecatedPropertiesMap = new HashMap>(); } /** * Describe searchArgs method here. * * @param longName * a String value * @param shortName * a String value * @return an int value */ private int searchArgs(ArrayList args, Option option) { if (args == null) { throw new IllegalArgumentException( " The argument args may not be null!"); } if (option == null) { throw new IllegalArgumentException( " The argument option may not be null!"); } String arg; for (int i = 0; i < args.size(); i++) { arg = args.get(i); if (arg.equals("--" + option.getLongName()) || arg.equals("-" + option.getMediumName()) || arg.equals("-" + option.getShortName())) { return i; } } return -1; } /** * Describe exists method here. * * @param longName * a String value * @param mediumName * a String value * @param shortName * a String value * @param propertyName * a String value * @return a boolean value */ private boolean exists(Option lookFor) { if (optList.contains(lookFor)) { return true; } if (isOptionNameAvailable(lookFor.getLongName()) == false) { return true; } if (isOptionNameAvailable(lookFor.getMediumName()) == false) { return true; } if (isOptionNameAvailable(lookFor.getShortName()) == false) { return true; } if (isOptionNameAvailable(lookFor.getPropertyName()) == false) { return true; } return false; } private boolean isOptionNameAvailable(String name) { if (name != null && name.length() > 0 && optMap.get(name) != null) { return false; } return true; } private String escape(String str) { if (str == null) { return ""; } StringBuffer buffer = new StringBuffer(); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); int n = (int) c; if (c == '\r') { continue; } if (n >= 0 && n < 128 && c != '\n' && c != '\\') { buffer.append(c); } else { buffer.append("\\u"); String hex = Integer.toHexString(n); for (int j = 0; j < 4 - hex.length(); j++) { buffer.append("0"); } buffer.append(hex); } } return buffer.toString(); } public boolean getFlag(String name, boolean def) { Option option = optMap.get(name); if (option != null && option instanceof BooleanOption) { return ((BooleanOption) option).getValue(); } return def; } public Option getTextOption(String name) { Option option = getOption(name); if (option instanceof SelectOption) { return (SelectOption) option; } if (option instanceof StringOption) { return (StringOption) option; } return null; } } /* * $Log$ */ src/java/org/dbdoclet/option/Resources_en.properties0000644000000000000000000000235212124530526021717 0ustar rootroot#Created by JInto - www.guh-software.de #Wed Feb 18 12:53:36 CET 2009 C_ERROR_INVALID_NUMBER=Invalid Parameter {1} for argument {0}\! Should be an integer. C_ERROR_INVALID_OPTION=Invalid option\: C_ERROR_OPTION_ALREADY_IN_USE=Can not add option {0}. There are naimng collisions with {1}\! C_ERROR_OPTION_INVALID_DIRECTORY=Invalid directory {1} for option {0}\! The directory does not exist. C_ERROR_OPTION_INVALID_FILE=Invalid file {1} for option {0}\! The file does not exist. C_ERROR_OPTION_INVALID_PATH=Invalid path {1} for option {0}\! The path element {2} does not exist. C_ERROR_OPTION_INVALID_SHORT_NAME=Invalid short option name\: {0}. C_ERROR_OPTION_INVALID_TYPE=The option {0} is not of type {1}, but of type {2}. C_ERROR_OPTION_INVALID_VALUE=The option "{0}" has an invalid value of "{1}". Possible values are\: {2}. C_ERROR_OPTION_NEEDS_ARG=The option "{0}" needs an argument. C_ERROR_OPTION_REQUIRED=The option "{0}" is required. C_ERROR_OPTION_UNKNOWN=Unknown option(s)\: {0}. C_ERROR_OPTION_WAS_FOUND_MORE_THAN_ONCE=The option "{0}" was found more than once. C_ERROR_PROPERTY_UNKNOWN=Unknown property\: "{0}" C_ERROR_WRONG_OPTIONS=ERROR Invalid options\: C_WARN_PROPERTY_DEPRECATED=The property "{0}" is deprecated. Please use "{1}" instead. src/java/org/dbdoclet/option/Resources_de.properties0000644000000000000000000000271312124530526021706 0ustar rootroot#Created by JInto - www.guh-software.de #Wed Feb 18 12:53:36 CET 2009 C_ERROR_INVALID_NUMBER=Ung\u00FCltiger Parameter {1} f\u00FCr die Option {0}\! C_ERROR_INVALID_OPTION=Ung\u00FCltige Option\: C_ERROR_OPTION_ALREADY_IN_USE=Die Option {0} konnte nicht zur Optionsliste hinzugef\u00FCgt werden. Sie kollidiert mit {1}\! C_ERROR_OPTION_INVALID_DIRECTORY=Ung\u00FCltiges Verzeichnis {1} f\u00FCr die Option {0}\! Das Verzeichnis existiert nicht. C_ERROR_OPTION_INVALID_FILE=Ung\u00FCltige Datei {1} f\u00FCr die Option {0}\! Die Datei existiert nicht. C_ERROR_OPTION_INVALID_PATH=Ung\u00FCltiger Pfad {1} f\u00FCr die Option {0}\! Das Pfadelement {2} existiert nicht. C_ERROR_OPTION_INVALID_SHORT_NAME=Ung\u00FCltiger kurzer Optionsname\: {0}. C_ERROR_OPTION_INVALID_TYPE=Die Option {0} ist nicht vom Typ {1}, sondern vom Typ {2}. C_ERROR_OPTION_INVALID_VALUE=Ung\u00FCltiger Parameter {1} f\u00FCr die Option "{0}". M\u00F6gliche Parameter sind\: {2}. C_ERROR_OPTION_NEEDS_ARG=Die Option "{0}" ben\u00F6tigt ein Argument. C_ERROR_OPTION_REQUIRED=Die Option "{0}" ist zwingend erforderlich. C_ERROR_OPTION_UNKNOWN=Unbekannte Option(en)\: {0}. C_ERROR_OPTION_WAS_FOUND_MORE_THAN_ONCE=Die Option "{0}" trat mehr als einmal auf. C_ERROR_PROPERTY_UNKNOWN=Unbekannte Eigenschaft (Property)\: "{0}" C_ERROR_WRONG_OPTIONS=FEHLER Ung\u00FCltige Optionen\: C_WARN_PROPERTY_DEPRECATED=Die Eigenschaft (Property) "{0}" ist \u00FCberholt. Bitte verwenden Sie statt dessen die Eigenschaft "{1}". src/java/org/dbdoclet/option/Option.java0000644000000000000000000002700612124530526017263 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet.option; import java.util.ArrayList; import java.util.Iterator; import java.util.ResourceBundle; import org.dbdoclet.service.FileServices; /** * Describe class Option here. * * @author Michael Fuchs * @version 1.0 */ public abstract class Option implements Comparable> { private static ResourceBundle res = ResourceBundle.getBundle("org.dbdoclet.option.Resources"); private String longName; private String shortName; private String mediumName; private String propertyName; private ArrayList values = new ArrayList(); private boolean isPresent = false; private boolean isRequired = false; private boolean isUnique = true; private boolean hasArgument = false; private boolean isLowerCase = false; private boolean isUnset = true; public Option() { this.longName = ""; this.shortName = ""; this.mediumName = ""; this.propertyName = ""; this.values = new ArrayList(); } public Option(String longName) { if (longName == null) { throw new IllegalArgumentException("Variable longName is null!"); } this.longName = longName; this.shortName = ""; this.mediumName = ""; this.propertyName = ""; this.values = new ArrayList(); } public Option(String longName, String shortName) { if (longName == null) { throw new IllegalArgumentException("Variable longName is null!"); } if (shortName == null) { throw new IllegalArgumentException("Variable shortName is null!"); } this.longName = longName; this.shortName = shortName; this.mediumName = ""; this.propertyName = ""; this.values = new ArrayList(); } public static ResourceBundle getResourceBundle() { return res; } public abstract void addValueFromString(String value); public void addValue(T value) { if (value == null) { throw new IllegalArgumentException("Variable value is null!"); } values.add(value); isUnset = false; } public int compareTo(Option other) { if (other == null) { return 1; } String name = getFQName(); return name.compareTo(other.getFQName()); } public boolean equals(Object obj) { if (obj == null) { return false; } if (obj instanceof Option) { Option option = (Option) obj; if (isValid() == false) { return false; } if (option.isValid() == false) { return false; } if (longName.equals(option.getLongName()) && mediumName.equals(option.getMediumName()) && shortName.equals(option.getShortName()) && propertyName.equals(option.getPropertyName())) { return true; } } return false; } public String getFQName() { String buffer = "("; if (propertyName != null && propertyName.length() > 0) { if (buffer.length() > 0 ) { buffer += "."; } buffer += propertyName; } if (longName != null && longName.length() > 0) { if (buffer.length() > 0 ) { buffer += "/"; } buffer += longName; } if (mediumName != null && mediumName.length() > 0) { if (buffer.length() > 0 ) { buffer += "/"; } buffer += mediumName; } if (shortName != null && shortName.length() > 0) { if (buffer.length() > 0 ) { buffer += "/"; } buffer += shortName; } buffer += ")"; return buffer; } public String getLongName() { return longName; } public String getMediumName() { return mediumName; } public String[] getNames() { ArrayList list = new ArrayList(); if (longName != null && longName.length() > 0 && list.contains(longName) == false) { list.add(longName); } if (mediumName != null && mediumName.length() > 0 && list.contains(mediumName) == false) { list.add(mediumName); } if (shortName != null && shortName.length() > 0 && list.contains(shortName) == false) { list.add(shortName); } if (propertyName != null && propertyName.length() > 0 && list.contains(propertyName) == false) { list.add(propertyName); } String[] names = new String[list.size()]; for (int i = 0; i 0) { return "--" + longName; } if (mediumName != null && mediumName.length() > 0) { return "-" + mediumName; } if (shortName != null && shortName.length() > 0) { return "-" + shortName; } if (propertyName != null && propertyName.length() > 0) { return propertyName; } return "???"; } public T getValue() { T value = null; if (values.size() > 0) { value = values.get(0); } return value; } public ArrayList getValues() { return values; } public int hashCode() { int result = 17; result = 37 * result + longName.hashCode(); result = 37 * result + mediumName.hashCode(); result = 37 * result + shortName.hashCode(); result = 37 * result + propertyName.hashCode(); return result; } public boolean isLowerCase() { return isLowerCase; } public boolean isRequired() { return isRequired; } public void isRequired(boolean value) { isRequired = value; } public boolean isUnique() { return isUnique; } public void isUnique(boolean value) { isUnique = value; } public boolean isUnset() { return isUnset; } public void isUnset(boolean isUnset) { this.isUnset = isUnset; } public boolean isValid() { if (longName == null) { return false; } if (mediumName == null) { return false; } if (shortName == null) { return false; } if (propertyName == null) { return false; } if (longName.length() == 0 && mediumName.length() == 0 && shortName.length() == 0 && propertyName.length() == 0) { return false; } // end of if (longName.length() == 0) return true; } public void setDefault(T value) { if (value == null) { throw new IllegalArgumentException(" The argument value may not be null!"); } values.clear(); values.add(value); } public void setLongName(String longName) { if (longName == null) { throw new IllegalArgumentException(" The argument longName may not be null!"); } this.longName = longName; } public void setLowerCase(boolean isLowerCase) { this.isLowerCase = isLowerCase; } public Option setMediumName(String mediumName) { if (mediumName == null) { throw new IllegalArgumentException(" The argument mediumName may not be null!"); } this.mediumName = mediumName; return this; } public void setPropertyName(String propertyName) { if (propertyName == null) { throw new IllegalArgumentException(" The argument propertyName may not be null!"); } this.propertyName = propertyName; } public void setShortName(String shortName) { if (shortName == null) { throw new IllegalArgumentException(" The argument shortName may not be null!"); } this.shortName = shortName; } public abstract void setValueFromString(String value); public void setValue(T value) { if (value == null) { throw new IllegalArgumentException("Variable value is null!"); } values.clear(); values.add(value); isUnset = false; } public String toString() { StringBuffer buffer = new StringBuffer(); T value; if (propertyName != null && propertyName.length() > 0) { buffer.append(propertyName + " "); } if (longName != null && longName.length() > 0) { buffer.append(longName + " "); } if (mediumName != null && mediumName.length() > 0) { buffer.append(mediumName + " "); } if (shortName != null && shortName.length() > 0) { buffer.append(shortName + " "); } buffer.append("["); if (hasArgument) { buffer.append('A'); } else { buffer.append('a'); } // end of else if (isPresent) { buffer.append('P'); } else { buffer.append('p'); } // end of else if (isRequired) { buffer.append('R'); } else { buffer.append('r'); } // end of else buffer.append(']'); for (int j = buffer.length(); j < 32; j++) { buffer.append('.'); } buffer.append(": "); int counter = 0; for (Iterator i = values.iterator(); i.hasNext();) { value = i.next(); if (counter > 0) { buffer.append(", "); } buffer.append(value); counter++; } return buffer.toString(); } protected boolean checkArgument(String arg) { return true; } protected String expandPath(String arg) { if (arg.startsWith("~") == true) { arg = FileServices.appendPath(System.getProperty("user.home"), arg .substring(1)); } return arg; } protected boolean hasArgument() { return hasArgument; } // Implementation of java.lang.Comparable protected void hasArgument(boolean value) { hasArgument = value; } protected void isPresent(boolean value) { isPresent = value; } public abstract OptionType getType(); } src/java/org/dbdoclet/option/OptionType.java0000644000000000000000000000012712124530526020120 0ustar rootrootpackage org.dbdoclet.option; public enum OptionType { BOOLEAN, FILE, INTEGER, TEXT } src/java/org/dbdoclet/herold/0000755000000000000000000000000012124530526015110 5ustar rootrootsrc/java/org/dbdoclet/herold/Resources.properties0000644000000000000000000000377712124530526021216 0ustar rootroot# Java Resource Bundle # Modified by Zaval JRC Editor (C) Zaval CE Group # http://www.zaval.org/products/jrc-editor/ C_COLUMN=Column C_DOCBOOK_FILE=DocBook File C_DOCBOOK_VERSION= C_ERROR=Error C_ERROR_CANT_FIND_DOCBOOK_XSD=Can't find DocBook Schema {1} for version {0}! C_ERROR_DOCBOOK_FILE_MISSING=

      DocBook File not defined

      \n\

      You must specify a DocBook file as output target. Please use the field "DocBook File" in the property dialog \n\ to choose the file where the DocBook output should be stored.

      C_ERROR_FILE_NOT_FOUND=Can't find file {0}. C_ERROR_HTML_FILE_MISSING=

      HTML File not defined

      \n\

      You must specify a HTML file for processing. Please use the field "HTML File" in the property dialog \n\ to choose the HTML file you want to convert to DocBook XML

      C_ERROR_PARSE=Parser: C_ERROR_RESOURCE_NOT_FOUND=Can't find resource {0}. C_ERROR_XML_NOT_VALID=The generated XML document is not valid. Please download the latest version of dbdoclet from \\nhttp://www.dbdoclet.org. If you encountered a bug, please send an email to michael.fuchs@unico-group.com. C_FATAL_ERROR=Fatal Error C_HTML_FILE=HTML File C_LINE=Line C_OPTION_DOCBOOK_VERSION=DocBook Version C_OPTION_INDEX_ELEMENT=Add Index Element C_OPTION_NO_TABLES=Suppress Tables C_OPTION_ROOT_ELEMENT=Document Type C_OVERVIEW=Overview C_REFERENCE_HANDBOOK=Reference Handbook C_TOOLTIP_OPTION_DOCBOOK_VERSION=

      The Version of the DocBook Schema, which is used for the generation of the DocBook XML.

      C_TOOLTIP_OPTION_INDEX_ELEMENT=

      If set and document type is book, an index element will be added at the end of the DocBook Xml file.

      C_TOOLTIP_OPTION_NO_TABLES=

      Suppressing tables may be helpful, if your HTML files contains tables for layout purposes.

      C_TOOLTIP_OPTION_ROOT_ELEMENT=The document type of generated DocBook XML. Actually the root element of the XML tree. C_USAGE=/org/dbdoclet/herold/usage.txt C_VALIDATING=Validating... C_WARNING=Warning src/java/org/dbdoclet/herold/COPYING0000644000000000000000000010451312124530526016147 0ustar rootroot GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . src/java/org/dbdoclet/herold/usage.txt0000644000000000000000000000242712124530526016762 0ustar rootrootherold Version {0} Copyright (C) 2001-2012 Michael Fuchs Syntax: herold [options] --docbook-encoding -d - Specifies the encoding of the generated DocBook XML files. Example: --destination-encoding=ISO-8859-1 --help -h - Print this message and quit. --in= -i - Input HTML file. --license -L - Display the herold license and quit. --out= -o - Output XML file. --profile= -p - Profile file with predefined parameter settings. --docbook-document-element= -r - The root element of the document. Possible values are: book and article. The default value is 'article'. --html-encoding -s - Specifies the encoding of the source files, such as ISO-8859-1. --docbook-title -t - The title for the resulting document. --docbook-decompose-tables -T - Tables inside the HTML file are decomposed during the transformation. --verbose -v - Progress messages on the console. --version -V - Version numbersrc/java/org/dbdoclet/herold/ConsoleProgressListener.java0000644000000000000000000000635712124530526022623 0ustar rootrootpackage org.dbdoclet.herold; import org.dbdoclet.progress.ProgressAdapter; import org.dbdoclet.progress.ProgressEvent; public class ConsoleProgressListener extends ProgressAdapter { private static final int DEFAULT_LINE_WIDTH = 77; private int prepareCounter = 0; private int actionCounter = 0; private final boolean dumb; private int lastPercent = 0; private ProgressEvent lastEvent; private int barWidth; private int lineWidth; private String lastLine; public ConsoleProgressListener(boolean dumb) { this.dumb = dumb; int lineWidth = DEFAULT_LINE_WIDTH; String value = System.getProperty("console.lineWidth"); if (value != null) { try { lineWidth = Integer.parseInt(value); } catch (Exception e) { lineWidth = DEFAULT_LINE_WIDTH; } } // print("LineWidth=" + lineWidth + "\n"); setLineWidth(lineWidth); } @Override public boolean progress(ProgressEvent event) { if (lastEvent != null) { if (lastEvent.getStage() == ProgressEvent.STAGE_ACTION && lastEvent.getConsider() == true && (event.getStage() != ProgressEvent.STAGE_ACTION || event.getConsider() == false)) { printBar(100); } } if (event.getConsider() == false) { print("\n" + event.getAction() + "\n"); lastEvent = event; return true; } if (event.getStage() == ProgressEvent.STAGE_PREPARE) { stagePrepare(event); } if (event.getStage() == ProgressEvent.STAGE_ACTION) { actionCounter++; int percent = 0; int max = getProgressMaximum(); if (max > 0) { percent = (100 * actionCounter) / getProgressMaximum(); } if (percent > 100) { percent = 100; } printBar(percent); } lastEvent = event; return true; } private void stagePrepare(ProgressEvent event) { if (dumb == false) { StringBuilder buffer = new StringBuilder(String.valueOf(++prepareCounter)); buffer.append(' '); String action = event.getAction(); if (action != null) { action = action.replaceAll("\n", " ").trim(); action = action.replaceAll("\r", " ").trim(); buffer.append(action); } while (buffer.length() < lineWidth) { buffer.append(' '); } if (buffer.length() > lineWidth) { buffer = buffer.delete(lineWidth, buffer.length()); } print(buffer.toString() + "\r"); } } private void printBar(int percent) { int pos = 0; if (percent > 0) { pos = (int) (percent * ((float) barWidth / 100)); } StringBuilder buffer = new StringBuilder(); for (int i = 0; i < pos; i++) { buffer.append('#'); } for (int i = pos; i < barWidth; i++) { buffer.append(' '); } if (dumb == true) { if (percent != lastPercent) { System.out.println(percent + "%"); lastPercent = percent; } } else { String line = String.format(" %3d%% |%s| 100%%\r", percent, buffer.toString()); print(line); } } @Override public void setProgressMaximum(int max) { super.setProgressMaximum(max); actionCounter = 0; } public void setLineWidth(int lineWidth) { if (lineWidth < 15) { return; } this.lineWidth = lineWidth; barWidth = lineWidth - 13; } private void print(String line) { if (lastLine != null && line.equals(lastLine)) { return; } System.out.print(line); lastLine = line; } } src/java/org/dbdoclet/herold/Resources_de.properties0000644000000000000000000000507712124530526021661 0ustar rootroot# Java Resource Bundle # Modified by Zaval JRC Editor (C) Zaval CE Group # http://www.zaval.org/products/jrc-editor/ C_COLUMN=Spalte C_DOCBOOK_FILE=DocBook-Datei C_ERROR=Fehler C_ERROR_CANT_FIND_DOCBOOK_XSD=Das DocBook XML Schema {1} fr Version {0} konnte nicht gefunden werden! C_ERROR_DOCBOOK_FILE_MISSING=

      DocBook Datei ist unbestimmt

      \n\

      Sie mssen die DocBook-Datei bestimmen, in der das DocBook XML gespeichert werden soll. Klicken Sie dazu in das \n\ Eingabefeld mit dem zugehrigen Attributnamen "DocBook-Datei" des Parameterdialog. Es ffnet sich nun ein \n\ Dateidialog in dem Sie eine entsprechende DocBook-Datei auswhlen knnen.

      \n\ C_ERROR_FILE_NOT_FOUND=Die Datei {0} konnte nicht gefunden werden. C_ERROR_HTML_FILE_MISSING=

      HTML Datei ist unbestimmt

      \n\

      Sie mssen die HTML-Datei bestimmen, die nach DocBook XML konvertiert werden soll. Klicken Sie dazu in das \n\ Eingabefeld mit dem zugehrigen Attributnamen "HTML-Datei" des Parameterdialog. Es ffnet sich nun ein \n\ Dateidialog in dem Sie die entsprechende HTML-Datei auswhlen knnen.

      \n\ C_ERROR_PARSE=Parser: C_ERROR_RESOURCE_NOT_FOUND=Die URL {0} konnte nicht gefunden werden. C_ERROR_XML_NOT_VALID=Das erzeugte XML-Dokument ist nicht gltig. Die aktuelle Version von dbdoclet kann\\nbei http://www.dbdoclet.org bezogen werden. Falls sie einen Fehler entdeckt haben,\\nschreiben sie bitte eine E-Mail an michael.fuchs@unico-group.com. C_FATAL_ERROR=Fataler Fehler C_HTML_FILE=HTML-Datei C_INDEX_ELEMENT=Element Index einfgen C_LINE=Zeile C_OPTION_DOCBOOK_VERSION=DocBook Version C_OPTION_INDEX_ELEMENT=Element Index einfgen C_OPTION_NO_TABLES=Tabellen ausblenden C_OPTION_ROOT_ELEMENT=Dokumenttyp C_OVERVIEW=berblick C_REFERENCE_HANDBOOK=Referenzhandbuch C_TOOLTIP_INDEX_ELEMENT=

      Bestimmt ob am Ende der DocBook XML Datei das Element index eingefgt wird.

      C_TOOLTIP_OPTION_DOCBOOK_VERSION=

      Die Version des DocBook Schemas, das fr die Generierung des DocBook XML verwendet werden soll.

      C_TOOLTIP_OPTION_INDEX_ELEMENT=

      Bestimmt fr den Dokumententyp book, ob am Ende der DocBook XML Datei das Element index eingefgt wird.

      C_TOOLTIP_OPTION_NO_TABLES=

      Das Ausblenden der Tabellen kann die Transformation von HTML-Dateien verbessern, die Tabellen fr \n\ das Layout verwenden.

      C_TOOLTIP_OPTION_ROOT_ELEMENT=Der Type des Dokumentes bestimmt das Wurzelelement des XML-Baumes. C_USAGE=/org/dbdoclet/herold/usage_de.txt C_VALIDATING=Validierung des DocBook-Dokumentes... C_WARNING=Warnung src/java/org/dbdoclet/herold/Herold.java0000644000000000000000000002662512124530526017203 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.herold; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.StringWriter; import java.net.URL; import java.text.MessageFormat; import java.util.ResourceBundle; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.option.BooleanOption; import org.dbdoclet.option.FileOption; import org.dbdoclet.option.Option; import org.dbdoclet.option.OptionException; import org.dbdoclet.option.OptionList; import org.dbdoclet.option.SelectOption; import org.dbdoclet.option.StringOption; import org.dbdoclet.service.FileServices; import org.dbdoclet.service.ResourceServices; import org.dbdoclet.service.StringServices; import org.dbdoclet.trafo.TrafoException; import org.dbdoclet.trafo.TrafoExceptionHandler; import org.dbdoclet.trafo.TrafoScriptManager; import org.dbdoclet.trafo.html.docbook.DbtConstants; import org.dbdoclet.trafo.html.docbook.DocBookTransformer; import org.dbdoclet.trafo.script.Script; /** * The class Herold implements a console converter to transform * HTML code to DocBook XML. * * @author Michael Fuchs * @version 1.0 */ public class Herold { private static Log logger = LogFactory.getLog(Herold.class); private static FileOption optIn; private static FileOption optOut; private static ResourceBundle res = ResourceBundle .getBundle("org/dbdoclet/herold/Resources"); private boolean verbose = false; private static boolean systemExitEnabled = true; private static int exitCode; public static void main(String[] args) { OptionList options = null; exitCode = 0; try { Option option; options = new OptionList(args); // help option = new BooleanOption("help", "h"); option.setMediumName("?"); options.add(option); // license option = new BooleanOption("license", "L"); options.add(option); // version option = new BooleanOption("version", "V"); options.add(option); options.validate(true); if (options.getFlag("help", false)) { printUsage(); return; } if (options.getFlag("version", false)) { printVersion(); return; } if (options.getFlag("license", false)) { printLicense(); exit(0); } options = createOptionList(args); if (options.validate() == false) { throw new OptionException(options.getError()); } Herold converter = new Herold(); StringOption optProfile = (StringOption) options .getOption("profile"); File profileFile = findProfile(optProfile); Script script; TrafoScriptManager mgr = new TrafoScriptManager(); script = mgr.parseScript(profileFile); logger.info(String.format("Using profile file %s.", profileFile.getAbsolutePath())); if (logger.isTraceEnabled()) { StringWriter buffer = new StringWriter(); mgr.writeScript(script, buffer); logger.trace("Script: " + buffer.toString()); } File outFile = converter.processCommandLineOptions(options, script); if (outFile != null) { logger.info(String.format("Output file is %s.", outFile.getPath())); } InputStream in = null; OutputStream out = null; if (optIn.isUnset()) { in = System.in; } else { in = new FileInputStream(optIn.getValue()); } out = createOutputStream(); converter.convert(in, out, script); } catch (OptionException oops) { if ((options != null) && (options.getFlag("help", false) == false)) { printUsage(); String msg = oops.getMessage(); if (msg != null) { System.err.println(msg); } } else { oops.printStackTrace(); printUsage(); } exitCode = 1; } catch (TrafoException oops) { logger.fatal("TrafoException", TrafoExceptionHandler.getCause(oops)); exitCode = 2; } catch (FileNotFoundException oops) { logger.fatal(oops.getMessage()); exitCode = 3; } catch (IOException oops) { oops.printStackTrace(); exitCode = 4; } catch (Exception oops) { oops.printStackTrace(); exitCode = 5; } exit(exitCode); } private static OutputStream createOutputStream() throws FileNotFoundException { OutputStream out; if (optOut.isUnset()) { out = System.out; } else { File outDir = optOut.getValue().getParentFile(); if (outDir != null && outDir.exists() == false) { outDir.mkdir(); } out = new FileOutputStream(optOut.getValue()); } return out; } private static File findProfile(StringOption optProfile) throws FileNotFoundException { String profileName = "default.her"; if (optProfile.isUnset() == false) { profileName = optProfile.getValue(); } if (profileName == null || profileName.trim().length() == 0) { profileName = "default.her"; } File profile = new File(profileName); if (profile.exists() == true) { return profile; } String homePath = System.getProperty("herold.home"); if (homePath != null) { File homeDir = new File(homePath); if (homeDir.exists() == false) { throw new FileNotFoundException(String.format( "Home directory %s does not exist!", homePath)); } File profilesDir = new File(homeDir, "profiles"); if (profilesDir.exists() == false) { throw new FileNotFoundException(String.format( "Profiles directory %s does not exist!", profilesDir.getAbsolutePath())); } File file = new File(profilesDir, profileName); if (file.exists() == true) { return file; } file = new File(profilesDir, profileName + ".her"); if (file.exists() == true) { return file; } } throw new FileNotFoundException(String.format( "Profile %s does not exist!", profileName)); } private static void exit(int exitCode) { Herold.exitCode = exitCode; if (systemExitEnabled == true) { System.exit(exitCode); } } private static OptionList createOptionList(String[] args) { Option option; SelectOption selopt; BooleanOption bopt; StringOption sopt; OptionList options = new OptionList(args); // docbook-add-index bopt = new BooleanOption(DbtConstants.SECTION_DOCBOOK.toLowerCase() + "-" + DbtConstants.PARAM_ADD_INDEX, "x"); bopt.setValue(false); options.add(bopt); // docbook-encoding sopt = new StringOption(DbtConstants.SECTION_DOCBOOK.toLowerCase() + "-" + DbtConstants.PARAM_ENCODING, "d"); sopt.setDefault("UTF-8"); options.add(sopt); // decompose-tables bopt = new BooleanOption(DbtConstants.SECTION_DOCBOOK.toLowerCase() + "-" + DbtConstants.PARAM_DECOMPOSE_TABLES, "T"); bopt.setDefault(false); options.add(bopt); // document-element selopt = new SelectOption(DbtConstants.SECTION_DOCBOOK.toLowerCase() + "-" + DbtConstants.PARAM_DOCUMENT_ELEMENT, "r"); String[] optv2 = { "article", "book", "reference", "part", "chapter", "section" }; selopt.setList(optv2); selopt.setDefault("article"); options.add(selopt); // title sopt = new StringOption(DbtConstants.SECTION_DOCBOOK.toLowerCase() + "-" + DbtConstants.PARAM_TITLE, "t"); sopt.setDefault("http://www.dbdoclet.org/herold"); options.add(sopt); // source-encoding sopt = new StringOption(DbtConstants.SECTION_HTML.toLowerCase() + "-" + DbtConstants.PARAM_HTML_SOURCE_ENCODING, "s"); sopt.setDefault("UTF-8"); options.add(sopt); // in optIn = new FileOption("in", "i"); optIn.isExisting(true); options.add(optIn); // loglevel SelectOption optLogLevel = new SelectOption("logging-level", "l"); optLogLevel.setList(new String[] { "debug5", "debug4", "debug3", "debug2", "debug", "info", "warn", "error", "fatal" }); optLogLevel.setDefault("error"); options.add(optLogLevel); // out optOut = new FileOption("out", "o"); options.add(optOut); StringOption optProfile = new StringOption("profile", "p"); options.add(optProfile); // verbose option = new BooleanOption("verbose", "v"); options.add(option); return options; } private static String getVersion() { Package p = Herold.class.getPackage(); return p.getImplementationVersion(); } private static void printLicense() throws IOException { URL url = ResourceServices .getResourceAsUrl("/org/dbdoclet/herold/COPYING"); if (url != null) { BufferedReader reader = new BufferedReader(new InputStreamReader( url.openStream())); String line = reader.readLine(); while (line != null) { println(line); line = reader.readLine(); } reader.close(); } else { logger.fatal("Can't find resource for license!"); } } private static void println(String str) { System.out.println(str); } private static void printUsage() { try { String resname = ResourceServices.getString(res, "C_USAGE"); String buffer = ResourceServices.getResourceAsString(resname); println(MessageFormat.format(buffer, getVersion())); } catch (IOException oops) { logger.fatal("Printing usage message failed!", oops); } } private static void printVersion() { println("herold version \"" + getVersion() + "\""); } public void convert(InputStream in, OutputStream out, Script script) throws TrafoException { DocBookTransformer trafo = new DocBookTransformer(); if (verbose == true) { trafo.addProgressListener(new ConsoleProgressListener(false)); } trafo.setScript(script); trafo.convert(in, out); if (verbose == true) { System.out.println(); } } public boolean isCanceled() { return false; } public File processCommandLineOptions(OptionList options, Script script) { for (Option option : options) { String name = option.getLongName(); if (name.startsWith(DbtConstants.SECTION_DOCBOOK.toLowerCase())) { script.selectSection(DbtConstants.SECTION_DOCBOOK); name = StringServices.cutPrefix(name, DbtConstants.SECTION_DOCBOOK.toLowerCase()); } else if (name.startsWith(DbtConstants.SECTION_HTML.toLowerCase())) { script.selectSection(DbtConstants.SECTION_HTML); name = StringServices.cutPrefix(name, DbtConstants.SECTION_HTML.toLowerCase()); } name = StringServices.cutPrefix(name, "-"); if (option.isUnset() == false) { switch (option.getType()) { case BOOLEAN: script.setBoolParameter(name, (Boolean) option.getValue()); break; default: script.setTextParameter(name, option.getValue().toString()); break; } } } setVerbose(options.getFlag("verbose", false)); File outFile; if (optOut.isUnset() && optIn.isUnset() == false) { String outFileName = FileServices.getFileBase(optIn.getValue()) + ".xml"; // outFile = FileServices.createUniqueFile(new File(outFileName)); outFile = new File(outFileName); } else { outFile = optOut.getValue(); } return outFile; } public void setVerbose(boolean verbose) { this.verbose = verbose; } public void convert(File htmlFile, File xmlFile) throws TrafoException, FileNotFoundException { Script script = new Script(); convert(new FileInputStream(htmlFile), new FileOutputStream(xmlFile), script); } public static void setSystemExitEnabled(boolean systemExitEnabled) { Herold.systemExitEnabled = systemExitEnabled; } public static int getExitCode() { return exitCode; } } src/java/org/dbdoclet/herold/usage_de.txt0000644000000000000000000000260012124530526017423 0ustar rootrootherold Version {0} Copyright (C) 2001-2012 Michael Fuchs Aufruf: herold --docbook-encoding -d - Spezifiziert die Kodierung der generierten DocBook XML Dateien. Beispiel: --destination-encoding ISO-8859-1. --help -h - Diesen Text ausgeben. --in= -i - Zu verarbeitende HTML Datei. --license -L - Anzeige der herold Lizenz. --out= -o - Name der zu erzeugenden DocBook XML Datei. --profile= -p - Angabe einer Profildatei mit vordefinierten Parametern. --docbook-document-element= -r - Das Wurzelelement des Dokumentes: Mögliche Elemente sind: book und article. Die Standardeinstellung ist 'article'. --html-encoding -s - Spezifiziert die Kodierung der Quelldateien, z.B. ISO-8859-1. --docbook-title -t - Der Title des generierten Dokuments. --docbook-decompose-tables -T - Tabellen innerhalb der HTML Datei werden bei der Umwandlung in das DocBook-Format aufgelöst. --verbose -v - Fortschrittsanzeige auf der Konsole. --version -V - Ausgabe der Versionsnummer. src/java/org/dbdoclet/Sfv.java0000644000000000000000000000114412124530526015234 0ustar rootrootpackage org.dbdoclet; public class Sfv { public static final String FSEP = System.getProperty("file.separator"); public static final String LSEP = System.getProperty("line.separator"); public static final String PSEP = System.getProperty("path.separator"); public static final int FORMAT_SHORT = 1; public static final int FORMAT_MEDIUM = 2; public static final int FORMAT_LONG = 3; public static final String NS_DOCBOOK= "http://docbook.org/ns/docbook"; public static final String NS_XHTML = "http://www.w3.org/1999/xhtml"; public static final String NS_OPF = "http://www.idpf.org/2007/opf"; } src/java/org/dbdoclet/io/0000755000000000000000000000000012124530534014241 5ustar rootrootsrc/java/org/dbdoclet/io/EndsWithFilter.java0000644000000000000000000000444512124530526020007 0ustar rootroot/* * $Id: EndsWithFileNameFilter.java,v 1.1.1.1 2004/12/21 14:06:38 mfuchs Exp $ * * ### Copyright (C) 2001-2004 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * * Unico Media GmbH, Görresstr. 12, 80798 München, Germany * http://www.unico-group.com * * RCS Information * Author..........: $Author: mfuchs $ * Date............: $Date: 2004/12/21 14:06:38 $ * Revision........: $Revision: 1.1.1.1 $ * State...........: $State: Exp $ */ package org.dbdoclet.io; import java.io.File; import java.io.FilenameFilter; /** * Die Klasse EndsWithFilter überprüft ob der Name einer Datei mit * der definierten Endung übereinstimmt. * * @author Michael Fuchs * @version 1.0 */ public class EndsWithFilter implements FilenameFilter { /** Die Endung, die überprüft werden soll. */ private String[] extensions; /** * Erzeugt eine neue Instanz der Klasse EndsWithFileNameFilter. * * @param extensions * Die Endung, die überprüft werden soll. */ public EndsWithFilter(String... extensions) { if (extensions == null) { throw new IllegalArgumentException("The argument extensions may not be null!"); } this.extensions = extensions; } /** * Die Methode accept überprüft ob der angegebene Dateiname auf * die definierte Endung endet. * * Die Überprüfung der Endung erfolgt ohne Beachtung der Groß- und * Kleinschreibung. * * @param file * File * @param name * String * @return boolean */ public boolean accept(File file, String name) { String s1 = name.toLowerCase(); for (String extension : extensions) { String s2 = extension.toLowerCase(); if (s1.endsWith(s2)) { return true; } } return false; } } /* * $Log: EndsWithFileNameFilter.java,v $ Revision 1.1.1.1 2004/12/21 14:06:38 * mfuchs Reimport * * Revision 1.2 2004/08/27 19:30:32 mfuchs Dokumentation * * Revision 1.1.1.1 2004/05/13 17:14:37 mfuchs Services */ src/java/org/dbdoclet/io/MimeType.java0000644000000000000000000002273412124530526016646 0ustar rootrootpackage org.dbdoclet.io; import java.util.HashMap; import org.dbdoclet.service.StringServices; public class MimeType { public static final MimeType COMP = new MimeType("COMP", "Cocs Stock File (.comp)", "text/comp", ".comp", "\\.comp$", false); public static final MimeType CSV = new MimeType("CSV", "CSV File (.csv)", "text/csv", ".csv", "\\.csv$", true); public static final MimeType DOC = new MimeType("DOC", "Microsoft Word (.doc)", "application/msword", ".doc", "\\.doc$", true); public static final MimeType DOCX = new MimeType("DOCX", "Microsoft Word (.docx)", "application/msword (xml)", ".docx", "\\.docx$", true); public static final MimeType GIF = new MimeType("GIF", "GIF Image (.gif)", "image/gif", ".gif", "\\.gif$", true); public static final MimeType PNG = new MimeType("PNG", "PNG Image (.png)", "image/png", ".png", "\\.png$", true); public static final MimeType JPEG = new MimeType("JPEG", "JPEG Image (.jpg)", "image/jpeg", ".jpg", "\\.jpg$", true); public static final MimeType HTML = new MimeType("HTML", "HTML (.html)", "text/html", ".html", "\\.htm(l)?$", false); public static final MimeType MIDI = new MimeType("MIDI", "Audio MIDI (.midi)", "audio/midi", ".midi", "\\.mid(i)?$", true); public static final MimeType MP3 = new MimeType("MP3", "Audio MP3 (.mp3)", "audio/mpeg", ".mp3", "\\.mp3$", true); public static final MimeType MPEG = new MimeType("MPEG", "Video MPEG (.mpeg)", "video/mpeg", ".mpeg", "\\.mp(e)?g$", true); public static final MimeType ODP = new MimeType("ODP", "OpenOffice Impress (.odp)", "application/vnd.oasis.opendocument.presentation", ".odp", "\\.odp$", true); public static final MimeType ODS = new MimeType("ODS", "OpenOffice Calc (.ods)", "application/vnd.oasis.opendocument.spreadsheet", ".ods", "\\.ods$", true); public static final MimeType ODT = new MimeType("ODT", "OpenOffice Writer (.odt)", "application/vnd.oasis.opendocument.text", ".odt", "\\.odt$", true); public static final MimeType PDF = new MimeType("PDF", "PDF - Portable Document Format (.pdf)", "application/pdf", ".pdf", "\\.pdf$", true); public static final MimeType POD = new MimeType("POD", "OpenProj Format (.pod)", "application/pod", ".pod", "\\.pod$", true); public static final MimeType PPT = new MimeType("PPT", "Microsoft Powerpoint (.ppt)", "application/mspowerpoint", ".ppt", "\\.ppt$", true); public static final MimeType PPTX = new MimeType("PPTX", "Microsoft Powerpoint (.pptx)", "application/mspowerpoint (xml)", ".pptx", "\\.pptx$", true); public static final MimeType PPTM = new MimeType("PPTM", "Microsoft Powerpoint with Macros (.pptm)", "application/mspowerpoint with macros (xml)", ".pptm", "\\.pptm$", true); public static final MimeType POTX = new MimeType("POTX", "Microsoft Powerpoint (.potx)", "application/mspowerpoint template (xml)", ".potx", "\\.potx$", true); public static final MimeType WAV = new MimeType("WAV", "Audio WAV (.wav)", "audio/wav", ".wav", "\\.wav$", true); public static final MimeType WMV = new MimeType("WMV", "Video WMV (.wmv)", "video/x-ms-wmv", ".wmv", "\\.wmv$", true); public static final MimeType XLS = new MimeType("XLS", "Microsoft Excel (.xls)", "application/msexcel", ".xls", "\\.xls", true); public static final MimeType XLSX = new MimeType("XLSX", "Microsoft Excel (.xlsx)", "application/msexcel (xml)", ".xlsx", "\\.xlsx", true); public static final MimeType XML = new MimeType("XML", "XML (.xml)", "application/xml", ".xml", "\\.xml$", false); private static HashMap mimeTypeMap = initMimeTypeMap(); private static HashMap extensionMap = initExtensionMap(); private String extension; private String id; private String label; private String mimeType; private boolean binary; private final String regexp; public MimeType(String id, String label, String mimeType, String extension, String regexp, boolean binary) { if (id == null) { throw new IllegalArgumentException("The argument id must not be null!"); } if (label == null) { throw new IllegalArgumentException("The argument label must not be null!"); } if (mimeType == null) { throw new IllegalArgumentException("The argument mimeType must not be null!"); } if (extension == null) { throw new IllegalArgumentException("The argument extension must not be null!"); } if (regexp == null) { throw new IllegalArgumentException("The parameter regexp must not be null!"); } this.id = id; this.label = label; this.mimeType = mimeType; this.extension = extension; this.regexp = regexp; this.binary = binary; } public static MimeType valueOf(String mime) { if (mime == null) { throw new IllegalArgumentException("The argument mime must not be null!"); } MimeType mimeType = mimeTypeMap.get(mime); if (mimeType == null) { throw new IllegalArgumentException("'" + mime + "' is not a valid MimeType!"); } return mimeType; } public static MimeType findByExtension(String extension) { if (extension == null) { throw new IllegalArgumentException("The argument extension must not be null!"); } extension = StringServices.cutPrefix(extension, "."); extension = extension.toLowerCase(); MimeType mimeType = extensionMap.get(extension ); return mimeType; } public void setId(String id) { this.id = id; } public String getId() { return id; } public String getLabel() { return label; } public String getDescription() { return label; } protected void setLabel(String label) { this.label = label; } public void setExtension(String extension) { this.extension = extension; } public String getExtension() { if (extension.startsWith(".") == false) { return "." + extension; } return extension; } public boolean isBinary() { return binary; } public void setBinary(boolean binary) { this.binary = binary; } public String getRegexp() { return regexp; } public void setMimeType(String mimeType) { this.mimeType = mimeType; } public String getMimeType() { return mimeType; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj instanceof String) { String mimeType = (String) obj; if (mimeType.equals(this.mimeType)) { return true; } else { return false; } } if (obj instanceof MimeType) { MimeType item = (MimeType) obj; String mimeType = item.getMimeType(); if (mimeType.equals(this.mimeType)) { return true; } } return false; } @Override public int hashCode() { int hashCode = mimeType.hashCode(); return hashCode; } @Override public String toString() { return label; } private static HashMap initExtensionMap() { HashMap map = new HashMap(); map.put("comp", COMP); map.put("csv", CSV); map.put("doc", DOC); map.put("docx", DOCX); map.put("gif", GIF); map.put("html", HTML); map.put("jpg", JPEG); map.put("midi", MIDI); map.put("mp3", MP3); map.put("mpeg", MPEG); map.put("odp", ODP); map.put("ods", ODS); map.put("odt", ODT); map.put("pdf", PDF); map.put("pod", POD); map.put("png", PNG); map.put("ppt", PPT); map.put("pptx", PPTX); map.put("pptm", PPTM); map.put("potx", POTX); map.put("wav", WAV); map.put("wmv", WMV); map.put("xml", XML); map.put("xsl", XLS); map.put("xslx", XLSX); return map; } private static HashMap initMimeTypeMap() { HashMap map = new HashMap(); map.put("application/msexcel", XLS); map.put("application/mspowerpoint", PPT); map.put("application/msword", DOC); map.put("application/msexcel (xml)", XLSX); map.put("application/mspowerpoint (xml)", PPTX); map.put("application/mspowerpoint with macros (xml)", PPTM); map.put("application/mspowerpoint template (xml)", POTX); map.put("application/msword (xml)", DOCX); map.put("application/pdf", PDF); map.put("application/pod", POD); map.put("application/vnd.oasis.opendocument.presentation", ODP); map.put("application/vnd.oasis.opendocument.spreadsheet", ODS); map.put("application/vnd.oasis.opendocument.text", ODT); map.put("application/xml", XML); map.put("audio/midi", MIDI); map.put("audio/mpeg", MP3); map.put("audio/wav", WAV); map.put("image/gif", GIF); map.put("image/jpeg", JPEG); map.put("image/png", PNG); map.put("text/comp", COMP); map.put("text/csv", CSV); map.put("text/html", HTML); map.put("video/mpeg", MPEG); map.put("video/x-ms-wmv", WMV); return map; } } src/java/org/dbdoclet/io/StartsWithFilter.java0000644000000000000000000000402712124530526020372 0ustar rootroot/* * $Id: StartsWithFileNameFilter.java,v 1.1.1.1 2004/12/21 14:06:38 mfuchs Exp $ * * ### Copyright (C) 2001-2004 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * * Unico Media GmbH, Görresstr. 12, 80798 München, Germany * http://www.unico-group.com * * RCS Information * Author..........: $Author: mfuchs $ * Date............: $Date: 2004/12/21 14:06:38 $ * Revision........: $Revision: 1.1.1.1 $ * State...........: $State: Exp $ */ package org.dbdoclet.io; import java.io.File; import java.io.FilenameFilter; /** * Die Klasse EndsWithFilter überprüft ob der Name einer * Datei mit dem definierten Anfang übereinstimmt. * * @author Michael Fuchs * @version 1.0 */ public class StartsWithFilter implements FilenameFilter { /** Der Anfang, der überprüft werden soll. */ private String start; /** * Erzeugt eine neue Instanz der Klasse * StartsWithFileNameFilter. * * @param start String */ public StartsWithFilter(String start) { this.start = start; } /** * Die Methode accept überprüft ob der angegebene Dateiname auf * den definierten Anfang passt. * * Die Überprüfung des Anfangs erfolgt ohne Beachtung der Groß- und * Kleinschreibung. * * @param file File * @param name String * @return boolean */ public boolean accept(File file, String name) { String s1 = name.toLowerCase(); String s2 = start.toLowerCase(); return s1.startsWith(s2); } } /* * $Log: StartsWithFileNameFilter.java,v $ * Revision 1.1.1.1 2004/12/21 14:06:38 mfuchs * Reimport * * Revision 1.3 2004/09/03 08:26:54 mfuchs * Sicherung * * Revision 1.2 2004/08/27 19:30:32 mfuchs * Dokumentation * * Revision 1.1.1.1 2004/05/13 17:14:37 mfuchs * Services * */ src/java/org/dbdoclet/io/DirectoryFilter.java0000644000000000000000000000076512124530526020227 0ustar rootroot/* * * ### Copyright (C) 2010 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de * */ package org.dbdoclet.io; import java.io.File; import java.io.FileFilter; public class DirectoryFilter implements FileFilter { public boolean accept(File file) { if (file.isDirectory()) { return true; } else { return false; } } } src/java/org/dbdoclet/CanceledException.java0000644000000000000000000000176612124530526020065 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet; /** * Diese Ausnahme signalisiert den gewünschten Abbruch einer Aktion, * beispielsweise aus einer Fortschrittsanzeige heraus. Die Ausnahme kann aus * tief verschachtelten Strukturen heraus geworfen werden. Da es eine * RuntimeException ist, muß sie nicht in der Methodesignatur * aufgeführt werden. * * @author Michael Fuchs */ public class CanceledException extends RuntimeException { private static final long serialVersionUID = 1L; public CanceledException() { super(); } public CanceledException(String msg) { super(msg); } public CanceledException(Throwable cause) { super(cause); } public CanceledException(String message, Throwable cause) { super(message, cause); } } src/java/org/dbdoclet/template/0000755000000000000000000000000012124530526015446 5ustar rootrootsrc/java/org/dbdoclet/template/TemplateTransformException.java0000644000000000000000000000157412124530526023646 0ustar rootroot/* * $Id: TemplateTransformException.java,v 1.1.1.1 2004/12/21 14:06:41 mfuchs Exp $ * * ### Copyright (C) 2004 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * * Unico Media GmbH, Görresstr. 12, 80798 München, Germany * http://www.unico-group.com * * RCS Information * Author..........: $Author: mfuchs $ * Date............: $Date: 2004/12/21 14:06:41 $ * Revision........: $Revision: 1.1.1.1 $ * State...........: $State: Exp $ */ package org.dbdoclet.template; public class TemplateTransformException extends Exception { /** * */ private static final long serialVersionUID = 1L; public TemplateTransformException(String msg) { super(msg); } public TemplateTransformException(String msg, Throwable oops) { super(msg, oops); } } src/java/org/dbdoclet/template/TemplateTransformer.java0000644000000000000000000001376712124530526022325 0ustar rootroot/* * ### Copyright (C) 2005-2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.template; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.io.StringReader; import java.io.StringWriter; import java.util.Iterator; import java.util.Map; import org.dbdoclet.service.StringServices; public class TemplateTransformer { private BufferedReader reader; public static TemplateTransformer newInstance(File template) throws TemplateTransformException { if (template == null) { throw new IllegalArgumentException("The argument template may not be null!"); } BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(template)); } catch (IOException oops) { throw new TemplateTransformException(oops.getMessage(), oops); } return new TemplateTransformer(reader); } public static TemplateTransformer newInstance(BufferedReader template) throws TemplateTransformException { if (template == null) { throw new IllegalArgumentException("The argument template may not be null!"); } return new TemplateTransformer(template); } public static TemplateTransformer newInstance(String template) throws TemplateTransformException { if (template == null) { throw new IllegalArgumentException("The argument template may not be null!"); } return new TemplateTransformer(new BufferedReader(new StringReader(template))); } private TemplateTransformer(BufferedReader reader) { this.reader = reader; } public String transform(Map vars) throws TemplateTransformException { StringWriter buffer = new StringWriter(); transform(vars, new PrintWriter(buffer)); return buffer.toString(); } public void transform(Map vars, String fileName) throws TemplateTransformException { if (fileName == null) { throw new IllegalArgumentException("The argument fileName must not be null!"); } transform(vars, new File(fileName)); } public void transform(Map vars, File file) throws TemplateTransformException { if (file == null) { throw new IllegalArgumentException("The argument file must not be null!"); } try { // if (file.getName().equals("default.css")) { // trace = true; // } transform(vars, new FileWriter(file)); } catch (IOException oops) { throw new TemplateTransformException(oops.getMessage(), oops); } } public void transform(Map vars, FileWriter fileWriter) throws TemplateTransformException { if (fileWriter == null) { throw new IllegalArgumentException("The argument fileWriter must not be null!"); } PrintWriter writer = new PrintWriter(fileWriter); transform(vars, writer); writer.close(); } public void transform(Map vars, PrintWriter writer) throws TemplateTransformException { if (reader == null) { throw new IllegalStateException("The field reader may not be null!"); } if (vars == null) { throw new IllegalArgumentException("The argument vars may not be null!"); } if (writer == null) { throw new IllegalArgumentException("The argument writer may not be null!"); } try { Iterator iterator; String name; Object value; String line; StringBuffer buffer = new StringBuffer(); while ((line = reader.readLine()) != null ) { if (line.trim().length() == 0) { buffer.append(line); buffer.append('\n'); continue; } if (line.indexOf('$') == -1) { buffer.append(line); buffer.append('\n'); continue; } // if (trace) { // System.out.println("line=" + line); // } iterator = vars.keySet().iterator(); while (iterator.hasNext()) { name = iterator.next(); value = vars.get(name); if (value != null) { name = "${" + name + "}"; // if (trace && name.equals("${css.hl1.font}")) { // System.out.println("name=" + name); // } line = StringServices.replace(line, name, value.toString()); // if (trace && name.equals("${css.hl1.font}")) { // System.out.println("new line=" + line); // } } } buffer.append(line); buffer.append('\n'); } reader.close(); // String str = ReplaceServices.replaceAll(buffer.toString(), "\\$\\{\\w*\\}", ""); String str = buffer.toString(); BufferedReader bufferReader = new BufferedReader(new StringReader(str)); while ((line = bufferReader.readLine()) != null ) { writer.println(line); } bufferReader.close(); } catch (Exception oops) { throw new TemplateTransformException(oops.getMessage(), oops); } } } src/java/org/dbdoclet/comparator/0000755000000000000000000000000012124530526016002 5ustar rootrootsrc/java/org/dbdoclet/comparator/PathTokenCountComparator.java0000644000000000000000000000207612124530526023610 0ustar rootroot/* * ### Copyright (C) 2008 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.comparator; import java.io.File; import java.util.Comparator; import org.dbdoclet.service.FileServices; public class PathTokenCountComparator implements Comparator { public int compare(File f1, File f2) { int i1 = FileServices.getPathTokenCount(f1.getAbsolutePath()); int i2 = FileServices.getPathTokenCount(f2.getAbsolutePath()); if (i1 == i2) { return 0; } if (i1 < i2) { return 1; } if (i1 > i2) { return -1; } return 0; } @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null) { return false; } if (other.getClass() != getClass()) { return false; } return true; } } src/java/org/dbdoclet/progress/0000755000000000000000000000000012124530534015476 5ustar rootrootsrc/java/org/dbdoclet/progress/ProgressManager.java0000644000000000000000000000271612124530526021447 0ustar rootrootpackage org.dbdoclet.progress; import java.util.ArrayList; public class ProgressManager { private final ArrayList listeners; public ProgressManager(ArrayList listeners) { this.listeners = listeners; if (listeners == null) { listeners = new ArrayList(); } } public ProgressManager(ProgressListener listener) { this.listeners = new ArrayList(); listeners.add(listener); } public void setProgressMaximum(int max) { for (ProgressListener listener : listeners) { listener.setProgressMaximum(max); } } public void setStageCount(int stageCount) { for (ProgressListener listener : listeners) { if (listener instanceof StageProgressListener) { ((StageProgressListener) listener).setStageCount(stageCount); } } } public void nextStage() { for (ProgressListener listener : listeners) { if (listener instanceof StageProgressListener) { ((StageProgressListener) listener).nextStage(); } } } public boolean fireProgressEvent(ProgressEvent event) { boolean rc = true; if (listeners != null) { for (ProgressListener listener : listeners) { if (listener.progress(event) == false) { rc = false; } } } return rc; } public void finished(String text) { for (ProgressListener listener : listeners) { if (listener instanceof StageProgressListener) { ((StageProgressListener) listener).finished(text); } } } } src/java/org/dbdoclet/progress/ProgressTimeListener.java0000644000000000000000000000054212124530526022474 0ustar rootrootpackage org.dbdoclet.progress; public interface ProgressTimeListener extends ProgressVetoListener { /** * Setzt die Startzeit der Verarbeitung. Die Startzeit kann dazu verwendet * werden eine Schätzung der verbleibenden Dauer der Aktion zu berechnen und * anzuzeigen. */ public void setProgressStartTime(long startTime); } src/java/org/dbdoclet/progress/ProgressListener.java0000644000000000000000000000126712124530526021662 0ustar rootrootpackage org.dbdoclet.progress; public interface ProgressListener { /** * Die Methode progress wird aufgerufen, wenn ein * Fortschrittsereignis ausgelöst wurde. * * @param event Das Fortschrittsereignis (ProgressEvent). * * @return boolean Der Rückgabewert muß auf false * gesetzt werden, wenn der Sender des Fortschrittsereignisses die * Verarbeitung abbrechen soll. */ public boolean progress(ProgressEvent event); /** * Setzt die maximale Anzahl von protokollierten Verarbeitungsschritten, die * ein berechenbares Fortschrittsereignis auslösen. */ public void setProgressMaximum(int max); }src/java/org/dbdoclet/progress/ProgressEvent.java0000644000000000000000000001064712124530526021160 0ustar rootroot/* * ### Copyright (C) 2006-2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.progress; /** * Die Klasse ProgressEvent wird dazu verwendet um interessierte * Objekte über den Fortschritt einer Aktion zu unterrichten. */ public class ProgressEvent { public static final int STAGE_PREPARE = 1; public static final int STAGE_ACTION = 2; private boolean consider = true; private int max = -1; private int index = -1; private int stage = STAGE_ACTION; private String action = ""; private String item = ""; private Object userObject = null; /** * Erzeugt ein leeres Forschrittsobjekt. */ public ProgressEvent() { this(-1, -1, "", "", true); } /** * Erzeugt ein Fortschrittsobjekt. * * @param action Die Aktionsbeschreibung. */ public ProgressEvent(String action) { this(-1, -1, "", action, true); } /** * Erzeugt ein Fortschrittsobjekt. * * Der Parameter consider gibt an, ob das Ereignis in die * Berechnung des Fortschrittswertes eingehen soll oder nicht. * * @param action Die Aktionsbeschreibung. * @param consider Schalter für die Gewichtung des Ereignisses. */ public ProgressEvent(String action, boolean consider) { this(-1, -1, "", action, consider); } /** * Erzeugt ein Fortschrittsobjekt. * * @param item Beschreibung des verarbeiteten Objekts * @param action Aktionsbeschreibung. */ public ProgressEvent(String item, String action) { this(-1, -1, item, action, true); } /** * Erzeugt ein Fortschrittsobjekt. * * @param index Index des Fortschrittswertes. * @param item Beschreibung des verarbeiteten Objekts. * @param action Aktionsbeschreibung. */ public ProgressEvent(int index, String item, String action) { this(-1, index, item, action, true); } /** * Erzeugt ein Fortschrittsobjekt. * * @param max Maximalwert des Fortschrittswertes * @param index Aktueller Wert des Fortschrittswertes. */ public ProgressEvent(int max, int index) { this(max, index, "", "", true); } /** * Erzeugt ein Fortschrittsobjekt. * * @param max Maximalwert des Fortschrittswertes * @param index Aktueller Wert des Fortschrittswertes. * @param item Beschreibung des verarbeiteten Objekts. * @param action Aktionsbeschreibung. */ public ProgressEvent(int max, int index, String item, String action) { this(max, index, item, action, true); } /** * Erzeugt ein Fortschrittsobjekt. * * @param max Maximalwert des Fortschrittswertes * @param index Aktueller Wert des Fortschrittswertes. * @param item Beschreibung des verarbeiteten Objekts. * @param action Aktionsbeschreibung. */ public ProgressEvent(int max, int index, String item, String action, boolean consider) { this.max = max; this.index = index; this.item = item; this.action = action; this.consider = consider; } public int getMax() { return max; } public int getIndex() { return index; } public void setItem(String item) { this.item = item; } public String getItem() { return item; } public void setConsider(boolean consider) { this.consider = consider; } public boolean getConsider() { return consider; } public String getAction() { return action; } public void setAction(String action) { this.action = action; } public ProgressEvent setStage(int stage) { this.stage = stage; return this; } public int getStage() { return stage; } /** * Setzt ein benutzerdefiniertes Objekt. */ public ProgressEvent setUserObject(Object userObject) { this.userObject = userObject; return this; } /** * Liefert das benutzerdefinierte Objekt. */ public Object getUserObject() { return userObject; } public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append(getAction()); return buffer.toString(); } } src/java/org/dbdoclet/progress/ProgressVetoListener.java0000644000000000000000000000324512124530526022516 0ustar rootrootpackage org.dbdoclet.progress; /** *

      Die Klasse ProgressListener stellt eine Schnittstelle zur * Verfügung um Fortschrittsereignisse (ProgressEvent) zu * empfangen.

      * *

      Eine Klasse, die an Fortschrittsereignissen interessiert ist, * implementiert diese Schnittstelle. Eine Instanz dieser Klasse wird dann bei * einem Objekt mit Fortschrittsbearbeitung registiert. Wenn ein * Fortschrittsereignis erzeugt wird, wird dann die Methode * progress der ProgressListener Instanz aufgerufen.

      */ public interface ProgressVetoListener extends ProgressListener { /** * Vor einem Verarbeitungsschritt kann der Sender nachfragen, ob der * Empfänger ein Veto für diesen Schritt einlegen will und eventuell die * Verarbeitung für diesen Schritt übergehen. * *

      Sollen zum Beispiel Dateien in ein Zielverzeichnis kopiert werden, * kann der Sender für jede Datei nachfragen, ob der Kopiervorgang * ausgeführt werden soll. Der Empfänger kann dann prüfen, ob die Datei im * Zielverzeichnis bereits existiert und gegebenfalls den Benutzer fragen, * ob die Datei überschrieben werden darf. Falls der Benutzer dies für diese * und vielleicht auch alle weiteren Dateien verneint, wird ein Veto * eingelegt. */ public boolean veto(ProgressEvent event); /** * Mit Hilfe der Methode isCanceled kann der ProgressListener * dem Aufrufer signalisieren, dass der Benutzer die Verarbeitung abbrechen * will, z.B. durch betätigen einer Schaltfläche "Abbrechen" einer * Fortschrittsanzeige. */ public boolean isCanceled(); } src/java/org/dbdoclet/progress/InfoListener.java0000644000000000000000000000046412124530526020747 0ustar rootroot/* * ### Copyright (C) 2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.progress; public interface InfoListener { public void info(String text); } src/java/org/dbdoclet/progress/ProgressAdapter.java0000644000000000000000000000146412124530526021454 0ustar rootrootpackage org.dbdoclet.progress; public class ProgressAdapter implements ProgressVetoListener, ProgressTimeListener { private int progressMaximum = 0; private int progressCounter = 0; private long progressStartTime = System.currentTimeMillis(); public int getProgressCounter() { return progressCounter; } public int getProgressMaximum() { return progressMaximum; } public long getProgressStartTime() { return progressStartTime; } public boolean isCanceled() { return false; } public boolean progress(ProgressEvent event) { progressCounter++; return true; } public void setProgressMaximum(int max) { this.progressMaximum = max; } public void setProgressStartTime(long startTime) { progressStartTime = startTime; } public boolean veto(ProgressEvent event) { return false; } } src/java/org/dbdoclet/progress/StageProgressListener.java0000644000000000000000000000032312124530526022636 0ustar rootrootpackage org.dbdoclet.progress; public interface StageProgressListener extends ProgressVetoListener { public void setStageCount(int stageCount); public void nextStage(); public void finished(String text); } src/java/org/dbdoclet/xiphias/0000755000000000000000000000000012124530534015277 5ustar rootrootsrc/java/org/dbdoclet/xiphias/Resources.properties0000644000000000000000000000165112124530526021373 0ustar rootroot# Java Resource Bundle # Modified by Zaval JRC Editor (C) Zaval CE Group # http://www.zaval.org/products/jrc-editor/ C_ERROR=Error C_INCLUDING_FILE=Including file {0}... C_XML_VALIDATION_ERROR={0}:{1}:{2}\n\ Error in row {1}, column {2}\n\ {3} C_XML_VALIDATION_ERROR_FILE_CAN_NOT_READ={0}: The file can not be read C_XML_VALIDATION_ERROR_FILE_NOT_FOUND={0}: The file couldn't be found. C_XML_VALIDATION_FAILED=The validation of the XML file FAILED! C_XML_VALIDATION_FATAL={0}:{1}:{2}\n\ Fatal error in row {1}, column {2}\n\ {3} C_XML_VALIDATION_NUMBER_OF_ERRORS=Number of errors: {0} C_XML_VALIDATION_OF_FILE=Validation of file {0}. C_XML_VALIDATION_REPORT=XML Validation Report C_XML_VALIDATION_REPORT_DATE=Date: {0} C_XML_VALIDATION_REPORT_TIME=Time: {0} C_XML_VALIDATION_SUCCESSFUL=The validation of the XML file was SUCCESSFUL. C_XML_VALIDATION_WARNING={0}:{1}:{2}\n\ Warning in row {1}, column {2}\n\ {3} src/java/org/dbdoclet/xiphias/XmlServices.java0000644000000000000000000013010312124530526020405 0ustar rootroot/* + * $Id$ * * ### Copyright (C) 2003-2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.xiphias; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.StringReader; import java.io.UnsupportedEncodingException; import java.net.URL; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Locale; import java.util.Stack; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.ErrorListener; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.xml.resolver.tools.CatalogResolver; import org.dbdoclet.service.FileServices; import org.dbdoclet.service.ReplaceServices; import org.dbdoclet.service.StringServices; import org.dbdoclet.service.UnicodeServices; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.Text; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; /** * Die Klasse XmlServices stellt eine Sammlung statischer Methoden * zur Bearbeitung von XML zur Verfügung. * * @author Michael Fuchs * @version 1.0 */ public class XmlServices { public enum HyphenationChar { SOFT_HYPHEN, ZERO_WIDTH_SPACE } public static HyphenationChar hyphenationChar = HyphenationChar.ZERO_WIDTH_SPACE; public static final String test = " "; private static final Pattern encPattern = Pattern .compile("^(?i).*<\\?xml\\s*.*encoding=['\"](.*)['\"].*\\?>.*$"); private static Log logger = LogFactory.getLog(XmlServices.class); private static final Pattern startsWithDigitPattern = Pattern .compile("^[0-9].*$"); static { System.setProperty("xml.catalog.ignoreMissing", "yes"); } /** * Die Methode findDocBookTextLength liefert die Textposition * innerhalb eines DocBook XML-Zeichenpuffers ohne Berücksichtigung der Tags * und Entities(!). Ebenso wird alles innerhalb von indexterm-Tags * ignoriert. * * @param buffer * String * @param index * int * @return int */ public static int findDocBookTextIndex(String buffer, int index) { char c; int length = 0; Stack blocked = new Stack(); StringBuffer tagName; String openTag; String closingTag; for (int i = 0; i < buffer.length(); i++) { c = buffer.charAt(i); if (c == '<') { tagName = new StringBuffer(); while (c != '>' && i < buffer.length()) { c = buffer.charAt(i++); tagName.append(c); } if (tagName.toString().startsWith("")) { if (blocked.empty() == false) { blocked.pop(); } } } else { openTag = tagName.toString(); if (openTag.equals("")) { blocked.push(openTag); } } i--; continue; } if (c == '&') { c = buffer.charAt(i++); while (c != ';' && c != ' ' && c != '\t' && c != '\r' && c != '\n' && i < buffer.length()) { c = buffer.charAt(i++); } i--; continue; } if (length == index) { return i; } if (blocked.size() == 0) { length++; } } return -1; } /** * Die Methode findXmlTextLength liefert die Textposition * innerhalb eines XML-Zeichenpuffers ohne Berücksichtigung der Tags und * Entities(!). * * @param buffer * String * @param index * int * @return int */ public static int findXmlTextIndex(String buffer, int index) { char c; int length = 0; for (int i = 0; i < buffer.length(); i++) { c = buffer.charAt(i); if (c == '<') { while (c != '>' && i < buffer.length()) { c = buffer.charAt(i++); } i--; continue; } if (c == '&') { c = buffer.charAt(i++); while (c != ';' && c != ' ' && c != '\t' && c != '\r' && c != '\n' && i < buffer.length()) { c = buffer.charAt(i++); } i--; continue; } if (length == index) { return i; } length++; } return -1; } /** * Die Methode getDocBookTextLength liefert die reine Textlänge * eines DocBook XML-Zeichenpuffers. * * Tags und Entities(!) gehen nicht in die Berechnung der Länge ein. Ebenso * wird alles innerhalb eines indexterm-Tags ignoriert. * * @param buffer * String * @return int */ public static int getDocBookTextLength(String buffer) { return getDocBookTextLength(new StringBuffer(buffer)); } /** * Die Methode getDocBookTextLength liefert die reine Textlänge * eines DocBook XML-Zeichenpuffers. * * Tags und Entities(!) gehen nicht in die Berechnung der Länge ein. Ebenso * wird alles innerhalb von indexterm-Tags ignoriert. * * @param buffer * StringBuffer * @return int */ public static int getDocBookTextLength(StringBuffer buffer) { char c; int length = 0; Stack blocked = new Stack(); StringBuffer tagName; String openTag; String closingTag; for (int i = 0; i < buffer.length(); i++) { c = buffer.charAt(i); if (c == '<') { tagName = new StringBuffer(); while (c != '>' && i < buffer.length()) { c = buffer.charAt(i++); tagName.append(c); } // System.out.println("tag=" + tagName.toString()); if (tagName.toString().startsWith("")) { if (blocked.empty() == false) { blocked.pop(); } } } else { openTag = tagName.toString(); if (openTag.equals("")) { blocked.push(openTag); } } i--; continue; } if (c == '&') { c = buffer.charAt(i++); while (c != ';' && c != ' ' && c != '\t' && c != '\r' && c != '\n' && i < buffer.length()) { c = buffer.charAt(i++); } i--; continue; } if (blocked.size() == 0) { length++; } } return length; } public static String getEncoding(File source) throws IOException { if (source == null) { throw new IllegalArgumentException( "The argument source must not be null!"); } BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(source)); String line; Matcher matcher; while ((line = reader.readLine()) != null) { logger.debug("line=" + line); matcher = encPattern.matcher(line); if (matcher.matches()) { return matcher.group(1); } } } finally { if (reader != null) { reader.close(); } } return "UTF-8"; } public static String getEncoding(String source) throws IOException { if (source == null) { throw new IllegalArgumentException( "The argument source must not be null!"); } BufferedReader reader = new BufferedReader(new StringReader(source)); String line; Matcher matcher; while ((line = reader.readLine()) != null) { matcher = encPattern.matcher(line); if (matcher.matches()) { return matcher.group(1); } } return "UTF-8"; } /** * Erstellt den Pfadnamen des Elements vom Wurzelelement ab. Die einzelnen * Elemente werden durch einen Schrägstrich voneinander getrennt, z.B. * /Dokument/Kapitel/Absatz. * * @param element * @return String */ public static String getFullyQualifiedElementName(Element element) { if (element == null) { return null; } Stack stack = new Stack(); Element parent = element; while (parent != null) { stack.push(parent.getTagName()); parent = (Element) parent.getParentNode(); } StringBuilder buffer = new StringBuilder(); buffer.append('/'); while (stack.isEmpty() == false) { buffer.append(stack.pop()); if (stack.isEmpty() == false) { buffer.append('/'); } } return buffer.toString(); } /** * Die Methode getXmlTextLength liefert die reine Textlänge * eines XML-Zeichenpuffers. * * Tags und Entities(!) gehen nicht in die Berechnung der Länge ien. * * @param buffer * String * @return int */ public static int getXmlTextLength(String buffer) { return getXmlTextLength(new StringBuffer(buffer)); } /** * Die Methode getXmlTextLength liefert die reine Textlänge * eines XML-Zeichenpuffers. * * Tags und Entities(!) gehen nicht in die Berechnung der Länge ien. * * @param buffer * StringBuffer * @return int */ public static int getXmlTextLength(StringBuffer buffer) { char c; int length = 0; for (int i = 0; i < buffer.length(); i++) { c = buffer.charAt(i); if (c == '<') { while (c != '>' && i < buffer.length()) { c = buffer.charAt(i++); } i--; continue; } if (c == '&') { c = buffer.charAt(i++); while (c != ';' && c != ' ' && c != '\t' && c != '\r' && c != '\n' && i < buffer.length()) { c = buffer.charAt(i++); } i--; continue; } length++; } return length; } public static boolean isEntity(StringBuffer word) { if (word == null) { throw new IllegalArgumentException( "The argument word must not be null!"); } char c; int length = word.length(); int max = length - 1; for (int i = 0; i < word.length(); i++) { c = word.charAt(i); if (i == 0 && c != '&') { return false; } if (i == max && c != ';') { return false; } if (Character.isWhitespace(c) == true) { return false; } } String buffer = word.toString(); buffer = StringServices.cutPrefix(buffer, "&"); buffer = StringServices.cutSuffix(buffer, ";"); Matcher matcher; matcher = startsWithDigitPattern.matcher(buffer); if (matcher.matches() == true) { return false; } return true; } public static String makeWrapable(String buffer, String token) { return makeWrapable(buffer, token, hyphenationChar); } public static String makeWrapable(String buffer, String token, HyphenationChar hyphenChar) { if (buffer == null || buffer.length() == 0) { return buffer; } if (token == null || token.length() == 0) { return buffer; } String[] tokens = { token }; return makeWrapable(buffer, tokens, hyphenChar); } public static String makeWrapable(String buffer, String[] tokens) { return makeWrapable(buffer, tokens, hyphenationChar); } public static String makeWrapable(String buffer, String[] tokens, HyphenationChar hyphenChar) { if (buffer == null || buffer.length() == 0) { return buffer; } if (tokens == null || tokens.length == 0) { return buffer; } String wrapable = buffer; String token; for (int i = 0; i < tokens.length; i++) { token = tokens[i]; if (token == null || token.length() == 0) { continue; } if (hyphenChar == HyphenationChar.SOFT_HYPHEN) { wrapable = StringServices.replace(wrapable, token, token + "­"); } else { wrapable = StringServices.replace(wrapable, token, token + "​"); } } return wrapable; } public static String normalizeText(String text) { if (text == null) { return null; } return text.replaceAll("\\s+", " "); } public static Document parse(File source) throws IOException, SAXException, ParserConfigurationException { return parse(source, true, null); } public static Document parse(File source, boolean validate) throws IOException, SAXException, ParserConfigurationException { return parse(source, validate, null); } public static Document parse(File source, boolean validate, URL schemaUrl) throws IOException, SAXException, ParserConfigurationException { if (source == null) { throw new IllegalArgumentException( "The argument source may not be null!"); } System.setProperty("xml.catalog.ignoreMissing", "yes"); DocumentBuilderFactory factory; DocumentBuilder parser; if (schemaUrl != null) { factory = DocumentBuilderFactory.newInstance(); factory.setValidating(validate); factory.setXIncludeAware(true); Schema schema = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaUrl); factory.setNamespaceAware(true); factory.setSchema(schema); parser = factory.newDocumentBuilder(); } else { factory = DocumentBuilderFactory.newInstance(); factory.setValidating(validate); factory.setXIncludeAware(true); parser = factory.newDocumentBuilder(); parser.setEntityResolver(new CatalogResolver()); } XmlValidationResult result = new XmlValidationResult(source, Locale.getDefault()); parser.setErrorHandler(result); Document doc = parser.parse(source); return doc; } /** * Einlesen einer XML-Datei in einen DOM-Tree. Die XML-Daten müssen nur wohl * geformt sein. Es wird keinerlei Validierung vorgenommen. * * @param file * @return Document * @throws SAXException * @throws IOException * @throws ParserConfigurationException */ public static Document loadDocument(File file) throws SAXException, IOException, ParserConfigurationException { if (file == null) { throw new IllegalArgumentException( "The argument source may not be null!"); } DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); DocumentBuilder parser = factory.newDocumentBuilder(); parser.setEntityResolver(new EntityResolver() { @Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { return new InputSource(new ByteArrayInputStream( "".getBytes())); } }); XmlValidationResult result = new XmlValidationResult(file, Locale.getDefault()); parser.setErrorHandler(result); Document doc = parser.parse(file); return doc; } public static Document parse(File source, URL schemaUrl) throws IOException, SAXException, ParserConfigurationException { return parse(source, true, schemaUrl); } public static void recode(File file, String to, URL schemaUrl) throws IOException, SAXException, ParserConfigurationException { if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } if (to == null) { throw new IllegalArgumentException( "The argument to must not be null!"); } String from = getEncoding(file); if (from == null) { from = "UTF-8"; } if (from.toLowerCase().equals(to.toLowerCase())) { return; } Document doc = parse(file, false, schemaUrl); NodeSerializer serializer = new NodeSerializer(); serializer.write(doc, file, to); } public static String replaceAmpersand(String text, boolean isHtml) { char c; String entity; StringBuffer source = new StringBuffer(text); StringBuffer dest = new StringBuffer(); StringBuffer word; int max = source.length() - 1; for (int i = 0; i <= max; i++) { c = source.charAt(i); if (c == '&') { word = new StringBuffer(); if (i == max) { dest.append("&"); continue; } else { if (source.charAt(i + 1) == ';') { i++; dest.append("&;"); continue; } else { word.append('&'); } } while (i < max) { c = source.charAt(++i); if (Character.isWhitespace(c) || (c == '&') || (c == ';') || (i == max)) { if (c == ';') { word.append(c); } if (isEntity(word)) { entity = word.toString(); if (isHtml) { entity = resolveHtmlEntity(entity); } entity = resolveNumericEntity(entity); dest.append(entity); if (Character.isWhitespace(c)) { dest.append(c); } break; } else { dest.append("&"); dest.append(word.substring(1)); if (Character.isWhitespace(c)) { dest.append(c); } if (i == max) { if (c == '&') { dest.append("&"); } else if (c != ';') { dest.append(c); } } logger.debug("dest: " + dest.toString()); if (c == '&') { word = new StringBuffer(); word.append('&'); } else { break; } } } else { word.append(c); } } } else { dest.append(c); } } return dest.toString(); } public static String resolveHtmlEntity(String entity) { if (entity == null || entity.length() == 0) { return ""; } if (entity.startsWith("&") == false || entity.endsWith(";") == false) { return entity; } if (entity.equals(" ")) { return resolveNumericEntity(" "); } if (entity.equals("¡")) { return resolveNumericEntity("¡"); } if (entity.equals("¤")) { return resolveNumericEntity("¤"); } if (entity.equals("¢")) { return resolveNumericEntity("¢"); } if (entity.equals("£")) { return resolveNumericEntity("£"); } if (entity.equals("¥")) { return resolveNumericEntity("¥"); } if (entity.equals("¦")) { return resolveNumericEntity("¦"); } if (entity.equals("§")) { return resolveNumericEntity("§"); } if (entity.equals("¨")) { return resolveNumericEntity("¨"); } if (entity.equals("©")) { return resolveNumericEntity("©"); } if (entity.equals("ª")) { return resolveNumericEntity("ª"); } if (entity.equals("«")) { return resolveNumericEntity("«"); } if (entity.equals("¬")) { return resolveNumericEntity("¬"); } if (entity.equals("­")) { return resolveNumericEntity("­"); } if (entity.equals("®")) { return resolveNumericEntity("®"); } if (entity.equals("™")) { return resolveNumericEntity("™"); } if (entity.equals("¯")) { return resolveNumericEntity("¯"); } if (entity.equals("°")) { return resolveNumericEntity("°"); } if (entity.equals("±")) { return resolveNumericEntity("±"); } if (entity.equals("²")) { return resolveNumericEntity("²"); } if (entity.equals("³")) { return resolveNumericEntity("³"); } if (entity.equals("´")) { return resolveNumericEntity("´"); } if (entity.equals("µ")) { return resolveNumericEntity("µ"); } if (entity.equals("¶")) { return resolveNumericEntity("¶"); } if (entity.equals("·")) { return resolveNumericEntity("·"); } if (entity.equals("¸")) { return resolveNumericEntity("¸"); } if (entity.equals("¹")) { return resolveNumericEntity("¹"); } if (entity.equals("º")) { return resolveNumericEntity("º"); } if (entity.equals("»")) { return resolveNumericEntity("»"); } if (entity.equals("¼")) { return resolveNumericEntity("¼"); } if (entity.equals("½")) { return resolveNumericEntity("½"); } if (entity.equals("¾")) { return resolveNumericEntity("¾"); } if (entity.equals("¿")) { return resolveNumericEntity("¿"); } if (entity.equals("×")) { return resolveNumericEntity("×"); } if (entity.equals("÷")) { return resolveNumericEntity("÷"); } if (entity.equals("À")) { return resolveNumericEntity("À"); } if (entity.equals("Á")) { return resolveNumericEntity("Á"); } if (entity.equals("Â")) { return resolveNumericEntity("Â"); } if (entity.equals("Ã")) { return resolveNumericEntity("Ã"); } if (entity.equals("Ä")) { return resolveNumericEntity("Ä"); } if (entity.equals("Å")) { return resolveNumericEntity("Å"); } if (entity.equals("Æ")) { return resolveNumericEntity("Æ"); } if (entity.equals("Ç")) { return resolveNumericEntity("Ç"); } if (entity.equals("È")) { return resolveNumericEntity("È"); } if (entity.equals("É")) { return resolveNumericEntity("É"); } if (entity.equals("Ê")) { return resolveNumericEntity("Ê"); } if (entity.equals("Ë")) { return resolveNumericEntity("Ë"); } if (entity.equals("Ì")) { return resolveNumericEntity("Ì"); } if (entity.equals("Í")) { return resolveNumericEntity("Í"); } if (entity.equals("Î")) { return resolveNumericEntity("Î"); } if (entity.equals("Ï")) { return resolveNumericEntity("Ï"); } if (entity.equals("Ð")) { return resolveNumericEntity("Ð"); } if (entity.equals("Ñ")) { return resolveNumericEntity("Ñ"); } if (entity.equals("Ò")) { return resolveNumericEntity("Ò"); } if (entity.equals("Ó")) { return resolveNumericEntity("Ó"); } if (entity.equals("Ô")) { return resolveNumericEntity("Ô"); } if (entity.equals("Õ")) { return resolveNumericEntity("Õ"); } if (entity.equals("Ö")) { return resolveNumericEntity("Ö"); } if (entity.equals("Ø")) { return resolveNumericEntity("Ø"); } if (entity.equals("Ù")) { return resolveNumericEntity("Ù"); } if (entity.equals("Ú")) { return resolveNumericEntity("Ú"); } if (entity.equals("Û")) { return resolveNumericEntity("Û"); } if (entity.equals("Ü")) { return resolveNumericEntity("Ü"); } if (entity.equals("Ý")) { return resolveNumericEntity("Ý"); } if (entity.equals("Þ")) { return resolveNumericEntity("Þ"); } if (entity.equals("ß")) { return resolveNumericEntity("ß"); } if (entity.equals("à")) { return resolveNumericEntity("à"); } if (entity.equals("á")) { return resolveNumericEntity("á"); } if (entity.equals("â")) { return resolveNumericEntity("â"); } if (entity.equals("ã")) { return resolveNumericEntity("ã"); } if (entity.equals("ä")) { return resolveNumericEntity("ä"); } if (entity.equals("å")) { return resolveNumericEntity("å"); } if (entity.equals("æ")) { return resolveNumericEntity("æ"); } if (entity.equals("ç")) { return resolveNumericEntity("ç"); } if (entity.equals("è")) { return resolveNumericEntity("è"); } if (entity.equals("é")) { return resolveNumericEntity("é"); } if (entity.equals("ê")) { return resolveNumericEntity("ê"); } if (entity.equals("ë")) { return resolveNumericEntity("ë"); } if (entity.equals("ì")) { return resolveNumericEntity("ì"); } if (entity.equals("í")) { return resolveNumericEntity("í"); } if (entity.equals("î")) { return resolveNumericEntity("î"); } if (entity.equals("ï")) { return resolveNumericEntity("ï"); } if (entity.equals("ð")) { return resolveNumericEntity("ð"); } if (entity.equals("ñ")) { return resolveNumericEntity("ñ"); } if (entity.equals("ò")) { return resolveNumericEntity("ò"); } if (entity.equals("ó")) { return resolveNumericEntity("ó"); } if (entity.equals("ô")) { return resolveNumericEntity("ô"); } if (entity.equals("õ")) { return resolveNumericEntity("õ"); } if (entity.equals("ö")) { return resolveNumericEntity("ö"); } if (entity.equals("ø")) { return resolveNumericEntity("ø"); } if (entity.equals("ù")) { return resolveNumericEntity("ù"); } if (entity.equals("ú")) { return resolveNumericEntity("ú"); } if (entity.equals("û")) { return resolveNumericEntity("û"); } if (entity.equals("ü")) { return resolveNumericEntity("ü"); } if (entity.equals("ý")) { return resolveNumericEntity("ý"); } if (entity.equals("þ")) { return resolveNumericEntity("þ"); } if (entity.equals("ÿ")) { return resolveNumericEntity("ÿ"); } if (entity.equals("Œ")) { return resolveNumericEntity("Œ"); } if (entity.equals("œ")) { return resolveNumericEntity("œ"); } if (entity.equals("Š")) { return resolveNumericEntity("Š"); } if (entity.equals("š")) { return resolveNumericEntity("š"); } if (entity.equals("Ÿ")) { return resolveNumericEntity("Ÿ"); } if (entity.equals("ˆ")) { return resolveNumericEntity("ˆ"); } if (entity.equals("˜")) { return resolveNumericEntity("˜"); } if (entity.equals(" ")) { return resolveNumericEntity(" "); } if (entity.equals(" ")) { return resolveNumericEntity(" "); } if (entity.equals(" ")) { return resolveNumericEntity(" "); } if (entity.equals("‌")) { return resolveNumericEntity("‌"); } if (entity.equals("‍")) { return resolveNumericEntity("‍"); } if (entity.equals("‎")) { return resolveNumericEntity("‎"); } if (entity.equals("‏")) { return resolveNumericEntity("‏"); } if (entity.equals("–")) { return resolveNumericEntity("–"); } if (entity.equals("—")) { return resolveNumericEntity("—"); } if (entity.equals("‘")) { return resolveNumericEntity("‘"); } if (entity.equals("’")) { return resolveNumericEntity("’"); } if (entity.equals("‚")) { return resolveNumericEntity("‚"); } if (entity.equals("“")) { return resolveNumericEntity("“"); } if (entity.equals("”")) { return resolveNumericEntity("”"); } if (entity.equals("„")) { return resolveNumericEntity("„"); } if (entity.equals("†")) { return resolveNumericEntity("†"); } if (entity.equals("‡")) { return resolveNumericEntity("‡"); } if (entity.equals("…")) { return resolveNumericEntity("…"); } if (entity.equals("‰")) { return resolveNumericEntity("‰"); } if (entity.equals("‹")) { return resolveNumericEntity("‹"); } if (entity.equals("›")) { return resolveNumericEntity("›"); } if (entity.equals("€")) { return resolveNumericEntity("€"); } return entity; } public static String resolveNumericEntity(String entity) { if (entity == null || entity.length() == 0) { return ""; } if (entity.startsWith("&#") == false || entity.endsWith(";") == false) { return entity; } String str = entity; str = StringServices.cutPrefix(str, "&#"); str = StringServices.cutSuffix(str, ";"); int code = -1; int radix = 10; if (str.startsWith("x")) { str = StringServices.cutPrefix(str, "x"); radix = 16; } try { code = Integer.parseInt(str, radix); } catch (NumberFormatException oops) { return entity; } StringBuffer buffer = new StringBuffer(); buffer.append((char) code); return buffer.toString(); } public static String textToHtml(String text) { if (text == null) { return null; } text = textToXml(text, true); return text; } /** * Die Methode textToXml wandelt Text in XML-Text um. * * Dazu werden die von XML reservierter Zeichen "kleiner als", "größer als" * und das kaufmännische Und durch ihre entsprechenden Entities ersetzt. * * @param text * String * @return String */ public static String textToXml(String text) { return textToXml(text, false); } /** * Die Methode textToXml wandelt Text in XML-Text um. * * Dazu werden die von XML reservierter Zeichen "kleiner als", "größer als" * und das kaufmännische Und durch ihre entsprechenden Entities ersetzt. * * @param text * String * @return String */ public static String textToXml(String text, boolean isHtml) { logger.debug("Argument text: \"" + text + "\""); logger.debug("Argument isHtml: \"" + isHtml + "\""); if (text == null) { return null; } text = StringServices.replace(text, "<", "<"); text = StringServices.replace(text, ">", ">"); text = StringServices.replace(text, """, "\""); text = StringServices.replace(text, "'", "'"); text = StringServices.replace(text, "'", "'"); text = StringServices.replace(text, "<", "<"); text = StringServices.replace(text, ">", ">"); text = StringServices.replace(text, "\"", """); text = StringServices.replace(text, "\uF0E0", ""); if (isHtml == true) { text = StringServices.replace(text, "'", "'"); } else { text = StringServices.replace(text, "'", "'"); } text = replaceAmpersand(text, isHtml); text = UnicodeServices.removeUndefinedCharacters(text); logger.debug("Return: \"" + text + "\""); return text; } /** * Die Methode validate validiert die angegebene XML-Datei. * * @param file * File * @exception ParserConfigurationException * ParserConfigurationException * @exception SAXException * SAXException * @exception IOException * IOException public static int validate(File source) throws * ParserConfigurationException, SAXException, IOException { * * XmlValidationResult result = validate(source); * * return result.getNumOfErrors(); } */ public static XmlValidationResult validate(File file) throws ParserConfigurationException, SAXException, IOException { return validate(file, null, Locale.getDefault()); } public static XmlValidationResult validate(File file, Locale locale) throws ParserConfigurationException, SAXException, IOException { return validate(file, null, locale); } public static XmlValidationResult validate(File file, URL schemaUrl) throws ParserConfigurationException, SAXException, IOException { return validate(file, schemaUrl, Locale.getDefault()); } public static XmlValidationResult validate(File file, URL schemaUrl, Locale locale) throws ParserConfigurationException, SAXException, IOException { if (file == null) { throw new IllegalArgumentException( "The argument file may not be null!"); } if (locale == null) { throw new IllegalArgumentException( "The argument locale must not be null!"); } XmlValidationResult result = new XmlValidationResult(file, locale); if (file.exists() == false) { result.setFileNotFound(true); return result; } if (file.canRead() == false) { result.setCanNotRead(true); return result; } System.setProperty("xml.catalog.ignoreMissing", "yes"); DocumentBuilderFactory factory; DocumentBuilder parser; if (schemaUrl != null) { Schema schema = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaUrl); factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setSchema(schema); factory.setXIncludeAware(true); parser = factory.newDocumentBuilder(); } else { factory = DocumentBuilderFactory.newInstance(); parser = factory.newDocumentBuilder(); parser.setEntityResolver(new CatalogResolver()); } factory.setValidating(true); parser.setErrorHandler(result); try { parser.parse(file); } catch (SAXParseException oops) { // Wird von XmlValidationResult verarbeitet } catch (Throwable oops) { result.setThrowable(oops); } return result; } public static XmlValidationResult validate(String source) throws ParserConfigurationException, SAXException, IOException { if (source == null) { throw new IllegalArgumentException( "The argument source may not be null!"); } return validate(new File(source)); } /** * Die Methode validate validiert die angegebene Zeichekette. * * Vor der Konvertierung wird die Zeichenkette in die angegebene Kodierung * umgewandelt. * * @param xmlCode * String * @param encoding * String * @return byte[] * @exception CharacterCodingException * CharacterCodingException * @exception ParserConfigurationException * ParserConfigurationException * @exception SAXException * SAXException * @exception IOException * IOException */ public static byte[] validate(String xmlCode, String encoding) throws CharacterCodingException, ParserConfigurationException, SAXException, IOException { return validate(xmlCode, encoding, null); } public static byte[] validate(String xmlCode, String encoding, URL schemaUrl) throws CharacterCodingException, ParserConfigurationException, SAXException, IOException { if (xmlCode == null) { throw new IllegalArgumentException( "The argument xmlCode may not be null!"); } if (encoding == null) { throw new IllegalArgumentException( "The argument encoding may not be null!"); } System.setProperty("xml.catalog.ignoreMissing", "yes"); Charset charset = Charset.forName(encoding); CharsetEncoder encoder = charset.newEncoder(); CharBuffer inBuffer = CharBuffer.wrap(xmlCode); ByteBuffer byteBuffer = encoder.encode(inBuffer); int limit = byteBuffer.limit(); byte[] data = new byte[limit]; byteBuffer.get(data, 0, limit); ByteArrayInputStream stream = new ByteArrayInputStream(data); DocumentBuilderFactory factory; DocumentBuilder parser; if (schemaUrl != null) { Schema schema = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaUrl); factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setSchema(schema); factory.setXIncludeAware(true); parser = factory.newDocumentBuilder(); } else { factory = DocumentBuilderFactory.newInstance(); parser = factory.newDocumentBuilder(); parser.setEntityResolver(new CatalogResolver()); } factory.setValidating(true); parser.parse(stream); return data; } public static boolean isNewline(Node node) { if (node != null && node instanceof Text) { String text = ((Text) node).getData(); if (text != null && text.trim().length() == 0 && text.indexOf('\n') != -1) { return true; } } return false; } public static String normalizeText(Text text) { String data = text.getData(); data = ReplaceServices.replaceAll(data, "\\s+", " "); return data; } public static String xmlToText(String text) { if (text == null) { return null; } text = StringServices.replace(text, "'", "'"); text = StringServices.replace(text, "'", "'"); text = StringServices.replace(text, """, "\""); text = StringServices.replace(text, "<", "<"); text = StringServices.replace(text, ">", ">"); text = StringServices.replace(text, "&", "&"); return text; } /** * Die Methode xslt führt eine XSL-Transformation durch. */ public static void xslt(File in, String xsl, HashMap params, File out, String encoding, boolean validate) throws IOException, SAXException, TransformerConfigurationException, TransformerException, UnsupportedEncodingException { xslt(in.getCanonicalPath(), xsl, params, out.getCanonicalPath(), encoding, validate, null); } public static void xslt(File in, String xsl, HashMap params, File out, String encoding, boolean validate, ErrorListener listener) throws IOException, SAXException, TransformerConfigurationException, TransformerException, UnsupportedEncodingException { xslt(in.getCanonicalPath(), xsl, params, out.getCanonicalPath(), encoding, validate, listener); } public static void xslt(String in, String xsl, HashMap params, String out) throws IOException, SAXException, TransformerConfigurationException, TransformerException, UnsupportedEncodingException { xslt(in, xsl, params, out, "UTF-8", false, null); } public static void xslt(String in, String xsl, HashMap params, String out, String encoding, boolean validate) throws IOException, SAXException, TransformerConfigurationException, TransformerException, UnsupportedEncodingException { xslt(in, xsl, params, out, encoding, validate, null); } /** * Die Methode xslt führt eine XSL-Transformation durch. */ public static void xslt(String in, String xsl, HashMap params, String out, String encoding, boolean validate, ErrorListener listener) throws IOException, SAXException, TransformerConfigurationException, TransformerException, UnsupportedEncodingException { if (in == null) { throw new IllegalArgumentException("Parameter in is null!"); } if (xsl == null) { throw new IllegalArgumentException("Parameter xsl is null!"); } if (out == null) { throw new IllegalArgumentException("Parameter out is null!"); } if (encoding == null) { throw new IllegalArgumentException( "The argument encoding may not be null!"); } System.setProperty("xml.catalog.ignoreMissing", "yes"); FileInputStream fis = null; FileOutputStream fos = null; logger.debug("validate=" + validate); String spf = System.getProperty("javax.xml.parsers.SAXParserFactory"); String dbf = System .getProperty("javax.xml.parsers.DocumentBuilderFactory"); String tf = System .getProperty("javax.xml.transform.TransformerFactory"); try { System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl"); System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl"); TransformerFactory transformerFactory = TransformerFactory .newInstance(); if (listener != null) { transformerFactory.setErrorListener(listener); } if (validate == true) { transformerFactory.setURIResolver(new CatalogResolver()); } Transformer transformer = transformerFactory .newTransformer(new StreamSource(xsl)); if (transformer == null) { throw new TransformerException( "Can't create transformer for stylesheet " + xsl + ". Working directory is " + new File(".").getAbsolutePath()); } if (listener != null) { transformer.setErrorListener(listener); } if (validate == true) { transformer.setURIResolver(new CatalogResolver()); } if (params != null) { Iterator iterator = params.keySet().iterator(); String param; String value; while (iterator.hasNext()) { param = iterator.next(); value = params.get(param); transformer.setParameter(param, value); } } fis = new FileInputStream(in); fos = new FileOutputStream(out); try { XMLReader reader = XMLReaderFactory.createXMLReader(); if (validate == true) { reader.setEntityResolver(new CatalogResolver()); } transformer .transform(new SAXSource(reader, new InputSource(in)), new StreamResult(new OutputStreamWriter(fos, encoding))); } catch (Exception oops) { logger.fatal("XmlServices.xslt", oops); } } finally { if (fis != null) { fis.close(); } if (fos != null) { fos.close(); } if (spf != null) { System.setProperty("javax.xml.parsers.SAXParserFactory", spf); } if (dbf != null) { System.setProperty("javax.xml.parsers.DocumentBuilderFactor", dbf); } if (tf != null) { System.setProperty("javax.xml.transform.TransformerFactory", tf); } } } public static void xslt(String in, String xsl, HashMap params, String out, String encoding, ErrorListener listener) throws IOException, SAXException, TransformerConfigurationException, TransformerException, UnsupportedEncodingException { xslt(in, xsl, params, out, encoding, false, listener); } /** * Führt eine XSLT-Transformation durch. * * @param in * XML-Eingabedatei * @param xsl * XSLT-Datei * @param out * Ausgabedatei * @throws IOException * @throws SAXException * @throws TransformerConfigurationException * @throws TransformerException * @throws UnsupportedEncodingException */ public static void xslt(String in, String xsl, String out) throws IOException, SAXException, TransformerConfigurationException, TransformerException, UnsupportedEncodingException { xslt(in, xsl, new HashMap(), out, "UTF-8", false, null); } public static void xslt(String in, String xsl, String out, ErrorListener listener) throws IOException, SAXException, TransformerConfigurationException, TransformerException, UnsupportedEncodingException { xslt(in, xsl, new HashMap(), out, "UTF-8", false, listener); } /** * Die Methode relocateSrc kopiert die Bilder der lokalen * Bildreferenzen einer HTML-Datei in das angegebene Zeilverzeichnis und * passt die Referenzen entsprechend an. * * @param file * @param imgDir * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ public static void relocateSrc(File file, File imgDir) throws IOException, SAXException, ParserConfigurationException { Document doc = loadDocument(file); ArrayList imgNodeList = XPathServices.getNodes(doc, "xhtml", "http://www.w3.org/1999/xhtml", "//xhtml:img"); for (Node node : imgNodeList) { Element img = (Element) node; String srcAttr = img.getAttribute("src"); if (srcAttr == null || srcAttr.trim().length() == 0) { continue; } File fromFile; if (srcAttr.startsWith("file:")) { URL srcUrl = new URL(srcAttr); fromFile = new File(srcUrl.getPath()); } else { fromFile = new File(srcAttr); } if (fromFile.exists() == false) { logger.warn("Image file doesn't exist: " + fromFile.getAbsolutePath()); continue; } String toFileName = FileServices.appendPath(imgDir, fromFile.getName()); File toFile = FileServices.createUniqueFile(new File(toFileName)); FileServices.copyFileToFile(fromFile, toFile); img.setAttribute("src", FileServices.relativePath(file, toFile)); } NodeSerializer serializer = new NodeSerializer(); serializer.write(doc, file); } public static String printPath(Node node) { if (node == null) { return "Path: null"; } StringBuilder buffer = new StringBuilder(); Node parent = node; while (parent != null) { buffer.insert(0, " -> "); buffer.insert(0, parent.getNodeName()); parent = parent.getParentNode(); } String text = buffer.toString(); text = StringServices.cutPrefix(text, " -> "); return "Path: " + text; } } src/java/org/dbdoclet/xiphias/W3cServices.java0000644000000000000000000002532612124530526020313 0ustar rootrootpackage org.dbdoclet.xiphias; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; public class W3cServices { public static Element getChildElement(Element parent, String childName) { if (parent == null) { throw new IllegalArgumentException("The argument parent may not be null!"); } if (childName == null) { throw new IllegalArgumentException("The argument childName may not be null!"); } Element element = null; String nodeName = null; NodeList childNodes = parent.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { if (childNodes.item(i) instanceof Element) { element = (Element) childNodes.item(i); nodeName = element.getNodeName(); if (nodeName != null && nodeName.equals(childName)) { return element; } } } return null; } public static List getChildElements(Element parent, String childName) { if (parent == null) { throw new IllegalArgumentException("The argument parent may not be null!"); } if (childName == null) { throw new IllegalArgumentException("The argument childName may not be null!"); } Element element = null; String nodeName = null; ArrayList children = new ArrayList(); NodeList childNodes = parent.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { if (childNodes.item(i) instanceof Element) { element = (Element) childNodes.item(i); nodeName = element.getNodeName(); if (nodeName != null && nodeName.equals(childName)) { children.add(element); } } } return children; } public static Element[] getElementPath(Element elem) { if (elem == null) { throw new IllegalArgumentException("The argument elem must not be null!"); } ArrayList elementList = new ArrayList(); elementList.add(elem); Node parent = elem.getParentNode(); while (parent != null) { if (parent instanceof Element) { elementList.add(parent); } parent = parent.getParentNode(); } Collections.reverse(elementList); Element[] path = new Element[elementList.size()]; for (int i = 0; i < elementList.size(); i++) { elem = (Element) elementList.get(i); path[i] = elem; } return path; } public static Element getFirstElement(Element parent) { if (parent == null) { throw new IllegalArgumentException("The argument parent may not be null!"); } NodeList childNodes = parent.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { if (childNodes.item(i) instanceof Element) { return (Element) childNodes.item(i); } } return null; } public static void setText(Element parent, String text) { if (parent == null) { throw new IllegalArgumentException("The argument parent must not be null!"); } NodeList childNodes = parent.getChildNodes(); if (childNodes != null && childNodes.getLength() > 0) { Node childNode; for (int i = 0; i < childNodes.getLength(); i++) { childNode = childNodes.item(i); parent.removeChild(childNode); } } Document doc = parent.getOwnerDocument(); if (doc == null) { throw new NullPointerException("Owner document of element must not be null!"); } Text textNode = doc.createTextNode(XmlServices.textToXml(text)); parent.appendChild(textNode); } public static String getText(Node parent) { if (parent == null) { throw new IllegalArgumentException("The argument parent must not be null!"); } String buffer = ""; NodeList childNodes = parent.getChildNodes(); if (childNodes == null || childNodes.getLength() == 0) { return buffer; } Node childNode; Text textNode; for (int i = 0; i < childNodes.getLength(); i++) { childNode = childNodes.item(i); if (childNode instanceof Text) { textNode = (Text) childNode; buffer += textNode.getNodeValue(); } else if (childNode instanceof Element) { buffer += W3cServices.getText(childNode); } } return buffer; } /** * Die Methode insertAfter fügt ein neues Element nach dem * angegebenen Referenzelement ein. * * @param node Element * @param refNode Element */ public static void insertElementAfter(Element newNode, Element refNode) { if (newNode == null) { throw new IllegalArgumentException("The argument newNode must not be null!"); } if (refNode == null) { throw new IllegalArgumentException("The argument refNode must not be null!"); } Element parentNode = (Element) refNode.getParentNode(); if (parentNode == null) { throw new IllegalStateException("The parent node of the destination node must not be null!"); } Element siblingNode = null; Node node = refNode.getNextSibling(); while (node != null && node instanceof Element == false) { node = node.getNextSibling(); } if (node != null && node instanceof Element) { siblingNode = (Element) node; } if (siblingNode != null) { parentNode.insertBefore(newNode, siblingNode); } else { parentNode.appendChild(newNode); } } public static void setElementText(Element elem, String text) { if (elem == null) { throw new IllegalArgumentException("The argument elem must not be null!"); } if (text == null) { text = ""; } Document doc = elem.getOwnerDocument(); if (doc == null) { return; } if (elem.hasChildNodes()) { Node childNode; NodeList childNodes = elem.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { childNode = childNodes.item(i); elem.removeChild(childNode); } } Text textNode = doc.createTextNode(text); elem.appendChild(textNode); } /** * Die Methode copyNode kopiert den Baum mit dem Wurzelelement * oNode in den Kontext des Dokumentes doc und * gibt den Wurzelknoten des neu erzeugten Baumes nNode zurück. * Diese Methode wird benötigt um Knoten aus einem Dokument in den Baum * eines anderen Dokumentes zu kopieren. * *

      Wird versucht Knoten eines Dokumentes in ein zweites zu einzuhängen, * erhält man die Fehlermeldung : WRONG_DOCUMENT_ERR: A node is used * in a different document than the one that created it.

      * *

      Beispiel:

      *
           * Document resourceDoc = XmlServices.parse(file);
           * elem = resourceDoc.getDocumentElement();
           * parent.appendChild(W3cServices.copyNode(manifestDoc, elem));
           * 
      * * @param doc Document * @param oNode Node * @return Node */ public static Node copyNode(Document doc, Node oNode) { if (doc == null) { throw new IllegalArgumentException("The argument doc must not be null!"); } if (oNode == null) { throw new IllegalArgumentException("The argument oNode must not be null!"); } Node nNode = null; Node nChild; int nodeType; switch (oNode.getNodeType()) { case Node.ELEMENT_NODE: nNode = doc.createElement(oNode.getNodeName()); NamedNodeMap attrMap = oNode.getAttributes(); Node attrNode; for (int i = 0; i < attrMap.getLength(); i++) { attrNode = attrMap.item(i); ((Element) nNode).setAttribute(attrNode.getNodeName(), attrNode.getNodeValue()); } break; case Node.TEXT_NODE: nNode = doc.createTextNode(oNode.getNodeValue()); break; case Node.ENTITY_NODE: nNode = doc.createTextNode(oNode.getNodeName()); break; case Node.ENTITY_REFERENCE_NODE: nNode = doc.createEntityReference(oNode.getNodeName()); break; case Node.COMMENT_NODE: nNode = doc.createComment(oNode.getNodeValue()); break; case Node.CDATA_SECTION_NODE: nNode = doc.createCDATASection(oNode.getNodeValue()); break; case Node.PROCESSING_INSTRUCTION_NODE: nNode = doc.createProcessingInstruction(oNode.getNodeName(), oNode.getNodeValue()); break; } if (nNode == null) { return null; } NodeList childNodes = oNode.getChildNodes(); if (childNodes != null && childNodes.getLength() > 0) { for (int i = 0; i < childNodes.getLength(); i++) { nodeType = childNodes.item(i).getNodeType(); if (nodeType != Node.ATTRIBUTE_NODE) { nChild = copyNode(doc, childNodes.item(i)); if (nChild != null) { nNode.appendChild(nChild); } } } } return nNode; } public static String getAttributesAsText(Element elem) { String buffer = ""; NamedNodeMap attributes = elem.getAttributes(); if (attributes != null) { for (int i = 0; i < attributes.getLength(); i++) { Node attr = attributes.item(i); buffer += " " + attr.getNodeName() + "=\"" + XmlServices.textToXml(attr.getNodeValue()) + "\""; } } return buffer; } } src/java/org/dbdoclet/xiphias/HtmlServices.java0000644000000000000000000006663312124530526020571 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2006 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.xiphias; import java.io.PrintWriter; import java.io.StringWriter; import org.dbdoclet.service.StringServices; public class HtmlServices { public static boolean isEntity(StringBuffer word) { return XmlServices.isEntity(word); } public static String textToHtml(String text) { if (text == null) { return null; } text = XmlServices.textToXml(text, true); return text; } public static String htmlToText(String text) { if (text == null) { return null; } text = XmlServices.xmlToText(text); text = StringServices.replace(text, "ä", "ä"); text = StringServices.replace(text, "Ö", "Ö"); text = StringServices.replace(text, "ö", "ö"); text = StringServices.replace(text, "Ü", "Ü"); text = StringServices.replace(text, "ü", "ü"); return text; } public static String createExceptionBox(String title, String msg, Throwable oops) { String name = "exception"; StringBuffer buffer = new StringBuffer(); buffer.append("
      \n"); buffer.append("
      "); buffer.append(title); buffer.append("
      \n"); buffer.append("
      \n"); buffer.append(msg); buffer.append("
      \n"); buffer.append("
      \n");
      
      		StringWriter stb = new StringWriter();
      		oops.printStackTrace(new PrintWriter(stb));
      		buffer.append(stb.toString());
      
      		buffer.append("  
      \n"); buffer.append("
      \n"); return buffer.toString(); } public static String createErrorBox(String title, String msg) { return createBox("error", title, msg); } public static String createWarningBox(String title, String msg) { return createBox("warning", title, msg); } public static String createInfoBox(String title, String msg) { return createBox("info", title, msg); } public static String createBox(String name, String title, String msg) { StringBuffer buffer = new StringBuffer(); buffer.append("
      \n"); buffer.append("
      "); buffer.append("

      " + title + "

      "); buffer.append("
      \n"); buffer.append("
      \n"); buffer.append(msg); buffer.append("
      \n"); buffer.append("
      \n"); return buffer.toString(); } public static String replaceEntities(String htmlCode) { String buffer = new String(htmlCode); buffer = StringServices.replace(buffer, " ", XmlServices.resolveNumericEntity(" ")); buffer = StringServices.replace(buffer, "¡", XmlServices.resolveNumericEntity("¡")); buffer = StringServices.replace(buffer, "¢", XmlServices.resolveNumericEntity("¢")); buffer = StringServices.replace(buffer, "£", XmlServices.resolveNumericEntity("£")); buffer = StringServices.replace(buffer, "¤", XmlServices.resolveNumericEntity("¤")); buffer = StringServices.replace(buffer, "¥", XmlServices.resolveNumericEntity("¥")); buffer = StringServices.replace(buffer, "¦", XmlServices.resolveNumericEntity("¦")); buffer = StringServices.replace(buffer, "§", XmlServices.resolveNumericEntity("§")); buffer = StringServices.replace(buffer, "¨", XmlServices.resolveNumericEntity("¨")); buffer = StringServices.replace(buffer, "©", XmlServices.resolveNumericEntity("©")); buffer = StringServices.replace(buffer, "ª", XmlServices.resolveNumericEntity("ª")); buffer = StringServices.replace(buffer, "«", XmlServices.resolveNumericEntity("«")); buffer = StringServices.replace(buffer, "¬", XmlServices.resolveNumericEntity("¬")); buffer = StringServices.replace(buffer, "­", XmlServices.resolveNumericEntity("­")); buffer = StringServices.replace(buffer, "®", XmlServices.resolveNumericEntity("®")); buffer = StringServices.replace(buffer, "¯", XmlServices.resolveNumericEntity("¯")); buffer = StringServices.replace(buffer, "°", XmlServices.resolveNumericEntity("°")); buffer = StringServices.replace(buffer, "±", XmlServices.resolveNumericEntity("±")); buffer = StringServices.replace(buffer, "²", XmlServices.resolveNumericEntity("²")); buffer = StringServices.replace(buffer, "³", XmlServices.resolveNumericEntity("³")); buffer = StringServices.replace(buffer, "´", XmlServices.resolveNumericEntity("´")); buffer = StringServices.replace(buffer, "µ", XmlServices.resolveNumericEntity("µ")); buffer = StringServices.replace(buffer, "¶", XmlServices.resolveNumericEntity("¶")); buffer = StringServices.replace(buffer, "·", XmlServices.resolveNumericEntity("·")); buffer = StringServices.replace(buffer, "¸", XmlServices.resolveNumericEntity("¸")); buffer = StringServices.replace(buffer, "¹", XmlServices.resolveNumericEntity("¹")); buffer = StringServices.replace(buffer, "º", XmlServices.resolveNumericEntity("º")); buffer = StringServices.replace(buffer, "»", XmlServices.resolveNumericEntity("»")); buffer = StringServices.replace(buffer, "¼", XmlServices.resolveNumericEntity("¼")); buffer = StringServices.replace(buffer, "½", XmlServices.resolveNumericEntity("½")); buffer = StringServices.replace(buffer, "¾", XmlServices.resolveNumericEntity("¾")); buffer = StringServices.replace(buffer, "¿", XmlServices.resolveNumericEntity("¿")); buffer = StringServices.replace(buffer, "À", XmlServices.resolveNumericEntity("À")); buffer = StringServices.replace(buffer, "Á", XmlServices.resolveNumericEntity("Á")); buffer = StringServices.replace(buffer, "Â", XmlServices.resolveNumericEntity("Â")); buffer = StringServices.replace(buffer, "Ã", XmlServices.resolveNumericEntity("Ã")); buffer = StringServices.replace(buffer, "Ä", XmlServices.resolveNumericEntity("Ä")); buffer = StringServices.replace(buffer, "Å", XmlServices.resolveNumericEntity("Å")); buffer = StringServices.replace(buffer, "Æ", XmlServices.resolveNumericEntity("Æ")); buffer = StringServices.replace(buffer, "Ç", XmlServices.resolveNumericEntity("Ç")); buffer = StringServices.replace(buffer, "È", XmlServices.resolveNumericEntity("È")); buffer = StringServices.replace(buffer, "É", XmlServices.resolveNumericEntity("É")); buffer = StringServices.replace(buffer, "Ê", XmlServices.resolveNumericEntity("Ê")); buffer = StringServices.replace(buffer, "Ë", XmlServices.resolveNumericEntity("Ë")); buffer = StringServices.replace(buffer, "Ì", XmlServices.resolveNumericEntity("Ì")); buffer = StringServices.replace(buffer, "Í", XmlServices.resolveNumericEntity("Í")); buffer = StringServices.replace(buffer, "Î", XmlServices.resolveNumericEntity("Î")); buffer = StringServices.replace(buffer, "Ï", XmlServices.resolveNumericEntity("Ï")); buffer = StringServices.replace(buffer, "Ð", XmlServices.resolveNumericEntity("Ð")); buffer = StringServices.replace(buffer, "Ñ", XmlServices.resolveNumericEntity("Ñ")); buffer = StringServices.replace(buffer, "Ò", XmlServices.resolveNumericEntity("Ò")); buffer = StringServices.replace(buffer, "Ó", XmlServices.resolveNumericEntity("Ó")); buffer = StringServices.replace(buffer, "Ô", XmlServices.resolveNumericEntity("Ô")); buffer = StringServices.replace(buffer, "Õ", XmlServices.resolveNumericEntity("Õ")); buffer = StringServices.replace(buffer, "Ö", XmlServices.resolveNumericEntity("Ö")); buffer = StringServices.replace(buffer, "×", XmlServices.resolveNumericEntity("×")); buffer = StringServices.replace(buffer, "Ø", XmlServices.resolveNumericEntity("Ø")); buffer = StringServices.replace(buffer, "Ù", XmlServices.resolveNumericEntity("Ù")); buffer = StringServices.replace(buffer, "Ú", XmlServices.resolveNumericEntity("Ú")); buffer = StringServices.replace(buffer, "Û", XmlServices.resolveNumericEntity("Û")); buffer = StringServices.replace(buffer, "Ü", XmlServices.resolveNumericEntity("Ü")); buffer = StringServices.replace(buffer, "Ý", XmlServices.resolveNumericEntity("Ý")); buffer = StringServices.replace(buffer, "Þ", XmlServices.resolveNumericEntity("Þ")); buffer = StringServices.replace(buffer, "ß", XmlServices.resolveNumericEntity("ß")); buffer = StringServices.replace(buffer, "à", XmlServices.resolveNumericEntity("à")); buffer = StringServices.replace(buffer, "á", XmlServices.resolveNumericEntity("á")); buffer = StringServices.replace(buffer, "â", XmlServices.resolveNumericEntity("â")); buffer = StringServices.replace(buffer, "ã", XmlServices.resolveNumericEntity("ã")); buffer = StringServices.replace(buffer, "ä", XmlServices.resolveNumericEntity("ä")); buffer = StringServices.replace(buffer, "å", XmlServices.resolveNumericEntity("å")); buffer = StringServices.replace(buffer, "æ", XmlServices.resolveNumericEntity("æ")); buffer = StringServices.replace(buffer, "ç", XmlServices.resolveNumericEntity("ç")); buffer = StringServices.replace(buffer, "è", XmlServices.resolveNumericEntity("è")); buffer = StringServices.replace(buffer, "é", XmlServices.resolveNumericEntity("é")); buffer = StringServices.replace(buffer, "ê", XmlServices.resolveNumericEntity("ê")); buffer = StringServices.replace(buffer, "ë", XmlServices.resolveNumericEntity("ë")); buffer = StringServices.replace(buffer, "ì", XmlServices.resolveNumericEntity("ì")); buffer = StringServices.replace(buffer, "í", XmlServices.resolveNumericEntity("í")); buffer = StringServices.replace(buffer, "î", XmlServices.resolveNumericEntity("î")); buffer = StringServices.replace(buffer, "ï", XmlServices.resolveNumericEntity("ï")); buffer = StringServices.replace(buffer, "ð", XmlServices.resolveNumericEntity("ð")); buffer = StringServices.replace(buffer, "ñ", XmlServices.resolveNumericEntity("ñ")); buffer = StringServices.replace(buffer, "ò", XmlServices.resolveNumericEntity("ò")); buffer = StringServices.replace(buffer, "ó", XmlServices.resolveNumericEntity("ó")); buffer = StringServices.replace(buffer, "ô", XmlServices.resolveNumericEntity("ô")); buffer = StringServices.replace(buffer, "õ", XmlServices.resolveNumericEntity("õ")); buffer = StringServices.replace(buffer, "ö", XmlServices.resolveNumericEntity("ö")); buffer = StringServices.replace(buffer, "÷", XmlServices.resolveNumericEntity("÷")); buffer = StringServices.replace(buffer, "ø", XmlServices.resolveNumericEntity("ø")); buffer = StringServices.replace(buffer, "ù", XmlServices.resolveNumericEntity("ù")); buffer = StringServices.replace(buffer, "ú", XmlServices.resolveNumericEntity("ú")); buffer = StringServices.replace(buffer, "û", XmlServices.resolveNumericEntity("û")); buffer = StringServices.replace(buffer, "ü", XmlServices.resolveNumericEntity("ü")); buffer = StringServices.replace(buffer, "ý", XmlServices.resolveNumericEntity("ý")); buffer = StringServices.replace(buffer, "þ", XmlServices.resolveNumericEntity("þ")); buffer = StringServices.replace(buffer, "ÿ", XmlServices.resolveNumericEntity("ÿ")); buffer = StringServices.replace(buffer, "Α", XmlServices.resolveNumericEntity("Α")); buffer = StringServices.replace(buffer, "α", XmlServices.resolveNumericEntity("α")); buffer = StringServices.replace(buffer, "Β", XmlServices.resolveNumericEntity("Β")); buffer = StringServices.replace(buffer, "β", XmlServices.resolveNumericEntity("β")); buffer = StringServices.replace(buffer, "Γ", XmlServices.resolveNumericEntity("Γ")); buffer = StringServices.replace(buffer, "γ", XmlServices.resolveNumericEntity("γ")); buffer = StringServices.replace(buffer, "Δ", XmlServices.resolveNumericEntity("Δ")); buffer = StringServices.replace(buffer, "δ", XmlServices.resolveNumericEntity("δ")); buffer = StringServices.replace(buffer, "Ε", XmlServices.resolveNumericEntity("Ε")); buffer = StringServices.replace(buffer, "ε", XmlServices.resolveNumericEntity("ε")); buffer = StringServices.replace(buffer, "Ζ", XmlServices.resolveNumericEntity("Ζ")); buffer = StringServices.replace(buffer, "ζ", XmlServices.resolveNumericEntity("ζ")); buffer = StringServices.replace(buffer, "Η", XmlServices.resolveNumericEntity("Η")); buffer = StringServices.replace(buffer, "η", XmlServices.resolveNumericEntity("η")); buffer = StringServices.replace(buffer, "Θ", XmlServices.resolveNumericEntity("Θ")); buffer = StringServices.replace(buffer, "θ", XmlServices.resolveNumericEntity("θ")); buffer = StringServices.replace(buffer, "Ι", XmlServices.resolveNumericEntity("Ι")); buffer = StringServices.replace(buffer, "ι", XmlServices.resolveNumericEntity("ι")); buffer = StringServices.replace(buffer, "Κ", XmlServices.resolveNumericEntity("Κ")); buffer = StringServices.replace(buffer, "κ", XmlServices.resolveNumericEntity("κ")); buffer = StringServices.replace(buffer, "Λ", XmlServices.resolveNumericEntity("Λ")); buffer = StringServices.replace(buffer, "λ", XmlServices.resolveNumericEntity("λ")); buffer = StringServices.replace(buffer, "Μ", XmlServices.resolveNumericEntity("Μ")); buffer = StringServices.replace(buffer, "μ", XmlServices.resolveNumericEntity("μ")); buffer = StringServices.replace(buffer, "Ν", XmlServices.resolveNumericEntity("Ν")); buffer = StringServices.replace(buffer, "ν", XmlServices.resolveNumericEntity("ν")); buffer = StringServices.replace(buffer, "Ξ", XmlServices.resolveNumericEntity("Ξ")); buffer = StringServices.replace(buffer, "ξ", XmlServices.resolveNumericEntity("ξ")); buffer = StringServices.replace(buffer, "Ο", XmlServices.resolveNumericEntity("Ο")); buffer = StringServices.replace(buffer, "ο", XmlServices.resolveNumericEntity("ο")); buffer = StringServices.replace(buffer, "Π", XmlServices.resolveNumericEntity("Π")); buffer = StringServices.replace(buffer, "π", XmlServices.resolveNumericEntity("π")); buffer = StringServices.replace(buffer, "Ρ", XmlServices.resolveNumericEntity("Ρ")); buffer = StringServices.replace(buffer, "ρ", XmlServices.resolveNumericEntity("ρ")); buffer = StringServices.replace(buffer, "Σ", XmlServices.resolveNumericEntity("Σ")); buffer = StringServices.replace(buffer, "ς", XmlServices.resolveNumericEntity("ς")); buffer = StringServices.replace(buffer, "σ", XmlServices.resolveNumericEntity("σ")); buffer = StringServices.replace(buffer, "Τ", XmlServices.resolveNumericEntity("Τ")); buffer = StringServices.replace(buffer, "τ", XmlServices.resolveNumericEntity("τ")); buffer = StringServices.replace(buffer, "Υ", XmlServices.resolveNumericEntity("Υ")); buffer = StringServices.replace(buffer, "υ", XmlServices.resolveNumericEntity("υ")); buffer = StringServices.replace(buffer, "Φ", XmlServices.resolveNumericEntity("Φ")); buffer = StringServices.replace(buffer, "φ", XmlServices.resolveNumericEntity("φ")); buffer = StringServices.replace(buffer, "Χ", XmlServices.resolveNumericEntity("Χ")); buffer = StringServices.replace(buffer, "χ", XmlServices.resolveNumericEntity("χ")); buffer = StringServices.replace(buffer, "Ψ", XmlServices.resolveNumericEntity("Ψ")); buffer = StringServices.replace(buffer, "ψ", XmlServices.resolveNumericEntity("ψ")); buffer = StringServices.replace(buffer, "Ω", XmlServices.resolveNumericEntity("Ω")); buffer = StringServices.replace(buffer, "ω", XmlServices.resolveNumericEntity("ω")); buffer = StringServices.replace(buffer, "ϑ", XmlServices.resolveNumericEntity("ϑ")); buffer = StringServices.replace(buffer, "ϒ", XmlServices.resolveNumericEntity("ϒ")); buffer = StringServices.replace(buffer, "ϖ", XmlServices.resolveNumericEntity("ϖ")); buffer = StringServices.replace(buffer, "∀", XmlServices.resolveNumericEntity("∀")); buffer = StringServices.replace(buffer, "∂", XmlServices.resolveNumericEntity("∂")); buffer = StringServices.replace(buffer, "∃", XmlServices.resolveNumericEntity("∃")); buffer = StringServices.replace(buffer, "∅", XmlServices.resolveNumericEntity("∅")); buffer = StringServices.replace(buffer, "∇", XmlServices.resolveNumericEntity("∇")); buffer = StringServices.replace(buffer, "∈", XmlServices.resolveNumericEntity("∈")); buffer = StringServices.replace(buffer, "∉", XmlServices.resolveNumericEntity("∉")); buffer = StringServices.replace(buffer, "∋", XmlServices.resolveNumericEntity("∋")); buffer = StringServices.replace(buffer, "∏", XmlServices.resolveNumericEntity("∏")); buffer = StringServices.replace(buffer, "∑", XmlServices.resolveNumericEntity("∑")); buffer = StringServices.replace(buffer, "−", XmlServices.resolveNumericEntity("−")); buffer = StringServices.replace(buffer, "∗", XmlServices.resolveNumericEntity("∗")); buffer = StringServices.replace(buffer, "√", XmlServices.resolveNumericEntity("√")); buffer = StringServices.replace(buffer, "∝", XmlServices.resolveNumericEntity("∝")); buffer = StringServices.replace(buffer, "∞", XmlServices.resolveNumericEntity("∞")); buffer = StringServices.replace(buffer, "∠", XmlServices.resolveNumericEntity("∠")); buffer = StringServices.replace(buffer, "∧", XmlServices.resolveNumericEntity("∧")); buffer = StringServices.replace(buffer, "∨", XmlServices.resolveNumericEntity("∨")); buffer = StringServices.replace(buffer, "∩", XmlServices.resolveNumericEntity("∩")); buffer = StringServices.replace(buffer, "∪", XmlServices.resolveNumericEntity("∪")); buffer = StringServices.replace(buffer, "∫", XmlServices.resolveNumericEntity("∫")); buffer = StringServices.replace(buffer, "∴", XmlServices.resolveNumericEntity("∴")); buffer = StringServices.replace(buffer, "∼", XmlServices.resolveNumericEntity("∼")); buffer = StringServices.replace(buffer, "≅", XmlServices.resolveNumericEntity("≅")); buffer = StringServices.replace(buffer, "≈", XmlServices.resolveNumericEntity("≈")); buffer = StringServices.replace(buffer, "≠", XmlServices.resolveNumericEntity("≠")); buffer = StringServices.replace(buffer, "≡", XmlServices.resolveNumericEntity("≡")); buffer = StringServices.replace(buffer, "≤", XmlServices.resolveNumericEntity("≤")); buffer = StringServices.replace(buffer, "≥", XmlServices.resolveNumericEntity("≥")); buffer = StringServices.replace(buffer, "⊂", XmlServices.resolveNumericEntity("⊂")); buffer = StringServices.replace(buffer, "⊃", XmlServices.resolveNumericEntity("⊃")); buffer = StringServices.replace(buffer, "⊄", XmlServices.resolveNumericEntity("⊄")); buffer = StringServices.replace(buffer, "⊆", XmlServices.resolveNumericEntity("⊆")); buffer = StringServices.replace(buffer, "⊇", XmlServices.resolveNumericEntity("⊇")); buffer = StringServices.replace(buffer, "⊕", XmlServices.resolveNumericEntity("⊕")); buffer = StringServices.replace(buffer, "⊗", XmlServices.resolveNumericEntity("⊗")); buffer = StringServices.replace(buffer, "⊥", XmlServices.resolveNumericEntity("⊥")); buffer = StringServices.replace(buffer, "⋅", XmlServices.resolveNumericEntity("⋅")); buffer = StringServices.replace(buffer, "◊", XmlServices.resolveNumericEntity("◊")); buffer = StringServices.replace(buffer, "⌈", XmlServices.resolveNumericEntity("⌈")); buffer = StringServices.replace(buffer, "⌉", XmlServices.resolveNumericEntity("⌉")); buffer = StringServices.replace(buffer, "⌊", XmlServices.resolveNumericEntity("⌊")); buffer = StringServices.replace(buffer, "⌋", XmlServices.resolveNumericEntity("⌋")); buffer = StringServices.replace(buffer, "⟨", XmlServices.resolveNumericEntity("〈")); buffer = StringServices.replace(buffer, "⟩", XmlServices.resolveNumericEntity("〉")); buffer = StringServices.replace(buffer, "←", XmlServices.resolveNumericEntity("←")); buffer = StringServices.replace(buffer, "↑", XmlServices.resolveNumericEntity("↑")); buffer = StringServices.replace(buffer, "→", XmlServices.resolveNumericEntity("→")); buffer = StringServices.replace(buffer, "↓", XmlServices.resolveNumericEntity("↓")); buffer = StringServices.replace(buffer, "↔", XmlServices.resolveNumericEntity("↔")); buffer = StringServices.replace(buffer, "↵", XmlServices.resolveNumericEntity("↵")); buffer = StringServices.replace(buffer, "⇐", XmlServices.resolveNumericEntity("⇐")); buffer = StringServices.replace(buffer, "⇑", XmlServices.resolveNumericEntity("⇑")); buffer = StringServices.replace(buffer, "⇒", XmlServices.resolveNumericEntity("⇒")); buffer = StringServices.replace(buffer, "⇓", XmlServices.resolveNumericEntity("⇓")); buffer = StringServices.replace(buffer, "⇔", XmlServices.resolveNumericEntity("⇔")); buffer = StringServices.replace(buffer, "•", XmlServices.resolveNumericEntity("•")); buffer = StringServices.replace(buffer, "′", XmlServices.resolveNumericEntity("′")); buffer = StringServices.replace(buffer, "″", XmlServices.resolveNumericEntity("″")); buffer = StringServices.replace(buffer, "‾", XmlServices.resolveNumericEntity("‾")); buffer = StringServices.replace(buffer, "⁄", XmlServices.resolveNumericEntity("⁄")); buffer = StringServices.replace(buffer, "℘", XmlServices.resolveNumericEntity("℘")); buffer = StringServices.replace(buffer, "ℑ", XmlServices.resolveNumericEntity("ℑ")); buffer = StringServices.replace(buffer, "ℜ", XmlServices.resolveNumericEntity("ℜ")); buffer = StringServices.replace(buffer, "™", XmlServices.resolveNumericEntity("™")); buffer = StringServices.replace(buffer, "€", XmlServices.resolveNumericEntity("€")); buffer = StringServices.replace(buffer, "ℵ", XmlServices.resolveNumericEntity("ℵ")); buffer = StringServices.replace(buffer, "♠", XmlServices.resolveNumericEntity("♠")); buffer = StringServices.replace(buffer, "♣", XmlServices.resolveNumericEntity("♣")); buffer = StringServices.replace(buffer, "♥", XmlServices.resolveNumericEntity("♥")); buffer = StringServices.replace(buffer, "♦", XmlServices.resolveNumericEntity("♦")); buffer = StringServices.replace(buffer, "Œ", XmlServices.resolveNumericEntity("Œ")); buffer = StringServices.replace(buffer, "œ", XmlServices.resolveNumericEntity("œ")); buffer = StringServices.replace(buffer, "Š", XmlServices.resolveNumericEntity("Š")); buffer = StringServices.replace(buffer, "š", XmlServices.resolveNumericEntity("š")); buffer = StringServices.replace(buffer, "Ÿ", XmlServices.resolveNumericEntity("Ÿ")); buffer = StringServices.replace(buffer, "ƒ", XmlServices.resolveNumericEntity("ƒ")); buffer = StringServices.replace(buffer, " ", XmlServices.resolveNumericEntity(" ")); buffer = StringServices.replace(buffer, " ", XmlServices.resolveNumericEntity(" ")); buffer = StringServices.replace(buffer, " ", XmlServices.resolveNumericEntity(" ")); buffer = StringServices.replace(buffer, "‌", XmlServices.resolveNumericEntity("‌")); buffer = StringServices.replace(buffer, "‍", XmlServices.resolveNumericEntity("‍")); buffer = StringServices.replace(buffer, "‎", XmlServices.resolveNumericEntity("‎")); buffer = StringServices.replace(buffer, "‏", XmlServices.resolveNumericEntity("‏")); buffer = StringServices.replace(buffer, "–", XmlServices.resolveNumericEntity("–")); buffer = StringServices.replace(buffer, "—", XmlServices.resolveNumericEntity("—")); buffer = StringServices.replace(buffer, "‘", XmlServices.resolveNumericEntity("‘")); buffer = StringServices.replace(buffer, "’", XmlServices.resolveNumericEntity("’")); buffer = StringServices.replace(buffer, "‚", XmlServices.resolveNumericEntity("‚")); buffer = StringServices.replace(buffer, "“", XmlServices.resolveNumericEntity("“")); buffer = StringServices.replace(buffer, "”", XmlServices.resolveNumericEntity("”")); buffer = StringServices.replace(buffer, "„", XmlServices.resolveNumericEntity("„")); buffer = StringServices.replace(buffer, "†", XmlServices.resolveNumericEntity("†")); buffer = StringServices.replace(buffer, "‡", XmlServices.resolveNumericEntity("‡")); buffer = StringServices.replace(buffer, "…", XmlServices.resolveNumericEntity("…")); buffer = StringServices.replace(buffer, "‰", XmlServices.resolveNumericEntity("‰")); buffer = StringServices.replace(buffer, "‹", XmlServices.resolveNumericEntity("‹")); buffer = StringServices.replace(buffer, "›", XmlServices.resolveNumericEntity("›")); buffer = StringServices.replace(buffer, "ˆ", XmlServices.resolveNumericEntity("ˆ")); buffer = StringServices.replace(buffer, "˜", XmlServices.resolveNumericEntity("˜")); return buffer; } } src/java/org/dbdoclet/xiphias/NodeSerializer.java0000644000000000000000000002160412124530526021065 0ustar rootrootpackage org.dbdoclet.xiphias; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.util.ArrayList; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.Sfv; import org.dbdoclet.progress.ProgressEvent; import org.dbdoclet.progress.ProgressListener; import org.dbdoclet.xiphias.dom.DocumentImpl; import org.dbdoclet.xiphias.dom.ElementImpl; import org.dbdoclet.xiphias.dom.NodeImpl; import org.dbdoclet.xiphias.dom.TextImpl; import org.w3c.dom.Comment; import org.w3c.dom.Document; import org.w3c.dom.DocumentType; import org.w3c.dom.Element; import org.w3c.dom.Entity; import org.w3c.dom.EntityReference; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.Text; public class NodeSerializer { private static Log logger = LogFactory.getLog(NodeSerializer.class); private ArrayList listeners; private int literalContext = 0; public static String toXML(Node node) { try { StringWriter buffer = new StringWriter(); NodeSerializer serializer = new NodeSerializer(); serializer.write(node, buffer); return buffer.toString(); } catch (IOException oops) { return oops.getMessage(); } } public static void writeDocumentType(DocumentType docType, Writer out) throws IOException { out.write(" 0) { out.write(" PUBLIC '" + docType.getPublicId() + "'"); } else { out.write(" SYSTEM"); } out.write(" '" + docType.getSystemId() + "'"); NamedNodeMap entityMap = docType.getEntities(); if (entityMap != null && entityMap.getLength() > 0) { out.write("[\n"); for (int i = 0; i < entityMap.getLength(); i++) { Entity entity = (Entity) entityMap.item(i); out.write("\n"); } out.write("]"); } out.write(">"); out.write(Sfv.LSEP); } public void setProgressListeners(ArrayList listeners) { this.listeners = listeners; } public void write(Node node, File file) throws IOException { write(node, file, "UTF-8"); } public void write(Node node, File file, String encoding) throws IOException { if (node == null) { throw new IllegalArgumentException( "The argument node must not be null!"); } if (file == null) { throw new IllegalArgumentException( "The argument file must not be null!"); } FileOutputStream fos = null; OutputStreamWriter out = null; try { fos = new FileOutputStream(file); out = new OutputStreamWriter(fos, encoding); write(node, out, ""); } finally { /* * if (fos != null) { fos.close(); } */ if (out != null) { out.close(); } } } public void write(Node node, Writer out) throws IOException { write(node, out, ""); } public void write(Node node, Writer out, boolean inMixedContent, String indent) throws IOException { if (node == null) { throw new IllegalArgumentException( "The argument node must not be null!"); } if (out == null) { throw new IllegalArgumentException( "The argument out must not be null!"); } NodeList nodes; ProgressEvent event = new ProgressEvent(node.toString()); fireProgressEvent(event); // logger.debug("node=" + node); switch (node.getNodeType()) { case Node.DOCUMENT_FRAGMENT_NODE: nodes = node.getChildNodes(); if (nodes != null) { for (int i = 0; i < nodes.getLength(); i++) { write(nodes.item(i), out, ""); out.write(Sfv.LSEP); } } break; case Node.DOCUMENT_NODE: Document tdoc = (Document) node; Element documentElement = tdoc.getDocumentElement(); if (documentElement != null) { if (tdoc instanceof DocumentImpl) { out.write(((DocumentImpl) tdoc).createXmlDeclaration()); } else { out.write("" + Sfv.LSEP); } DocumentType docType = tdoc.getDoctype(); if (docType != null) { writeDocumentType(docType, out); } write(documentElement, out, ""); } else { NodeList children = tdoc.getChildNodes(); if (children != null && children.getLength() != 0) { for (int i = 0; i < children.getLength(); i++) { write(children.item(i), out, ""); out.write(Sfv.LSEP); } } } break; case Node.DOCUMENT_TYPE_NODE: writeDocumentType((DocumentType) node, out); break; case Node.ENTITY_NODE: Entity entity = (Entity) node; out.write("&" + entity.getNodeName() + ";"); break; case Node.ENTITY_REFERENCE_NODE: EntityReference entityReference = (EntityReference) node; out.write("&" + resolveEntityReference(entityReference.getNodeName()) + ";"); break; case Node.ELEMENT_NODE: try { writeElement(node, out, inMixedContent, indent); } catch (StackOverflowError oops) { logger.fatal("[NodeSerializer.write] StackOverflowError. Possibly recursive structure detected!!! Node: " + node.toString()); } break; case Node.TEXT_NODE: Text text = (Text) node; String data = text.getData(); // logger.info("text=[" + data + "]"); if (data != null) { if (isInsideLiteralElement() == false) { data = XmlServices.normalizeText(data); } } if (text instanceof TextImpl) { if (((TextImpl) text).isRawData() == true) { out.write(data); } else { out.write(XmlServices.textToXml(data)); } } else { out.write(XmlServices.textToXml(data)); } break; /* * case Node.CDATA_SECTION_NODE: * * CDATASection cdata = (CDATASection) node; out.write(""); break; */ case Node.COMMENT_NODE: Comment comment = (Comment) node; out.write(indent + ""); out.write(Sfv.LSEP); break; case Node.PROCESSING_INSTRUCTION_NODE: ProcessingInstruction pi = (ProcessingInstruction) node; out.write(indent + ""); out.write(Sfv.LSEP); break; } } private boolean isInsideLiteralElement() { if (literalContext > 0) { return true; } return false; } protected boolean isInsideLiteralElement(Text text) { Node parent = text.getParentNode(); while (parent != null) { if (parent instanceof ElementImpl) { ElementImpl elem = (ElementImpl) parent; if (elem.isLiteral()) { return true; } } } return false; } private String resolveEntityReference(String entityName) { if (entityName == null) { return null; } if (entityName.equals("linefeed")) { return "#x0A"; } return entityName; } public void write(Node node, Writer out, String indent) throws IOException { write(node, out, false, indent); } private void fireProgressEvent(ProgressEvent event) { if (listeners != null) { for (ProgressListener listener : listeners) { listener.progress(event); } } } private void writeElement(Node node, Writer out, boolean inMixedContent, String indent) throws IOException { Element elem = (Element) node; String name = elem.getNodeName(); ElementImpl elemImpl = null; if (elem instanceof ElementImpl) { elemImpl = (ElementImpl) elem; } if (inMixedContent == false) { out.write(indent + "<" + name); } else { out.write("<" + name); } if (elemImpl != null) { out.write(elemImpl.getAttributesAsText()); if (elemImpl.isLiteral()) { literalContext++; } } else { out.write(W3cServices.getAttributesAsText(elem)); } NodeList children = elem.getChildNodes(); if (children != null && children.getLength() != 0) { out.write(">"); boolean hasMixedContent = false; for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ENTITY_REFERENCE_NODE) { hasMixedContent = true; } if (child.getNodeType() == Node.TEXT_NODE) { String buffer = child.getTextContent(); if (buffer != null && buffer.trim().length() > 0) { hasMixedContent = true; } } } if (elemImpl != null) { if (elemImpl.getFormatType() != NodeImpl.FORMAT_BLOCK) { hasMixedContent = true; } } if (hasMixedContent == false) { out.write(Sfv.LSEP); } for (int i = 0; i < children.getLength(); i++) { write(children.item(i), out, hasMixedContent, indent + " "); } if (hasMixedContent == false) { out.write(indent + ""); out.write(Sfv.LSEP); } else { out.write(""); if (inMixedContent == false) { out.write(Sfv.LSEP); } } } else { out.write("/>"); if (inMixedContent == false) { out.write(Sfv.LSEP); } } if (elemImpl != null && elemImpl.isLiteral()) { literalContext--; } } } src/java/org/dbdoclet/xiphias/Resources_de.properties0000644000000000000000000000175612124530526022051 0ustar rootroot# Java Resource Bundle # Modified by Zaval JRC Editor (C) Zaval CE Group # http://www.zaval.org/products/jrc-editor/ C_ERROR=Fehler C_INCLUDING_FILE=Einbinden der Datei {0}... C_XML_VALIDATION_ERROR={0}:{1}:{2}\n\ Fehler in Zeile {1}, Spalte {2}\n\ {3} C_XML_VALIDATION_ERROR_FILE_CAN_NOT_READ={0}: Die Datei darf nicht gelesen werden C_XML_VALIDATION_ERROR_FILE_NOT_FOUND={0}: Die Datei konnte nicht gefunden werden.\ C_XML_VALIDATION_FAILED=Die Validierung der XML-Datei ist FEHLGESCHLAGEN! C_XML_VALIDATION_FATAL={0}:{1}:{2}\n\ Fataler Fehler in Zeile {1}, Spalte {2}\n\ {3} C_XML_VALIDATION_NUMBER_OF_ERRORS=Anzahl der Fehler: {0} C_XML_VALIDATION_OF_FILE=Validierung der Datei {0}. C_XML_VALIDATION_REPORT=Report der XML-Validierung C_XML_VALIDATION_REPORT_DATE=Datum: {0} C_XML_VALIDATION_REPORT_TIME=Uhrzeit: {0} C_XML_VALIDATION_SUCCESSFUL=Die Validierung der XML-Datei verlief ERFOLGREICH. C_XML_VALIDATION_WARNING={0}:{1}:{2}\n\ Warnung in Zeile {1}, Spalte {2}\n\ {3} src/java/org/dbdoclet/xiphias/XPathServices.java0000644000000000000000000001010012124530526020663 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet.xiphias; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.commons.jxpath.CompiledExpression; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Node; public class XPathServices { private static Log logger = LogFactory.getLog(XPathServices.class); public static Object getValue(Object contextBean, String query) { return getValue(contextBean, null, null, query); } /** * Die Methode getValue liefert den Wert eines Kontent. * * @param contextBean * Object * @param query * String * @return Object */ public static Object getValue(Object contextBean, String namespace, String namespaceUrl, String query) { Object obj = null; JXPathContext context = JXPathContext.newContext(contextBean); if (namespace != null && namespaceUrl != null) { context.registerNamespace(namespace, namespaceUrl); } CompiledExpression expr = JXPathContext.compile(query); try { obj = expr.getValue(context); } catch (JXPathException oops) { logger.debug("JXPathException: " + oops.getMessage()); obj = null; } return obj; } public static ArrayList getValues(Object contextBean, String query) { return getValues(contextBean, null, null, query); } @SuppressWarnings("unchecked") public static ArrayList getValues(Object contextBean, String namespace, String namespaceUrl, String query) { Object obj = null; JXPathContext context = JXPathContext.newContext(contextBean); if (namespace != null && namespaceUrl != null) { context.registerNamespace(namespace, namespaceUrl); } CompiledExpression expr = JXPathContext.compile(query); Iterator iterator; ArrayList list = new ArrayList(); try { // Unchecked iterator iterator = expr.iterate(context); while (iterator.hasNext()) { obj = iterator.next(); if (obj != null) { list.add(obj.toString()); } } } catch (JXPathException oops) { oops.printStackTrace(); } return list; } public static ArrayList getNodes(Object contextBean, String query) { return getNodes(contextBean, null, null, query); } public static ArrayList getNodes(Object contextBean, String namespace, String namespaceUrl, String query) { JXPathContext context = JXPathContext.newContext(contextBean); if (namespace != null && namespaceUrl != null) { context.registerNamespace(namespace, namespaceUrl); } List list = context.selectNodes(query); ArrayList nodeList = new ArrayList(); for (Object obj : list) { if (obj instanceof Node) { nodeList.add((Node) obj); } } return nodeList; } public static Node getNode(Object contextBean, String query) { return getNode(contextBean, null, null, query); } public static Node getNode(Object contextBean, String namespace, String namespaceUrl, String query) { ArrayList list = getNodes(contextBean, namespace, namespaceUrl, query); if (list.size() > 0) { return list.get(0); } else { return null; } } } src/java/org/dbdoclet/xiphias/ImageServices.java0000644000000000000000000002253612124530526020701 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.xiphias; import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.HeadlessException; import java.awt.Image; import java.awt.Transparency; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.PixelGrabber; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.xmlgraphics.java2d.GraphicContext; import org.apache.xmlgraphics.java2d.ps.EPSDocumentGraphics2D; import org.dbdoclet.service.FileServices; public class ImageServices { private static Log logger = LogFactory.getLog(ImageServices.class); public static double A4_WIDTH = 210.0; public static double A4_HEIGHT = 297.0; public static double INCH = 25.4; public static int DPI = 72; public static int getWidth(File imageFile) { if (imageFile == null) { throw new IllegalArgumentException( "The argument imageFile must not be null!"); } try { ImageIcon image = new ImageIcon(imageFile.toURI().toURL()); return image.getIconWidth(); } catch (Throwable oops) { logger.fatal("ImageServices.getWidth", oops); return 100; } } public static int getHeight(File imageFile) { if (imageFile == null) { throw new IllegalArgumentException( "The argument imageFile must not be null!"); } try { ImageIcon image = new ImageIcon(imageFile.toURI().toURL()); return image.getIconHeight(); } catch (Throwable oops) { logger.fatal("ImageServices.getWidth", oops); return 100; } } public static File giftopng(File gifFile) throws IOException { if (gifFile == null) { throw new IllegalArgumentException( "The argument gifFile must not be null!"); } String pngPath = FileServices.getFileBase(gifFile) + ".png"; File pngFile = new File(pngPath); return giftopng(gifFile, pngFile); } public static File giftopng(File gifFile, File pngFile) throws IOException { if (gifFile == null) { throw new IllegalArgumentException( "The argument gifFile must not be null!"); } if (pngFile == null) { throw new IllegalArgumentException( "The argument pngFile must not be null!"); } BufferedImage image = ImageIO.read(gifFile); ImageIO.write(image, "png", pngFile); return pngFile; } public static String toBase64(File inFile) throws IOException { if (inFile == null) { throw new IllegalArgumentException( "The argument inFile must not be null!"); } if (inFile.exists() == false) { throw new IllegalArgumentException( "The argument inFile must exist!"); } byte[] enc = Base64.encodeBase64(FileServices.readToByteArray(inFile)); return new String(enc, "UTF-8"); } public static String toXml(File inFile) throws IOException { String xml = toBase64(inFile); xml = "\n" + "" + xml + "\n"; return xml; } public static void toEps(File inFile, File epsFile) throws IOException { if (inFile == null) { throw new IllegalArgumentException( "The argument inFile must not be null!"); } if (epsFile == null) { throw new IllegalArgumentException( "The argument epsFile must not be null!"); } String format = FileServices.getExtension(inFile.getName()); format = format.toLowerCase(); if (format.equals("gif") == false && format.equals("jpg") == false && format.equals("png") == false && format.equals("bmp") == false) { throw new IllegalArgumentException("UnsupportedFormat " + format + "!"); } if (inFile.exists() == false) { throw new FileNotFoundException("No such file : " + inFile.getAbsolutePath()); } if (inFile.canRead() == false) { throw new IOException("File is not readable: " + inFile.getAbsolutePath()); } BufferedImage image = ImageIO.read(inFile); EPSDocumentGraphics2D graphics = new EPSDocumentGraphics2D(false); graphics.setGraphicContext(new GraphicContext()); FileOutputStream out = new FileOutputStream(epsFile); int maxWidth = (int) (A4_WIDTH * 0.95 / INCH) * DPI; if (image.getWidth() > maxWidth) { double ratio = (double) image.getHeight() / (double) image.getWidth(); int newHeight = (int) (ratio * maxWidth); // This code ensures that all the pixels in the image are loaded image = toBufferedImage(image.getScaledInstance(maxWidth, newHeight, Image.SCALE_SMOOTH)); } graphics.setupDocument(out, image.getWidth(null), image.getHeight(null)); graphics.drawImage(image, 0, 0, null); graphics.finish(); } public static boolean scale(File imageFile, int maxWidth) throws IOException { if (imageFile == null) { throw new IllegalArgumentException( "The argument imageFile must not be null!"); } if (maxWidth < 1) { throw new IllegalArgumentException( "The argument maxWidth must not be less than 1!"); } String format = FileServices.getExtension(imageFile.getName()); BufferedImage image = ImageIO.read(imageFile); logger.debug("Bild = " + imageFile.getName()); int width = image.getWidth(); logger.debug("Bildbreite = " + width); int height = image.getHeight(); logger.debug("Bildhöhe = " + height); if (width > maxWidth) { float factor = (float) maxWidth / (float) width; logger.debug("Skalierungsfaktor = " + factor); height *= factor; width = maxWidth; Image scaledImage = image.getScaledInstance(width, height, Image.SCALE_SMOOTH); BufferedImage scaledBufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics graphics = scaledBufferedImage.getGraphics(); graphics.drawImage(scaledImage, 0, 0, null); ImageIO.write(scaledBufferedImage, format, imageFile); return true; } return false; } public static ImageIcon getScaledIcon(ImageIcon icon, int width, int height) { if (height < 1 && width < 1) { throw new IllegalArgumentException( "Both arguments height and width must not be smaller than 1!"); } int iconHeight = icon.getIconHeight(); int iconWidth = icon.getIconWidth(); if (iconHeight < 1 && iconWidth < 1) { return icon; } if (width < 1) { width = (height * iconWidth) / iconHeight; if (width < 1) { width = 1; } } if (height < 1) { height = (width * iconHeight) / iconWidth; if (height < 1) { height = 1; } } Image image = icon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH); icon.setImage(image); return icon; } public static BufferedImage toBufferedImage(Image image) { if (image == null) { throw new IllegalArgumentException( "The argument image must not be null!"); } if (image instanceof BufferedImage) { return (BufferedImage) image; } // This code ensures that all the pixels in the image are loaded image = new ImageIcon(image).getImage(); // Determine if the image has transparent pixels; for this method's // implementation, see e661 Determining If an Image Has Transparent // Pixels boolean hasAlpha = hasAlpha(image); // Create a buffered image with a format that's compatible with the // screen BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); try { // Determine the type of transparency of the new buffered image int transparency = Transparency.OPAQUE; if (hasAlpha) { transparency = Transparency.BITMASK; } // Create the buffered image GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency); } catch (HeadlessException e) { // The system does not have a screen logger.error("headless exception creating buffered image", e); } if (bimage == null) { // Create a buffered image using the default color model int type = BufferedImage.TYPE_INT_RGB; if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; } bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); } // Copy image to buffered image Graphics g = bimage.createGraphics(); // Paint the image onto the buffered image g.drawImage(image, 0, 0, null); g.dispose(); return bimage; } /** * This method returns true if the specified image has transparent pixels */ public static boolean hasAlpha(Image image) { // If buffered image, the color model is readily available if (image instanceof BufferedImage) { BufferedImage bimage = (BufferedImage) image; return bimage.getColorModel().hasAlpha(); } // Use a pixel grabber to retrieve the image's color model; // grabbing a single pixel is usually sufficient PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false); try { pg.grabPixels(); } catch (InterruptedException oops) { oops.printStackTrace(); } // Get the image's color model ColorModel cm = pg.getColorModel(); return cm.hasAlpha(); } } src/java/org/dbdoclet/xiphias/XmlValidationResult.java0000644000000000000000000002032012124530526022112 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2006 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.xiphias; import java.io.File; import java.io.StringReader; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Iterator; import java.util.Locale; import java.util.ResourceBundle; import org.dbdoclet.service.ResourceServices; import org.w3c.dom.bootstrap.DOMImplementationRegistry; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSInput; import org.w3c.dom.ls.LSResourceResolver; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXParseException; /** * Die Klasse XmlValidationResult wird benachrichtigt falls beim * Parsen einer XML-Datei ein Fehler auftritt. * * Die Fehlermeldungen werden formatiert und auf System.err über * die Konsole ausgegeben. * * @author Michael Fuchs * @version 1.0 */ public class XmlValidationResult implements ErrorHandler, LSResourceResolver { private boolean hasErrors = false; private boolean fileNotFound = false; private boolean canNotRead = false; private int errorCounter = 0; private int warningCounter = 0; private final ArrayList errorList; private final ArrayList warningList; private final ArrayList exceptionList; private Throwable throwable; private final File xmlFile; private final ResourceBundle res; private String systemId; public XmlValidationResult(File xmlFile, Locale locale) { if (locale == null) { throw new IllegalArgumentException( "The argument locale must not be null!"); } this.xmlFile = xmlFile; res = ResourceBundle .getBundle("org/dbdoclet/xiphias/Resources", locale); errorList = new ArrayList(); warningList = new ArrayList(); exceptionList = new ArrayList(); } public XmlValidationResult(File xmlFile) { this(xmlFile, Locale.getDefault()); } public XmlValidationResult(String systemId) { this(null, Locale.getDefault()); this.systemId = systemId; } public File getXmlFile() { return xmlFile; } public String getSourceDescription() { if (xmlFile != null) { return xmlFile.getAbsolutePath(); } else { if (systemId == null || systemId.length() == 0) { return "Anonymous InputStream"; } else { return systemId; } } } public boolean failed() { return hasErrors; } public void setFileNotFound(boolean fileNotFound) { this.fileNotFound = fileNotFound; String msg = MessageFormat.format(ResourceServices.getString(res, "C_XML_VALIDATION_ERROR_FILE_NOT_FOUND"), getSourceDescription()); errorList.add(msg); hasErrors = true; errorCounter++; } public boolean getFileNotFound() { return fileNotFound; } public void setCanNotRead(boolean canNotRead) { this.canNotRead = canNotRead; String msg = MessageFormat.format( res.getString("C_XML_VALIDATION_ERROR_FILE_CAN_NOT_READ"), getSourceDescription()); errorList.add(msg); hasErrors = true; errorCounter++; } public boolean getCanNotRead() { return canNotRead; } public int getNumOfErrors() { return errorCounter; } public void setThrowable(Throwable throwable) { if (throwable == null) { throw new IllegalArgumentException( "The argument throwable must not be null!"); } this.throwable = throwable; String msg = "(" + throwable.getClass().getName() + ") " + throwable.getMessage(); if (msg == null || msg.length() == 0) { msg = throwable.getClass().getName(); } msg = getSourceDescription() + ": " + msg; errorList.add(msg); hasErrors = true; errorCounter++; } public Throwable getThrowable() { return throwable; } /** * Die Methode fatalError wird bei Auftreten eines fatalen * Fehlers vom Sax-Parser aufgerufen. * * @param oops * SAXParseException */ @Override public void fatalError(SAXParseException oops) { errorCounter++; String msg = MessageFormat.format( ResourceServices.getString(res, "C_XML_VALIDATION_FATAL"), getSourceDescription(), String.valueOf(oops.getLineNumber()), String.valueOf(oops.getColumnNumber()), oops.getMessage()); errorList.add(msg); exceptionList.add(oops); hasErrors = true; } /** * Die Methode error wird bei Auftreten eines Fehlers vom * Sax-Parser aufgerufen. * * @param oops * SAXParseException */ @Override public void error(SAXParseException oops) { errorCounter++; String msg = MessageFormat.format( ResourceServices.getString(res, "C_XML_VALIDATION_ERROR"), getSourceDescription(), String.valueOf(oops.getLineNumber()), String.valueOf(oops.getColumnNumber()), oops.getMessage()); errorList.add(msg); exceptionList.add(oops); hasErrors = true; } /** * Die Methode warning wird bei Auftreten einer Warnung vom * SAX-Parser aufgerufen. * * @param oops * SAXParseException */ @Override public void warning(SAXParseException oops) { warningCounter++; String msg = MessageFormat.format( ResourceServices.getString(res, "C_XML_VALIDATION_WARNING"), getSourceDescription(), String.valueOf(oops.getLineNumber()), String.valueOf(oops.getColumnNumber()), oops.getMessage()); warningList.add(msg); // exceptionList.add(oops); } public String createTextReport() { return createReport(false); } public String createHtmlReport() { return createReport(true); } public String createReport(boolean isHtml) { String msg; StringBuffer buffer = new StringBuffer(); buffer.append('\n'); if (isHtml) { buffer.append("

      "); } msg = MessageFormat.format( ResourceServices.getString(res, "C_XML_VALIDATION_OF_FILE"), getSourceDescription()); buffer.append(msg); if (isHtml) { buffer.append("

      "); } Iterator iterator = warningList.iterator(); while (iterator.hasNext()) { if (isHtml) { buffer.append("
      ");
      			}
      
      			buffer.append('\n');
      
      			msg = iterator.next();
      			buffer.append(msg);
      
      			if (isHtml) {
      				buffer.append("
      "); } buffer.append('\n'); } buffer.append('\n'); if (failed() == false) { if (isHtml) { buffer.append("

      "); buffer.append(ResourceServices.getString(res, "C_XML_VALIDATION_SUCCESSFUL")); buffer.append("

      "); } else { buffer.append(ResourceServices.getString(res, "C_XML_VALIDATION_SUCCESSFUL")); } buffer.append('\n'); } else { iterator = errorList.iterator(); while (iterator.hasNext()) { if (isHtml) { buffer.append("
      ");
      				}
      
      				buffer.append('\n');
      
      				msg = iterator.next();
      				buffer.append(msg);
      
      				if (isHtml) {
      					buffer.append("
      "); } buffer.append('\n'); } buffer.append('\n'); msg = MessageFormat.format(ResourceServices.getString(res, "C_XML_VALIDATION_NUMBER_OF_ERRORS"), String .valueOf(errorCounter)); buffer.append(msg); buffer.append('\n'); if (isHtml) { buffer.append("

      "); buffer.append(ResourceServices.getString(res, "C_XML_VALIDATION_FAILED")); buffer.append("

      "); } else { buffer.append(ResourceServices.getString(res, "C_XML_VALIDATION_FAILED")); } buffer.append('\n'); } return buffer.toString(); } @Override public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { // System.out.println("XMLValidationResult: Resolving resource [type=" + // type // + ", namespaceURI=" + namespaceURI + ", publicId=" + publicId + // ", systemId=" // + systemId + ", baseURI=" + baseURI); if (systemId != null && systemId.length() > 0) { if (systemId.startsWith("http://")) { try { DOMImplementationRegistry registry = DOMImplementationRegistry .newInstance(); DOMImplementationLS domImpl = (DOMImplementationLS) registry .getDOMImplementation("LS"); LSInput input = domImpl.createLSInput(); input.setCharacterStream(new StringReader("")); return input; } catch (Exception oops) { oops.printStackTrace(); } } } return null; } } src/java/org/dbdoclet/xiphias/dom/0000755000000000000000000000000012124530534016056 5ustar rootrootsrc/java/org/dbdoclet/xiphias/dom/DOMTraverser.java0000644000000000000000000000327712124530526021250 0ustar rootrootpackage org.dbdoclet.xiphias.dom; import java.util.ArrayList; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class DOMTraverser { private ArrayList visitors = new ArrayList(); public DOMTraverser(INodeVisitor visitor) { addVisitor(visitor); } public void addVisitor(INodeVisitor visitor) { visitors.add(visitor); } public void traverse(Node node) throws Exception { if (node.getNodeType() == Node.ELEMENT_NODE) { openTag(node); } accept(node); if ((node.getNodeType() == Node.ELEMENT_NODE) && node.hasAttributes()) { NamedNodeMap attrs = ((Element) node).getAttributes(); for (int i = 0; i < attrs.getLength(); i++) { Node attr = attrs.item(i); accept(attr); } } if (node.hasChildNodes()) { NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); traverse(child); } } if (node.getNodeType() == Node.ELEMENT_NODE) { closeTag(node); } } private void openTag(Node node) throws Exception { for (INodeVisitor visitor : visitors) { visitor.openTag(node); } } private void accept(Node node) throws Exception { for (INodeVisitor visitor : visitors) { visitor.accept(node); } } private void closeTag(Node node) throws Exception { for (INodeVisitor visitor : visitors) { visitor.closeTag(node); } } } src/java/org/dbdoclet/xiphias/dom/TextImpl.java0000644000000000000000000000360612124530526020475 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet.xiphias.dom; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.DOMException; import org.w3c.dom.Text; public class TextImpl extends CharacterDataImpl implements Text { private static Log logger = LogFactory.getLog(TextImpl.class); public TextImpl(String text, NodeImpl parent) { super(); setNodeType(TEXT_NODE); setNodeName("#text"); setParentNode(parent); setData(text); logger.debug("Text text=[" + text + "]"); } public TextImpl(String text) { this(text, null); } /** * The method toString returns the first 24 characters of the * text of this node. * * If the length of the text is greater than 24 characters, the text is * truncated and three digits are appended. * * @return a String value */ @Override public String toString() { String data = getData(); if ((data == null) || (data.length() == 0)) { return ""; } if (data.length() < 24) { return data.trim(); } else { return data.substring(0, 23) + "..."; } } @Override public String getWholeText() { // TODO Auto-generated method stub return null; } @Override public boolean isElementContentWhitespace() { // TODO Auto-generated method stub return false; } @Override public Text replaceWholeText(String content) throws DOMException { // TODO Auto-generated method stub return null; } @Override public Text splitText(int offset) throws DOMException { // TODO Auto-generated method stub return null; } } src/java/org/dbdoclet/xiphias/dom/TransformInstruction.java0000644000000000000000000000123712124530526023142 0ustar rootrootpackage org.dbdoclet.xiphias.dom; import org.w3c.dom.Node; /** * TransformInstruction is used by a Node to tell a transformation engine, by * which node or subtree it wants to be replaced and wich node is new parent in * the resulting tree for future appends. * * @author michael * */ public class TransformInstruction { private Node replacement; private Node newParent; public Node getReplacement() { return replacement; } public void setReplacement(NodeImpl replacement) { this.replacement = replacement; } public Node getNewParent() { return newParent; } public void setNewParent(NodeImpl newParent) { this.newParent = newParent; } } src/java/org/dbdoclet/xiphias/dom/DocumentImpl.java0000644000000000000000000001313712124530526021327 0ustar rootroot/* * ### Copyright (C) 2003-2009 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@dbdoclet.org * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.xiphias.dom; import org.dbdoclet.xiphias.W3cServices; import org.w3c.dom.Attr; import org.w3c.dom.CDATASection; import org.w3c.dom.Comment; import org.w3c.dom.DOMConfiguration; import org.w3c.dom.DOMException; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; import org.w3c.dom.DocumentFragment; import org.w3c.dom.DocumentType; import org.w3c.dom.Element; import org.w3c.dom.EntityReference; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.Text; public class DocumentImpl extends NodeImpl implements Document { private String xmlEncoding = "UTF-8"; private String xmlVersion = "1.0"; private ElementImpl documentElement; private DocumentType docType; public DocumentImpl() { super("#document", null); setNodeType(DOCUMENT_NODE); setXmlEncoding("UTF-8"); setXmlVersion("1.0"); } @Override public Node adoptNode(Node source) throws DOMException { throw new IllegalStateException("Not yet implemented"); } @Override public Attr createAttribute(String name) throws DOMException { throw new IllegalStateException("Not yet implemented"); } @Override public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException { throw new IllegalStateException("Not yet implemented"); } @Override public CDATASection createCDATASection(String data) throws DOMException { throw new IllegalStateException("Not yet implemented"); } @Override public Comment createComment(String data) { throw new IllegalStateException("Not yet implemented"); } @Override public DocumentFragment createDocumentFragment() { throw new IllegalStateException("Not yet implemented"); } @Override public ElementImpl createElement(String tagName) throws DOMException { ElementImpl elem = new ElementImpl(tagName); elem.setDocument(this); elem.setFormatType(FORMAT_BLOCK); return elem; } @Override public Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException { throw new IllegalStateException("Not yet implemented"); } @Override public EntityReference createEntityReference(String name) throws DOMException { throw new IllegalStateException("Not yet implemented"); } @Override public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException { throw new IllegalStateException("Not yet implemented"); } @Override public Text createTextNode(String data) { TextImpl text = new TextImpl(data); return text; } public String createXmlDeclaration() { return "\n"; } @Override public DocumentType getDoctype() { return docType; } @Override public ElementImpl getDocumentElement() { return documentElement; } @Override public String getDocumentURI() { throw new IllegalStateException("Not yet implemented"); } @Override public DOMConfiguration getDomConfig() { throw new IllegalStateException("Not yet implemented"); } @Override public Element getElementById(String elementId) { throw new IllegalStateException("Not yet implemented"); } @Override public NodeList getElementsByTagName(String tagname) { throw new IllegalStateException("Not yet implemented"); } @Override public NodeList getElementsByTagNameNS(String namespaceURI, String localName) { throw new IllegalStateException("Not yet implemented"); } @Override public DOMImplementation getImplementation() { throw new IllegalStateException("Not yet implemented"); } @Override public String getInputEncoding() { throw new IllegalStateException("Not yet implemented"); } @Override public boolean getStrictErrorChecking() { throw new IllegalStateException("Not yet implemented"); } @Override public String getXmlEncoding() { return xmlEncoding; } @Override public boolean getXmlStandalone() { throw new IllegalStateException("Not yet implemented"); } @Override public String getXmlVersion() { return xmlVersion; } @Override public Node importNode(Node importedNode, boolean deep) throws DOMException { Node clone = W3cServices.copyNode(this, importedNode); if (deep == false) { NodeList childList = clone.getChildNodes(); for (int i = 0; i < childList.getLength(); i++) { clone.removeChild(childList.item(i)); } } return clone; } @Override public void normalizeDocument() { throw new IllegalStateException("Not yet implemented"); } @Override public Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException { throw new IllegalStateException("Not yet implemented"); } public void setDocumentElement(ElementImpl documentElement) { this.documentElement = documentElement; } public void setDoctype(DocumentType docType) { this.docType = docType; } @Override public void setDocumentURI(String documentURI) { throw new IllegalStateException("Not yet implemented"); } @Override public void setStrictErrorChecking(boolean strictErrorChecking) { throw new IllegalStateException("Not yet implemented"); } public void setXmlEncoding(String xmlEncoding) { this.xmlEncoding = xmlEncoding; } @Override public void setXmlStandalone(boolean xmlStandalone) throws DOMException { throw new IllegalStateException("Not yet implemented"); } @Override public void setXmlVersion(String xmlVersion) throws DOMException { this.xmlVersion = xmlVersion; } } src/java/org/dbdoclet/xiphias/dom/EntityImpl.java0000644000000000000000000000275312124530526021027 0ustar rootrootpackage org.dbdoclet.xiphias.dom; import org.w3c.dom.Entity; import org.w3c.dom.Node; public class EntityImpl extends NodeImpl implements Entity { private String inputEncoding; private String notationName; private String publicId; private String systemId; private String xmlEncoding; private String xmlVersion; public EntityImpl(String name, String systemId) { this.systemId = systemId; setNodeType(Node.ENTITY_NODE); setNodeName(name); } public String getInputEncoding() { return inputEncoding; } public String getNotationName() { return notationName; } public String getPublicId() { return publicId; } public String getSystemId() { return systemId; } public String getXmlEncoding() { return xmlEncoding; } public String getXmlVersion() { return xmlVersion; } public void setInputEncoding(String inputEncoding) { this.inputEncoding = inputEncoding; } public void setNotationName(String notationName) { this.notationName = notationName; } public void setPublicId(String publicId) { this.publicId = publicId; } public void setSystemId(String systemId) { this.systemId = systemId; } public void setXmlEncoding(String xmlEncoding) { this.xmlEncoding = xmlEncoding; } public void setXmlVersion(String xmlVersion) { this.xmlVersion = xmlVersion; } } src/java/org/dbdoclet/xiphias/dom/ElementByTagNameVisitor.java0000644000000000000000000000173412124530526023430 0ustar rootrootpackage org.dbdoclet.xiphias.dom; import org.w3c.dom.Element; import org.w3c.dom.Node; public class ElementByTagNameVisitor implements INodeVisitor { private final String tagName; private NodeListImpl elementList; public NodeListImpl getElementList() { return elementList; } public ElementByTagNameVisitor(String tagName) { this.tagName = tagName; elementList = new NodeListImpl(); } public void accept(Node node) { if (node == null || node instanceof Element == false) { return; } Element element = (Element) node; String otherTagName = element.getTagName(); if (tagName != null && otherTagName != null) { if (tagName.equals(otherTagName)) { elementList.add((NodeImpl) element); } } } @Override public void openTag(Node node) { // } @Override public void closeTag(Node node) { // } } src/java/org/dbdoclet/xiphias/dom/NodeListImpl.java0000644000000000000000000000345512124530526021274 0ustar rootroot/* * ### Copyright (C) 2001-2003 Michael Fuchs ### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Michael Fuchs * E-Mail: mfuchs@unico-consulting.com * * RCS Information: * --------------- * Id.........: $Id: NodeList.java,v 1.1.1.1 2004/12/21 14:00:21 mfuchs Exp $ * Author.....: $Author: mfuchs $ * Date.......: $Date: 2004/12/21 14:00:21 $ * Revision...: $Revision: 1.1.1.1 $ * State......: $State: Exp $ */ package org.dbdoclet.xiphias.dom; import java.util.ArrayList; import java.util.Iterator; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class NodeListImpl extends ArrayList implements NodeList { private static final long serialVersionUID = 1L; public int getLength() { return size(); } public Node item(int index) { if ((index < 0) || (index >= size())) { return null; } Object obj = get(index); if (obj instanceof Node) { return (Node) obj; } else { throw new IllegalStateException( "Object in NodeList is not of type Node but of type " + obj); } } @Override public Iterator iterator() { Iterator iterator = super.iterator(); return iterator; } } src/java/org/dbdoclet/xiphias/dom/NamedNodeMapImpl.java0000644000000000000000000000263312124530526022040 0ustar rootrootpackage org.dbdoclet.xiphias.dom; import java.util.LinkedHashMap; import org.w3c.dom.DOMException; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class NamedNodeMapImpl extends LinkedHashMap implements NamedNodeMap { private static final long serialVersionUID = 1L; public int getLength() { return size(); } public Node getNamedItem(String name) { return get(name); } public Node getNamedItemNS(String namespaceURI, String localName) throws DOMException { return get(namespaceURI + ":" + localName); } public Node item(int index) { Node[] nodes = values().toArray(new Node[0]); if (nodes == null || index >= nodes.length || index < 0) { return null; } return nodes[index]; } public Node removeNamedItem(String name) throws DOMException { return remove(name); } public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException { return remove(namespaceURI + ":" + localName); } public Node setNamedItem(Node node) throws DOMException { put(node.getLocalName(), node); return node; } public Node setNamedItemNS(Node node) throws DOMException { String namespace = node.getNamespaceURI(); put(namespace + ":" + node.getLocalName(), node); return node; } } src/java/org/dbdoclet/xiphias/dom/CommentImpl.java0000644000000000000000000000114412124530526021146 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2006 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.xiphias.dom; import org.w3c.dom.Comment; public class CommentImpl extends CharacterDataImpl implements Comment { public CommentImpl(String text) { this(text, null); } public CommentImpl(String text, NodeImpl parent) { setNodeType(COMMENT_NODE); setNodeName("#comment"); setData(text); setParentNode(parent); } } src/java/org/dbdoclet/xiphias/dom/CharacterDataImpl.java0000644000000000000000000000220312124530526022227 0ustar rootrootpackage org.dbdoclet.xiphias.dom; import org.w3c.dom.CharacterData; import org.w3c.dom.DOMException; public class CharacterDataImpl extends NodeImpl implements CharacterData { private String data; public void appendData(String arg) throws DOMException { // TODO Auto-generated method stub } public void deleteData(int offset, int count) throws DOMException { // TODO Auto-generated method stub } public String getData() throws DOMException { return data; } public int getLength() { // TODO Auto-generated method stub return 0; } public void insertData(int offset, String arg) throws DOMException { // TODO Auto-generated method stub } public void replaceData(int offset, int count, String arg) throws DOMException { // TODO Auto-generated method stub } public void setData(String data) throws DOMException { this.data = data; setNodeValue(data); } public String substringData(int offset, int count) throws DOMException { // TODO Auto-generated method stub return null; } } src/java/org/dbdoclet/xiphias/dom/DocumentFragmentImpl.java0000644000000000000000000000056412124530526023013 0ustar rootroot/* * ### Copyright (C) 2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.xiphias.dom; import org.w3c.dom.DocumentFragment; public class DocumentFragmentImpl extends ElementImpl implements DocumentFragment { // } src/java/org/dbdoclet/xiphias/dom/AttrImpl.java0000644000000000000000000000204412124530526020456 0ustar rootrootpackage org.dbdoclet.xiphias.dom; import org.w3c.dom.Attr; import org.w3c.dom.DOMException; import org.w3c.dom.Element; import org.w3c.dom.TypeInfo; public class AttrImpl extends NodeImpl implements Attr { public AttrImpl(String namespaceUri, String name, String value) { setNodeName(name); setNodeValue(value); setNamespaceURI(namespaceUri); } public String getName() { return getNodeName(); } public Element getOwnerElement() { // TODO Auto-generated method stub return null; } public TypeInfo getSchemaTypeInfo() { // TODO Auto-generated method stub return null; } public boolean getSpecified() { // TODO Auto-generated method stub return false; } public String getValue() { return getNodeValue(); } public boolean isId() { // TODO Auto-generated method stub return false; } public void setValue(String value) throws DOMException { setNodeValue(value); } } src/java/org/dbdoclet/xiphias/dom/NodeCountVisitor.java0000644000000000000000000000134712124530526022205 0ustar rootrootpackage org.dbdoclet.xiphias.dom; import java.util.ArrayList; import org.dbdoclet.progress.ProgressEvent; import org.dbdoclet.progress.ProgressListener; import org.w3c.dom.Node; public class NodeCountVisitor extends AbstractNodeVisitor implements INodeVisitor { private int counter = 0; public NodeCountVisitor(ArrayList listeners) { super(listeners); } public int getNumberOfNodes() { return counter; } public void accept(Node node) { counter++; fireProgressEvent(String.valueOf(counter), ProgressEvent.STAGE_PREPARE); } public INodeVisitor reset() { counter = 0; return this; } @Override public void openTag(Node node) { // } @Override public void closeTag(Node node) { // } } src/java/org/dbdoclet/xiphias/dom/INodeVisitor.java0000644000000000000000000000037712124530526021307 0ustar rootrootpackage org.dbdoclet.xiphias.dom; import org.w3c.dom.Node; public interface INodeVisitor { public void openTag(Node node) throws Exception; public void accept(Node node) throws Exception; public void closeTag(Node node) throws Exception; } src/java/org/dbdoclet/xiphias/dom/NodeImpl.java0000644000000000000000000006421412124530526020440 0ustar rootroot/* * ### Copyright (C) 2001-2007 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.xiphias.dom; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.service.StringServices; import org.dbdoclet.xiphias.XmlServices; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; import org.w3c.dom.UserDataHandler; /** * The class Node represents a node in a document tree. * * @author Michael Fuchs * @version 1.0 */ public class NodeImpl implements Node { public static final int FORMAT_BLOCK = 3; public static final int FORMAT_CONTENT = 2; public static final int FORMAT_INLINE = 1; public static final int HTML = 3; public static final int SGML = 1; public static final int XML = 2; public static final short XML_DECLARATION = 23; private static int flavour = XML; private static Log logger = LogFactory.getLog(NodeImpl.class); private static final String LSEP = System.getProperty("line.separator"); /** * The method findParent tries to find the nearest parent, * which is of type parentClass. * * If no parent of this type can be found null is returned. * * @param node * a Node value * @param parentClass * a Class value * @return a Node value */ public static NodeImpl findParent(Node node, Class parentClass) { if (node == null || parentClass == null) { return null; } Node parent = node.getParentNode(); while (parent != null && !parentClass.isInstance(parent)) { parent = parent.getParentNode(); } return (NodeImpl) parent; } public static String getTextContent(NodeImpl node) { String buffer = ""; if (node instanceof TextImpl) { buffer += ((TextImpl) node).getData(); } NodeListImpl children = node.getTrafoChildNodes(); if (children == null) { return buffer; } Iterator iterator = children.iterator(); NodeImpl o; while (iterator.hasNext()) { o = iterator.next(); if (o == null || o instanceof CommentImpl) { continue; } if (o instanceof TextImpl) { buffer += ((TextImpl) o).getData(); } else { try { buffer += NodeImpl.getTextContent(o); } catch (StackOverflowError oops) { logger.fatal("[NodeImpl.getTextContent] StackOverflowError. Possibly recursive structure detected!!! Node: " + node.toString()); } } } return buffer; } public static void setCodeType(int type) { switch (type) { case HTML: flavour = HTML; break; case SGML: flavour = SGML; break; case XML: flavour = XML; break; default: throw new IllegalArgumentException("Wrong type " + type); } // end of switch () } public static void setCodeType(String type) { if (type == null) { return; } if (type.equalsIgnoreCase("xml")) { flavour = XML; } else if (type.equalsIgnoreCase("sgml")) { flavour = SGML; } else if (type.equalsIgnoreCase("html")) { flavour = HTML; } else { logger.error("Unknown type " + type + ". Using SGML!"); } } public static void traverse(Node node, INodeVisitor visitor) throws Exception { if (node != null) { if (node instanceof Document) { node = ((Document) node).getDocumentElement(); } if (visitor != null) { visitor.accept(node); } NodeList childList = node.getChildNodes(); for (int i = 0; i < childList.getLength(); i++) { traverse(childList.item(i), visitor); } } } private NodeListImpl childNodes = new NodeListImpl(); private DocumentImpl document; private boolean isEmpty = false; private boolean isMute = false; private boolean isRawData = false; private String namespaceUri; private boolean needsPadding = false; private String nodeName = "node"; private short nodeType = ELEMENT_NODE; private String nodeValue; private NodeImpl parent = null; private TransformInstruction transformInstruction; private HashMap userDataMap; private int column; private int line; protected boolean isCaseInsensitive = false; public NodeImpl() { super(); } public NodeImpl(String name) { this(name, null); } public NodeImpl(String name, NodeImpl parent) { if (name != null) { nodeName = name; } if (isCaseInsensitive) { nodeName = nodeName.toLowerCase(); } this.parent = parent; } @Override public Node appendChild(Node newChild) throws DOMException { if (newChild instanceof NodeImpl) { return appendChild((NodeImpl) newChild); } throw new IllegalArgumentException("The new child must be of type " + NodeImpl.class.getName()); } /** * The method appendChild adds a child node to this node. * * The parent of the child node is explicitly set to this node to this node * to avoid inconsistencies in the resulting document tree. * * @param node * The child node {@link NodeImpl (Node)}. */ public NodeImpl appendChild(NodeImpl node) { if (node == null) { throw new IllegalArgumentException("Variable node is null!"); } if (childNodes == null) { throw new IllegalStateException("Variable childNodes is null!"); } node.setParentNode(this); childNodes.add(node); logger.debug("Appended child " + node + " to " + this + "."); return this; } public NodeImpl appendChild(String text) { return appendChild(text, true); } public NodeImpl appendChild(String text, boolean escape) { TextImpl node; if (escape == true) { node = new TextImpl(XmlServices.textToXml(text)); } else { node = new TextImpl(text); node.isRawData(true); } node.setParentNode(this); childNodes.add(node); return this; } @Override public Node cloneNode(boolean deep) { System.err.println("Not yet implemented"); return null; } @Override public short compareDocumentPosition(Node other) throws DOMException { System.err.println("Not yet implemented"); return 0; } public Text findFirstText() { Text firstText = getFirstText(); if (firstText != null) { return firstText; } for (Element element : getChildElementList()) { firstText = ((ElementImpl) element).findFirstText(); if (firstText != null) { return firstText; } } return null; } public NodeImpl findChildElement(String tagName) { if (tagName == null) { throw new IllegalArgumentException( "The argument tagName must not be null!"); } if ((childNodes == null) || (childNodes.size() < 1)) { return null; } NodeImpl element = null; String nodeName = null; for (int i = 0; i < childNodes.size(); i++) { if (childNodes.get(i) instanceof ElementImpl) { element = childNodes.get(i); nodeName = element.getNodeName(); if (nodeName != null && nodeName.equals(tagName)) { return element; } } } return null; } public NodeImpl findParent(Class parentClass) { Node parent = this.getParentNode(); return findParent(parent, parentClass); } @Override public NamedNodeMap getAttributes() { if (this instanceof Element) { return ((Element) this).getAttributes(); } return null; } @Override public String getBaseURI() { System.err.println("Not yet implemented"); return null; } public ArrayList getChildElementList() { ArrayList list = new ArrayList(); if (childNodes != null) { for (Node child : childNodes) { if (child instanceof Element) { list.add((Element) child); } } } return list; } /** * The method getChildNodes returns a list with all children of * this node.. * * @return an ArrayList value */ @Override public NodeList getChildNodes() { if (childNodes == null) { throw new IllegalStateException("Variable childNodes is null!"); } return childNodes; } public int getColumn() { return column; } public DocumentImpl getDocument() { return document; } public NodeListImpl getElementChildNodes() { if (childNodes == null) { throw new IllegalStateException("Variable childNodes is null!"); } NodeListImpl list = new NodeListImpl(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); if (child instanceof ElementImpl) { list.add((NodeImpl) child); } } return list; } @Override public Object getFeature(String feature, String version) { System.err.println("Not yet implemented"); return null; } /** * The method getFirstChild returns the first child of this * node. * * If this node has no children, null is returned. * * @return a Node value */ @Override public NodeImpl getFirstChild() { if (childNodes == null || childNodes.size() < 1) { return null; } return childNodes.get(0); } /** * The method getFirstElement returns the first child of this * node that is of type ELEMENT_NODE. * * If this node has no element child, null is returned. * * @return The element or null, if element child can be found. */ public Element getFirstElement() { if ((childNodes == null) || (childNodes.size() < 1)) { return null; } NodeImpl element = null; for (int i = 0; i < childNodes.size(); i++) { if (childNodes.get(i) instanceof ElementImpl) { element = childNodes.get(i); break; } } return (Element) element; } public Text getFirstText() { if ((childNodes == null) || (childNodes.size() < 1)) { return null; } NodeImpl element = null; for (int i = 0; i < childNodes.size(); i++) { if (childNodes.get(i) instanceof Text) { element = childNodes.get(i); break; } } return (Text) element; } /* ========================================================== */ /* Extensions */ /* ========================================================== */ public int getFlavour() { return flavour; } @Override public Node getLastChild() { if (childNodes == null || childNodes.size() == 0) { return null; } return childNodes.get(childNodes.size() - 1); } public NodeImpl getLastChild(Class type) { if (type == null) { throw new IllegalArgumentException( "The argument type must not be null!"); } if ((childNodes == null) || (childNodes.size() < 1)) { return null; } NodeImpl element = null; NodeImpl node; String classname; for (int i = 0; i < childNodes.size(); i++) { node = childNodes.get(i); classname = node.getClass().getName(); if (classname.equals(type.getName())) { element = childNodes.get(i); } } return element; } public int getLine() { return line; } @Override public String getLocalName() { if (this instanceof ElementImpl || this instanceof AttrImpl || this instanceof EntityImpl) { String qualifiedName = getNodeName(); if (qualifiedName.indexOf(':') == -1) { return qualifiedName; } else { return qualifiedName.split(":")[1]; } } return null; } @Override public String getNamespaceURI() { return namespaceUri; } @Override public Node getNextSibling() { NodeImpl parent = getTrafoParentNode(); if (parent == null) { return null; } int index = 0; NodeListImpl children = parent.getTrafoChildNodes(); for (NodeImpl child : children) { if (child == this) { break; } index++; } if (index < (children.size() - 1)) { return children.get(index + 1); } return null; } @Override public String getNodeName() { return nodeName; } @Override public short getNodeType() { return nodeType; } @Override public String getNodeValue() throws DOMException { return nodeValue; } public int getNumberOfChildNodes() { return childNodes.size(); } @Override public Document getOwnerDocument() { System.err.println("Not yet implemented"); return null; } @Override public Node getParentNode() { return parent; } @Override public String getPrefix() { if (this instanceof ElementImpl || this instanceof AttrImpl) { String qualifiedName = getNodeName(); if (qualifiedName.indexOf(':') == -1) { return null; } else { return qualifiedName.split(":")[0]; } } return null; } @Override public Node getPreviousSibling() { NodeImpl parent = getTrafoParentNode(); if (parent == null) { return null; } int index = 0; NodeListImpl children = parent.getTrafoChildNodes(); for (NodeImpl child : children) { if (child == this) { break; } index++; } if (index > 0) { return children.get(index - 1); } return null; } public NodeImpl getRoot() { Node parent = getParentNode(); if (parent == null) { return this; } Node root = parent; while (parent != null) { parent = parent.getParentNode(); if (parent != null) { root = parent; } } return (NodeImpl) root; } @Override public String getTextContent() { return NodeImpl.getTextContent(this); } public Map getTrafoAttributes() { if (this instanceof ElementImpl) { return this.getTrafoAttributes(); } return null; } public NodeListImpl getTrafoChildNodes() { if (childNodes == null) { childNodes = new NodeListImpl(); } return childNodes; } public NodeImpl getTrafoParentNode() { return parent; } public TransformInstruction getTransformInstruction() { return transformInstruction; } @Override public Object getUserData(String key) { if (key == null || userDataMap == null) { return null; } return userDataMap.get(key); } public String hardenText(String text) { if (text == null) { return ""; } String buffer = StringServices.replace(text, "&", "&"); buffer = StringServices.replace(buffer, "<", "<"); buffer = StringServices.replace(buffer, ">", ">"); return buffer; } @Override public boolean hasAttributes() { System.err.println("Not yet implemented"); return false; } /** * The method hasChildren returns true, if the node contains * any children. * * @return an int value */ @Override public boolean hasChildNodes() { if (childNodes == null) { throw new IllegalStateException("Parameter childNodes is null!"); } int size = childNodes.size(); if (size > 0) { return true; } else { return false; } } /** * The method hasElementChildren returns true, if the node * contains any children, which are elements. * * @return an int value */ public boolean hasElementChildren() { if (childNodes == null) { throw new IllegalStateException("Parameter childNodes is null!"); } NodeImpl node; for (int i = 0; i < childNodes.size(); i++) { node = childNodes.get(i); if (node instanceof ElementImpl) { return true; } } return false; } public boolean hasSiblingElements() { NodeImpl parent = (NodeImpl) getParentNode(); if (parent == null) { return false; } NodeListImpl list = parent.getElementChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.get(i); if (node != this) { return true; } } return false; } public boolean hasText() { String text = getTextContent(); if ((text != null) && !text.trim().equals("")) { return true; } return false; } public Node insertAfter(Node newChild, Node refChild) { if (newChild == null) { throw new IllegalArgumentException( "The argument newChild must not be null!"); } if (refChild == null) { throw new IllegalArgumentException( "The argument refChild must not be null!"); } NodeImpl node; int index = -1; if ((childNodes != null) && (childNodes.size() > 0)) { for (int i = 0; i < childNodes.size(); i++) { node = childNodes.get(i); if (node == refChild) { index = i; } } if (index > -1) { NodeImpl newChildImpl = (NodeImpl) newChild; newChildImpl.setParentNode(this); childNodes.add(index + 1, newChildImpl); } } return this; } @Override public Node insertBefore(Node newChild, Node refChild) throws DOMException { NodeListImpl childList = (NodeListImpl) getChildNodes(); for (int i = 0; i < childList.getLength(); i++) { Node child = childList.item(i); if (child.equals(refChild)) { NodeImpl newChildImpl = (NodeImpl) newChild; newChildImpl.setParentNode(this); logger.debug("Inserting " + newChild + "before " + refChild); childList.add(i, newChildImpl); return this; } } logger.warn("InsertBefore: Couldn't find reference child " + refChild); return this; } /** * The method insertChild inserts a child node at the specified * index. * * @param index * an int value * @param node * a Node value * @return a Node value */ public NodeImpl insertChild(int index, NodeImpl node) { node.setParentNode(this); childNodes.add(index, node); return this; } /** * Falls die Sprache nicht zwischen Groß- und Kleinschreibung unterscheidet, * muss das Attribute isCaseSensitive auf true * gesetzt werden. * *

      * Die Methode konvertiert bereits bestehende Daten in Kleinbuchstaben. * Sollten dabei Doppeldeutigkeiten auftreten, gilt der letzte, verarbeitete * Wert. * * @param isCaseInsensitive * @return NodeImpl */ public NodeImpl isCaseInsensitive(boolean isCaseInsensitive) { this.isCaseInsensitive = isCaseInsensitive; if (nodeName != null) { nodeName = nodeName.toLowerCase(); } return this; } @Override public boolean isDefaultNamespace(String namespaceURI) { System.err.println("Not yet implemented"); return false; } public boolean isEmpty() { return isEmpty; } public NodeImpl isEmpty(boolean isEmpty) { this.isEmpty = isEmpty; return this; } @Override public boolean isEqualNode(Node otherNode) { return equals(otherNode); } public boolean isMute() { return isMute; } public void isMute(boolean isMute) { this.isMute = isMute; } public boolean isRawData() { return isRawData; } public void isRawData(boolean isRawData) { this.isRawData = isRawData; } /** * The method isRoot returns true if this node is Root * node. * * @return a boolean value */ public boolean isRoot() { if (parent == null || this instanceof DocumentFragmentImpl) { return true; } return false; } @Override public boolean isSameNode(Node other) { System.err.println("Not yet implemented"); return false; } @Override public boolean isSupported(String feature, String version) { System.err.println("Not yet implemented"); return false; } @Override public String lookupNamespaceURI(String prefix) { System.err.println("Not yet implemented"); return null; } @Override public String lookupPrefix(String namespaceURI) { System.err.println("Not yet implemented"); return null; } public boolean needsPadding() { return needsPadding; } public NodeImpl needsPadding(boolean needsPadding) { this.needsPadding = needsPadding; return this; } @Override public void normalize() { System.err.println("Not yet implemented"); } @Override public Node removeChild(Node node) throws DOMException { if (node == null) { throw new IllegalArgumentException("Variable node is null!"); } if (childNodes == null) { throw new IllegalStateException("Variable childNodes is null!"); } Node child; Node removedChild = null; for (int i = 0; i < childNodes.getLength(); i++) { child = childNodes.item(i); if (child.equals(node)) { childNodes.remove(i); removedChild = child; break; } } return removedChild; } /** * {@inheritDoc} * * The method replaceChild exchanges a node against another * one. * * Beware of that the parent of the old child is set to null. If either * oldNode or newNode is null, an * IllegalArgumentException is thrown. * * @param oldChild * a Node value * @param newChild * a Node value * @return a Node value */ @Override public Node replaceChild(Node newChild, Node oldChild) throws DOMException { logger.debug("(W3C) Replacing child " + oldChild + " with child " + newChild); NodeList childList = getChildNodes(); for (int i = 0; i < childList.getLength(); i++) { Node child = childList.item(i); if (child.equals(oldChild)) { logger.debug("Found child to replace."); insertBefore(newChild, oldChild); removeChild(oldChild); } } return this; } public void setChildNodes(NodeList children) { if (children == null) { childNodes = new NodeListImpl(); } childNodes = (NodeListImpl) children; } /** * Die Methode setColumn setzt die Spaltennummer in der das * Element ursprünglich vom Tokenizer gefunden wurde. * * @param column * int */ public void setColumn(int column) { this.column = column; } public void setDocument(DocumentImpl document) { this.document = document; } /** * Die Methode setLine setzt die Zeilennummer in der das * Element ursprünglich vom Tokenizer gefunden wurde. * * @param line * int */ public void setLine(int line) { this.line = line; } public void setMute(boolean isMute) { this.isMute = isMute; } public void setNamespaceURI(String namespaceUri) { this.namespaceUri = namespaceUri; } public void setNodeName(String nodeName) { this.nodeName = nodeName; } public void setNodeType(short nodeType) { this.nodeType = nodeType; } @Override public void setNodeValue(String nodeValue) throws DOMException { this.nodeValue = nodeValue; } public void setParentNode(NodeImpl parent) { if (this == parent) { throw new IllegalStateException("Self referencing " + parent); } this.parent = parent; } @Override public void setPrefix(String prefix) throws DOMException { System.err.println("Not yet implemented"); } @Override public void setTextContent(String textContent) throws DOMException { childNodes.clear(); if (textContent != null) { if (this instanceof TextImpl) { ((TextImpl) this).setData(textContent); } else { appendChild(new TextImpl(textContent)); } } } public void setTransformInstruction( TransformInstruction transformInstruction) { this.transformInstruction = transformInstruction; } @Override public Object setUserData(String key, Object data, UserDataHandler handler) { if (userDataMap == null) { userDataMap = new HashMap(); } if (key != null) { userDataMap.put(key, data); } return data; } public void swapWithParent() { NodeList childNodes1 = childNodes; NodeList childNodes2 = parent.getChildNodes(); Node hook = parent.getParentNode(); if (hook == null) { return; } parent.setChildNodes(childNodes1); setChildNodes(childNodes2); removeChild(this); insertChild(0, parent); hook.replaceChild(this, parent); } @Override public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append("name="); if (nodeName != null) { buffer.append(nodeName); } buffer.append(','); buffer.append("value="); if (nodeValue != null) { buffer.append(nodeValue); } buffer.append(",line="); buffer.append(getLine()); buffer.append(",column="); buffer.append(getColumn()); String text = buffer.toString(); if (text.length() > 42) { text = text.substring(0, 39) + "..."; } return text; } public String toTag() { String str = "<" + nodeName + ">"; return str; } public String toTree(String prefix, int[] levels, int level) { if (level >= levels.length) { logger.fatal(String.format( "Resulting node tree has more than %d levels.", levels.length)); return ""; } String buffer = ""; levels[level] = getTrafoChildNodes().size(); buffer = "+ " + getNodeName() + "[" + hashCode() + "]:children[" + getTrafoChildNodes().size() + "]\n"; String spaces = ""; for (int i = 0; i <= level; i++) { if (levels[i] > 0) { spaces += "| "; } else { spaces += " "; } } buffer += (spaces + LSEP); spaces = ""; for (int i = 0; i < level; i++) { if (levels[i] > 0) { spaces += "| "; } else { spaces += " "; } } prefix = spaces + "+--"; for (NodeImpl node : getTrafoChildNodes()) { levels[level]--; if (node instanceof TextImpl) { buffer += (prefix + ((TextImpl) node).toString() + "(Text)\n"); } else if (node instanceof ElementImpl) { NodeImpl elem = node; buffer += (prefix + elem.toTree(prefix, levels, level + 1)); } } return buffer; } public void traverse(INodeVisitor visitor) throws Exception { traverse(this, visitor); } public String treeView() { int[] levels = new int[1024]; return toTree("", levels, 0); } protected boolean validateAttributes() { // To be overwritten return true; } public boolean validateParentPath( HashMap> validParentMap) { NodeImpl parent = getTrafoParentNode(); if (parent == null || isRoot() == true) { return true; } while (parent.isMute()) { parent = parent.getTrafoParentNode(); if (parent == null) { return true; } } String path = parent.getNodeName() + " -> " + toTag(); while (parent != null && parent instanceof DocumentFragmentImpl == false) { if (validParentMap.get(parent.getNodeName()) == null) { return false; } parent = parent.getTrafoParentNode(); if (parent != null) { while (parent.isMute()) { parent = parent.getTrafoParentNode(); if (parent == null) { return true; } } path = parent.getNodeName() + " -> " + path; } } return true; } public void vanish() { if (parent != null) { NodeListImpl children = parent.getTrafoChildNodes(); children.remove(this); } } } src/java/org/dbdoclet/xiphias/dom/ElementImpl.java0000644000000000000000000002240012124530526021133 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2006 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de */ package org.dbdoclet.xiphias.dom; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.ArrayList; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dbdoclet.service.StringServices; import org.dbdoclet.xiphias.XmlServices; import org.w3c.dom.Attr; import org.w3c.dom.DOMException; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.TypeInfo; public class ElementImpl extends NodeImpl implements Element { public static final int FORMAT_BLOCK = 3; public static final int FORMAT_CONTENT = 2; public static final int FORMAT_INLINE = 1; private static final Pattern xmlIdPattern = Pattern.compile("[^\\w\\.-]+"); private static final Pattern xmlNameStartPattern = Pattern .compile("^[a-zA-Z_].*$"); private static Log logger = LogFactory.getLog(ElementImpl.class); private static int idCounter = 1; private int formatType = FORMAT_CONTENT; private boolean isLiteral = false; private Map attributes = new TreeMap(); public static String hardenId(String id) { if (id == null || id.length() == 0) { id = StringServices.fillInt(idCounter++, 5); id = "N" + id; } String buffer = new String(id); try { buffer = URLDecoder.decode(buffer, "UTF-8"); } catch (UnsupportedEncodingException oops) { logger.fatal("Decoding of id '" + buffer + "' failed!", oops); } Matcher matcher = xmlIdPattern.matcher(buffer); buffer = matcher.replaceAll("-"); matcher = xmlNameStartPattern.matcher(buffer); if (matcher.matches() == false) { buffer = "dbdoclet." + buffer; } return buffer; } public ElementImpl() { super(); setNodeType(Node.ELEMENT_NODE); } public ElementImpl(String name) { super(name); setNodeType(Node.ELEMENT_NODE); } public ElementImpl(String name, NodeImpl parent) { super(name, parent); setNodeType(Node.ELEMENT_NODE); } public void clearAttributes() { attributes = new TreeMap(); } @Override public String getAttribute(String name) { if ((name == null) || name.equals("")) { return ""; } name = name.toLowerCase(); AttrImpl attr = attributes.get(name); if (attr == null) { return null; } return attr.getValue(); } @Override public Attr getAttributeNode(String name) { if ((name == null) || name.equals("")) { return null; } name = name.toLowerCase(); return attributes.get(name); } @Override public Attr getAttributeNodeNS(String namespaceURI, String localName) throws DOMException { // TODO Auto-generated method stub return null; } @Override public String getAttributeNS(String namespaceURI, String localName) throws DOMException { // TODO Auto-generated method stub return null; } @Override public NamedNodeMap getAttributes() { NamedNodeMapImpl map = new NamedNodeMapImpl(); for (AttrImpl attr : attributes.values()) { map.setNamedItem(attr); } return map; } public String getAttributesAsText() { String buffer = ""; String key; if ((attributes != null) && (attributes.size() > 0)) { validateAttributes(); Iterator iterator = attributes.keySet().iterator(); while (iterator.hasNext()) { key = iterator.next(); buffer += " " + key + "=\"" + XmlServices.textToXml(attributes.get(key).getValue()) + "\""; } } return buffer; } public boolean getBooleanAttribute(String name) { if ((name == null) || name.equals("")) { return false; } AttrImpl attr = attributes.get(name); String bval = "false"; if (attr != null) { String value = attr.getValue(); if (value != null && value.trim().equals("1")) { bval = "true"; } } Boolean b = new Boolean(bval); return b.booleanValue(); } @Override public NodeList getElementsByTagName(String name) { ElementByTagNameVisitor visitor = new ElementByTagNameVisitor(name); DOMTraverser dt = new DOMTraverser(visitor); try { dt.traverse(this); } catch (Exception e) { e.printStackTrace(); } return visitor.getElementList(); } @Override public NodeList getElementsByTagNameNS(String namespaceURI, String localName) throws DOMException { // TODO Auto-generated method stub return null; } public int getFormatType() { return formatType; } public String getId() { return getAttribute("id"); } public Integer getIntAttribute(String name) { if ((name == null) || name.equals("")) { return null; } AttrImpl attr = attributes.get(name); if (attr == null) { return null; } String value = attr.getValue(); if (value == null || value.trim().length() == 0) { return null; } int number = 0; try { number = Integer.parseInt(value.trim()); } catch (NumberFormatException oops) { logger.warn("Attribute " + name + " of tag " + getTagName() + " is not a valid integer. It has a value of '" + value + "'."); return null; } return number; } @Override public TypeInfo getSchemaTypeInfo() { // TODO Auto-generated method stub return null; } @Override public String getTagName() { return getNodeName(); } @Override public Map getTrafoAttributes() { if (attributes == null) { attributes = new TreeMap(); } return attributes; } @Override public boolean hasAttribute(String name) { // TODO Auto-generated method stub return false; } @Override public boolean hasAttributeNS(String namespaceURI, String localName) throws DOMException { // TODO Auto-generated method stub return false; } public boolean isLiteral() { return isLiteral; } public NodeImpl isLiteral(boolean isLiteral) { this.isLiteral = isLiteral; return this; } @Override public void removeAttribute(String name) throws DOMException { if (name != null) { if (isCaseInsensitive) { name = name.toLowerCase(); } attributes.remove(name); } } @Override public Attr removeAttributeNode(Attr oldAttr) throws DOMException { if (oldAttr == null) { return null; } return attributes.remove(oldAttr.getName()); } @Override public void removeAttributeNS(String namespaceURI, String localName) throws DOMException { // TODO Auto-generated method stub } public void setAttribute(String name, Object value) throws DOMException { if (value != null) { setAttribute(name, value.toString()); } } @Override public void setAttribute(String name, String value) throws DOMException { if (name != null && name.length() > 0 && value != null) { if (isCaseInsensitive) { name = name.toLowerCase(); } AttrImpl attr = new AttrImpl(null, name, value); attributes.put(name, attr); } } @Override public Attr setAttributeNode(Attr newAttr) throws DOMException { // TODO Auto-generated method stub return null; } @Override public Attr setAttributeNodeNS(Attr newAttr) throws DOMException { // TODO Auto-generated method stub return null; } @Override public void setAttributeNS(String namespaceUri, String qualifiedName, String value) throws DOMException { AttrImpl attr = new AttrImpl(namespaceUri, qualifiedName, value); attributes.put(qualifiedName, attr); } public NodeImpl setFormatType(int formatType) { this.formatType = formatType; return this; } public void setId(int number) { setAttribute("id", String.valueOf(number)); } public void setId(String id) { setAttribute("id", hardenId(id)); } @Override public void setIdAttribute(String name, boolean isId) throws DOMException { // TODO Auto-generated method stub } @Override public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException { // TODO Auto-generated method stub } @Override public void setIdAttributeNS(String namespaceURI, String localName, boolean isId) throws DOMException { // TODO Auto-generated method stub } public NodeImpl setTrafoAttributes(Map nattrs) { if (nattrs == null) { throw new IllegalArgumentException("Parameter attributes is null!"); } attributes.putAll(nattrs); return this; } public NodeImpl setTrafoStringAttributes(Map tokenAttrs) { if (tokenAttrs == null) { throw new IllegalArgumentException("Parameter attributes is null!"); } for (String tokenAttrName : tokenAttrs.keySet()) { String attrName = tokenAttrName; if (isCaseInsensitive) { attrName = attrName.toLowerCase(); } attributes .put(attrName, new AttrImpl(null, attrName, tokenAttrs .get(tokenAttrName))); } return this; } /** * Liefert alle Kindelement des angegebenen Typs zurück. * * @param type * @return ArrayList */ @SuppressWarnings("unchecked") public ArrayList findChildren(Class type) { ArrayList list = new ArrayList(); for (Element element : getChildElementList()) { if (type.isInstance(element)) { list.add((T) element); } } return list; } } src/java/org/dbdoclet/xiphias/dom/AbstractNodeVisitor.java0000644000000000000000000000210012124530526022644 0ustar rootrootpackage org.dbdoclet.xiphias.dom; import java.util.ArrayList; import org.dbdoclet.progress.ProgressEvent; import org.dbdoclet.progress.ProgressListener; import org.dbdoclet.progress.ProgressManager; import org.w3c.dom.Node; public abstract class AbstractNodeVisitor implements INodeVisitor { protected final ArrayList listeners; private ProgressManager pm; public AbstractNodeVisitor() { this.listeners = new ArrayList(); pm = new ProgressManager(listeners); } public AbstractNodeVisitor(ArrayList listeners) { this.listeners = listeners; pm = new ProgressManager(listeners); } protected void fireProgressEvent(String msg, int stage) { ProgressEvent event = new ProgressEvent(msg); event.setStage(stage); pm.fireProgressEvent(event); } public abstract void accept(Node node) throws Exception; protected void removeNodes(ArrayList nodeList) { for (Node node : nodeList) { Node parent = node.getParentNode(); if (parent != null) { parent.removeChild(node); } } } }src/java/org/dbdoclet/CreatePathException.java0000644000000000000000000000304712124530526020401 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet; import java.io.IOException; public class CreatePathException extends IOException { /** * */ private static final long serialVersionUID = 1L; public static final int UNKNOWN = 0; public static final int FILE_PARENT = 1; public static final int PERMISSION_DENIED = 2; public static final int PATH_TOO_LONG = 3; private String path; private int reason; public CreatePathException(String path) { super(path); this.path = path; } public CreatePathException(String path, int reason) { super(path); this.path = path; this.reason = reason; } public String getPath() { return path; } public int getReason() { return reason; } public boolean hasFileParent() { if (reason == FILE_PARENT) { return true; } return false; } public boolean isPermissionDenied() { if (reason == PERMISSION_DENIED) { return true; } return false; } public boolean isPathTooLong() { if (reason == PATH_TOO_LONG) { return true; } return false; } } src/java/org/dbdoclet/RenameFileException.java0000644000000000000000000000165712124530526020375 0ustar rootroot/* * $Id$ * * ### Copyright (C) 2005 Michael Fuchs ### * ### All Rights Reserved. ### * * Author: Michael Fuchs * E-Mail: michael.fuchs@unico-group.com * URL: http://www.michael-a-fuchs.de * * RCS Information * Author..........: $Author$ * Date............: $Date$ * Revision........: $Revision$ * State...........: $State$ */ package org.dbdoclet; import java.io.File; import java.io.IOException; public class RenameFileException extends IOException { /** * */ private static final long serialVersionUID = 1L; private String from; private String to; public RenameFileException(File from, File to) { super(from.getAbsolutePath() + " -> " + to.getAbsolutePath()); this.from = from.getAbsolutePath(); this.to = to.getAbsolutePath(); } public String getFrom() { return from; } public String getTo() { return to; } } src/java/META-INF/0000755000000000000000000000000012124530526012424 5ustar rootrootsrc/java/META-INF/MANIFEST.MF0000644000000000000000000000055112124530526014057 0ustar rootrootManifest-Version: 1.0 Ant-Version: Apache Ant 1.8.2 Created-By: 1.6.0_32-b05 (Sun Microsystems Inc.) Main-Class: org.dbdoclet.herold.Herold Specification-Version: 6.1.0 Implementation-Version: 6.1.0 Class-Path: ../conf/ org.antlr.runtime.jar org.apache.comm ons.jxpath.jar org.apache.commons.logging.jar org.apache.lo g4j.jar src/java/OSGI-INF/0000755000000000000000000000000012124530526012437 5ustar rootrootsrc/java/OSGI-INF/component-description.xml0000644000000000000000000000045312124530526017506 0ustar rootroot