diff --git a/MudClient.md b/MudClient.md new file mode 100644 index 00000000..60397f40 --- /dev/null +++ b/MudClient.md @@ -0,0 +1,23 @@ +## Description ## +A mudclient written entirely in java, using the swing UI components, and some of it's own custom components. + +## Aims ## +Initially the mud client will only work with Elephant Mud , however later on in the project it is planned to make specific support and features plugins. + +The mudclient requires java 1.4 or higher which can be downloaded from www.java.com . + +## Current Status ## + +### Implemented ### + * Telnet Negotiation + * Ansi control code support + * Elephant Mud external client mode support + * Multiple output windows for one mud + * Configurable Keybindings +### To Do ### + * Make the configuration alterable at runtime + * Make the configuration persistent + * Aliases, Macros & Triggers + * Support for using 'ed' whilst in external client mode + * A pluggin framework + * Remove specific Elephant Mud stuff and make it into a plugin \ No newline at end of file diff --git a/ProjectHome.md b/ProjectHome.md new file mode 100644 index 00000000..32068455 --- /dev/null +++ b/ProjectHome.md @@ -0,0 +1,30 @@ +A small (inactive) community of open-source Java(tm) components. + +Projects: + + * charlotte - A bit format utility. + * jardiff - Visualizes API differences between two different versions of a Java project. + * [MudClient](MudClient.md) - Swing mudclient for the Elephant MUD + * norbert - robots.txt parser + * oscube - Simple-JNDI based framework. + * payload - Self-extracting jar creator. + * [SimpleJNDI](SimpleJNDI.md) - In-memory JNDI implementation. + * scraping–engine - oscube based website scraping framework. + * trail-taglib - Breadcrumbs JSP tag library. + * Tig-Threads - Thread management utility. + * [XmlWriter](XmlWriter.md) - Simple API to output XML. + + * genjava: + * gj-core - General utility library. + * gj-config - Simple configuration API, for use with JNDI. + * gj-scrape - HTML/XML semi-parser. + * gj-csv - CSV reader/writer. + * gj-find - UNIX find command-like library. + * gj-mail - JavaMail helper utility. + * gj-xml - Simple XML parser. + +The latest version of each component is available in the [Downloads](http://code.google.com/p/osjava/downloads/list). + +For older versions, see the [SVN dist directory](http://osjava.googlecode.com/svn/dist/releases/official/). + +JAR files are available via a [Maven repository](http://osjava.googlecode.com/svn/dist/maven/). \ No newline at end of file diff --git a/SimpleJNDI.md b/SimpleJNDI.md new file mode 100644 index 00000000..32a4d82a --- /dev/null +++ b/SimpleJNDI.md @@ -0,0 +1,11 @@ +## The Problem ## +Simple-JNDI is intended to solve two problems. The first is that of finding a container independent way of opening a database connection, the second is to find a good way of specifying application configurations. + +Unit tests or prototype code often need to emulate the environment within which the code is expected to run. A very common one is to get an object of type javax.sql.DataSource from JNDI so a java.sql.Connection to your database of choice may be opened. +Applications need configuration; a JNDI implementation makes a handy location for configuration values. Either as a globally available system, or via IoC through the use of some kind of JNDI configuration facade (see gj-config). + +## A Solution ## + +A simple implementation of JNDI. It is entirely library based, so no server instances are started, and it sits upon Java .properties files, XML files or Windows-style .ini files, so it is easy to use and simple to understand. The files may be either on the file system or in the classpath. + +Simple-JNDI depends on no external jars for its basic functionality, however to get certain optional features you will still need to download external jars. When describing these features, the manual will point out which jars are needed and where to get them. \ No newline at end of file diff --git a/XmlWriter.md b/XmlWriter.md new file mode 100644 index 00000000..67e76103 --- /dev/null +++ b/XmlWriter.md @@ -0,0 +1,3 @@ +A great way to output Xml. Far easier to code with than painful DOM or SAX like solutions and much nicer in terms of speed and memory usage. + +While XmlWriter contains its own xml outputter, it has the ability to sit on top of other core Xml writing products, such as XmlEnc. In addition, the user may layer other functionalities on top of the core writing, such as on the fly schema checking, date/number formatting, specific empty-element handling and pretty-printing. \ No newline at end of file diff --git a/cachew/project.xml b/cachew/project.xml deleted file mode 100644 index 63598d2d..00000000 --- a/cachew/project.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - 3 - - cachew - cachew - - 0.1 - - - OSJava - http://www.osjava.org - http://www.osjava.org/images/osjava.gif - - 2004 - - org.osjava.cachew - - http://www.osjava.org/images/1x1.gif - - - - - - - http://www.osjava.org/cachew/ - - - - - scm:svn:http://svn.osjava.org/svn/osjava/trunk/cachew - http://svn.osjava.org/svn/osjava/trunk/cachew - - - - - osjava-users - http://lists.flamefew.net/mailman/listinfo/osjava-users - http://lists.flamefew.net/mailman/listinfo/osjava-users - http://lists.flamefew.net/mailman/private/osjava-users/ - - - - - - - servletapi - servletapi - 2.4 - - - - - - src/java - - src/test - - - - **/*Test.java - - - - - - - maven-jxr-plugin - maven-javadoc-plugin - maven-license-plugin - maven-changes-plugin - - - - diff --git a/cachew/src/java/org/osjava/cachew/Cachew.java b/cachew/src/java/org/osjava/cachew/Cachew.java deleted file mode 100755 index e7517d19..00000000 --- a/cachew/src/java/org/osjava/cachew/Cachew.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Created on Jun 10, 2005 - */ -package org.osjava.cachew; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -/** - * Caches a selection of items that came from the same core URL. - * - * @author hen - */ -public class Cachew { - - // TODO: Make this configurable - private long interval = 60000L; - - private CachewItemCreator creator = null; - - private Map map = new HashMap(); - - public CachewItem getItem(String path) { - Iterator itr = map.keySet().iterator(); - while (itr.hasNext()) { - String key = (String) itr.next(); - if (path.matches(key)) { - CachewItem item = (CachewItem) map.get(path); - if (item.getCreationTime().getTime() + interval - > System.currentTimeMillis()) - { - return createItem(path); - } - } - } - return null; - } - - public CachewItem createItem(String path) { - CachewItem item = creator.create(path); - // TODO: Store regexp, not path here? - map.put(path, item); - return item; - } - -} \ No newline at end of file diff --git a/cachew/src/java/org/osjava/cachew/CachewGetServlet.java b/cachew/src/java/org/osjava/cachew/CachewGetServlet.java deleted file mode 100755 index 64ab91e1..00000000 --- a/cachew/src/java/org/osjava/cachew/CachewGetServlet.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Created on Jun 10, 2005 - */ -package org.osjava.cachew; - -import java.io.IOException; -import java.io.OutputStream; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author hen - */ -public class CachewGetServlet extends HttpServlet { - - static CachewManager cManager = new CachewManager(); - - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - String path = request.getPathInfo(); - - // getPath. Ask CachewManager for CachewItem matching that. - CachewItem cItem = cManager.getItem(path); - - // if not found, ask CachewManager to create new CachewItem. - if(cItem == null) { - cItem = cManager.createItem(path); - } - - // write CachewItem to stream - response.setContentType(cItem.getContentType()); - OutputStream out = response.getOutputStream(); - out.write(cItem.getBytes()); - out.flush(); - } -} diff --git a/cachew/src/java/org/osjava/cachew/CachewItem.java b/cachew/src/java/org/osjava/cachew/CachewItem.java deleted file mode 100755 index 8aa7529b..00000000 --- a/cachew/src/java/org/osjava/cachew/CachewItem.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Created on Jun 10, 2005 - */ -package org.osjava.cachew; - -import java.util.Date; - -/** - * @author hen - */ -public class CachewItem { - - private byte[] bytes; - private String contentType; - private Date creationTime; - - /** - * @return Returns the bytes. - */ - public byte[] getBytes() { - return bytes; - } - /** - * @param bytes The bytes to set. - */ - public void setBytes(byte[] bytes) { - this.bytes = bytes; - } - - /** - * @return Returns the contentType. - */ - public String getContentType() { - return contentType; - } - /** - * @param contentType The contentType to set. - */ - public void setContentType(String contentType) { - this.contentType = contentType; - } - - /** - * @return Returns the creationTime. - */ - public Date getCreationTime() { - return creationTime; - } - /** - * @param creationTime The creationTime to set. - */ - public void setCreationTime(Date creationTime) { - this.creationTime = creationTime; - } -} diff --git a/cachew/src/java/org/osjava/cachew/CachewItemCreator.java b/cachew/src/java/org/osjava/cachew/CachewItemCreator.java deleted file mode 100755 index a3c5b8c2..00000000 --- a/cachew/src/java/org/osjava/cachew/CachewItemCreator.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Created on Jun 10, 2005 - */ -package org.osjava.cachew; - -/** - * @author hen - */ -public interface CachewItemCreator { - - CachewItem create(String url); - -} diff --git a/cachew/src/java/org/osjava/cachew/CachewManager.java b/cachew/src/java/org/osjava/cachew/CachewManager.java deleted file mode 100755 index a097556d..00000000 --- a/cachew/src/java/org/osjava/cachew/CachewManager.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Created on Jun 10, 2005 - */ -package org.osjava.cachew; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -/** - * @author hen - */ -public class CachewManager { - - private Map map = new HashMap(); - - public CachewItem getItem(String path) { - Cachew cachew = getCachew(path); - return cachew.getItem(path); - } - - public CachewItem createItem(String path) { - Cachew cachew = getCachew(path); - return cachew.createItem(path); - } - - private Cachew getCachew(String path) { - Iterator itr = map.keySet().iterator(); - while(itr.hasNext()) { - String key = (String) itr.next(); - if(path.matches(key)) { - return (Cachew) map.get(path); - } - } - return null; - } - -} diff --git a/cachew/src/java/org/osjava/cachew/CachewRefreshServlet.java b/cachew/src/java/org/osjava/cachew/CachewRefreshServlet.java deleted file mode 100755 index e2ae0d62..00000000 --- a/cachew/src/java/org/osjava/cachew/CachewRefreshServlet.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Created on Jun 10, 2005 - */ -package org.osjava.cachew; - -import java.io.IOException; -import java.io.OutputStream; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author hen - */ -public class CachewRefreshServlet extends HttpServlet { - - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - String path = request.getPathInfo(); - - // ask CachewManager to create new CachewItem. - CachewItem cItem = CachewGetServlet.cManager.createItem(path); - - // write CachewItem to stream - response.setContentType(cItem.getContentType()); - OutputStream out = response.getOutputStream(); - out.write(cItem.getBytes()); - out.flush(); - } -} diff --git a/charlotte/.classpath b/charlotte/.classpath deleted file mode 100644 index 79885524..00000000 --- a/charlotte/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/charlotte/.project b/charlotte/.project deleted file mode 100644 index 0f483127..00000000 --- a/charlotte/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - charlotte - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/charlotte/TODO.txt b/charlotte/TODO.txt deleted file mode 100644 index 2fdab02e..00000000 --- a/charlotte/TODO.txt +++ /dev/null @@ -1,8 +0,0 @@ -From the now defunct JIRA: - -* user documentation - -* move utility functions out the encoding class into the EncodingUtil class - -* code generation - the ability to generate class files representing the values described by an encoding instance. diff --git a/charlotte/maven.xml b/charlotte/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/charlotte/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/charlotte/project.properties b/charlotte/project.properties deleted file mode 100644 index f1e00f86..00000000 --- a/charlotte/project.properties +++ /dev/null @@ -1,17 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#eeffee -maven.ui.banner.background=#66CC00 -maven.ui.section.background=#66CC00 -maven.ui.subsection.background=#66CC00 -maven.ui.breadcrumbs.background=#eeffee - -maven.xdoc.theme=classic -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory - -maven.javadoc.stylesheet = ../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/charlotte/project.xml b/charlotte/project.xml deleted file mode 100644 index 79ae5331..00000000 --- a/charlotte/project.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - 3 - charlotte - charlotte - - - 1.0-rc6 - - - OSJava - http://www.osjava.org - http://www.osjava.org/images/osjava-green.gif - - - 2003 - code316.charlotte - - http://www.osjava.org/images/1x1.gif - - - A bit format utility - - - A bit format utility - - http://www.osjava.org/charlotte/ - - - http://issues.osjava.org:8080/jira/browse/BrowseProject.jspa?id=10031 - - - scm:svn:http://svn.osjava.org/svn/osjava/trunk/charlotte - http://svn.osjava.org/svn/osjava/trunk/charlotte - - - - - osjava-users - http://lists.osjava.org/mailman/listinfo/osjava-users - http://lists.osjava.org/mailman/listinfo/osjava-users - http://lists.osjava.org/mailman/private/osjava-users/ - - - - - - - - David Petersheim - dave - david.petersheim@genscape.com - code316 - - Java Developer - - - - - - - - - - - - - - - code316 - code316-core - 0.8 - http://www.code316.com/ - - http://dist.osjava.org/releases/multidoc-jnr - - - - - jep - 2.24 - - - - junit - 3.8.1 - - - - - - - src/java - - - src/test - - - - **/*Test.java - - - - - - - maven-jxr-plugin - maven-javadoc-plugin - maven-license-plugin - maven-changes-plugin - - - diff --git a/charlotte/src/java/code316/charlotte/DefaultDefinition.java b/charlotte/src/java/code316/charlotte/DefaultDefinition.java deleted file mode 100644 index 8cb73a55..00000000 --- a/charlotte/src/java/code316/charlotte/DefaultDefinition.java +++ /dev/null @@ -1,48 +0,0 @@ -package code316.charlotte; -public class DefaultDefinition implements FieldDefinition { - private String name; - private String operands = ""; - private int offset; - private int length; - private int index; - - public String getName() { - return name; - } - - public String getOperands() { - return operands; - } - - public void setName(String string) { - name = string; - } - - public void setOperands(String string) { - operands = string; - } - - public int getWidth() { - return this.length; - } - - public int getOffset() { - return offset; - } - - public void setOffset(int i) { - offset = i; - } - - public void setWidth(int length) { - this.length = length; - } - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } - -} diff --git a/charlotte/src/java/code316/charlotte/DefaultEncoding.java b/charlotte/src/java/code316/charlotte/DefaultEncoding.java deleted file mode 100644 index eb735ed8..00000000 --- a/charlotte/src/java/code316/charlotte/DefaultEncoding.java +++ /dev/null @@ -1,268 +0,0 @@ -package code316.charlotte; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.nfunk.jep.JEP; - -import code316.core.PropertiesUtil; - -public class DefaultEncoding implements Encoding { - private ArrayList fieldNames = new ArrayList(); - private int bitCount; - private ArrayList fieldDefinitions = new ArrayList(); - private String encodingName = "UNNAMED"; - - public DefaultEncoding() {} - - private List getNames() { - return (List) this.fieldNames.clone(); - } - - public int getLength() { - return this.bitCount; - } - - - public List getFieldDefinitions() { - return (List) this.fieldDefinitions.clone(); - } - - private BigInteger extractFieldValue(String name, BigInteger bi) { - int count = 0; - Iterator tor = this.fieldNames.iterator(); - while (tor.hasNext()) { - if (tor.next().equals(name)) { - return extractFieldValue(count, bi); - } - count++; - } - - throw new IllegalArgumentException("field named: '" + name + "' not found"); - } - - public BigInteger extractFieldValue(int i, BigInteger bi) { - DefaultDefinition fd = (DefaultDefinition) this.fieldDefinitions.get(i); - return bi.shiftRight(fd.getOffset()).and(EncodingUtil.getMaxValue(fd.getWidth())); - } - - - public BigInteger getMaxValue() { - return EncodingUtil.getMaxValue(getLength()); - } - - private String dumpValues(BigInteger bi) { - int count = this.fieldDefinitions.size(); - - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < count; i++) { - DefaultDefinition fd = (DefaultDefinition) this.fieldDefinitions.get(i); - sb.append(fd.getName()) - .append("=") - .append(extractFieldValue(i, bi)) - .append("\n"); - } - - return sb.toString(); - } - - private String dumpFields() { - int count = this.fieldDefinitions.size(); - - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < count; i++) { - DefaultDefinition fd = (DefaultDefinition) this.fieldDefinitions.get(i); - sb.append(fd).append("\n"); - } - - return sb.toString(); - } - - private BigInteger encode(Map values) { - BigInteger encoded = new BigInteger("0"); - Iterator tor = this.fieldDefinitions.iterator(); - - while (tor.hasNext()) { - DefaultDefinition fd = (DefaultDefinition) tor.next(); - Object o = values.get(fd.getName()); - - if ( o == null ) { - continue; - } - - BigInteger val = null; - - if ( o instanceof BigInteger ) { - val = (BigInteger) o; - } - else { - val = new BigInteger(String.valueOf(o)); - } - - if ( val.longValue() > EncodingUtil.getMaxValue(fd.getWidth()).longValue()) { - throw new IllegalArgumentException("value to large for field width: " + val); - } - - encoded = encoded.or(val.shiftLeft(fd.getOffset())); - } - - return encoded; - } - - - private FieldDefinition getField(String name) { - int count = this.fieldDefinitions.size(); - for (int i = 0; i < count; i++) { - DefaultDefinition fd = (DefaultDefinition) this.fieldDefinitions.get(i); - if ( fd.getName().equals(name) ) { - return fd; - } - } - - return null; - } - - private FieldDefinition getField(int index) { - if ( index < 0 || index >= this.fieldDefinitions.size() ) { - return null; - } - - return (FieldDefinition) this.fieldDefinitions.get(index); - } - - public double expandFieldValue(int index, BigInteger bits) { - FieldDefinition fd = getField(index); - BigInteger raw = extractFieldValue(fd.getName(), bits); - String expression = fd.getOperands(); - JEP expressionParser = new JEP(); - - - if ( PropertiesUtil.isEmpty(expression) ) { - return raw.doubleValue(); - } - - - if (expression.indexOf('[') != -1 ) { - // this is a look up expresion - double []vals = parseLookupTable(expression); - - return vals[raw.intValue()]; - } - - List ids = parseIdentifiers(expression); - - if ( ids.size() != 0 ) { - expression = removeIdentifiers(expression); - - Iterator tor = ids.iterator(); - while (tor.hasNext()) { - String idName = (String) tor.next(); - FieldDefinition fieldDefinition = (FieldDefinition) getField(idName); - - if ( fieldDefinition == null ) { - throw new IllegalArgumentException("unknown field: " + idName); - } - - if ( fieldDefinition.getOffset() < fd.getOffset() ) { - throw new IllegalStateException("cannot access downstream field: " + idName); - } - - expressionParser.addVariable(idName, expandFieldValue(fieldDefinition.getIndex(), bits)); - } - } - - expressionParser.addVariable("x", raw.floatValue()); - expressionParser.addVariable("fieldWidth", fd.getWidth()); - expressionParser.addVariable("maxValue", EncodingUtil.getMaxValue(fd.getWidth()).floatValue()); - expressionParser.parseExpression(expression); - - - return expressionParser.getValue(); - } - - - private String removeIdentifiers(String expression) { - StringBuffer sb = new StringBuffer(expression.length()); - char []buffer = expression.toCharArray(); - for (int i = 0; i < buffer.length; i++) { - char ch = buffer[i]; - - if ( ch != '$' && ch != '{' && ch != '}' ) { - sb.append(ch); - } - } - return sb.toString(); - } - - private List parseIdentifiers(String expression) { - int begin = expression.indexOf("${"); - List ids = new ArrayList(1); - - while (begin != -1) { - int end = expression.indexOf("}", begin + 2); - String name = expression.substring(begin + 2, end); - - if ( !ids.contains(name) ) { - ids.add(name); - } - - begin = expression.indexOf("${", end); - } - - return ids; - } - - /** - * Parse a string into an array of doubles - * e.g. string: [2.3, 1, 4.5] - */ - private double[] parseLookupTable(String expression) { - int start = expression.indexOf('['); - int stop = expression.indexOf(']'); - - if ( start == -1 || stop == -1 || start > stop ) { - throw new IllegalArgumentException("invalid table definition: " + expression); - } - - String def = expression.substring(start + 1, stop).trim(); - StringTokenizer st = new StringTokenizer(def, ","); - double []vals = new double[st.countTokens()]; - - int i = 0; - - while (st.hasMoreTokens()) { - vals[i] = Double.parseDouble(st.nextToken()); - i++; - } - - return vals; - } - - public String getName() { - return encodingName; - } - - public void setName(String name) { - this.encodingName = name; - } - - public void addFieldDefinition(FieldDefinition def) { - DefaultEncoding.this.fieldNames.add(def.getName()); - DefaultEncoding.this.fieldDefinitions.add(def); - this.bitCount += def.getWidth(); - } - - - - public FieldDefinition getFieldDefinition(int index) { - return (FieldDefinition) this.fieldDefinitions.get(index); - } - - public int getFieldCount() { - return this.fieldDefinitions.size(); - } -} diff --git a/charlotte/src/java/code316/charlotte/Encoding.java b/charlotte/src/java/code316/charlotte/Encoding.java deleted file mode 100644 index ae870014..00000000 --- a/charlotte/src/java/code316/charlotte/Encoding.java +++ /dev/null @@ -1,17 +0,0 @@ -package code316.charlotte; -import java.math.BigInteger; -import java.util.List; - -public interface Encoding { - public static final char WHITE_SPACE[] = {' ', '\t'}; - String getName(); - void setName(String name); - void addFieldDefinition(FieldDefinition fd); - FieldDefinition getFieldDefinition(int index); - int getLength(); - List getFieldDefinitions(); - int getFieldCount(); - BigInteger getMaxValue(); - BigInteger extractFieldValue(int index, BigInteger bits); - double expandFieldValue(int index, BigInteger bits); -} diff --git a/charlotte/src/java/code316/charlotte/EncodingUtil.java b/charlotte/src/java/code316/charlotte/EncodingUtil.java deleted file mode 100644 index 649d6aab..00000000 --- a/charlotte/src/java/code316/charlotte/EncodingUtil.java +++ /dev/null @@ -1,129 +0,0 @@ -package code316.charlotte; - -import java.math.BigInteger; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - - -public class EncodingUtil { - private static final BigInteger NEGATIVE_ONE = new BigInteger("-1"); - - public static String encodingToString(Encoding ed) { - StringBuffer me = new StringBuffer(); - StringBuffer legend = new StringBuffer(); - StringBuffer map = new StringBuffer(); - - me.append("encoding name: ") - .append(ed.getName()) - .append("\n") - .append("length: ") - .append(ed.getLength()) - .append(" bits\n"); - - - me.append("\nmap: \n"); - char marker = 'A'; - - Iterator tor = ed.getFieldDefinitions().iterator(); - while (tor.hasNext()) { - FieldDefinition td = (FieldDefinition) tor.next(); - - int length = td.getWidth(); - for (int i = 0; i < length; i++) { - map.append(marker); - } - - legend.append(marker) - .append(" - ") - .append(td.getName()) - .append(": ") - .append(length) - .append(" bits,") - .append(" mutator expression: ") - .append(td.getOperands()) - .append("\n"); - - marker++; - map.append("|"); - } - - int count = map.length(); - StringBuffer temp = new StringBuffer((count * 3) + 2); - temp.append(" "); - for (int i = 0; i < (count - 1); i++) { - temp.append("-"); - } - - temp.append("\n|") - .append(map) - .append("\n"); - - temp.append(" "); - for (int i = 0; i < (count - 1); i++) { - temp.append("-"); - } - - me.append(temp); - - me.append("\n\nlegend: \n").append(legend); - - return me.toString(); - } - - public static BigInteger getMaxValue(int numBits) { - return new BigInteger("1").shiftLeft(numBits).add(NEGATIVE_ONE); - } - - - public static Value[] expandFieldsToArray(Encoding encoding, BigInteger bits) { - int count = encoding.getFieldCount(); - Value []vals = new Value[count]; - - for (int i = 0; i < vals.length; i++) { - FieldDefinition fd = encoding.getFieldDefinition(i); - vals[i] = new Value(); - - vals[i].setFieldDefinition(fd); - vals[i].setRaw(encoding.extractFieldValue(i, bits).longValue()); - vals[i].setExpanded(encoding.expandFieldValue(fd.getIndex(), bits)); - } - - return vals; - } - - /** - * returns a Map of Doubles representing a set of expanded values - * @param encoding - * @param bits - * @return - */ - public static Map expandFields(Encoding encoding, BigInteger bits) { - Value []vals = expandFieldsToArray(encoding, bits); - Map expanded = new HashMap(vals.length); - - for (int i = 0; i < vals.length; i++) { - expanded.put(vals[i].getFieldDefinition().getName(), new Double(vals[i].getExpandedAsDouble())); - } - - return expanded; - } - - /** - * returns a Map of Doubles representing a set of extracted values - * @param encoding - * @param bits - * @return - */ - public static Map extractFields(Encoding encoding, BigInteger bits) { - Value []vals = expandFieldsToArray(encoding, bits); - Map expanded = new HashMap(vals.length); - - for (int i = 0; i < vals.length; i++) { - expanded.put(vals[i].getFieldDefinition().getName(), new Double(vals[i].getRaw())); - } - - return expanded; - } - -} diff --git a/charlotte/src/java/code316/charlotte/EncodingViewer.java b/charlotte/src/java/code316/charlotte/EncodingViewer.java deleted file mode 100644 index 89b9bb67..00000000 --- a/charlotte/src/java/code316/charlotte/EncodingViewer.java +++ /dev/null @@ -1,15 +0,0 @@ -package code316.charlotte; - -import java.io.FileInputStream; -import java.io.IOException; - - -public class EncodingViewer { - public static void main(String[] args) throws IOException { - FileInputStream in = new FileInputStream(args[0]); - Parser p = new Parser(); - Encoding e = p.parse(in); - - System.out.println(EncodingUtil.encodingToString(e)); - } -} diff --git a/charlotte/src/java/code316/charlotte/FieldDefinition.java b/charlotte/src/java/code316/charlotte/FieldDefinition.java deleted file mode 100644 index e140529b..00000000 --- a/charlotte/src/java/code316/charlotte/FieldDefinition.java +++ /dev/null @@ -1,20 +0,0 @@ -package code316.charlotte; - - -public interface FieldDefinition { - String getName(); - void setName(String name); - - int getWidth(); - void setWidth(int width); - - - String getOperands(); - void setOperands(String string); - - int getOffset(); - void setOffset(int i); - - int getIndex(); - void setIndex(int index); -} \ No newline at end of file diff --git a/charlotte/src/java/code316/charlotte/Parser.java b/charlotte/src/java/code316/charlotte/Parser.java deleted file mode 100644 index 849b60e8..00000000 --- a/charlotte/src/java/code316/charlotte/Parser.java +++ /dev/null @@ -1,186 +0,0 @@ -package code316.charlotte; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; - - -public class Parser { - private int lineNumber = 0; - public Encoding parse(InputStream is) throws IOException { - if (is == null) { - throw new IllegalArgumentException("invalid value for input stream: " + is); - } - - BufferedReader in = new BufferedReader(new InputStreamReader(is)); - String line = null; - int bitPos = 0; - Encoding encoding = new DefaultEncoding(); - String encodingName = null; - - while ((line = in.readLine()) != null) { - lineNumber++; - line = line.trim(); - - if ( line.startsWith("#") || line.length() == 0 ) { - // skip comments and blank lines - continue; - } - else if ( line.startsWith("name:") ) { - if ( encodingName != null) { - throw new IllegalArgumentException("error on line: " + lineNumber + " (encoding name already defined)"); - } - - encodingName = parseEncodingName(line); - encoding.setName(encodingName); - continue; - } - - FieldDefinition def = parseDefinition(line); - - if ( def == null ) { - throw new IllegalStateException("invalid field definition on line: " + lineNumber); - } - - bitPos += def.getWidth(); - - def.setIndex(encoding.getFieldCount()); - encoding.addFieldDefinition(def); - } - - int count = encoding.getFieldCount(); - int pos = 0; - for (int i = count - 1; i >= 0; i--) { - FieldDefinition fd = (FieldDefinition) encoding.getFieldDefinition(i); - fd.setOffset(pos); - pos += fd.getWidth(); - } - - return encoding; - } - - - private FieldDefinition parseDefinition(String line) { - int equalPos = line.indexOf('='); - int commaPos = line.indexOf(','); - - if ( equalPos == -1 ) { - return null; - } - - FieldDefinition def = new DefaultDefinition(); - - String typeAndName = line.substring(0, equalPos).trim(); - - String fieldName = parseName(typeAndName); - - - def.setName(fieldName); - - String bitDef = null; - - if ( commaPos != -1 ) { - // definition is from equal to comma - if ( commaPos <= (equalPos + 1)) { - return null; - } - else { - bitDef = line.substring(equalPos + 1, commaPos).trim(); - def.setOperands(line.substring(commaPos + 1).trim()); - } - } - else { - // rest of line is definition - bitDef = line.substring(equalPos + 1).trim(); - } - - if ( bitDef == null ) { - return null; - } - - def.setWidth(Integer.parseInt(bitDef)); - - return def; - } - - - - - - /** - * parse a type and name from a line that looks like this: - * [type] - * if more than one word is found, then the first word - * is a type name and the second word is a name. - * - * if only one word is found then that - * word is a name and the name can not be a reserved word. - * - * there can be no leading or trailing whitespace - * - * @param typeAndName - * @return a field type or null if no type is found - */ - private String parseName(String typeAndName) { - int pos = indexOfAny(Encoding.WHITE_SPACE, typeAndName); - - if ( pos == -1) { - return typeAndName; - } - - String name = typeAndName.substring(pos + 1).trim(); - - if ( indexOfAny(Encoding.WHITE_SPACE, name) != -1 ) { - throw new IllegalStateException("white space found where none expected. line: " - + this.lineNumber); - } - - - return name; - } - - - /** - * Encoding name line looks like this: - * name: My Favorite Encoding - * @param line - * @return - */ - private String parseEncodingName(String line) { - int pos = line.indexOf(':'); - - if ( pos == -1) { - return null; - } - - return line.substring(pos + 1).trim(); - } - - - private int indexOfAny(char[] findAny, String typeAndName) { - for (int i = 0; i < findAny.length; i++) { - int index; - if ( (index = typeAndName.indexOf(findAny[i])) != -1) { - return index; - } - } - return -1; - } - - private int parseInteger(String bitDef) { - int pos = bitDef.indexOf('.'); - - return (pos == -1) - ? Integer.parseInt(bitDef) - : Integer.parseInt(bitDef.substring(0, pos)); - } - - private int parseDecimal(String bitDef) { - int pos = bitDef.indexOf('.'); - - return (pos == -1) - ? 0 - : Integer.parseInt(bitDef.substring(pos + 1)); - } -} \ No newline at end of file diff --git a/charlotte/src/java/code316/charlotte/Value.java b/charlotte/src/java/code316/charlotte/Value.java deleted file mode 100644 index 20c9b447..00000000 --- a/charlotte/src/java/code316/charlotte/Value.java +++ /dev/null @@ -1,50 +0,0 @@ -package code316.charlotte; - - -public class Value { - private double expanded; - private FieldDefinition fieldDefinition; - private long raw; - - public FieldDefinition getFieldDefinition() { - return fieldDefinition; - } - - - public void setFieldDefinition(FieldDefinition fieldDefinition) { - this.fieldDefinition = fieldDefinition; - } - - public void setRaw(long raw) { - this.raw = raw; - } - - /** - * Returns the long value represented by a fields bits within a set - * of encoded bits. To receive the value of the field with any - * expressions applied to it, see getExpanded - */ - public long getRaw() { - return raw; - } - - public double getExpandedAsDouble() { - return this.expanded; - } - - public long getExpandedAsLong() { - return (long) this.expanded; - } - - public int getExpandedAsInt() { - return (int) this.expanded; - } - - public float getExpandedAsFloat() { - return (float) this.expanded; - } - - public void setExpanded(double expanded) { - this.expanded = expanded; - } -} diff --git a/charlotte/src/java/code316/charlotte/ValueExtractor.java b/charlotte/src/java/code316/charlotte/ValueExtractor.java deleted file mode 100644 index a07f47d1..00000000 --- a/charlotte/src/java/code316/charlotte/ValueExtractor.java +++ /dev/null @@ -1,34 +0,0 @@ -package code316.charlotte; -import java.math.BigInteger; - - -public class ValueExtractor { - public static void main(String[] args) { - if (args.length != 3) { - System.err.println("use: ValueExtractor "); - return; - } - - - int shift = Integer.parseInt(args[1]); - - - System.out.println(extract(args[0], shift, new BigInteger(args[2]))); - } - - public static BigInteger extract(String valString, int shift, BigInteger maxVal) { - int radix = 10; - String val = valString; - char last = valString.charAt(valString.length() - 1); - if ( last == 'h' || last == 'H') { - radix = 16; - val = valString.substring(0, valString.length() - 1); - } - else if ( last == 'b' || last == 'B') { - radix = 2; - val = valString.substring(0, valString.length() - 1); - } - - return new BigInteger(val, radix).shiftRight(shift).and(maxVal); - } -} diff --git a/charlotte/src/test/code316/charlotte/AllTests.java b/charlotte/src/test/code316/charlotte/AllTests.java deleted file mode 100644 index 83a73d5d..00000000 --- a/charlotte/src/test/code316/charlotte/AllTests.java +++ /dev/null @@ -1,17 +0,0 @@ -package code316.charlotte; - -import junit.framework.Test; -import junit.framework.TestSuite; - - -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite("Test for code316.bits"); - //$JUnit-BEGIN$ - suite.addTest(new TestSuite(ValueExtractorTest.class)); - suite.addTest(new TestSuite(EncodingTest.class)); - //$JUnit-END$ - return suite; - } -} diff --git a/charlotte/src/test/code316/charlotte/EncodingTest.java b/charlotte/src/test/code316/charlotte/EncodingTest.java deleted file mode 100644 index 52aa1ff5..00000000 --- a/charlotte/src/test/code316/charlotte/EncodingTest.java +++ /dev/null @@ -1,183 +0,0 @@ -package code316.charlotte; - -import java.io.ByteArrayInputStream; -import java.math.BigInteger; - -import junit.framework.TestCase; - -public class EncodingTest extends TestCase { - public static final int ENCODING_LENGTH = 32; - public static final int VALUE_COUNT = 7; - public static final String ENCODING = - "# test encoding\n" - + "name: Test Encoding\t \n" - + "angle=5 , (x / maxValue) * 2.8\n" - + "fails=2, [700, 705, 775.562, 800.1]\n" - + "level=1 \n" - + "\n" - + "# another comment \n" - + "temp=13, (x / 8191) * 78\n" - + "door_open=1\n" - + "rms=4, (x * 15) + 3\n" - + "velocity=6, (${angle} / x * 4.312) + ${level}"; - - - private static Encoding getTestEncoding() throws Exception { - Parser parser = new Parser(); - return parser.parse(new ByteArrayInputStream(ENCODING.getBytes())); - } - - public void testUnpackFields() throws Exception { - Encoding e = getTestEncoding(); - BigInteger bits = new BigInteger("10101101011101111000000101101101", 2); - - Value []vals = EncodingUtil.expandFieldsToArray(e, bits); - - assertEquals(7, vals.length); - - // check values - assertEquals(21, vals[0].getRaw()); - assertEquals(2, vals[1].getRaw()); - assertEquals(1, vals[2].getRaw()); - assertEquals(3824, vals[3].getRaw()); - assertEquals(0, vals[4].getRaw()); - assertEquals(5, vals[5].getRaw()); - assertEquals(45, vals[6].getRaw()); - - assertEquals(1.896, vals[0].getExpandedAsDouble(), .001); - assertEquals(775.562, vals[1].getExpandedAsDouble(), .001); - assertEquals(1, vals[2].getExpandedAsDouble(), 0); - assertEquals(36.414, vals[3].getExpandedAsDouble(), .001); - assertEquals(0, vals[4].getExpandedAsDouble(), 0); - assertEquals(78, vals[5].getExpandedAsDouble(), 0); - assertEquals(1.1816, vals[6].getExpandedAsDouble(), .001); - } - - - - - public void testParseEncoding() throws Exception { - Encoding e = getTestEncoding(); - - assertEquals("Test Encoding", e.getName()); - assertEquals(ENCODING_LENGTH, e.getLength()); - assertEquals(VALUE_COUNT, e.getFieldCount()); - - - System.out.println(EncodingUtil.encodingToString(e)); - } - - - - public void testMaxValue() throws Exception { - Encoding e = getTestEncoding(); - - assertEquals(new BigInteger("11111111111111111111111111111111", 2), e.getMaxValue()); - } - /* - public void testExtractFieldsByIndex() throws IOException { - Encoding e = new Encoding(); - - e.parse(new ByteArrayInputStream(ENCODING.getBytes())); - - BigInteger bits = new BigInteger("10110100110100001001", 2); - - assertEquals(new BigInteger("5"), e.extractFieldValue(0, bits)); - assertEquals(new BigInteger("2"), e.extractFieldValue(1, bits)); - assertEquals(new BigInteger("1"), e.extractFieldValue(2, bits)); - assertEquals(new BigInteger("1668"), e.extractFieldValue(3, bits)); - assertEquals(new BigInteger("1"), e.extractFieldValue(4, bits)); - } - - public void testExtractFieldsByName() throws IOException { - Encoding e = new Encoding(); - - e.parse(new ByteArrayInputStream(ENCODING.getBytes())); - - BigInteger bits = new BigInteger("10110100110100001001", 2); - - assertEquals(new BigInteger("5"), e.extractFieldValue("angle", bits)); - assertEquals(new BigInteger("2"), e.extractFieldValue("fails", bits)); - assertEquals(new BigInteger("1"), e.extractFieldValue("level", bits)); - assertEquals(new BigInteger("1668"), e.extractFieldValue("temp", bits)); - assertEquals(new BigInteger("1"), e.extractFieldValue("door_open", bits)); - } - - public void testUnpackFieldsByName() throws IOException { - Encoding e = new Encoding(); - - e.parse(new ByteArrayInputStream(ENCODING.getBytes())); - - BigInteger bits = new BigInteger("10110100110100001001", 2); - - float result = e.unpackFieldValue(3, bits).floatValue(); - - assertEquals(new BigDecimal("16").floatValue(), result, 1); - } - - - public void testDumpValues() throws Exception { - Encoding e = new Encoding(); - - e.parse(new ByteArrayInputStream(ENCODING.getBytes())); - - BigInteger bi = new BigInteger("10110100110100001001", 2); - System.out.println("dump: " + e.dumpValues(bi)); - } - - - - public void testEncode() throws Exception { - Encoding e = new Encoding(); - - e.parse(new ByteArrayInputStream(ENCODING.getBytes())); - - HashMap map = new HashMap(); - - map.put("angle", new BigInteger("3")); - map.put("fails", new BigInteger("2")); - map.put("level", new BigInteger("1")); - map.put("temp", new BigInteger("3336")); - map.put("door_open", new BigInteger("1")); - - - BigInteger encoded = e.encode(map); - - assertEquals(new BigInteger("481809"), encoded); - } - - - public void testGetByName() throws Exception { - Encoding e = new Encoding(); - Encoding e2 = new Encoding(); - - e.parse(new ByteArrayInputStream(ENCODING.getBytes())); - e2.parse(new ByteArrayInputStream(ENCODING.getBytes())); - - assertEquals(e.getField("temp").getName(), "temp"); - assertEquals(null, e.getField("fairy")); - - assertEquals(e2.getField("temp").getName(), "temp"); - assertEquals(null, e2.getField("fairy")); - } - - public void testGetByIndex() throws Exception { - Encoding e = new Encoding(); - Encoding e2 = new Encoding(); - - e.parse(new ByteArrayInputStream(ENCODING.getBytes())); - e2.parse(new ByteArrayInputStream(ENCODING.getBytes())); - - assertEquals(e.getField(3).getName(), "temp"); - assertEquals(null, e.getField(10)); - assertEquals(null, e.getField(-1)); - - assertEquals(e2.getField(3).getName(), "temp"); - assertEquals(null, e2.getField(10)); - assertEquals(null, e2.getField(-1)); - } - - -*/ -} - diff --git a/charlotte/src/test/code316/charlotte/ValueExtractorTest.java b/charlotte/src/test/code316/charlotte/ValueExtractorTest.java deleted file mode 100644 index a0add2c7..00000000 --- a/charlotte/src/test/code316/charlotte/ValueExtractorTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package code316.charlotte; - -import java.math.BigInteger; - -import junit.framework.TestCase; - - -public class ValueExtractorTest extends TestCase { - public void testExtraction() { - int shift = 2; - - BigInteger maxVal = new BigInteger("2047"); - - // decimal test - BigInteger result = ValueExtractor.extract("2748", shift, maxVal); - assertEquals(new BigInteger("687"), result); - - - // hex test - result = ValueExtractor.extract("abch", shift, maxVal); - assertEquals(new BigInteger("687"), result); - - result = ValueExtractor.extract("abcH", shift, maxVal); - assertEquals(new BigInteger("687"), result); - - - // binary test - result = ValueExtractor.extract("101010111100b", shift, maxVal); - assertEquals(new BigInteger("687"), result); - - result = ValueExtractor.extract("101010111100B", shift, maxVal); - assertEquals(new BigInteger("687"), result); - } - - - public void testMainMethod() { - ValueExtractor.main(new String[] {"2748", "2", "2047"}); - } -} diff --git a/charlotte/xdocs/changes.xml b/charlotte/xdocs/changes.xml deleted file mode 100644 index 26c458b4..00000000 --- a/charlotte/xdocs/changes.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - David Petersheim - Changes - - - - - First release of Charlotte. - - - diff --git a/charlotte/xdocs/data-dictionary.txt b/charlotte/xdocs/data-dictionary.txt deleted file mode 100644 index f76e8527..00000000 --- a/charlotte/xdocs/data-dictionary.txt +++ /dev/null @@ -1,10 +0,0 @@ -encoding-definition = (field-definiton)+ -field-definition = (bit-count)[,(expression-string)] -expression-string = (lookup-table|mathematic-expression) -lookup-table = ([)(float)(,float)*(]) -float = floating point number -mathematic-expression = a mathematical function containing simple math operators and - the variable (x). The function may also contain the variables - maxValue and fieldWidth and any of the JEP standard functions - such as cos, sin, etc. - diff --git a/charlotte/xdocs/navigation.xml b/charlotte/xdocs/navigation.xml deleted file mode 100644 index 80c6ab7e..00000000 --- a/charlotte/xdocs/navigation.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - Charlotte - - - - - - - - - - - - - - - - - - - - - - diff --git a/charlotte/xdocs/style/custom.css b/charlotte/xdocs/style/custom.css deleted file mode 100644 index 3e6d9d73..00000000 --- a/charlotte/xdocs/style/custom.css +++ /dev/null @@ -1,9 +0,0 @@ - -.code { - margin-left: 4em; - margin-right: 4em; - padding: 1em; - background-color: #eeffee; - border: 1px solid #aaa; -} - diff --git a/charlotte/xdocs/tcp-header.enc b/charlotte/xdocs/tcp-header.enc deleted file mode 100644 index 7e9e51b1..00000000 --- a/charlotte/xdocs/tcp-header.enc +++ /dev/null @@ -1,13 +0,0 @@ -name: TCP Header -version=4 -headerLength=4 -typeOfService=8 -totalLength=16 -id=16 -flags=3 -fragmentOffset=13 -timeToLive=8 -protocol=8 -headerChecksum=16 -sourceIp=32 -destinationIp=32 \ No newline at end of file diff --git a/charlotte/xdocs/tcp.txt b/charlotte/xdocs/tcp.txt deleted file mode 100644 index c37517d2..00000000 --- a/charlotte/xdocs/tcp.txt +++ /dev/null @@ -1,22 +0,0 @@ -encoding name: TCP Header -length: 160 bits - -map: - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -|AAAA|BBBB|CCCCCCCC|DDDDDDDDDDDDDDDD|EEEEEEEEEEEEEEEE|FFF|GGGGGGGGGGGGG|HHHHHHHH|IIIIIIII|JJJJJJJJJJJJJJJJ|KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK|LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL| - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -legend: -A - version: 4 bits, mutator expression: -B - headerLength: 4 bits, mutator expression: -C - typeOfService: 8 bits, mutator expression: -D - totalLength: 16 bits, mutator expression: -E - id: 16 bits, mutator expression: -F - flags: 3 bits, mutator expression: -G - fragmentOffset: 13 bits, mutator expression: -H - timeToLive: 8 bits, mutator expression: -I - protocol: 8 bits, mutator expression: -J - headerChecksum: 16 bits, mutator expression: -K - sourceIp: 32 bits, mutator expression: -L - destinationIp: 32 bits, mutator expression: - diff --git a/charlotte/xdocs/tutorial.xml b/charlotte/xdocs/tutorial.xml deleted file mode 100644 index 94d36add..00000000 --- a/charlotte/xdocs/tutorial.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - David Petersheim - Tutorial - - - -
-

Charlotte is a tool for manipulating Bit Based Packet (BBP). - A BBP is a single series of bits representing multiple values. - For example, a TCP header has the following form.

- - -

The total number of bits in the above definition is 160 bytes.

- -

A charlotte encoding description for a TCP Header would look like this:

- -
-name: TCP Header
-version=4
-headerLength=4
-typeOfService=8
-totalLength=16
-id=16
-flags=3
-fragmentOffset=13
-timeToLive=8
-protocol=8
-headerChecksum=16
-sourceIp=32
-destinationIp=32
-
- -

It would then be used like this:

- -
-import code316.charlotte.Encoding;
-import code316.charlotte.EncodingUtil;
-import code316.charlotte.Parser;
-
-public class Test {
-
-    private static final Encoding TCP_ENCODING;
-    private static final String TCP_ENCODING_FILE = "encoding-definitions/tcp-encoding.enc";
-    static {
-        try {
-            Parser ep = new Parser();
-            InputStream in =
-                Test.class.getClassLoader().getResourceAsStream(TCP_ENCODING_FILE);
-
-            if ( in == null ) {
-                throw new IllegalStateException("could not load tcp encoding file: " + TCP_ENCODING_FILE);
-            }
-            TCP_ENCODING = ep.parse(in);
-        }
-        catch (IOException ioe) {
-            throw new RuntimeException("Could not create encoding", ioe);
-        }
-    }
-
-    public static TcpValue decodeTcpValue(BigInteger bits) {
-        // contains a Map of String to Double
-        Map valueMap = EncodingUtil.expandFields(TCP_ENCODING, bits);
-        TcpValue tcp = new TcpValue();
-        tcp.setVersion( valueMap.get("version") );
-        ....
-
- -
- -
diff --git a/code316-core/.classpath b/code316-core/.classpath deleted file mode 100644 index b856274c..00000000 --- a/code316-core/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/code316-core/.project b/code316-core/.project deleted file mode 100644 index 0b3c6ae6..00000000 --- a/code316-core/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - code316-core - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/code316-core/Manifest.mf b/code316-core/Manifest.mf deleted file mode 100644 index e69de29b..00000000 diff --git a/code316-core/TODO.txt b/code316-core/TODO.txt deleted file mode 100644 index d29a59de..00000000 --- a/code316-core/TODO.txt +++ /dev/null @@ -1,4 +0,0 @@ -From the now defunct JIRA: - -* FileUtil class should accept a java.io.File object in addition to String - its the decent thing to do diff --git a/code316-core/changelog.txt b/code316-core/changelog.txt deleted file mode 100644 index 83a08c2e..00000000 --- a/code316-core/changelog.txt +++ /dev/null @@ -1,88 +0,0 @@ ------------------------------------- -.7d to 0.8 -- General - deprecated ModelDescription 'names' in favor of 'columnNames' -- added BeanTable, beans package, BeanUtil, and BeanProperty class -- Launcher is now public -- removed bits package again - ------------------------------------- -.7c to .7d - 22jul2003 -- BeanTableModel - now caches parsed property names and method names -- BeanTableModel - added absolute method call ability for bean properties - e.g. message.body.topPart().category.name.length() - ------------------------------------- -.7b to .7c - 17jul2003 -- new class ExceptionUtil -- BeanTableModel now supports nested property names, e.g. "message.body.size" -- BeanTableModel now supports boolean "get" methods starting with "is" - ------------------------------------- -.7a to .7b - 10jul2003 -- add new methods to fileutil -- exposed clear method for bean table model -- clearing bean table model now fires rows deleted - ------------------------------------- -.6b to .7 - 14jun2003 -- added bits package, Encoding stuff -- added methods to Args parser, better javadoc also - ------------------------------------- -.6a to .6b - - ------------------------------------- -.6 to .6a - 14may2003 -- launch script builder now uses path separator to determine argument character - - ------------------------------------- -.5b to .6 - 12may2003 -- imported gui package from code316 - ------------------------------------- -.5a to .5b - 09may2003 -- added argument to launchscriptbuilder - ------------------------------------- -.5 to .5a - 22apr2003 -- added get extension methods to FileUtil - ------------------------------------- -.4a to .5 - ? -- added FileMaskFilter to project (from sentinel) -- changed package names, this will break everything - ------------------------------------- -.4 to .4a - 02mar2003 -- added features to launchscriptbuilder -- added addl parse method to Args class - - ------------------------------------- -.3 to .4 - 07feb2003 -- added filterProperties method to PropertiesUtil -- removed logging from PropertiesUtil - - ------------------------------------- -.2.1 to .3 - 05feb2003 -- added isEmpty method to PropertiesUtil -- added charlotte project to core - - charlotte should be it's own project - - ------------------------------------- -.2 to .2.1 - 27dec2002 - -- ClassUtil - - add quiteInstantiatiate - - changed instantiate to throw exceptions - -- imported class loading utilities from code316 - - ------------------------------------- -.1 to .2 - -removed deprecated methods diff --git a/code316-core/encoding.g b/code316-core/encoding.g deleted file mode 100644 index 730cdf87..00000000 --- a/code316-core/encoding.g +++ /dev/null @@ -1,62 +0,0 @@ - - -class P extends Parser; - -// match one-or-more 'name followed by age' pairs - - -fieldDefinition - : ( - n:NAME e:EQUAL u:NUM (c:COLON (m:NUM o:OPERATOR)*)? - { - System.out.println("name: " + n.getText()); - if ( c != null ) { - System.out.println("colon found: " + c.getText()); - } - } - )+ - ; - - -class L extends Lexer; - -NAME: ( 'a'..'z' | 'A'..'Z' | '$' | '_')+ - ; - -OPERATOR: ('+' | '-' | '*' | '/' | '^' ) - ; - -DOT : '.' - ; - -SEMI : ';' - ; - -COLON: ':' - ; - -EQUAL: '=' - ; - - - - -//BITDEF: NUM ('B' | 'b') -// ; - - - - -NUM : ('0'..'9')+ (DOT)? ('0'..'9')* - ; - - - -WS : ( ' ' - | '\t' - | '\r' '\n' { newline(); } - | '\n' { newline(); } - ) - {$setType(Token.SKIP);} //ignore this token - ; - diff --git a/code316-core/encodingdescriptions b/code316-core/encodingdescriptions deleted file mode 100644 index ccd69a19..00000000 --- a/code316-core/encodingdescriptions +++ /dev/null @@ -1,4 +0,0 @@ -sampleEncoding = 32 -encoding-two = 34 : - - \ No newline at end of file diff --git a/code316-core/g.txt b/code316-core/g.txt deleted file mode 100644 index 9a6977b2..00000000 --- a/code316-core/g.txt +++ /dev/null @@ -1,235 +0,0 @@ - -C:\px\projects\code316-core>c:\px\classes\maven\bin\maven -g - __ __ -| \/ |__ Jakarta _ ___ -| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~ -|_| |_\__,_|\_/\___|_||_| v. 1.0-beta-6 - -C:\px\projects\code316-core - - -Available [Plugins] / Goals -``````````````````````````` -[activity] : Generate developer and file activity reports - generate ................... Generate developer and file activity reports - -[ant] : Generate an Ant build file - generate-build ............. Generate an Ant build file - -[appserver] ( NO DEFAULT GOAL ) - clean ...................... Safely delete an installed appserver instance - install .................... Install or reinstall a appserver instance - start ...................... Start or restart an appserver instance - stop ....................... Stop an appserver instance if started - -[aspectj] : Compile code with AspectJ - compile .................... Compile code with AspectJ - -[changelog] : Generate a changelog report - generate ................... Generate a changelog report - -[checkstyle] : Generate code convention conformance reports - check-license-file ......... Checks the existence of the LICENSE.txt file - generate-report ............ Generate code convention conformance reports - -[clean] : Remove all project artifacts - clean ...................... Remove all project artifacts - -[clover] : Generate HTML test coverage reports with Clover - html-report ................ Generate HTML test coverage reports with Clover - on ......................... Create the needed directory structure - swing-report ............... Generate Swing test coverage reports with Clover - -[codeswitcher] ( NO DEFAULT GOAL ) - init ....................... Validate the Maven XML project descriptor - -[console] : Generate the .jnlp file - help ....................... Prints the help message. - listGoals .................. Lists all available goals - -[dependency] : Map the packages to dependencies, check out the sources, discover - the dependencies and update the POM - checkout-sources ........... Check out the sources of the projects - dependencies-to-pom ........ Put the generated dependencies back to the POM - package-project-map ........ Map the packages to project names in a file - process-project-descriptors Map the packages to dependencies, check out the - sources, discover the dependencies and update - the POM - resolve-projects ........... Discovers the dependencies from the source code - -[deploy] ( NO DEFAULT GOAL ) - pom ........................ Deploy POM to the central repository. - -[dist] : Build a complete distribution. - build ...................... Build a complete distribution. - build-bin .................. Build the binary distribution. - build-src .................. Build the source distribution. - prepare-bin-filesystem ..... Builds the binary distribution file system. - prepare-src-filesystem ..... Builds the source distribution file system. - -[docbook] ( NO DEFAULT GOAL ) - transform .................. Transform any docbook-simple source into xdocs - for later use - -[eclipse] : Generate Eclipse project files - add-maven-repo ............. Ensure that the classpath variable MAVEN_REPO is - available - external-tools ............. Generate an Eclipse external tool for each goal - generate-project ........... Generate Eclipse .project and .classpath project - files - -[fo] : Generate XSL:FO project documentation - fo ......................... Generate XSL:FO project documentation - -[graph] : Create an xdoc document from the project goals - goals-to-image ............. Get a .gif graph of current goals and their - dependencies - goals-to-xdoc .............. Create an xdoc document from the project goals - goals-to-xml ............... Get an xml file representing the goal structure - -[gump] : Generate Gump descriptor from Maven descriptor - generate-descriptor ........ Generate Gump descriptor from Maven descriptor - -[idea] : Generate IDEA project files - generate-project ........... Generate IDEA .ipr and .iws project files - -[importscrubber] : Scrub import statements - -[init-dvsl-tag] ( NO DESCRIPTION ) - -[init-texen-tag] ( NO DESCRIPTION ) - -[j2ee] : Check that a war file is valid - ear ........................ Create an EAR file from the project - validate-war ............... Check that a war file is valid - -[jalopy] : Format all sources with code convention conformance - format ..................... Format all sources with code convention - conformance - -[jar] ( NO DEFAULT GOAL ) - deploy ..................... Deploy a jar to the remote repository - deploy-snapshot ............ Deploy a snapshot jar to the remote repository - install .................... Install the jar in the local repository - snapshot ................... Create a snapshot jar, ie 'id-YYYYMMDD.hhmmss. - jar' - -[java] ( NO DEFAULT GOAL ) - compile .................... Compile the project - jar ........................ Create the deliverable jar file. - jar-resources .............. Copy any resources that must be present in the - deployed JAR file - prepare-filesystem ......... Create the directory structure needed to compile - -[javadoc] : Generate API documentation - generate ................... Generate API documentation - -[jbuilder] : Generate JBuilder project files - generate-library ........... Generate JBuilder [id_project].library file - generate-project ........... Generate JBuilder [id_project].jpx file - -[jdepend] : Generate a dependency report with JDepend - generate-report ............ Generate a dependency report with JDepend - -[jdiff] : generate an api difference report between versions - -[junit-report] : Generate a report from the test results - -[jxr] : Generate HTML cross reference sources - generate ................... Generate HTML cross reference sources - -[license] : Generate a xml file from your license.txt - transfer ................... Generate a xml file from your license.txt - -[pdf] : Generate PDF project documentation - pdf ........................ Generate PDF project documentation - -[pom] : Validate the Maven XML project descriptor - update ..................... Update the POM from its current version to a - specified version - validate ................... Validate the Maven XML project descriptor - validate-new ............... Validate the Maven XML project descriptor ( - experimental) - -[site] : Generate the web site - generate ................... Generate the web site - -[statcvs] : Generate CVS statistics for the current CVS project - generate ................... Generate CVS statistics for the current CVS - project - -[struts] : Ensure a war file containing a Struts application is valid - validate-war ............... Ensure a war file containing a Struts - application is valid - -[tasklist] : Generate a list of tasks from @task tags in your code - -[test] : Test the application - compile .................... Compile the TestCases and TestSuites - match ...................... Execute all the tests matching the given ' - testmatch' variable - match-test ................. [deprecated] please use the test:match goal - instead - prepare-filesystem ......... Create the needed directory structure - single ..................... Execute a single test defined using the ' - testcase' variable - single-test ................ [deprecated] please use the test:single goal - instead - test ....................... Test the application - test-resources ............. Copy any resources that must be present for run - tests - ui ......................... Starts the Swing TestRunner front end - -[war] : Build a war file - install .................... Install the war in the local repository - war ........................ Build a war file - webapp ..................... Build a webapp directory - -[webserver] ( NO DEFAULT GOAL ) - apache-2.x-reqs ............ ( NO DESCRIPTION ) - clean ...................... Safely delete an installed webserver instance - install .................... Install or reinstall a webserver instance - start ...................... Start or restart a webserver instance - stop ....................... Stop a webserver instance if started - -[xdoc] : Generate html project documentation xdoc sources - generate-from-pom .......... Generates xdocs for site based on project - descriptor - transform .................. Generate html project documentation xdoc sources - -[xdoclet] : Perform XDocelt routines - ejbdoclet .................. Invokes xdoclet - prepare-filesystem ......... Prepares Filesystem for XDoclet - webdoclet .................. Create the directory structure needed to create - the war - - -Non documented goals : - - appserver:init - appserver:install-tomcat-4.x - appserver:reinstall - appserver:restart - appserver:start-tomcat-4.x - appserver:stop-tomcat-4.x - dist:build-setup - dist:deploy - dist:deploy-bin - dist:deploy-snapshot - dist:deploy-src - graph:project-dependencies - init-dvsl-tag - init-texen-tag - jalopy:taskdef - junit-report:generate - site:deploy - tasklist:generate - webserver:apache-2.x-reqs - webserver:init - webserver:install-apache-2.x - webserver:reinstall - webserver:restart - webserver:restart-apache-2.x - webserver:start-apache-2.x - webserver:stop-apache-2.x - diff --git a/code316-core/launch.bat b/code316-core/launch.bat deleted file mode 100644 index c9ab0f7f..00000000 --- a/code316-core/launch.bat +++ /dev/null @@ -1,2 +0,0 @@ -javaw -cp c:\px\lib\activation.jar;c:\px\lib\aelfred.jar;c:\px\lib\classes12.zip;c:\px\lib\classworlds.jar;c:\px\lib\code316-.1.jar;c:\px\lib\code316-.3.jar;c:\px\lib\code316-.5.jar;c:\px\lib\code316-.6.jar;c:\px\lib\code316-core-.1.jar;c:\px\lib\code316-core-.2.1.jar;c:\px\lib\code316.jar;c:\px\lib\commons-beanutils.jar;c:\px\lib\commons-collections.jar;c:\px\lib\commons-collections2.0.jar;c:\px\lib\commons-dbutils-SNAPSHOT.jar;c:\px\lib\commons-digester.jar;c:\px\lib\commons-lang-1.0-b1.1.jar;c:\px\lib\commons-logging-1.0.2.jar;c:\px\lib\commons-strings.jar;c:\px\lib\crimson.jar;c:\px\lib\cvslib.jar;c:\px\lib\de.abstrakt.mock.jar;c:\px\lib\dirty.jar;c:\px\lib\doug.jar;c:\px\lib\genjava-src.jar;c:\px\lib\GenJavaCore.jar;c:\px\lib\genscape-common-2.2.jar;c:\px\lib\j2ee.jar;c:\px\lib\javacvs.jar;c:\px\lib\java_look_and_feel_graphics_repository.jar;c:\px\lib\jaxp.jar;c:\px\lib\jboss-jdbc_ext.jar;c:\px\lib\jboss.jar;c:\px\lib\jbosspool.jar;c:\px\lib\jdbc2_0-stdext.jar;c:\px\lib\jdom.jar;c:\px\lib\jdomb8.jar;c:\px\lib\jmxri.jar;c:\px\lib\jretina.jar;c:\px\lib\junit.jar;c:\px\lib\log4j-1.2.6.jar;c:\px\lib\log4j.jar;c:\px\lib\mail.jar;c:\px\lib\manager.jar;c:\px\lib\mockobjects-0-01.jar;c:\px\lib\mysql-driver.jar;c:\px\lib\ojb-0.9.1-src.jar;c:\px\lib\ojb-0.9.7.jar;c:\px\lib\old-classes12.zip;c:\px\lib\opta2000.jar;c:\px\lib\oro.jar;c:\px\lib\prevayler-1.03.003alpha.jar;c:\px\lib\rxclient.jar;c:\px\lib\rxmisctools.jar;c:\px\lib\rxpublisher.jar;c:\px\lib\saxon.jar;c:\px\lib\servlet.jar;c:\px\lib\songscraper.jar;c:\px\lib\sqlserver.jar;c:\px\lib\strutstest.jar;c:\px\lib\tidy.jar;c:\px\lib\velocity-1.2.jar;c:\px\lib\xalan.jar;c:\px\lib\xerces.jar;c:\px\lib\xml4j.jar Guppy - diff --git a/code316-core/launch.properties b/code316-core/launch.properties deleted file mode 100644 index 8f4f28df..00000000 --- a/code316-core/launch.properties +++ /dev/null @@ -1,2 +0,0 @@ -main=com.code316.bunny.Bunny -lib=deploy/lib/ diff --git a/code316-core/license.htm b/code316-core/license.htm deleted file mode 100644 index 109d213a..00000000 --- a/code316-core/license.htm +++ /dev/null @@ -1,187 +0,0 @@ - - - -Creative Commons Legal Code - - - - - -

Creative Commons

- -
-
Creative Commons Legal Code
- -

Attribution 1.0

- -
- -
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL - SERVICES. DISTRIBUTION OF THIS DRAFT LICENSE DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON - AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE - INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - ITS USE.
- - -

License

- - -

THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE IS PROHIBITED.

- -

BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.

- -

1. Definitions

- -
    -
  1. -"Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License. -
  2. - -
  3. -"Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. -
  4. - -
  5. -"Licensor" means the individual or entity that offers the Work under the terms of this License. -
  6. - -
  7. -"Original Author" means the individual or entity who created the Work. -
  8. - -
  9. -"Work" means the copyrightable work of authorship offered under the terms of this License. -
  10. - -
  11. -"You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. -
  12. -
- -

2. Fair Use Rights. Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws.

- -

3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:

- - -
    -
  1. -to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works; -
  2. - -
  3. -to create and reproduce Derivative Works; -
  4. - -
  5. -to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works; - -
  6. - -
  7. -to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works; -
  8. - -
- -

The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved.

- - -

4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:

- - -
    -
  1. -You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any reference to such Licensor or the Original Author, as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any reference to such Licensor or the Original Author, as requested.
  2. - - -
  3. -If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and give the Original Author credit reasonable to the medium or means You are utilizing by conveying the name (or pseudonym if applicable) of the Original Author if supplied; the title of the Work if supplied; in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit. -
  4. -
- - - -

5. Representations, Warranties and Disclaimer

- -
    -
  1. -By offering the Work for public release under this License, Licensor represents and warrants that, to the best of Licensor's knowledge after reasonable inquiry: - - -
      -
    1. -Licensor has secured all rights in the Work necessary to grant the license rights hereunder and to permit the lawful exercise of the rights granted hereunder without You having any obligation to pay any royalties, compulsory license fees, residuals or any other payments; -
    2. - -
    3. -The Work does not infringe the copyright, trademark, publicity rights, common law rights or any other right of any third party or constitute defamation, invasion of privacy or other tortious injury to any third party. -
    4. -
    -
  2. - -
  3. -EXCEPT AS EXPRESSLY STATED IN THIS LICENSE OR OTHERWISE AGREED IN WRITING OR REQUIRED BY APPLICABLE LAW, THE WORK IS LICENSED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES REGARDING THE CONTENTS OR ACCURACY OF THE WORK. -
  4. -
- -

6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, AND EXCEPT FOR DAMAGES ARISING FROM LIABILITY TO A THIRD PARTY RESULTING FROM BREACH OF THE WARRANTIES IN SECTION 5, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

- - -

7. Termination

- -
    - -
  1. -This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. -
  2. - -
  3. -Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. -
  4. -
- -

8. Miscellaneous

- -
    - -
  1. -Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. -
  2. - -
  3. -Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. -
  4. - -
  5. -If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. -
  6. - -
  7. -No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. -
  8. - -
  9. -This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. -
  10. -
- - -
- -

Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor.

- -

Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, neither party will use the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time.

- -

Creative Commons may be contacted at http://creativecommons.org/.

- -
- - -
- - - -
- diff --git a/code316-core/license.txt b/code316-core/license.txt deleted file mode 100644 index 8102f2d1..00000000 --- a/code316-core/license.txt +++ /dev/null @@ -1,8 +0,0 @@ - - -This work is licensed under the Creative Commons Attribution License. - -A copy of that license is included in this distribution in the file license.html. - -To view a copy of this license, visit http://creativecommons.org/licenses/by/1.0 or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. - diff --git a/code316-core/maven.xml b/code316-core/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/code316-core/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/code316-core/project.properties b/code316-core/project.properties deleted file mode 100644 index 21f1d7f8..00000000 --- a/code316-core/project.properties +++ /dev/null @@ -1,4 +0,0 @@ -maven.repo.remote=http://repo1.maven.org/maven - -maven.javadoc.stylesheet = ../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/code316-core/project.xml b/code316-core/project.xml deleted file mode 100644 index 54873cdb..00000000 --- a/code316-core/project.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - 3 - code316 core - code316-core - 0.9 - - code316 - http://www.code316.com/ - - 2002 - com.code316.core - - code316 core components. Programmer utility classes that depend only on core java SE APIs. - code316 core components. Programmer utility classes that depend only on core java SE APIs. - - - scm:svn:http://svn.osjava.org/svn/osjava/trunk/code316-core - http://svn.osjava.org/svn/osjava/trunk/code316-core - - - - - David Petersheim - dave - david.petersheim@genscape.com - code316 - - - - - - dave@code316.com - src/java - src/test - - diff --git a/code316-core/src/java/code316/beans/BeanProperty.java b/code316-core/src/java/code316/beans/BeanProperty.java deleted file mode 100644 index 6fb6b85e..00000000 --- a/code316-core/src/java/code316/beans/BeanProperty.java +++ /dev/null @@ -1,55 +0,0 @@ -package code316.beans; - -import java.lang.reflect.Method; - - -public class BeanProperty { - private String name; - private Method getter; - private Method setter; - private Class type; - - - public boolean isValid() { - if ( this.getter == null - || this.setter == null - || this.name == null - || this.type == null) { - return false; - } - - return true; - } - - public Class getType() { - return type; - } - - public void setType(Class type) { - this.type = type; - } - - public Method getGetter() { - return getter; - } - - public void setGetter(Method getter) { - this.getter = getter; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Method getSetter() { - return setter; - } - - public void setSetter(Method setter) { - this.setter = setter; - } -} diff --git a/code316-core/src/java/code316/beans/BeanUtil.java b/code316-core/src/java/code316/beans/BeanUtil.java deleted file mode 100644 index 2d8b13ac..00000000 --- a/code316-core/src/java/code316/beans/BeanUtil.java +++ /dev/null @@ -1,169 +0,0 @@ -package code316.beans; - -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - - -public class BeanUtil { - /** - * Extracts BeanProperty instances from the supplied class - * based loosely on the Java beans naming standard. - * - *

A method pair of Y getX(), void setX(Y y) would result in a - * BeanProperty of Y - *

- * - *

A method pair of Y isX(), void setX(Y y) would result in a - * BeanProperty of Y - *

- * - * @param _class - * @return - */ - public static BeanProperty[] getProperties(Class _class) { - Method methods[] = _class.getMethods(); - Map properties = new HashMap(); - - for (int i = 0; i < methods.length; i++) { - Method method = methods[i]; - String name = method.getName(); - if ( name.startsWith("get") - || name.startsWith("is") ) { - String pName = extractPropertyName(name); - - if ( pName == null ) { - continue; - } - BeanProperty p = (BeanProperty) properties.get(pName); - - if ( p == null ) { - Class returnType = getReturnType(method); - - if ( returnType == null ) { - continue; - } - - p = new BeanProperty(); - p.setName(pName); - p.setType(returnType); - - properties.put(pName, p); - } - else { - if ( !p.getType().equals(method.getReturnType()) ) { - properties.remove(pName); - continue; - } - } - - p.setGetter(method); - } - else if ( name.startsWith("set") ) { - String pName = extractPropertyName(name); - - if ( pName == null ) { - continue; - } - - BeanProperty p = (BeanProperty) properties.get(pName); - - if ( p == null ) { - p = new BeanProperty(); - p.setName(pName); - - Class paramType = getFirstParameterType(method); - if ( paramType == null || getReturnType(method) != null ) { - continue; - } - - p.setType(paramType); - - properties.put(pName, p); - } - else { - Class paramType = getFirstParameterType(method); - if ( !p.getType().equals(paramType) || getReturnType(method) != null ) { - properties.remove(pName); - continue; - } - } - - p.setSetter(method); - } - } - - Iterator tor = properties.keySet().iterator(); - while (tor.hasNext()) { - String key = (String) tor.next(); - BeanProperty p = (BeanProperty) properties.get(key); - if ( !p.isValid() ) { - tor.remove(); - } - } - - return (BeanProperty[]) properties.values().toArray(new BeanProperty[properties.size()]); - } - - /** - * Returns the return type of the supplied method. - * - * @param method - * @return - */ - public static Class getReturnType(Method method) { - Class type = method.getReturnType(); - - if ( type.equals(Void.TYPE) ) { - return null; - } - return type; - } - - /** - * Gets the Class of the methods first parameter. If there are no - * arguments, then null is returned; - * - * @param method - * @return - */ - public static Class getFirstParameterType(Method method) { - Class paramTypes[] = method.getParameterTypes(); - - if ( paramTypes.length == 0 ) { - return null; - } - return paramTypes[0]; - } - - /** - * Extracts a propertyName based on the bean - * naming standard from the supplied methodName. - * - * e.g. getX, setX, isX - * @param methodName - * @return property name or null if a name can not - * be determined - * - */ - public static String extractPropertyName(String methodName) { - if ( methodName == null ) { - return null; - } - - try { - if ( methodName.startsWith("get") || methodName.startsWith("set") ) { - return methodName.substring(3); - } - else if ( methodName.startsWith("is") ) { - return methodName.substring(2); - } - } - catch (IndexOutOfBoundsException e) { - e.printStackTrace(); - } - - return null; - } -} diff --git a/code316-core/src/java/code316/classloading/Boot.java b/code316-core/src/java/code316/classloading/Boot.java deleted file mode 100644 index c7bd0892..00000000 --- a/code316-core/src/java/code316/classloading/Boot.java +++ /dev/null @@ -1,80 +0,0 @@ -package code316.classloading; - -import java.io.File; - -import java.lang.reflect.Method; - -public class Boot -{ - private static String guppyHome; - - public static void main(String[] args) - { - if (System.getProperty("guppy.home") == null) - { - throw new IllegalArgumentException("guppy.home must be set"); - } - - setGuppyHome(System.getProperty("guppy.home").toString()); - - // create and install a class loader - ClassLoaderX kingLoader = new ClassLoaderX("rootloader"); - - Thread.currentThread().setContextClassLoader(kingLoader); - - // Load our startup class and call its process() method - try - { - String libDir = getGuppyHome() + "lib" + File.separator; - File home = new File(libDir); - File[] files = home.listFiles(); - - for (int i = 0; i < files.length; i++) - { - File file = files[i]; - String name = file.getName().toLowerCase(); - - if (name.endsWith(".jar") || name.endsWith(".zip")) - { - kingLoader.addClassSource(libDir + file.getName()); - } - } - - Class _class = kingLoader.findClass("com.code316.guppy.MainFrame"); - Class[] paramTypes = { String[].class, ClassLoaderX.class }; - Method main = _class.getMethod("main", paramTypes); - - Object[] params = { args, kingLoader }; - - main.invoke(null, params); - - //MainFrame mf = new MainFrame(kingLoader); - } - catch (Exception e) - { - e.printStackTrace(); - System.out.println("Exception during startup processing"); - } - } - - private static void setGuppyHome(String path) - { - if (path == null) - { - throw new IllegalArgumentException("invalid value for path: " - + path); - } - - if (!path.endsWith(File.separator)) - { - path += File.separator; - } - - guppyHome = path; - } - - private static String getGuppyHome() - { - return guppyHome; - } -} \ No newline at end of file diff --git a/code316-core/src/java/code316/classloading/ClassLoaderX.java b/code316-core/src/java/code316/classloading/ClassLoaderX.java deleted file mode 100644 index 25913f42..00000000 --- a/code316-core/src/java/code316/classloading/ClassLoaderX.java +++ /dev/null @@ -1,358 +0,0 @@ -package code316.classloading; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -public class ClassLoaderX extends ClassLoader { - private static int id = 1; - private static List loaders = Collections.synchronizedList(new ArrayList()); - private static ClassLoaderX root; - private List sources = new ArrayList(); - private boolean archivesLoaded; - private Hashtable loaded = new Hashtable(); - private String name = ""; - private int myId = id++; - private Logger log; - - public ClassLoaderX(String name) { - log = new Logger(name); - log.debug("created loader (default parent): " + name); - log.debug("adding self (root) to loaders"); - } - - public ClassLoaderX(ClassLoader parent, String name) { - super(parent); - - log = new Logger(name); - log.debug("created loader: " + name); - - if (parent instanceof ClassLoaderX) { - log.debug("parent is ClassLoaderX"); - } - - log.debug("adding self to loaders"); - } - - public Class findClass(String name) { - log.debug("find class called"); - - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - - log.debug("thread loader: " + cl); - - if (!(getParent() instanceof ClassLoaderX) - && cl instanceof ClassLoaderX - && (cl != this)) { - log.debug("cascading load to thread loader"); - - ClassLoaderX l = (ClassLoaderX) cl; - - return l.findClass(name); - } - - return findClassDirect(name); - } - - public List which(String name) { - List found = new ArrayList(); - - Iterator tor = sources.iterator(); - - while (tor.hasNext()) { - Object source = tor.next(); - - InputStream in = null; - try { - in = getInputStream(source, name); - } - catch (IOException e1) {} - - if (in != null) { - if ( found == null ) { - found = new ArrayList(); - } - - found.add(source); - - try { - in.close(); - } - catch (IOException e) {} - } - } - - return found; - } - - protected Class findClassDirect(String name) { - String classFileName = getClassFileName(name); - - if (this.loaded.containsKey(classFileName)) { - log.debug("using cached class"); - - return (Class) this.loaded.get(name); - } - - byte[] buffer = loadBytes(classFileName); - - if (buffer == null) { - log.debug("class not found, will try parent loader"); - - if ((root != this) || (getParent() == null)) { - throw new IllegalStateException( - "no parent to load class from: " + name); - } - - try { - return getParent().loadClass(name); - } - catch (ClassNotFoundException e) { - log.error("parent couldn't load class"); - throw new NoClassDefFoundError("could not load class: " + name); - } - } - - log.debug("calling define class: " + name); - - Class _class = defineClass(name, buffer, 0, buffer.length); - - log.debug("parent defined class: " + name); - this.loaded.put(classFileName, _class); - - ClassLoader cl = _class.getClassLoader(); - - if (cl != this) { - log.debug("why aren't we the loader!!!"); - } - - return _class; - } - - public void clearCache() { - this.loaded.clear(); - } - - private byte[] loadBytes(String name) { - log.debug("loading resource: " + name); - - try { - Iterator tor = sources.iterator(); - - while (tor.hasNext()) { - Object source = tor.next(); - - InputStream in = getInputStream(source, name); - - if (in != null) { - return getBytesFromStream(in); - } - } - } - catch (IOException e) { - log.debug(e); - } - - return null; - } - - private byte[] getBytesFromStream(InputStream source) throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - int bytesRead = 0; - byte[] buffer = new byte[4096]; - int read = -1; - - while ((read = source.read(buffer)) != -1) { - log.debug("read: " + read); - out.write(buffer, 0, read); - } - - source.close(); - - return out.toByteArray(); - } - - private String getClassFileName(String className) { - if (className == null) { - throw new IllegalArgumentException( - "invalid value for className: " + className); - } - - log.debug("getting class name for: " + className); - - if (className.endsWith(".class")) { - int lastDot = className.lastIndexOf('.'); - - className = className.substring(0, lastDot); - } - - char[] buffer = className.toCharArray(); - char[] newBuffer = new char[buffer.length]; - - for (int i = 0; i < buffer.length; i++) { - char ch = buffer[i]; - - if (ch == '.') { - newBuffer[i] = '/'; - } - else { - newBuffer[i] = ch; - } - } - - log.debug("built classname: " + new String(newBuffer) + ".class"); - - return (new String(newBuffer) + ".class"); - } - - public static void main(String[] args) { - // ClassLoaderX loader = new ClassLoaderX(); - // loader.testLoader(args[1]); - } - - private static List getChildren(File path) throws FileNotFoundException { - if (path == null) { - throw new IllegalArgumentException( - "invalid value for path: " + path); - } - - if (!(path.isDirectory())) { - throw new IllegalArgumentException(path + " is not a directory"); - } - - List children = new ArrayList(); - File[] files = path.listFiles(); - - for (int i = 0; i < files.length; i++) { - children.add(files[i]); - } - - return children; - } - - /** - * The string is either the name of a directory or the name of a jar/zip file. - * Anything else will cause an IOException. - * If the file does not exist, then an IOException is thrown. - */ - public void addClassSource(String source) throws IOException { - if (source == null) { - throw new IllegalArgumentException( - "invalid value for element: " + source); - } - - if (source.toLowerCase().endsWith(".jar") - || source.toLowerCase().endsWith(".zip")) { - try { - JarFile jar = new JarFile(new File(source)); - - log.debug("adding source as jar: " + source); - - this.sources.add(jar); - } - catch (Exception e) { - e.printStackTrace(); - } - } - else { - // better be a path - if (!source.endsWith(File.separator)) { - source += File.separator; - } - - log.debug("adding source as path: " + source); - - File path = new File(source); - - if (!path.exists() || !path.isDirectory()) { - throw new IOException( - path + " does not exist or is not a directory"); - } - - this.sources.add(path); - } - } - - public InputStream getResourceAsStream(String name) { - byte[] bytes = loadBytes(name); - - if (bytes != null) { - return new ByteArrayInputStream(bytes); - } - - return null; - } - - public byte[] getResourceBytes(String name) { - return loadBytes(name); - } - - private InputStream getInputStream(Object source, String name) - throws IOException { - if (source instanceof JarFile) { - return getInputStream((JarFile) source, name); - } - else if (source instanceof File) { - return getInputStream((File) source, name); - } - else { - throw new IllegalStateException( - "don't know how to load from source: " + source); - } - } - - private InputStream getInputStream(JarFile source, String name) - throws IOException { - log.debug("looking for archive entry: " + name); - - if (name.indexOf("jtds") != -1) { - Enumeration e = source.entries(); - - while (e.hasMoreElements()) { - JarEntry entry = (JarEntry) e.nextElement(); - - log.debug("entry: " + entry.getName()); - } - } - - if (source.getEntry(name) == null) { - return null; - } - - log.debug("found resource in: " + source.getName()); - - return source.getInputStream(source.getEntry(name)); - } - - private InputStream getInputStream(File source, String name) - throws IOException { - File file = new File(source + File.separator + name); - - if (file.exists()) { - return new FileInputStream(file); - } - - return null; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/code316-core/src/java/code316/classloading/Logger.java b/code316-core/src/java/code316/classloading/Logger.java deleted file mode 100644 index eb2e2616..00000000 --- a/code316-core/src/java/code316/classloading/Logger.java +++ /dev/null @@ -1,58 +0,0 @@ -package code316.classloading; - -import java.io.FileOutputStream; -import java.io.PrintStream; - -class Logger -{ - private StringBuffer log = new StringBuffer(); - private PrintStream out; - private String name; - - public Logger(String name) - { - this.name = name; - - try - { - FileOutputStream o = new FileOutputStream("debug" + name + ".log"); - - out = new PrintStream(o); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public void error(Object o) - { - System.err.println(o); - } - - public void fatal(Object o) - { - System.err.println(o); - } - - public void warn(Object o) - { - System.out.println(o); - } - - public void info(Object o) - { - System.out.println(o); - } - - public void debug(Object o) - { - if (this.out != null) - { - out.println("[" + this.name + "] " + o); - out.flush(); - } - - System.out.println("[" + name + "] " + o); - } -} \ No newline at end of file diff --git a/code316-core/src/java/code316/core/Args.java b/code316-core/src/java/code316/core/Args.java deleted file mode 100644 index f108a050..00000000 --- a/code316-core/src/java/code316/core/Args.java +++ /dev/null @@ -1,187 +0,0 @@ -package code316.core; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; - -/** - * Command line argument helper class. - * - * @author david.petersheim - * - */ - -public class Args { - private static final String SWITCH_CHAR = "-"; - static class Argument { - private String name; - private String[] vals = {""}; - private short valCount = 0; - - public Argument(String name) { - if (name == null) { - throw new IllegalArgumentException( - "invalid value for name: " + name); - } - - this.name = name; - } - - public Argument(String name, String value) { - this(name); - addValue(value); - } - - public void addValue(String val) { - if ( this.valCount == vals.length ) { - String na[] = new String[vals.length + 1]; - System.arraycopy(this.vals, 0, na, 0, this.vals.length); - this.vals = na; - } - - this.vals[this.valCount] = val; - this.valCount++; - } - - - /** - * Returns the first element of the backing values array. - * If there is only one value, then this is what you want. - * If there are multiple values and you want them all, call - * getValues to get the whole array values. - *

- * To check how many values this argument has, call valCount - */ - public String getValue() { - return this.vals[0]; - } - - - /** - * Returns the values of this argument as an array of - * of Strings. - */ - public String[] getValues() { - return this.vals; - } - - /** - * Returns a space separated list of this Arguments values. - */ - public String getValueString() { - StringBuffer line = new StringBuffer(); - for (int i = 0; i < this.vals.length; i++) { - line.append(this.vals[i]).append(" "); - } - return line.toString().trim(); - } - - public int valueCount() { - return this.valCount; - } - - public String getName() { - return this.name; - } - - public String toString() { - StringBuffer me = new StringBuffer(); - me.append("[").append(super.toString()) - .append(",vals=").append(this.vals) - .append(",valCount=").append(this.valCount) - .append(",name=").append(this.name) - .append("]"); - - return me.toString(); - } - } - - /** - * Parses the command line arguments contained in the supplied array. If the - * array is empty an empty Properties object is returned. If the Properties - * object is null null is returned. - * - * @param args - array to parse - * @param offset - index at which parsing should begin - * @param - max properties to parse - * - * @exception ArrayIndexOutOfBoundsException if offset >= length - * @exception RuntimeException If there is an error while parsing - */ - public static Properties parse(String args[], int offset, int length) { - if ( args == null ) { - // ltdawpndwi - return null; - } - - Properties props = new Properties(); - - if ( length == 0 ) { - return props; - } - - if ( offset >= length ) { - throw new ArrayIndexOutOfBoundsException(); - } - - List parsed = new ArrayList(); - Argument arg = null; - - for (int i = offset; i < length; i++) { - String a = args[i].trim(); - - if ( a.startsWith(SWITCH_CHAR) ) { - String name = a.substring(1); - - arg = new Argument(name); - parsed.add(arg); - - // yes we put it in twice, but the first put - // ensures that the last - // arg is put in, even if it's a flag. - props.put(arg.getName(), arg.getValue()); - continue; - } - else { - if ( arg == null ) { - System.err.println("ignoring argument with no '" + SWITCH_CHAR + "'"); - continue; - } - } - - arg.addValue(a); - - Iterator tor = parsed.iterator(); - while (tor.hasNext()) { - Argument key = (Argument) tor.next(); - if ( arg.valCount == 1) { - props.put(arg.getName(), arg.getValue()); - } - else { - props.put(arg.getName(), arg.getValues()); - } - } - } - - return props; - } - - /** - * Parses the command line arguments contained in the supplied array. If the - * array is empty an empty Properties object is returned. If the Properties - * object is null null is returned. - * - * @param args - array to parse - * - * @exception RuntimeException If there is an error while parsing - */ - public static Properties parse(String args[]) { - if ( args == null ) { - // ltdawpndwi - return null; - } - - return parse(args, 0, args.length); - } -} diff --git a/code316-core/src/java/code316/core/Category.java b/code316-core/src/java/code316/core/Category.java deleted file mode 100644 index 0fde850e..00000000 --- a/code316-core/src/java/code316/core/Category.java +++ /dev/null @@ -1,369 +0,0 @@ -package code316.core; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.io.StringWriter; - -import java.text.SimpleDateFormat; - -import java.util.Date; -import java.util.Properties; - - -/** - * A helper class built to mimic basic functions of log4j when log4j is not - * around. Used for debugging and testing only. - * - * @author david.petersheim - */ -public class Category extends OutputStream { - private static PrintStream commonOut; - private static int id = 1; - public static final int DEBUG = 50; - public static final int INFO = 40; - public static final int WARN = 30; - public static final int ERROR = 20; - public static final int FATAL = 10; - private int instanceId = id++; - private int logLevel = DEBUG; - private boolean capturing = false; - private PrintStream out = null; - private StringBuffer captured; - private String name = ""; - private String prefix = null; - private SimpleDateFormat formatter = new SimpleDateFormat( - "ddMMMyyyy kk:mm:ss"); - - public Category(Class _class) { - this(_class.getName()); - } - - public Category(String name) { - setName(name); - } - - public Category() { - this("NONAME"); - } - - public Category(int logLevel) { - this("NONAME"); - setLogLevel(logLevel); - } - - public Category(final OutputStream os, String name) { - this.out = new PrintStream(os); - - if (commonOut == null) { - commonOut = this.out; - } - - setName(name); - - Runtime.getRuntime().addShutdownHook(new Thread() { - public void run() { - try { - if (os != null) { - os.close(); - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - }); - } - - public static Category getInstance(Class _class) { - return new Category(_class); - } - - private static int getLevelForName(String name) { - if (name == null) { - throw new IllegalArgumentException("invalid value for name: " - + name); - } - - if (name.equals("DEBUG")) { - return DEBUG; - } - else if (name.equals("INFO")) { - return INFO; - } - else if (name.equals("ERROR")) { - return ERROR; - } - else if (name.equals("FATAL")) { - return FATAL; - } - else if (name.equals("WARN")) { - return WARN; - } - - throw new IllegalStateException("unknown level name: " + name); - } - - public static void main(String[] args) { - int level = Category.getLevelForName(args[0]); - - Category log = new Category("TT"); - - log.setLogLevel(level); - System.out.println("loglevel set to:" + level); - - log.debug("DEBUG MESSAGE"); - log.info("INFO MESSAGE"); - log.fatal("FATAL MESSAGE"); - log.error("ERROR MESSAGE"); - log.warn("WARN MESSAGE"); - } - - public void debug(Object o) { - if (this.logLevel < DEBUG) { - return; - } - - outImpl(o, DEBUG); - } - - public void debug(Object o, Throwable t) { - if (this.logLevel < DEBUG) { - return; - } - - outImpl(o, DEBUG); - outImpl(t, DEBUG); - } - - private void errorImpl(Object o) { - if (this.logLevel < ERROR) { - return; - } - - outImpl(o, ERROR); - } - - public void error(Object o) { - errorImpl(o); - } - - public void error(Object o, Throwable t) { - errorImpl(o); - errorImpl(t); - } - - public void info(Object o) { - if (this.logLevel < INFO) { - return; - } - - outImpl(o, INFO); - } - - public void info(Object o, Throwable t) { - if (this.logLevel < INFO) { - return; - } - - info(o); - info(t); - } - - public void warn(Object o) { - if (this.logLevel < WARN) { - return; - } - - outImpl(o, WARN); - } - - public void warn(Object o, Throwable t) { - warn(o); - warn(t); - } - - public void fatal(Object o) { - if (this.logLevel < FATAL) { - return; - } - - outImpl(o, FATAL); - } - - public void fatal(Object o, Throwable t) { - errorImpl(o); - errorImpl(t); - } - - private String getTimeStamp() { - return formatter.format(new Date()); - } - - private String getLevelPrefix(int level) { - switch (level) { - case Category.DEBUG: - return "DEBUG] "; - - case Category.INFO: - return "INFO] "; - - case Category.ERROR: - return "ERROR] "; - - case Category.WARN: - return "WARN] "; - - case Category.FATAL: - return "FATAL] "; - - default: - return "FAULT] "; - } - } - - private void outImpl(Object o, int level) { - String value = String.valueOf(o); - String entry = "[" + getTimeStamp() + "-" - + Thread.currentThread().getName() + ":" + this.prefix - + getLevelPrefix(level) + value; - - if (o instanceof Throwable) { - ((Throwable) o).printStackTrace(); - } - - if (commonOut != null) { - synchronized (commonOut) { - commonOut.println(entry); - - if (o instanceof Properties) { - ((Properties) o).list(commonOut); - } - - if (o instanceof Throwable) { - ((Throwable) o).printStackTrace(commonOut); - } - - commonOut.flush(); - } - - if ((this.out != null) && (this.out != commonOut)) { - this.out.println(entry); - - if (o instanceof Properties) { - ((Properties) o).list(this.out); - } - - if (o instanceof Throwable) { - ((Throwable) o).printStackTrace(this.out); - } - - this.out.flush(); - } - } - - System.out.println(entry); - - if (capturing) { - captured.append(entry + "\n"); - } - } - - public String getCaptured(boolean reset) { - String capturedContent = getCaptured(); - - if (reset && (this.captured != null)) { - this.captured.setLength(0); - } - - return capturedContent; - } - - public String getCaptured() { - if (this.captured != null) { - return this.captured.toString(); - } - - return null; - } - - public boolean isCapturing() { - return capturing; - } - - public void setCapturing(boolean capturing) { - this.capturing = capturing; - - if (this.capturing) { - if (this.captured == null) { - captured = new StringBuffer(); - } - } - } - - public int getLogLevel() { - return logLevel; - } - - public void setLogLevel(int logLevel) { - this.logLevel = logLevel; - } - - public PrintStream getOut() { - return this.out; - } - - public void setOut(PrintStream out) { - this.out = out; - } - - public String getName() { - return name; - } - - public void setName(String name) { - if (name == null) { - return; - } - - this.name = name; - - String shortName = name; - int pos = shortName.lastIndexOf('.'); - - if ((pos != -1) && (pos < (shortName.length() - 1))) { - shortName = shortName.substring(pos + 1); - } - - this.prefix = shortName + "(" + instanceId + ")-"; - } - - public static String getStackTrace() { - StringWriter sout = new StringWriter(); - PrintWriter out = new PrintWriter(sout); - Exception e = new Exception(); - - e.printStackTrace(out); - out.close(); - - String breakAt = "at "; - int pos = sout.toString().indexOf(breakAt); - - return (sout.toString().substring(pos + breakAt.length())); - } - - public void write(byte[] b, int off, int len) throws IOException { - info(new String(b, off, len)); - } - - public void write(byte[] b) throws IOException { - info(new String(b)); - } - - public void write(int b) throws IOException { - byte[] buffer = { (byte) b }; - - write(buffer); - } -} \ No newline at end of file diff --git a/code316-core/src/java/code316/core/ClassFinder.java b/code316-core/src/java/code316/core/ClassFinder.java deleted file mode 100644 index 3057a9ae..00000000 --- a/code316-core/src/java/code316/core/ClassFinder.java +++ /dev/null @@ -1,11 +0,0 @@ - -package code316.core; - -public class ClassFinder { - public static void main(String[] args) { - // args - // TODO fillin - - } - -} diff --git a/code316-core/src/java/code316/core/ClassUtil.java b/code316-core/src/java/code316/core/ClassUtil.java deleted file mode 100644 index 4b6346b7..00000000 --- a/code316-core/src/java/code316/core/ClassUtil.java +++ /dev/null @@ -1,45 +0,0 @@ -package code316.core; - - - -public class ClassUtil { - /** - * Returns an instance of the supplied className. - * @param className - Name of class to be instantiated. - * @return an instance of the class or null if the class could not be instantiated - * @exception IllegalArgumentException if the className is null. - */ - public static Object quiteInstantiate(String className) { - if (className == null) { - throw new IllegalArgumentException("invalid value for className: " + className); - } - - try { - return instantiate(className); - } - catch (Exception e) { - e.printStackTrace(); - } - - return null; - } - - /** - * Returns an instance of the supplied className. - * @param className - Name of class to be instantiated. - * @exception IllegalArgumentException if the className is null. - */ - public static Object instantiate(String className) - throws ClassNotFoundException, - InstantiationException, - IllegalAccessException { - if (className == null) { - throw new IllegalArgumentException("invalid value for className : " - + className); - } - - Class _class = Class.forName(className); - - return _class.newInstance(); - } -} \ No newline at end of file diff --git a/code316-core/src/java/code316/core/DbHelper.java b/code316-core/src/java/code316/core/DbHelper.java deleted file mode 100644 index 702fcf20..00000000 --- a/code316-core/src/java/code316/core/DbHelper.java +++ /dev/null @@ -1,315 +0,0 @@ -package code316.core; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -import java.util.ArrayList; -import java.util.Iterator; - - - -/** - * Feed this class all your Connections, ResultSets, and - * Statements. When you're done, call the closeAll() method and - * all of the objects will be closed for you. - *

This helper class helps eliminate the sql pyramid found in - * the finally class of lots of jdbc code.

- * Old Code - *
- * Connection conn;
- * ResultSet rs;
- * Statement stmt;
- * 
- * try {
- *     ... sql stuff here
- * }
- *    ...
- * finally {
- *    if ( rs != null ) {
- *        try {
- *           rs.close();
- *        }
- *        catch (SqlException e) {}
- *    }
- * 
- *    if ( stmt != null ) {
- *        try {
- *           stmt.close();
- *        }
- *        catch (SqlException e) {}
- *    }
- * 
- *    if ( conn != null ) {
- *        try {
- *           conn.close();
- *        }
- *        catch (SqlException e) {}
- *    }
- * }
- * 
- */ -public class DbHelper { - private ArrayList connections = new ArrayList(); - private ArrayList statements = new ArrayList(); - private ArrayList resultSets = new ArrayList(); - private boolean suppress = true; - private boolean silent = false; - private Category log = new Category(DbHelper.class); - - public DbHelper() { - super(); - log.setLogLevel(Category.FATAL); - } - - public void closeAll() { - Exception resultsException = null; - Exception statementsException = null; - Exception connectionsException = null; - - // close result sets - Iterator tor = resultSets.iterator(); - - while (tor.hasNext()) { - ResultSet rs = (ResultSet) tor.next(); - - try { - log.debug("closing resultset: " + rs); - rs.close(); - log.debug("closed resultset: " + rs); - } - catch (Exception e) { - e.printStackTrace(); - resultsException = e; - } - } - - - // close statements - tor = statements.iterator(); - - while (tor.hasNext()) { - Statement statement = (Statement) tor.next(); - - try { - log.debug("closing statement: " + statement); - statement.close(); - log.debug("closed statement: " + statement); - } - catch (Exception e) { - e.printStackTrace(); - statementsException = e; - } - } - - - // close connections - tor = connections.iterator(); - - while (tor.hasNext()) { - Connection connection = (Connection) tor.next(); - - try { - log.debug("closing connection: " + connection); - connection.close(); - log.debug("closed connection: " + connection); - } - catch (Exception e) { - e.printStackTrace(); - connectionsException = e; - } - } - - } - - - private void closeConnections() { - Iterator tor = connections.iterator(); - - while (tor.hasNext()) { - Connection connection = (Connection) tor.next(); - - try { - connection.close(); - } - catch (SQLException e) { - e.printStackTrace(); - } - } - } - - private void closeResultSets() { - Iterator tor = resultSets.iterator(); - - while (tor.hasNext()) { - ResultSet rs = (ResultSet) tor.next(); - - try { - rs.close(); - } - catch (SQLException e) { - e.printStackTrace(); - } - } - } - - private void closeStatements() { - Iterator tor = statements.iterator(); - - while (tor.hasNext()) { - Statement statement = (Statement) tor.next(); - - try { - statement.close(); - } - catch (SQLException e) { - e.printStackTrace(); - } - } - } - - public Connection addConnection(Connection connection) { - if (connection == null) { - throw new NullPointerException("connection can not be null"); - } - - connections.add(connection); - - return connection; - } - - public PreparedStatement addPreparedStatement(PreparedStatement statement) { - return (PreparedStatement) addStatement(statement); - } - - public ResultSet addResultSet(ResultSet resultSet) { - if (resultSet == null) { - throw new NullPointerException("resultSet can not be null"); - } - - resultSets.add(resultSet); - - return resultSet; - } - - public Statement addStatement(Statement statement) { - if (statement == null) { - throw new NullPointerException("statement can not be null"); - } - - statements.add(statement); - - return statement; - } - - /** - * Closes a Connection. If an SQLException is thrown during the - * close, it is thrown back to the caller. - * - * @param connection null is a valid value. - * @throws SQLException - */ - public static void close(Connection connection) throws SQLException { - if ( connection == null ) { - return; - } - connection.close(); - } - - /** - * Closes Connection. Will not throw an Exception if - * there is problem while closing the Connection. - * - *

- * If an Exception is thrown during the close prinStackTrace - * is called on the Exception. - * - * @param connection is a valid value. - */ - public static void closeQuietly(Connection connection) { - if ( connection == null ) { - return; - } - - try { - connection.close(); - } - catch (SQLException e) { - e.printStackTrace(); - } - } - - - public static void close(Statement statement) throws SQLException { - if ( statement == null ) { - return; - } - statement.close(); - } - - /** - * @see DbHelper - * @param stmt - */ - public static void closeQuietly(Statement stmt) { - if ( stmt == null ) { - return; - } - - try { - stmt.close(); - } - catch (SQLException e) { - e.printStackTrace(); - } - } - - - - public static void close(ResultSet rs) throws SQLException { - if ( rs == null ) { - return; - } - rs.close(); - } - - public static void closeQuietly(ResultSet rs) { - if ( rs == null ) { - return; - } - - try { - rs.close(); - } - catch (SQLException e) { - e.printStackTrace(); - } - } - - - - - public static void close(Connection connection, Statement statement, ResultSet rs) throws SQLException { - DbHelper.close(rs); - DbHelper.close(statement); - DbHelper.close(connection); - } - - - - - - - - - - - - - - - - -} \ No newline at end of file diff --git a/code316-core/src/java/code316/core/ExceptionUtil.java b/code316-core/src/java/code316/core/ExceptionUtil.java deleted file mode 100644 index 5652438a..00000000 --- a/code316-core/src/java/code316/core/ExceptionUtil.java +++ /dev/null @@ -1,13 +0,0 @@ -package code316.core; - -import java.io.PrintWriter; -import java.io.StringWriter; - - -public class ExceptionUtil { - public static String stackTraceToString(Exception e) { - StringWriter writer = new StringWriter(); - e.printStackTrace(new PrintWriter(writer)); - return writer.toString(); - } -} diff --git a/code316-core/src/java/code316/core/FileUtil.java b/code316-core/src/java/code316/core/FileUtil.java deleted file mode 100644 index 7b92b814..00000000 --- a/code316-core/src/java/code316/core/FileUtil.java +++ /dev/null @@ -1,331 +0,0 @@ -package code316.core; - -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -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.util.ArrayList; -import java.util.Iterator; -import java.util.List; - - -public class FileUtil { - private volatile static int fileIndex = 1; - public static String getUnusedFileName(String path, String seed, String extension) throws IOException { - File file = null; - path = endPath(path); - while (true) { - file = new File(path + seed + fileIndex + extension); - - if ( !file.exists() ) return file.getAbsolutePath(); - - fileIndex++; - } - } - - /** - * Returns a list of java.io.File objects that are immediate children of - * the given path name. - * - * Does not include "." or ".." - * - * @exception IllegalArgument If the supplied name is a not a directory. - * @exception FileNotFoundException If the supplied path does not exist. - */ - public static List getChildren(String path) throws FileNotFoundException { - return getChildren(new File(path)); - } - - /** - * Returns a list of java.io.File objects that are immediate children of - * the given path name and whose file extension matches the supplied extension - * argument. - * - * Does not include "." or ".." - * - * @param path path to search - * @param extension file extension to filter on, e.g. "txt" or ".txt" - * - * @exception IllegalArgument If the supplied name is a not a directory. - * @exception FileNotFoundException If the supplied path does not exist. - */ - public static List getChildrenWithExtension(String path, String extension) throws FileNotFoundException { - List children = getChildren(new File(path)); - List selected = new ArrayList(); - Iterator tor = children.iterator(); - - while (tor.hasNext()) { - File file = (File) tor.next(); - if ( file.toString().endsWith(extension) ) { - selected.add(file); - } - } - - return selected; - } - - - - /** - * Returns a list of java.io.File objects that are immediate children of - * the given path name. - * - * Does not include "." or ".." - * - * @exception IllegalArgument If the supplied name is a not a directory. - * @exception FileNotFoundException If the supplied path does not exist. - */ - public static List getChildren(File path) throws FileNotFoundException { - if (path == null) { - throw new IllegalArgumentException("invalid value for path: " + path); - } - - - if (!(path.isDirectory()) ) { - throw new IllegalArgumentException(path + " is not a directory"); - } - - List children = new ArrayList(); - File files[] = path.listFiles(); - - for (int i = 0; i < files.length; i++) { - children.add(files[i]); - } - - return children; - } - - - - - /** - * Returns all the immediate children of the supplied path that are - * themselves directories as a list of java.io.File objects. - * - * Does not include "." or ".." - * - * @exception IllegalArgument If the supplied name is a not a directory. - * @exception FileNotFoundException If the supplied path does not exist. - */ - public static List getChildDirectories(String path) throws FileNotFoundException { - return getChildDirectories(new File(path)); - } - - - - /** - * Returns all the immediate children of the supplied path that are - * themselves directories as a list of java.io.File objects. - * - * Does not include "." or ".." - * - * @exception IllegalArgument If the supplied name is a not a directory. - * @exception FileNotFoundException If the supplied path does not exist. - */ - public static List getChildDirectories(File path) throws FileNotFoundException { - List children = getChildren(path); - List directories = new ArrayList(); - Iterator tor = children.iterator(); - while (tor.hasNext()) { - File file = (File) tor.next(); - if ( file.isDirectory() ) { - directories.add(file); - } - } - return directories; - } - - - - /** - * Writes the supplied content to a file with the supplied name. - */ - public static void writeToFile(String content, String fileName) - throws IOException { - FileOutputStream out = new FileOutputStream(fileName); - out.write(content.getBytes()); - out.close(); - } - - - /** - * Returns the contents of the supplied filename as a String. - */ - public static String loadTextFile(String fileName) throws IOException { - return new String(loadFile(fileName)); - } - - - - public static byte[] loadFile(String fileName, ClassLoader loader) throws IOException { - if (fileName == null) { - throw new IllegalArgumentException("invalid value for fileName: " - + fileName); - } - - InputStream in = getFileAsStream(fileName, loader); - ByteArrayOutputStream out = new ByteArrayOutputStream(4096); - byte[] buffer = new byte[4096]; - int bytesRead = -1; - - while ((bytesRead = in.read(buffer)) != -1) { - out.write(buffer, 0, bytesRead); - } - - in.close(); - - return out.toByteArray(); - } - - /** - * Returns the contents of the supplied filename as an array of bytes. - */ - public static byte[] loadFile(String fileName) throws IOException { - return loadFile(fileName, null); - } - - public static String[] loadLines(String fileName) throws IOException { - BufferedReader in = new BufferedReader(new FileReader(fileName)); - - - ArrayList lines = new ArrayList(); - String line = null; - - while ((line = in.readLine()) != null) { - lines.add(line.trim()); - } - - return (String[]) lines.toArray(new String[lines.size()]); - } - - - /** - * Trys to make a fileName. - *

- * Replaces any non-ascii, non-alphanumeric characters - * with the underscore character '_'. - *

- */ - public static String getSafeFileName(String fileName) { - if ( fileName == null ) { - return null; - } - - fileName = fileName.toLowerCase(); - - int count = fileName.length(); - int maxLength = 128; - char[] buffer = new char[count]; - fileName.getChars(0, count, buffer, 0); - - if (maxLength > buffer.length) { - maxLength = buffer.length; - } - - boolean changed = false; - - for (int i = 0; i < maxLength; i++) { - char ch = (char) buffer[i]; - - if ((ch >= 48 && ch <= 57)) { - continue; - } - else if ((ch >= 65 && ch <= 90)) { - continue; - } - else if ((ch >= 97 && ch <= 122)) { - continue; - } - - buffer[i] = '_'; - changed = true; - } - - if (changed) { - fileName = new String(buffer, 0, maxLength); - } - - return fileName; - } - - - - public static String getExtension(String fileName) { - return getExtension(fileName, "."); - } - - public static String getExtension(String fileName, String extensionSeparator) { - if ( fileName == null ) { - return null; - } - - int pos = fileName.lastIndexOf(extensionSeparator); - return (pos != -1 && pos < fileName.length()) - ? fileName.substring(pos + 1) - : ""; - } - - /** - * Appends File.separator to the end of the supplied - * path name if needed. - */ - public static String endPath(String path) { - if (path == null) { - throw new IllegalArgumentException("invalid value for path: " + path); - } - - if ( path.endsWith(File.separator) ) { - return path; - } - - return path + File.separator; - } - - - - public static InputStream getFileAsStream(String name) throws FileNotFoundException { - return getFileAsStream(name, null); - } - - - /** - * Returns an InputStream for the supplied file name. - */ - public static InputStream getFileAsStream(String name, ClassLoader loader) throws FileNotFoundException { - if (name == null) { - throw new IllegalArgumentException("invalid value for name: " + name); - } - - - - FileNotFoundException e = null; - InputStream in = null; - - try { - return new FileInputStream(name); - } - catch (FileNotFoundException fnfe) { - e = fnfe; - } - - System.out.println("loader: " + loader); - - if ( loader == null ) { - in = ClassLoader.getSystemResourceAsStream(name); - } - else { - in = loader.getResourceAsStream(name); - } - - if ( in == null ) { - throw e; - } - - return in; - } -} \ No newline at end of file diff --git a/code316-core/src/java/code316/core/LaunchScriptBuilder.java b/code316-core/src/java/code316/core/LaunchScriptBuilder.java deleted file mode 100644 index bc00505b..00000000 --- a/code316-core/src/java/code316/core/LaunchScriptBuilder.java +++ /dev/null @@ -1,160 +0,0 @@ -package code316.core; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.StringTokenizer; - - -public class LaunchScriptBuilder { - public static final String DEFAULT_PROPERTIES_FILE = "run.properties"; - - - public static class Launcher { - public static void main(String[] args) { - try { - Runtime.getRuntime().exec(getExecString(args)); - } - catch (IOException e) { - e.printStackTrace(); - } - } - } - - public static void printUsage() { - System.err.println("use: LaunchScriptBuilder -[sf] "); - System.err.println(" -s separator - class path separator"); - System.err.println(" -f separator - file separator"); - } - - public static String getExecString(String args[]) throws IOException { - String pathSeparator = null; - String propertiesFile = DEFAULT_PROPERTIES_FILE; - String fileSeparator = null; - - if ( args.length != 0 ) { - propertiesFile = args[args.length-1]; - - Properties overrides = Args.parse(args, 0, (args.length - 1)); - Iterator tor = overrides.keySet().iterator(); - while (tor.hasNext()) { - String key = (String) tor.next(); - String val = overrides.getProperty(key); - - // has the path separator been overridden - if ( key.equals("s") ) { - pathSeparator = val; - } - else if ( key.equals("f")) { - fileSeparator = val; - } - else { - printUsage(); - return null; - } - } - } - - - Properties props = PropertiesUtil.loadPropertiesFromFile(propertiesFile); - String mainClass = props.getProperty("main"); - - if ( PropertiesUtil.isEmpty(mainClass) ) { - throw new IllegalStateException("main is a required property"); - } - - String jvm = props.getProperty("jvm", "java"); - String lib = props.getProperty("lib"); - StringBuffer exec = new StringBuffer(); - String additionalPaths = props.getProperty("add.path"); - - if ( pathSeparator == null ) { - pathSeparator = props.getProperty("pathSeparator", File.pathSeparator); - } - - if ( fileSeparator == null ) { - fileSeparator = props.getProperty("fileSeparator", File.separator); - } - - exec.append(jvm).append(" -cp "); - - - // append additional paths - - if ( !PropertiesUtil.isEmpty(additionalPaths) ) { - StringTokenizer st = new StringTokenizer(additionalPaths, ","); - - while (st.hasMoreTokens()) { - exec.append(st.nextToken()); - - if ( st.hasMoreTokens() ) { - exec.append(pathSeparator); - } - } - } - - appendArchives(pathSeparator, exec, lib, fileSeparator); - - if ( exec.charAt(exec.length() - 1) != ' ') { - exec.append(' '); - } - - exec.append(mainClass); - - if ( pathSeparator.equals(":") ) { - exec.append(" $*"); - } - else if ( pathSeparator.equals(";") ) { - exec.append(" %*"); - } - - return exec.toString(); - } - - public static void main(String []args) { - try { - String exec = getExecString(args); - System.out.println(exec); - } - catch (IOException e) { - e.printStackTrace(); - } - } - - private static void appendArchives( - String pathSeparator, - StringBuffer exec, - String lib, - String fileSeparator) - throws FileNotFoundException { - int appended = 0; - String libString = null; - List files = FileUtil.getChildren(lib); - - if ( lib.endsWith(fileSeparator)) { - libString = lib; - } - else { - libString = lib + fileSeparator; - } - - Iterator tor = files.iterator(); - while (tor.hasNext()) { - File file = (File) tor.next(); - - String fileName = file.getName(); - if ( fileName.endsWith("jar") || fileName.endsWith("zip") ) { - exec.append(pathSeparator); - appended++; - exec.append(libString).append(fileName); - } - } - - if (appended > 0) { - exec.append(" "); - } - } -} diff --git a/code316-core/src/java/code316/core/Logger.java b/code316-core/src/java/code316/core/Logger.java deleted file mode 100644 index 2230de43..00000000 --- a/code316-core/src/java/code316/core/Logger.java +++ /dev/null @@ -1,28 +0,0 @@ -package code316.core; - -import java.io.OutputStream; - -public class Logger extends Category { - public Logger(Class _class) { - super(_class); - } - - public Logger(String name) { - super(name); - } - - public Logger() { - super(); - } - - public Logger(int logLevel) { - super(logLevel); - } - - public Logger(OutputStream os, String name) { - super(os, name); - } - - - -} diff --git a/code316-core/src/java/code316/core/PropertiesUtil.java b/code316-core/src/java/code316/core/PropertiesUtil.java deleted file mode 100644 index 63639bd9..00000000 --- a/code316-core/src/java/code316/core/PropertiesUtil.java +++ /dev/null @@ -1,140 +0,0 @@ -package code316.core; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Properties; - - -public class PropertiesUtil { - private static HashMap bundles = new HashMap(); - - public PropertiesUtil() { - super(); - } - - /** - * Gets the value named propertyName from the ResoureBundle - * associated with bundleName. - * - * If the specified properties file has been loaded before, - * the previously loaded properties will be loaded. - * - * Returns null if the property is not found. - * - * @exception IllegalArgumentException if the properties file - * can not be loaded. - */ - public static String getProperty(String propertiesFile, String propertyName) { - if ( propertiesFile == null || propertyName == null ) { - return null; - } - - synchronized (bundles) { - Properties props = (Properties) bundles.get(propertiesFile); - - if ( props == null ) { - try { - props = loadPropertiesFromFile(propertiesFile); - bundles.put(propertiesFile, props); - } - catch (IOException e) { - e.printStackTrace(); - throw new IllegalArgumentException("could not load properties: " + e); - } - } - - return (String) props.get(propertyName); - } - } - - /** - * Returns a Properties object loaded from the supplied - * fileName. - * - */ - public static Properties loadPropertiesFromFile(String fileName) throws IOException { - Properties props = new Properties(); - - InputStream in = FileUtil.getFileAsStream(fileName); - - props.load(in); - - in.close(); - - return props; - } - - - /** - * Store the supplied Properties object to the supplied - * fileName. - * - * If the header argument is not null, then an ASCII # character, the header string, and a line separator are first written to the output stream. Thus, the header can serve as an identifying comment. - */ - public static void storeProperties(Properties properties, String fileName) throws IOException { - storeProperties(properties, fileName, null); - } - - - - /** - * Store the supplied Properties object to the supplied - * fileName. - * - * If the header argument is not null, then an ASCII # character, the header string, and a line separator are first written to the output stream. Thus, the header can serve as an identifying comment. - */ - public static void storeProperties(Properties properties, String fileName, String header) throws IOException { - if (properties == null || fileName == null ) { - return ; - } - - FileOutputStream out = new FileOutputStream(fileName); - - properties.store(out, header); - - out.close(); - } - - public static boolean isEmpty(Object[] value) { - if ( value == null || value.length == 0 ) { - return true; - } - - return false; - } - - - public static boolean isEmpty(String value) { - if ( value != null && value.trim().length() != 0 ) { - return false; - } - - return true; - } - - /** - * @param props Properties object to be filtered. - * @param filter String that key names must start with to be included - * in the returned Map. - * @return Propeties A Properties object containing properties whose key - * names match the supplied filter. - */ - public static Properties filter(Properties props, String filter) { - Properties filtered = new Properties(); - - Iterator tor = props.keySet().iterator(); - while (tor.hasNext()) { - String key = (String) tor.next(); - - if ( key.startsWith(filter) ) { - Object value = props.get(key); - filtered.put(key, value); - } - } - - return filtered; - } -} diff --git a/code316-core/src/java/code316/core/WindowUtil.java b/code316-core/src/java/code316/core/WindowUtil.java deleted file mode 100644 index 8c118211..00000000 --- a/code316-core/src/java/code316/core/WindowUtil.java +++ /dev/null @@ -1,32 +0,0 @@ -package code316.core; - -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Toolkit; -import java.awt.Window; - -public class WindowUtil { - public static Point getCenteredLocation(Window window) { - if (window == null) { - throw new IllegalArgumentException("invalid value for window: " + window); - } - - return getScreenCenteredLocation(window.getSize()); - } - - public static Point getScreenCenteredLocation(Dimension d) { - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - - int x = (int) ((screen.getWidth() - d.getWidth()) / 2); - int y = (int) ((screen.getHeight() - d.getHeight()) / 2); - - return new Point(x, y); - } - public static void centerWindow(Window win) { - if ( win == null ) { - return; - } - - win.setLocation(getCenteredLocation(win)); - } -} diff --git a/code316-core/src/java/code316/debug/DebugInputStream.java b/code316-core/src/java/code316/debug/DebugInputStream.java deleted file mode 100644 index b82ac02d..00000000 --- a/code316-core/src/java/code316/debug/DebugInputStream.java +++ /dev/null @@ -1,74 +0,0 @@ -package code316.debug; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * Collects all bytes read from the backing InputStream. - */ -public class DebugInputStream extends InputStream { - private InputStream backingStream; - private ByteArrayOutputStream collector = new ByteArrayOutputStream(); - private StreamListener listener; - - public DebugInputStream(InputStream backingStream) { - this.backingStream = backingStream; - } - - public int read() throws IOException { - int read = this.backingStream.read(); - this.collector.write(read); - if ( this.listener != null ) { - this.listener.read(read); - } - - return read; - } - - public int read(byte[] b, int off, int len) throws IOException { - int read = this.backingStream.read(b, off, len); - this.collector.write(b, off, read); - if ( this.listener != null ) { - this.listener.read(b, off, read); - } - - return read; - } - - public int available() throws IOException { - return this.backingStream.available(); - } - - public void close() throws IOException { - this.backingStream.close(); - } - - public synchronized void mark(int readlimit) { - this.backingStream.mark(readlimit); - } - - public boolean markSupported() { - return this.backingStream.markSupported(); - } - - public int read(byte[] b) throws IOException { - return read(b, 0, b.length); - } - - public synchronized void reset() throws IOException { - this.backingStream.reset(); - } - - public long skip(long n) throws IOException { - return this.backingStream.skip(n); - } - - public byte[] getCollectedBytes() { - return this.collector.toByteArray(); - } - - public void addStreamListener(StreamListener listener) { - this.listener = listener; - } -} diff --git a/code316-core/src/java/code316/debug/DebugOutputStream.java b/code316-core/src/java/code316/debug/DebugOutputStream.java deleted file mode 100644 index dab0ec66..00000000 --- a/code316-core/src/java/code316/debug/DebugOutputStream.java +++ /dev/null @@ -1,56 +0,0 @@ -package code316.debug; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; - - - -/** - * Collects all bytes written to the backing OutputStream - */ -public class DebugOutputStream extends OutputStream { - private OutputStream backingStream; - private ByteArrayOutputStream collector = new ByteArrayOutputStream(); - private StreamListener listener; - - public DebugOutputStream(OutputStream backingStream) { - this.backingStream = backingStream; - } - - public void write(int b) throws IOException { - this.collector.write(b); - this.backingStream.write(b); - if (this.listener != null) { - this.listener.wrote(b); - } - } - - public void write(byte[] b, int off, int len) throws IOException { - this.collector.write(b, off, len); - this.backingStream.write(b, off, len); - if (this.listener != null) { - this.listener.wrote(b, off, len); - } - } - - public void write(byte[] b) throws IOException { - write(b, 0, b.length); - } - - public void close() throws IOException { - this.backingStream.close(); - } - - public void flush() throws IOException { - this.backingStream.flush(); - } - - public byte[] getCollectedBytes() { - return this.collector.toByteArray(); - } - - public void addStreamListener(StreamListener listener) { - this.listener = listener; - } -} diff --git a/code316-core/src/java/code316/debug/StreamCollector.java b/code316-core/src/java/code316/debug/StreamCollector.java deleted file mode 100644 index 639a1aab..00000000 --- a/code316-core/src/java/code316/debug/StreamCollector.java +++ /dev/null @@ -1,85 +0,0 @@ -package code316.debug; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class StreamCollector implements StreamListener { - private ByteArrayOutputStream collector = new ByteArrayOutputStream(); - public static final int WRITE_DIRECTION = 1; - public static final int READ_DIRECTION = 2; - private int currentDirection = 0; - private int index = 0; - private List directionChanges = new ArrayList(); - - private void checkDirection(int direction) { - if ( this.currentDirection != direction ) { - // mark direction change - directionChanges.add(new Integer(this.index)); - this.currentDirection = direction; - } - } - - - public void read(int data) throws IOException { - checkDirection(READ_DIRECTION); - this.collector.write(data); - this.index++; - } - - - public void wrote(int data) throws IOException { - checkDirection(WRITE_DIRECTION); - this.collector.write(data); - this.index++; - } - - public void read(byte[] buffer, int start, int length) throws IOException { - checkDirection(READ_DIRECTION); - this.collector.write(buffer, start, length); - this.index += length; - } - - public void wrote(byte[] buffer, int offset, int length) throws IOException { - checkDirection(WRITE_DIRECTION); - this.collector.write(buffer, offset, length); - this.index += length; - } - - public byte[] getCollectedBytes() { - return this.collector.toByteArray(); - } - - public String getFormattedBytes() { - byte buffer[] = this.collector.toByteArray(); - String test = new String (buffer); - int nextmark = -1; - StringBuffer sb = new StringBuffer(buffer.length + this.directionChanges.size()); - - if ( this.directionChanges .size() > 0 ) { - nextmark = ((Integer) this.directionChanges.remove(0)).intValue(); - } - - for (int i = 0; i < buffer.length; i++) { - if ( nextmark != -1 ) { - if ( nextmark == i) { - nextmark = -1; - sb.append("\n"); - if ( this.directionChanges .size() > 0 ) { - nextmark = ((Integer) this.directionChanges.remove(0)).intValue(); - } - } - } - - if ( Character.isLetterOrDigit((char) buffer[i])) { - sb.append((char) buffer[i]); - } - else { - sb.append("[").append(buffer[i]).append("]"); - } - } - - return sb.toString(); - } -} diff --git a/code316-core/src/java/code316/debug/StreamListener.java b/code316-core/src/java/code316/debug/StreamListener.java deleted file mode 100644 index 1e8b45cf..00000000 --- a/code316-core/src/java/code316/debug/StreamListener.java +++ /dev/null @@ -1,12 +0,0 @@ -package code316.debug; - -import java.io.IOException; - - -public interface StreamListener { - void wrote(int data) throws IOException; - void wrote(byte buffer[], int start, int offset) throws IOException; - - void read(int data) throws IOException; - void read(byte buffer[], int start, int offset) throws IOException; -} diff --git a/code316-core/src/java/code316/event/MessagePump.java b/code316-core/src/java/code316/event/MessagePump.java deleted file mode 100644 index e02eef6d..00000000 --- a/code316-core/src/java/code316/event/MessagePump.java +++ /dev/null @@ -1,80 +0,0 @@ -package code316.event; - -import java.beans.Beans; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - - -public class MessagePump { - private Method methods[]; - private Propagator propagators[]; - private Class listenerType; - private List listeners = new LinkedList(); - - public MessagePump(Class listenerType) { - this.methods = listenerType.getMethods(); - this.listenerType = listenerType; - } - - public boolean removeListener(Object listener) { - return this.listeners.remove(listener); - } - - public void addListener(Object listener) { - if ( !Beans.isInstanceOf(listener, listenerType) ) { - throw new IllegalArgumentException("wrong type for listener. " - + " expected: " + this.listenerType - + " received: " + listener.getClass()); - } - - this.listeners.add(listener); - } - - public void pump(String methodName) { - pump(methodName, null); - } - - public void pump(String methodName, Object arg) { - try { - Method m = getMethod(methodName, this.methods); - if ( m != null ) { - Iterator tor = Collections.unmodifiableList(this.listeners).iterator(); - while (tor.hasNext()) { - if ( arg != null ) { - m.invoke(methodName, new Object[]{arg}); - } - else { - m.invoke(methodName, null); - } - } - } - else { - throw new IllegalStateException("unknown method: " + methodName); - } - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - - public void pump(String methodName, Object args[]) { - - } - - private static Method getMethod(String name, Method methods[]) { - for (int i = 0; i < methods.length; i++) { - if ( methods[i].getName().equals(name)) { - return methods[i]; - } - } - - return null; - } -} diff --git a/code316-core/src/java/code316/event/Propagator.java b/code316-core/src/java/code316/event/Propagator.java deleted file mode 100644 index 8a6f054b..00000000 --- a/code316-core/src/java/code316/event/Propagator.java +++ /dev/null @@ -1,71 +0,0 @@ -package code316.event; - -import java.beans.Beans; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - - -/** - * A utility class to be used by message pumps to - * propagate messages to a listener. - */ -public class Propagator { - private List listeners = new ArrayList(); - - private Class listenerType; - private String methodName; - private String subjectType; - private Method targetMethod; - - public Propagator(String listenerClass, String listenerMethod, Class _class) { - try { - this.listenerType = Class.forName(listenerClass); - this.targetMethod = null; - - if (_class != null) { - targetMethod = this.listenerType.getMethod(listenerMethod, new Class[]{_class}); - } - else { - targetMethod = this.listenerType.getMethod(listenerMethod, null); - } - } - catch (Exception e) { - throw new IllegalStateException("error creating Propagator: " + e); - } - } - - public void addListener(Object listener) { - if ( !Beans.isInstanceOf(listener, listenerType) ) { - throw new IllegalArgumentException("wrong type for listener. " - + " expected: " + this.listenerType - + " received: " + listener.getClass()); - } - - this.listeners.add(listener); - } - - public boolean removeListener(Object listener) { - return this.listeners.remove(listener); - } - - public void propagate(Object o) { - Iterator tor = Collections.unmodifiableList(this.listeners).iterator(); - while (tor.hasNext()) { - Object listener = tor.next(); - try { - if ( o == null ) { - this.targetMethod.invoke(listener, null); - } - else { - this.targetMethod.invoke(listener, new Object[]{o}); - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - } -} diff --git a/code316-core/src/java/code316/gui/BeanModelAdapter.java b/code316-core/src/java/code316/gui/BeanModelAdapter.java deleted file mode 100644 index fabd7338..00000000 --- a/code316-core/src/java/code316/gui/BeanModelAdapter.java +++ /dev/null @@ -1,25 +0,0 @@ -package code316.gui; - -public class BeanModelAdapter { - private boolean selected; - private Object bean; - public BeanModelAdapter(Object bean) { - setBean(bean); - } - - public boolean isSelected() { - return selected; - } - - public void setSelected(boolean selected) { - this.selected = selected; - } - - public Object getBean() { - return bean; - } - - public void setBean(Object bean) { - this.bean = bean; - } -} diff --git a/code316-core/src/java/code316/gui/BeanTable.java b/code316-core/src/java/code316/gui/BeanTable.java deleted file mode 100644 index 8b447928..00000000 --- a/code316-core/src/java/code316/gui/BeanTable.java +++ /dev/null @@ -1,74 +0,0 @@ -package code316.gui; - - - -import java.awt.Component; - - -import javax.swing.JTable; -import javax.swing.table.DefaultTableCellRenderer; - - -import code316.beans.BeanProperty; -import code316.beans.BeanUtil; - - -public class BeanTable extends JTable { - private boolean editable; - - - public BeanTable() { - DefaultTableCellRenderer o = new DefaultTableCellRenderer(){ - - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - } - }; - - setDefaultRenderer(long.class, getDefaultRenderer(Long.class)); - setDefaultRenderer(int.class, getDefaultRenderer(Integer.class)); - setDefaultRenderer(boolean.class, getDefaultRenderer(Boolean.class)); - setDefaultRenderer(short.class, getDefaultRenderer(Short.class)); - setDefaultRenderer(byte.class, getDefaultRenderer(Byte.class)); - setDefaultRenderer(char.class, getDefaultRenderer(Character.class)); - setDefaultRenderer(double.class, getDefaultRenderer(Double.class)); - setDefaultRenderer(float.class, getDefaultRenderer(Float.class)); - - setDefaultEditor(long.class, getDefaultEditor(Long.class)); - setDefaultEditor(int.class, getDefaultEditor(Integer.class)); - setDefaultEditor(boolean.class, getDefaultEditor(Boolean.class)); - setDefaultEditor(short.class, getDefaultEditor(Short.class)); - setDefaultEditor(byte.class, getDefaultEditor(Byte.class)); - setDefaultEditor(char.class, getDefaultEditor(Character.class)); - setDefaultEditor(double.class, getDefaultEditor(Double.class)); - setDefaultEditor(float.class, getDefaultEditor(Float.class)); - } - - - public BeanTable(Class beanClass) { - this(); - BeanProperty properties[] = BeanUtil.getProperties(beanClass); - ModelDescription md = new ModelDescription(properties); - setModel(new BeanTableModel(md)); - } - - public static BeanTable forObject(Object o) { - return new BeanTable(o.getClass()); - } - - public static BeanTable forType(Class _class) { - return new BeanTable(_class); - } - - public boolean isCellEditable(int row, int column) { - return this.editable; - } - - public void setEditable(boolean b) { - this.editable = b; - } - - public boolean isEditable() { - return editable; - } -} diff --git a/code316-core/src/java/code316/gui/BeanTableModel.java b/code316-core/src/java/code316/gui/BeanTableModel.java deleted file mode 100644 index 69d65013..00000000 --- a/code316-core/src/java/code316/gui/BeanTableModel.java +++ /dev/null @@ -1,252 +0,0 @@ -package code316.gui; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import javax.swing.table.AbstractTableModel; - -import code316.beans.BeanProperty; - -public class BeanTableModel extends AbstractTableModel implements EasyTableModel { - private final List beans = new ArrayList(); - private ModelDescription modelDescription; - private boolean allowDuplicates; - private Map methods = new HashMap(); - private Map propertyNames = new HashMap(); - private Map methodNames = new HashMap(); - - public BeanTableModel(ModelDescription model) { - this.modelDescription = model; - } - - - /** - * @deprecated use getAll() instead - * @return - */ - public List getBeans() { - return new ArrayList(this.beans); - } - - - public Collection getAll() { - return new ArrayList(this.beans); - } - - - public void add(Object bean) { - synchronized (this.beans) { - insert(beans.size(), bean); - } - } - - - - - public void addAll(Collection beans) { - Iterator tor = beans.iterator(); - - while (tor.hasNext()) { - add(tor.next()); - } - } - - /** - * @deprecated use addAll() instead - * @param beans - */ - public void add(List beans) { - addAll(beans); - } - - public Object get(int index) { - if ( index >= this.beans.size() ) { - return null; - } - return this.beans.get(index); - } - - - - public void setData(Collection beans) { - clear(); - addAll(beans); - } - - - public void clear() { - int size = this.beans.size(); - this.beans.clear(); - fireTableRowsDeleted(0, 0); - } - - - public int indexOf(Object o) { - return this.beans.indexOf(o); - } - - public Object getValueAt(int rowIndex, int columnIndex) { - String defaultValue = "could not get property"; - - try { - String propertyString = this.modelDescription.getPropertyNames()[columnIndex]; - String names[] = (String[]) this.propertyNames.get(propertyString); - - if ( names == null ) { - names = parsePropertyNames(this.modelDescription.getPropertyNames()[columnIndex]); - this.propertyNames.put(propertyString, names); - } - - Object callee = this.beans.get(rowIndex); - Object result = null; - - for (int i = 0; i < names.length; i++) { - String propertyName = names[i]; - Method m = findMethod(propertyName, callee); - callee = result = m.invoke(callee, null); - } - - return result; - } - catch (Exception e) { - e.printStackTrace(); - defaultValue += ": " + e; - } - - return defaultValue; - } - - private Method findMethod(String propertyName, Object bean) throws NoSuchMethodException { - if ( bean == null ) { - throw new IllegalArgumentException("bean is null"); - } - String methodId = bean.getClass() + ":" + propertyName; - String methodName = (String) this.methodNames.get(methodId); - - if ( methodName == null && propertyName.endsWith("()") ) { - String newName = propertyName.substring(0, propertyName.length() - 2); - Method m = bean.getClass().getMethod(newName, null); - this.methodNames.put(methodId, newName); - this.methods.put(methodId, m); - return m; - } - - if ( methodName == null ) { - methodName = "get" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); - this.methodNames.put(methodId, methodName); - } - - Method m = (Method) this.methods.get(methodId); - - // try to find regular get method - try { - if (m == null) { - m = bean.getClass().getMethod(methodName, null); - this.methods.put(methodId, m); - } - } - catch (NoSuchMethodException e) { - // try to find boolean named method - methodName = "is" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); - this.methodNames.put(methodId, methodName); - m = bean.getClass().getMethod(methodName, null); - this.methods.put(methodId, m); - } - - return m; - } - - - public int getColumnCount() { - return modelDescription.getColumnCount(); - } - - public int getRowCount() { - return this.beans.size(); - } - - public String getColumnName(int columnIndex) { - try { - return (this.modelDescription.getColumnNames())[columnIndex]; - } - catch (ArrayIndexOutOfBoundsException e) { - throw new IllegalArgumentException("unknown property index: " + columnIndex); - } - } - - public void removeItem(Object bean) { - synchronized (this.beans) { - int index = this.beans.indexOf(bean); - - if ( index >= 0 ) { - this.beans.remove(index); - fireTableRowsDeleted(index - 1, index - 1); - } - } - } - - public Class getColumnClass(int columnIndex) { - try { - return (this.modelDescription.getClasses())[columnIndex]; - } - catch (ArrayIndexOutOfBoundsException e) { - throw new IllegalArgumentException("unknown column index: " + columnIndex); - } - } - - public void setValueAt(Object value, int rowIndex, int columnIndex) { - Object bean = get(rowIndex); - BeanProperty bp = this.modelDescription.getFields()[columnIndex]; - try { - bp.getSetter().invoke(bean, new Object[]{value}); - } - catch (IllegalArgumentException e) { - e.printStackTrace(); - } - catch (IllegalAccessException e) { - e.printStackTrace(); - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - - public boolean getAllowDuplicates() { - return allowDuplicates; - } - - public void setAllowDuplicates(boolean allowDuplicates) { - this.allowDuplicates = allowDuplicates; - } - - public void insert(int index, Object o) { - synchronized (this.beans) { - if ( !allowDuplicates && this.beans.contains(o) ) { - return; - } - - this.beans.add(index, o); - } - - fireTableRowsInserted(index, index); - } - - - static String[] parsePropertyNames(String propertyName) { - List names = new ArrayList(); - - StringTokenizer st = new StringTokenizer(propertyName, "."); - while (st.hasMoreTokens()) { - names.add(st.nextToken()); - } - - return (String[]) names.toArray(new String[0]); - } -} diff --git a/code316-core/src/java/code316/gui/EasyTableModel.java b/code316-core/src/java/code316/gui/EasyTableModel.java deleted file mode 100644 index 0b5303d2..00000000 --- a/code316-core/src/java/code316/gui/EasyTableModel.java +++ /dev/null @@ -1,14 +0,0 @@ -package code316.gui; - -import java.util.Collection; - -import javax.swing.table.TableModel; - -public interface EasyTableModel extends TableModel { - public abstract void add(Object o); - public abstract void addAll(Collection c); - public abstract void setData(Collection c); - public abstract Object get(int index); - public abstract Collection getAll(); - public abstract void insert(int index, Object o); -} diff --git a/code316-core/src/java/code316/gui/ModelDescription.java b/code316-core/src/java/code316/gui/ModelDescription.java deleted file mode 100644 index 63046a21..00000000 --- a/code316-core/src/java/code316/gui/ModelDescription.java +++ /dev/null @@ -1,131 +0,0 @@ -package code316.gui; - -import code316.beans.BeanProperty; - - -public class ModelDescription { - private Class classes[]; - private String columnNames[]; - private String propertyNames[]; - private BeanProperty fields[]; - - public ModelDescription(BeanProperty[] properties) { - this.fields = properties; - int count = properties.length; - this.classes = new Class[count]; - this.propertyNames = new String[count]; - this.columnNames = new String[count]; - - for (int i = 0; i < count; i++) { - BeanProperty prop = properties[i]; - classes[i] = prop.getType(); - propertyNames[i] = prop.getName(); - columnNames[i] = prop.getName(); - } - } - - - public ModelDescription(String properties[]) { - Class classes[] = new Class[properties.length]; - for (int i = 0; i < classes.length; i++) { - classes[i] = String.class; - } - - setClasses(classes); - setProperties(properties); - setColumnNames(properties); - } - - public ModelDescription(Class classes[], String properties[]) { - this(classes, properties, properties); - } - - public ModelDescription(Class classes[], - String properties[], - String columnHeaderNames[]) { - setClasses(classes); - setProperties(properties); - setColumnNames(columnHeaderNames); - } - - public BeanProperty[] getFields() { - return fields; - } - - public void setFields(BeanProperty[] fields) { - this.fields = fields; - } - - - public Class[] getClasses() { - return classes; - } - - public int getColumnCount() { - return propertyNames.length; - } - - - /** - * @deprecated Use getColumnCount() instead. - * - * @return Number of columns represented by this description - */ - public int getColumns() { - return propertyNames.length; - } - - public void setClasses(Class[] columnClasses) { - this.classes = columnClasses; - } - - public String[] getColumnNames() { - return columnNames; - } - - public void setColumnNames(String[] columnNames) { - this.columnNames = columnNames; - } - - - /** - * @deprecated Use getColumnNames() instead - * @param columnNames - */ - public String[] getNames() { - return columnNames; - } - - /** - * @deprecated Use setColumnNames() instead - * @param columnNames - */ - public void setNames(String[] columnNames) { - this.columnNames = columnNames; - } - - - /** - * @deprecated Use getPropertyNames instead. - * @return - */ - public String[] getProperties() { - return propertyNames; - } - - /** - * @deprecated Use setPropertyNames instead. - * @return - */ - public void setProperties(String[] propertyNames) { - this.propertyNames = propertyNames; - } - - public String[] getPropertyNames() { - return propertyNames; - } - - public void setPropertyNames(String[] propertyNames) { - this.propertyNames = propertyNames; - } -} diff --git a/code316-core/src/java/code316/io/FileMaskFilter.java b/code316-core/src/java/code316/io/FileMaskFilter.java deleted file mode 100644 index fac9d4b0..00000000 --- a/code316-core/src/java/code316/io/FileMaskFilter.java +++ /dev/null @@ -1,127 +0,0 @@ -package code316.io; - -import java.util.ArrayList; -import java.util.StringTokenizer; -import java.io.File; -import java.io.FilenameFilter; - -public class FileMaskFilter implements FilenameFilter { - public static final String FILE_MASK_SEPARATOR = ","; - - protected String fileMask = "*.*"; - protected boolean acceptAllFiles; - protected boolean accepting = true; - protected int maxFiles; - protected int accepted; - protected ArrayList masks = new ArrayList(); - - public FileMaskFilter(String fileMask) { - super(); - - setFileMask(fileMask); - } - - public String getFileMask() { - return fileMask; - } - - public boolean isAcceptAllFiles() { - return acceptAllFiles; - } - - public void setAcceptAllFiles(boolean newAcceptAllFiles) { - acceptAllFiles = newAcceptAllFiles; - } - - public boolean accept(File dir, String name) { - if (!accepting) { - return false; - } - - boolean accept = false; - - if (acceptAllFiles || fileMatchesMask(name)) { - accepted++; - accept = true; - - if (accepted == maxFiles) { - accepting = false; - } - } - - return accept; - } - - private void addFileMask(String newFileMask) { - fileMask = newFileMask; - - if (fileMask.equals("*.*")) { - acceptAllFiles = true; - } - - if (fileMask.startsWith("*.")) { - fileMask = fileMask.substring(1); - } - - masks.add(fileMask); - } - - private boolean fileMatchesMask(String name) { - boolean matches = false; - - int count = masks.size(); - - for (int i = 0; i < count; i++) { - String mask = (String) masks.get(i); - if (name.endsWith(mask)) { - matches = true; - break; - } - } - - return matches; - } - - public int getAccepted() { - return accepted; - } - - public int getMaxFiles() { - return maxFiles; - } - - public boolean isAccepting() { - return accepting; - } - - public void reset() { - accepted = 0; - accepting = true; - } - - public void setFileMask(String fileMask) { - if (fileMask == null || fileMask.trim().length() == 0) { - throw new IllegalArgumentException("invalid fileMask value: " + fileMask); - } - - this.fileMask = fileMask.trim(); - reset(); - masks.clear(); - - if (fileMask.indexOf(FILE_MASK_SEPARATOR) == -1) { - addFileMask(fileMask); - return; - // EARLY OUT ///////////////////// - } - - StringTokenizer tokenizer = new StringTokenizer(fileMask, FILE_MASK_SEPARATOR); - - while (tokenizer.hasMoreTokens()) { - addFileMask(tokenizer.nextToken().trim()); - } - } - - public void setMaxFiles(int newMaxFiles) { - maxFiles = newMaxFiles; - } -} \ No newline at end of file diff --git a/code316-core/src/test/code316/beans/AllTests.java b/code316-core/src/test/code316/beans/AllTests.java deleted file mode 100644 index 49d2f2c4..00000000 --- a/code316-core/src/test/code316/beans/AllTests.java +++ /dev/null @@ -1,16 +0,0 @@ -package code316.beans; - -import junit.framework.Test; -import junit.framework.TestSuite; - - -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite("Test for code316.beans"); - //$JUnit-BEGIN$ - suite.addTestSuite(BeanTableTest.class); - //$JUnit-END$ - return suite; - } -} diff --git a/code316-core/src/test/code316/beans/BeanTableTest.java b/code316-core/src/test/code316/beans/BeanTableTest.java deleted file mode 100644 index 30f1b26f..00000000 --- a/code316-core/src/test/code316/beans/BeanTableTest.java +++ /dev/null @@ -1,179 +0,0 @@ -package code316.beans; - -import java.lang.reflect.Method; -import java.util.Iterator; -import java.util.List; - -import javax.swing.JFrame; -import javax.swing.JScrollPane; -import javax.swing.WindowConstants; - -import code316.gui.BeanTable; -import code316.gui.BeanTableModel; - -import junit.framework.TestCase; - - -public class BeanTableTest extends TestCase { - public static class Filter { - private String name; - private String text; - private String type; - private int priority; - - - public int getPriority() { - return priority; - } - - public void setPriority(int priority) { - this.priority = priority; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String toString() { - StringBuffer me = new StringBuffer(); - me.append("[").append(super.toString()) - - .append(",name=").append(this.name) - .append(",type=").append(this.type) - .append(",priority=").append(this.priority) - - .append("]"); - - return me.toString(); - } - - } - public static class MyBean { - private int id; - private boolean ok; - private String name; - public boolean isOk() { - return ok; - } - - public void setOk(boolean ok) { - this.ok = ok; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public int getAge() { - return 0; - } - - public void setAge(long age) { - - } - } - public static void main(String[] args) { - - JFrame f = new JFrame(); - final BeanTable table = new BeanTable(Filter.class); - table.setEditable(true); - - for (int i = 0; i < 50; i++) { - Filter fi = new Filter(); - fi.setName("filter-" + i); - fi.setText("text-" + i); - fi.setType("class-name?-" + i); - - ((BeanTableModel) table.getModel()).add(fi); - } - - f.getContentPane().add(new JScrollPane(table)); - f.setSize(300, 200); - f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - f.show(); - - Runtime.getRuntime().addShutdownHook(new Thread(){ - public void run() { - List l = ((BeanTableModel) table.getModel()).getBeans(); - - Iterator tor = l.iterator(); - while (tor.hasNext()) { - System.out.println(tor.next()); - } - } - }); - } - - public void testExtractPropertyName() { - assertEquals("Name", BeanUtil.extractPropertyName("getName")); - assertEquals("Name", BeanUtil.extractPropertyName("setName")); - assertEquals("Name", BeanUtil.extractPropertyName("isName")); - - assertEquals("X", BeanUtil.extractPropertyName("getX")); - assertEquals("X", BeanUtil.extractPropertyName("setX")); - assertEquals("X", BeanUtil.extractPropertyName("isX")); - } - - public void testGetProperties() { - BeanProperty properties[] = BeanUtil.getProperties(MyBean.class); - - assertEquals(3, properties.length); - } - - public void testGetFirstParameter() throws Exception { - Method methods[] = MyBean.class.getMethods(); - for (int i = 0; i < methods.length; i++) { - Method method = methods[i]; - if ( method.getName().equals("setAge") ) { - assertEquals(long.class, BeanUtil.getFirstParameterType(method)); - return; - } - - } - assertTrue(false); - } - - public void testGetReturnType() throws Exception { - Method methods[] = MyBean.class.getMethods(); - for (int i = 0; i < methods.length; i++) { - Method method = methods[i]; - if ( method.getName().equals("getAge") ) { - assertEquals(int.class, BeanUtil.getReturnType(method)); - return; - } - } - assertTrue(false); - } -} diff --git a/code316-core/src/test/code316/core/AllTests.java b/code316-core/src/test/code316/core/AllTests.java deleted file mode 100644 index 58ca6f93..00000000 --- a/code316-core/src/test/code316/core/AllTests.java +++ /dev/null @@ -1,23 +0,0 @@ -package code316.core; - -import junit.framework.Test; -import junit.framework.TestResult; -import junit.framework.TestSuite; - - -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite("Test for code316.core"); - //$JUnit-BEGIN$ - suite.addTestSuite(FileUtilTest.class); - suite.addTestSuite(FilterPropertiesTest.class); - suite.addTestSuite(IsEmptyTest.class); - //$JUnit-END$ - return suite; - } - - public static void main(String[] args) { - suite().run(new TestResult()); - } -} diff --git a/code316-core/src/test/code316/core/FileUtilTest.java b/code316-core/src/test/code316/core/FileUtilTest.java deleted file mode 100644 index 10dcbd41..00000000 --- a/code316-core/src/test/code316/core/FileUtilTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package code316.core; - -import junit.framework.TestCase; - - -public class FileUtilTest extends TestCase { - - public FileUtilTest(String arg0) { - super(arg0); - } - - public void testGetExtension() { - String fileName = "a.b.c.d.e.f.txt"; - assertEquals("txt", FileUtil.getExtension(fileName)); - } -} diff --git a/code316-core/src/test/code316/core/FilterPropertiesTest.java b/code316-core/src/test/code316/core/FilterPropertiesTest.java deleted file mode 100644 index b725e93e..00000000 --- a/code316-core/src/test/code316/core/FilterPropertiesTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package code316.core; - -import java.util.Properties; - -import junit.framework.TestCase; - -public class FilterPropertiesTest extends TestCase { - public FilterPropertiesTest(String arg0) { - super(arg0); - } - - - public void test() throws Exception { - Properties props = new Properties(); - props.put("want1", "value"); - props.put("dontwant", "value"); - props.put("want2", "value"); - props.put("want3", "value"); - props.put("dontwant", "value"); - props.put("youwant2", "value"); - props.put("notwant1", "value"); - props.put("want_dashed", "value"); - props.put("want5", "value"); - props.put("want4", "value"); - props.put("dontwant", "value"); - props.put("keyname", "value"); - - Properties filtered = PropertiesUtil.filter(props, "want"); - - assertTrue(filtered.size() == 6); - } - - -} diff --git a/code316-core/src/test/code316/core/IsEmptyTest.java b/code316-core/src/test/code316/core/IsEmptyTest.java deleted file mode 100644 index 930d139e..00000000 --- a/code316-core/src/test/code316/core/IsEmptyTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package code316.core; -import code316.core.PropertiesUtil; - -import junit.framework.TestCase; - -public class IsEmptyTest extends TestCase { - - public IsEmptyTest(String arg0) { - super(arg0); - } - - public void test() throws Exception { - String emptyString = ""; - String nullString = null; - String whiteString = " \t "; - String goodString = " good "; - String goodString2 = "good"; - - assertTrue(PropertiesUtil.isEmpty(emptyString)); - assertTrue(PropertiesUtil.isEmpty(nullString)); - assertTrue(PropertiesUtil.isEmpty(whiteString)); - assertTrue(!PropertiesUtil.isEmpty(goodString)); - assertTrue(!PropertiesUtil.isEmpty(goodString2)); - } - -} diff --git a/code316-core/src/test/code316/gui/AllTests.java b/code316-core/src/test/code316/gui/AllTests.java deleted file mode 100644 index baf53558..00000000 --- a/code316-core/src/test/code316/gui/AllTests.java +++ /dev/null @@ -1,21 +0,0 @@ -package code316.gui; - -import junit.framework.Test; -import junit.framework.TestResult; -import junit.framework.TestSuite; - - -public class AllTests { - public static Test suite() { - TestSuite suite = new TestSuite("Test for code316.gui"); - //$JUnit-BEGIN$ - suite.addTestSuite(BeanModelTester.class); - suite.addTestSuite(ModelDescriptionTest.class); - //$JUnit-END$ - return suite; - } - - public static void main(String[] args) { - suite().run(new TestResult()); - } -} diff --git a/code316-core/src/test/code316/gui/BeanModelTester.java b/code316-core/src/test/code316/gui/BeanModelTester.java deleted file mode 100644 index 35b3819a..00000000 --- a/code316-core/src/test/code316/gui/BeanModelTester.java +++ /dev/null @@ -1,124 +0,0 @@ -package code316.gui; - - -import java.util.Arrays; - -import junit.framework.TestCase; - - -public class BeanModelTester extends TestCase { - public void testparsePropertyNames() { - String names[] = BeanTableModel.parsePropertyNames("message.sender.address"); - - assertEquals(3, names.length); - assertEquals("message", names[0]); - assertEquals("sender", names[1]); - assertEquals("address", names[2]); - - names = BeanTableModel.parsePropertyNames("message"); - - assertEquals(1, names.length); - assertEquals("message", names[0]); - } - - public void testGetValueAt() throws Exception { - class Deeper { - public int getNumber() { - return 7; - } - - public String getCategory() { - return "box"; - } - } - - class SampleItem { - public SampleItem getItem() { - return this; - } - - public String getName() { - return "tom"; - } - - public int getNumber() { - return 10; - } - - public boolean isOk() { - return false; - } - - public Deeper getDeeper() { - return new Deeper(); - } - } - - ModelDescription md = - new ModelDescription( - new String[]{ - "item.name", "item.number", - "ok", - "deeper.number", - "deeper.category", - "deeper.category.length()" - }); - BeanTableModel model = new BeanTableModel(md); - model.add(new SampleItem()); - - Object o = model.getValueAt(0, 0); - assertEquals("tom", o); - - o = model.getValueAt(0, 1); - assertEquals(new Integer(10), o); - - o = model.getValueAt(0, 0); - assertEquals("tom", o); - - o = model.getValueAt(0, 2); - assertEquals(Boolean.FALSE, o); - - o = model.getValueAt(0, 3); - assertEquals(new Integer(7), o); - - o = model.getValueAt(0, 4); - assertEquals("box", o); - - o = model.getValueAt(0, 5); - assertEquals(new Integer(3), o); - } - - public void testAddList() { - String [] names = new String[]{"dave", "jakob", "bethany", "betty"}; - ModelDescription md = new ModelDescription(new String[]{"toString()"}); - BeanTableModel model = new BeanTableModel(md); - - model.add(Arrays.asList(names)); - - assertEquals(4, model.getRowCount()); - assertEquals("dave", model.get(0)); - assertEquals("jakob", model.get(1)); - assertEquals("bethany", model.get(2)); - assertEquals("betty", model.get(3)); - - assertEquals(1, model.getColumnCount()); - - assertEquals(4, model.getBeans().size()); - model.clear(); - assertEquals(0, model.getRowCount()); - - model.setData(Arrays.asList(names)); - assertEquals(4, model.getRowCount()); - assertEquals("dave", model.get(0)); - assertEquals("jakob", model.get(1)); - assertEquals("bethany", model.get(2)); - assertEquals("betty", model.get(3)); - - assertEquals(1, model.getColumnCount()); - - assertEquals(4, model.getBeans().size()); - model.clear(); - assertEquals(0, model.getRowCount()); - - } -} diff --git a/code316-core/src/test/code316/gui/ModelDescriptionTest.java b/code316-core/src/test/code316/gui/ModelDescriptionTest.java deleted file mode 100644 index 4125ae17..00000000 --- a/code316-core/src/test/code316/gui/ModelDescriptionTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package code316.gui; - -import code316.beans.BeanProperty; -import code316.beans.BeanUtil; -import junit.framework.TestCase; - - -public class ModelDescriptionTest extends TestCase { - static class Test { - private int id; - private String name; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - } - public void testCreation() { - BeanProperty props[] = BeanUtil.getProperties(Test.class); - - ModelDescription md = new ModelDescription(props); - } -} diff --git a/code316-core/test-vals.txt b/code316-core/test-vals.txt deleted file mode 100644 index b2f31502..00000000 --- a/code316-core/test-vals.txt +++ /dev/null @@ -1,6 +0,0 @@ -angle=3 -fails=2 -level=1 -temp=3336 -door_open=1 - \ No newline at end of file diff --git a/code316-core/test.enc b/code316-core/test.enc deleted file mode 100644 index 58ba4606..00000000 --- a/code316-core/test.enc +++ /dev/null @@ -1,7 +0,0 @@ -# test encoding -angle=3 -fails=2 -level=1 -# another comment -temp=10.3 -door_open=1 \ No newline at end of file diff --git a/code316-core/test.vals b/code316-core/test.vals deleted file mode 100644 index e69de29b..00000000 diff --git a/dormant/atom4j/.classpath b/dormant/atom4j/.classpath deleted file mode 100644 index 41297f29..00000000 --- a/dormant/atom4j/.classpath +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/dormant/atom4j/.cvsignore b/dormant/atom4j/.cvsignore deleted file mode 100644 index b883a172..00000000 --- a/dormant/atom4j/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -build -bin -*.log diff --git a/dormant/atom4j/.project b/dormant/atom4j/.project deleted file mode 100644 index 3f6e2bc0..00000000 --- a/dormant/atom4j/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Atom4J - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/dormant/atom4j/LICENSE.txt b/dormant/atom4j/LICENSE.txt deleted file mode 100644 index aaf9619e..00000000 --- a/dormant/atom4j/LICENSE.txt +++ /dev/null @@ -1,16 +0,0 @@ - -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ \ No newline at end of file diff --git a/dormant/atom4j/README.txt b/dormant/atom4j/README.txt deleted file mode 100644 index bbc007fe..00000000 --- a/dormant/atom4j/README.txt +++ /dev/null @@ -1,32 +0,0 @@ -Atom4J serves as a library to assist in reading and generating Atom API -specified XML. Atom4J includes an abstract Servlet for assisting in the -implementation of a Servlet which supports the Atom API. Such a servlet -will soon be included in Roller (http://www.rollerweblogger.org) if you -would like to see an example. - -Atom4J does in no way include any security restrictions, beyond an -abstract authorized() method. The Atom API currently suggest using -Digest authentication. Again, this is not included in Atom4J. - -Future development may include the reading and writing of Atom feeds as -outlined in the Atom 0.2 Snapshot: -http://diveintomark.org/archives/2003/08/05/atom02 - -To compile and use the library, you will need: -commons-digester.jar and its associated jars: - commons-beanutils.jar - commons-collections.jar - commons-logging.jar -commons-lang.jar -servlet-2.3.jar - -To compile and run the tests, you will need to add -junit-3.8.1.jar or later. - -This version of Atom4J (v0.1) supports the AtomAPI as of 09/01/2003, -currently at version 0.7. -For more information refer to the following urls: -The Atom wiki : http://www.intertwingly.net/wiki/pie/ -Busy developers guide : http://bitworking.org/news/AtomAPI_URIs -The AtomAPI RFC : http://bitworking.org/rfc/draft-gregorio-07.html -RFC wiki : http://notabug.com/2002/awiki/api \ No newline at end of file diff --git a/dormant/atom4j/build.xml b/dormant/atom4j/build.xml deleted file mode 100644 index 41ec0c75..00000000 --- a/dormant/atom4j/build.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CLASSPATH:${atom4j.classpath} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BUILDING CLASS JAR FILE - - - - - - - - - - - - - - - - - - BUILDING SRC-JAR FILE - - - - - - - - - - - - - - - - - - - diff --git a/dormant/atom4j/build_xml.properties b/dormant/atom4j/build_xml.properties deleted file mode 100644 index 04dea584..00000000 --- a/dormant/atom4j/build_xml.properties +++ /dev/null @@ -1,3 +0,0 @@ -#choose classic, modern, jikes, or jvc -JAVAC=modern - diff --git a/dormant/atom4j/docs/feed/Atom03_Max.xml b/dormant/atom4j/docs/feed/Atom03_Max.xml deleted file mode 100644 index 82a21fe4..00000000 --- a/dormant/atom4j/docs/feed/Atom03_Max.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - dive into mark - - 2003-12-13T12:29:29Z - - -
- This is an Atom syndication feed. It is intended to be viewed in a news aggregator or syndicated to another site. Please visit the Atom Project for more information. -
-
- A <em>lot</em> of effort went into making this effortless - tag:example.org,2003:3 - Example Toolkit - Copyright (c) 2003, Mark Pilgrim - - - - Atom 0.3 snapshot - - tag:example.org,2003:3.2397 - 2003-12-13T08:29:29-04:00 - 2003-12-13T18:30:02Z - - 2003-12-13T12:29:29Z - The Atom 0.3 snapshot is out. Here are some sample feeds. - - Mark Pilgrim - http://example.org/ - f8dy@example.com - - - Sam Ruby - http://intertwingly.net/blog/ - rubys@example.com - - - Joe Gregorio - http://bitworking.org/ - joe@example.com - - -
-

The Atom 0.3 snapshot is out. Changes from the 0.2 snapshot:

-
    -
  1. MAY contain feed/info. Free-form info statement that describes the feed format. More explanation of info.
  2. -
  3. Expanded link syntax. All links now include rel, type, and href attributes.
  4. -
  5. Expanded content model. feed/title, feed/tagline, feed/info, feed/copyright, entry/title, and entry/summary can now contain arbitrary data (such as HTML). You must specify the data type in the type attribute, and (for non-XML formats) the escaping mode in the mode attribute.
  6. -
  7. feed/generator now has url and version attributes. The child text is now the human-readable toolkit name.
  8. -
  9. several other changes not listed here
  10. -
-
-
-
-
diff --git a/dormant/atom4j/docs/feed/Atom03_Min.xml b/dormant/atom4j/docs/feed/Atom03_Min.xml deleted file mode 100644 index 3201d858..00000000 --- a/dormant/atom4j/docs/feed/Atom03_Min.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - dive into mark - - 2003-12-13T18:30:02Z - - Mark Pilgrim - - - Atom 0.3 snapshot - - tag:diveintomark.org,2003:3.2397 - 2003-12-13T08:29:29-04:00 - 2003-12-13T18:30:02Z - - diff --git a/dormant/atom4j/docs/feed/Atom03_Multipart.xml b/dormant/atom4j/docs/feed/Atom03_Multipart.xml deleted file mode 100644 index 02f7a5a9..00000000 --- a/dormant/atom4j/docs/feed/Atom03_Multipart.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - dive into mark - - 2003-12-13T12:29:29Z - - A lot of effort went into making this effortless - tag:diveintomark.org,2003:3 - Movable Type - Copyright (c) 2003, Mark Pilgrim - - - - Atom 0.3 snapshot - - tag:diveintomark.org,2003:3.2397 - 2003-12-13T08:29:29-04:00 - 2003-12-13T12:29:29Z - 2003-12-13T18:30:02Z - - The Atom 0.3 snapshot is out. Here are some sample feeds. - - Mark Pilgrim - http://diveintomark.org/ - f8dy@example.com - - - Sam Ruby - http://intertwingly.net/blog/ - rubys@example.com - - - Joe Gregorio - http://bitworking.org/ - joe@example.com - - - - The Atom 0.3 snapshot is out. Changes from the 0.2 snapshot [http://diveintomark.org/archives/2003/08/05/atom02]: (1) MAY contain feed/info. Free-form info statement that describes the feed format. More explanation of info [http://www.shellen.com/sandbox/atom-info-proposal.html]. (2) Expanded link syntax. All links now include rel, type, and href attributes. (3) Expanded content model. feed/title, feed/tagline, feed/info, feed/copyright, entry/title, and entry/summary can now contain arbitrary data (such as HTML). You must specify the data type in the type attribute, and (for non-XML formats) the escaping mode in the mode attribute. (4) feed/generator now has url and version attributes. The child text is now the human-readable toolkit name. (5) several other changes not listed here. - - -
-

The Atom 0.3 snapshot is out. Changes from the 0.2 snapshot:

-
    -
  1. MAY contain feed/info. Free-form info statement that describes the feed format. More explanation of info.
  2. -
  3. Expanded link syntax. All links now include rel, type, and href attributes.
  4. -
  5. Expanded content model. feed/title, feed/tagline, feed/info, feed/copyright, entry/title, and entry/summary can now contain arbitrary data (such as HTML). You must specify the data type in the type attribute, and (for non-XML formats) the escaping mode in the mode attribute.
  6. -
  7. feed/generator now has url and version attributes. The child text is now the human-readable toolkit name.
  8. -
  9. several other changes not listed here
  10. -
-
-
-
-
-
diff --git a/dormant/atom4j/docs/feed/atom02entryauthor.xml b/dormant/atom4j/docs/feed/atom02entryauthor.xml deleted file mode 100644 index 55d75aa1..00000000 --- a/dormant/atom4j/docs/feed/atom02entryauthor.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - Collective Atom blog - http://example.com/atom/ - 2003-08-02T18:30:02Z - - Atom 0.2 snapshot examples - http://example.com/atom/atom_02_snapshot - tag:example.com,2003:atom.2 - 2003-08-02T08:29:29-04:00 - 2003-08-02T18:30:02Z - I have posted examples of Atom 0.2 feeds. - - Mark Pilgrim - http://diveintomark.org/ - f8dy@example.com - - - - Atom API draft 6 - http://example.com/atom/atom_api_draft_6 - tag:example.com,2003:atom.1 - 2003-07-29T09:15:29-04:00 - 2003-07-29T13:15:29Z - I have released draft 6 of the Atom API. Discussion welcome on the wiki at RestEchoApiDiscuss. - - Joe Gregorio - http://bitworking.org/ - joe@example.com - - - diff --git a/dormant/atom4j/docs/feed/atom02feedauthor.xml b/dormant/atom4j/docs/feed/atom02feedauthor.xml deleted file mode 100644 index c92fd015..00000000 --- a/dormant/atom4j/docs/feed/atom02feedauthor.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - dive into mark - http://diveintomark.org/ - 2003-08-05T18:30:02Z - - - Mark Pilgrim - - http://diveintomark.org/ - f8dy@example.com - - - Atom 0.2 snapshot - http://diveintomark.org/2003/08/05/atom_02_snapshot - tag:diveintomark.org,2003:3.2397 - 2003-08-05T08:29:29-04:00 - 2003-08-05T18:30:02Z - - - Atom API update - http://diveintomark.org/2003/07/29/atom_api_update - tag:diveintomark.org,2003:3.2396 - 2003-07-29T09:15:29-04:00 - 2003-07-29T13:15:29Z - - diff --git a/dormant/atom4j/docs/feed/atom02maximal.xml b/dormant/atom4j/docs/feed/atom02maximal.xml deleted file mode 100644 index 610a2b16..00000000 --- a/dormant/atom4j/docs/feed/atom02maximal.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - dive into mark - http://diveintomark.org/ - 2003-08-05T12:29:29Z - - A lot of effort went into making this effortless - tag:diveintomark.org,2003:3 - http://www.movabletype./org/?v=2.64 - Copyright (c) 2003, Mark Pilgrim - - - - Atom 0.2 snapshot - http://diveintomark.org/2003/08/05/atom02 - tag:diveintomark.org,2003:3.2397 - 2003-08-05T08:29:29-04:00 - 2003-08-05T18:30:02Z - - 2003-08-05T12:29:29Z - The Atom 0.2 snapshot is out. Here are some sample feeds. - - Mark Pilgrim - http://diveintomark.org/ - f8dy@example.com - - - Sam Ruby - http://intertwingly.net/blog/ - rubys@example.com - - - Joe Gregorio - http://bitworking.org/ - joe@example.com - - -
-

The Atom 0.2 snapshot is out. Changes from the 0.1 snapshot:

-
    -
  1. MAY contain feed/copyright. Free-form copyright statement that applies to the feed (XXX more here). Datatype is <xsd:string>. If present, MUST NOT be blank.
  2. -
  3. -

    MAY contain feed/generator. Datatype is <xsd:string>. If present, MUST be full URI and SHOULD point to the home page of the program which generated the feed.

    -

    Has optional @name attribute, whose datatype is also <xsd:string>. If present, @name MUST NOT be blank.

    -
  4. -
  5. several other changes not listed here
  6. -
-
-
-
-
diff --git a/dormant/atom4j/docs/feed/atom02minimal.xml b/dormant/atom4j/docs/feed/atom02minimal.xml deleted file mode 100644 index 720c20c1..00000000 --- a/dormant/atom4j/docs/feed/atom02minimal.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - dive into mark - http://diveintomark.org/ - 2003-08-05T18:30:02Z - - Mark Pilgrim - - - Atom 0.2 snapshot - http://diveintomark.org/2003/08/05/atom02 - tag:diveintomark.org,2003:3.2397 - 2003-08-05T08:29:29-04:00 - 2003-08-05T18:30:02Z - - diff --git a/dormant/atom4j/docs/feed/atom02multipart.xml b/dormant/atom4j/docs/feed/atom02multipart.xml deleted file mode 100644 index 321fc8a8..00000000 --- a/dormant/atom4j/docs/feed/atom02multipart.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - dive into mark - http://diveintomark.org/ - 2003-08-05T12:29:29Z - - A lot of effort went into making this effortless - tag:diveintomark.org,2003:3 - http://www.movabletype./org/?v=2.64 - Copyright (c) 2003, Mark Pilgrim - - - - Atom 0.2 snapshot - http://diveintomark.org/2003/08/05/atom02 - tag:diveintomark.org,2003:3.2397 - 2003-08-05T08:29:29-04:00 - 2003-08-05T12:29:29Z - 2003-08-05T18:30:02Z - - The Atom 0.2 snapshot is out. Here are some sample feeds. - - Mark Pilgrim - http://diveintomark.org/ - f8dy@example.com - - - Sam Ruby - http://intertwingly.net/blog/ - rubys@example.com - - - Joe Gregorio - http://bitworking.org/ - joe@example.com - - - - The Atom 0.2 snapshot is out. Changes from the 0.1 snapshot: (1) MAY contain feed/copyright. xsd:string. If present, MUST NOT be blank. (2) MAY contain feed/generator. xsd:string. If present, MUST be a full URI and SHOULD point to the home page of the program which generated the feed. (3) several other changes not listed here - - -
-

The Atom 0.2 snapshot is out. Changes from the 0.1 snapshot:

-
    -
  1. MAY contain feed/copyright. Free-form copyright statement that applies to the feed (XXX more here). Datatype is <xsd:string>. If present, MUST NOT be blank.
  2. -
  3. -

    MAY contain feed/generator. Datatype is <xsd:string>. If present, MUST be full URI and SHOULD point to the home page of the program which generated the feed.

    -

    Has optional @name attribute, whose datatype is also <xsd:string>. If present, @name MUST NOT be blank.

    -
  4. -
  5. several other changes not listed here
  6. -
-
-
-
-
-
diff --git a/dormant/atom4j/docs/feed/atom02spec.txt b/dormant/atom4j/docs/feed/atom02spec.txt deleted file mode 100644 index 096cf1da..00000000 --- a/dormant/atom4j/docs/feed/atom02spec.txt +++ /dev/null @@ -1,133 +0,0 @@ -[semantics are given in "quotes"] -[some elements are simply defined in terms of Dublin Core elements] -[uppercase MUST/SHOULD/MAY language is normative; lowercase language is just me -talking] -[this snapshot does not allow xml:base, although a future snapshot might, once -we figure out what it ought to apply to] -[xml:lang may appear on any element, including but not limited to feed, entry, -content, title, summary] - -- XML vocabulary -- no DTD -- no normative schema (yet) -- no strings have normative length limitations -- namespace: http://purl.org/atom/ns# -- top-level element: feed - -feed element - -required attributes of feed: -- @version. currently the only acceptable value is 0.2. (0.1 is obsolete and -should not be used.) - -optional attributes of feed: -- xml:lang. SHOULD be included. MAY be overwritten on individual entries, if -the feed contains entries in more than one language. - -required children of feed: -- title. occurs 1. xsd:string. "dc:title". if this feed describes a -website, SHOULD be the title of the website. -- link. occurs 1. xsd:anyURI. "the link to the website described by this -feed". if this feed describes a website, SHOULD be a link to the homepage of -the website. -- modified. occurs 1. W3DTF. "dcterms:modified". the modification date of -the feed, including any changes to any of the listed entries. SHOULD be UTC. -- author. no content, but has subchildren, see below. occurs 0 or 1. at -least one of the following MUST be true: 1. feed contains author; 2. every -entry contains author. if feed contains author and entry does not, the feed's -author element is inherited and applies to that entry. if both a feed and an -entry within the feed contain an author, the entry's author overrides the -feed's author. every entry MUST have exactly one author. - -optional children of feed: -- tagline. occurs 0 or 1. xsd:string. "dc:description". "a short -human-readable tagline for this feed". examples: "All the news that's fit to -print" (tagline of NYT). -- id. occurs 0 or 1. xsd:anyURI. "permanent, globally unique ID of this -feed." MUST NOT change, ever, even if the feed is moved to a new server. for -this reason, it probably shouldn't be the same as feed/link, although it MAY -be. we're currently discussing options, including and -GUID in the COM/CORBA sense. -- generator. occurs 0 or 1. xsd:anyURI. "URI of the toolkit that generated -this feed." SHOULD be home page of toolkit/program/hosting provider, example -http://www.movabletype.org/. MAY include version number, example: -http://www.movabletype.org/?v=2.64. - - generator optional attribute: @name. xsd:string. "human-readable name of -the toolkit that generated this feed". example: name="Movable Type" -- copyright. occurs 0 or 1. xsd:string. "dc:rights". "human-readable -copyright statement for this feed." for machine-readable licensing -information, producers SHOULD use an extension module (to be defined). -- entry. see below -- contributor. occurs 0 or more. no content, but has children, see below - -author element - -required children of author: -- name. occurs 1. xsd:string. "dc:creator" of feed or entry (depending on -where author element is). MAY be name of corporation, if there are no -individual authors or publisher does not wish to make their names available. -see - -optional children of author: -- url. occurs 0 or 1. xsd:anyURI. "the URL of this author". -- email. occurs 0 or 1. whatever standard defines email address syntax, -including plus signs and other allowable weird characters. "the email address -of this author". - -entry element - no content, no attributes (other than optional xml:lang) - -required children of entry: - -- title. occurs 1. xsd:string. "dc:title" -- link. occurs 1. xsd:anyURI. "permanent link to a representation of this -entry". is NOT defined as "link to an external resource described in the -content of this entry". MUST be permanent. MUST be globally unique. MUST be -clickable (not sure how to express this, perhaps "use an IANA-registered -protocol and point to a resource that is viewable by ... uh, something) -- id. occurs 1. xsd:anyURI. "dc:identifier". "permanent globally unique ID -of this entry". MUST be permanent, MUST be globally unique. MAY be same as -link. current recommendations are under active discussion, same issues as -feed/id. -- issued. occurs 1. W3DTF minus timezone requirement. "dcterms:issued". -SHOULD include timezone. SHOULD be expressed in publisher's local timezone. -MAY skip timezone (LiveJournal requirement). -- modified. W3DTF. "dcterms:modified". SHOULD be UTC. - -optional children of entry: - -- created. occurs 0 or 1. W3DTF. "dcterms:created". SHOULD be UTC. if not -present, its value is presumed to be identical to modified. -- summary. occurs 0 or 1. xsd:string. "dc:description". "short summary, -blurb, or excerpt about this entry". MUST be plain text (i.e. no escaped -HTML). examples of use: lead on first page of news site. -- author. see above -- contributor. occurs 0 or more. no content, but has children, see below -- content. occurs 0 or more. see below - -contributor element - -same required and optional elements as author. name is "dc:contributor", url -and email are the same as in author. - -content element - -required attributes: - -- @type. MIME type. "format of this content" - -optional attributes: - -- xml:lang. -- @mode. 'xml', 'escaped', or 'base64'. "method using to encode this -content". if 'xml', value is inline xml (probably namespaced XHTML). if -'escaped', value is an escaped xsd:string which consumers MUST unescap and -treat as @type. if 'base64', value is base64-encoded which consumers MUST -base64-decode and treat as @type. - -if content @type="multipart/alternative", @mode MUST NOT be specified, and -content element MUST contain 1 or more content elements. These content -elements MUST NOT specify @type="multipart/alternative" (i.e. only one level of -nesting is allowed). Consumers SHOULD look at all alternative content elements -and determine which one is most suitable, based on which @type and @mode the -consumer supports, and preferences specified by the end user (if any). -Consumers SHOULD NOT render more than one content alternative. diff --git a/dormant/atom4j/index.html b/dormant/atom4j/index.html deleted file mode 100644 index 0423d966..00000000 --- a/dormant/atom4j/index.html +++ /dev/null @@ -1,6 +0,0 @@ - - - -Please see this page. diff --git a/dormant/atom4j/lib/commons-beanutils.jar b/dormant/atom4j/lib/commons-beanutils.jar deleted file mode 100644 index 795655a6..00000000 Binary files a/dormant/atom4j/lib/commons-beanutils.jar and /dev/null differ diff --git a/dormant/atom4j/lib/commons-codec-1.1.jar b/dormant/atom4j/lib/commons-codec-1.1.jar deleted file mode 100644 index 9ff33b6d..00000000 Binary files a/dormant/atom4j/lib/commons-codec-1.1.jar and /dev/null differ diff --git a/dormant/atom4j/lib/commons-collections.jar b/dormant/atom4j/lib/commons-collections.jar deleted file mode 100644 index f66c6d27..00000000 Binary files a/dormant/atom4j/lib/commons-collections.jar and /dev/null differ diff --git a/dormant/atom4j/lib/commons-digester.jar b/dormant/atom4j/lib/commons-digester.jar deleted file mode 100644 index c2a7d9d3..00000000 Binary files a/dormant/atom4j/lib/commons-digester.jar and /dev/null differ diff --git a/dormant/atom4j/lib/commons-lang-1_0.jar b/dormant/atom4j/lib/commons-lang-1_0.jar deleted file mode 100644 index 43e515c3..00000000 Binary files a/dormant/atom4j/lib/commons-lang-1_0.jar and /dev/null differ diff --git a/dormant/atom4j/lib/commons-logging.jar b/dormant/atom4j/lib/commons-logging.jar deleted file mode 100644 index b99c9375..00000000 Binary files a/dormant/atom4j/lib/commons-logging.jar and /dev/null differ diff --git a/dormant/atom4j/lib/junit-3.8.1.jar b/dormant/atom4j/lib/junit-3.8.1.jar deleted file mode 100644 index 674d71e8..00000000 Binary files a/dormant/atom4j/lib/junit-3.8.1.jar and /dev/null differ diff --git a/dormant/atom4j/lib/log4j-1.2.7.jar b/dormant/atom4j/lib/log4j-1.2.7.jar deleted file mode 100644 index 1595a56e..00000000 Binary files a/dormant/atom4j/lib/log4j-1.2.7.jar and /dev/null differ diff --git a/dormant/atom4j/lib/servlet-2.3.jar b/dormant/atom4j/lib/servlet-2.3.jar deleted file mode 100644 index d368d0f6..00000000 Binary files a/dormant/atom4j/lib/servlet-2.3.jar and /dev/null differ diff --git a/dormant/atom4j/log4j.properties b/dormant/atom4j/log4j.properties deleted file mode 100644 index de88a28b..00000000 --- a/dormant/atom4j/log4j.properties +++ /dev/null @@ -1,22 +0,0 @@ -# console appender -log4j.rootCategory=ERROR, console, file -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} | %m%n - -# file appender -log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.File=Atom4J.log -log4j.appender.file.MaxFileSize=1000KB -log4j.appender.file.MaxBackupIndex=1 -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} | %m%n - -# If programmed properly the most messages would be at DEBUG -# and the least at FATAL. - -# Options are: DEBUG, INFO, WARN, ERROR, FATAL -log4j.category.org.apache.commons.beanutils=ERROR -log4j.category.org.apache.commons.digester=ERROR -log4j.category.org.osjava.atom4j=ERROR - diff --git a/dormant/atom4j/news.html b/dormant/atom4j/news.html deleted file mode 100644 index e6c0c2a5..00000000 --- a/dormant/atom4j/news.html +++ /dev/null @@ -1,120 +0,0 @@ - - - OSJava.org : Atom4J - - - - - - - - - -
- -
- -
- -

- Atom4J -

- -
2004-03-02 - v0.2 released
- -

The second release of Atom4J is finally ready. This version supports the 0.3 - Syndication format - and the 0.9 API specification, - both as of December 2003. - For more information, read the previous release notes.

- -

Atom4J jars, with and without sourcecode, can be found in the - releases directory. - Please report errors or lapses in the - JIRA - account for Atom4J.

- -

-Lance Lavandowska

- -
2003-09-01 - v0.1 released
- -

Atom4J serves as a library to assist in reading and generating Atom API specified XML. - Atom4J includes an abstract Servlet for assisting in the implementation of a Servlet which - supports the Atom API. Such a servlet will soon be included in Roller (http://www.rollerweblogger.org) - if you would like to see an example.

- -

Atom4J does in no way include any security restrictions, beyond an abstract authorized() method. - The Atom API currently suggests using Digest authentication. Again, this is not included in Atom4J.

- -

Future development may include the reading and writing of Atom feeds as outlined in the - Atom 0.2 Snapshot.

- -

To compile and use the library, you will need the following:
- commons-digester.jar and its associated jars:
-     commons-beanutils.jar
-     commons-collections.jar
-     commons-logging.jar
- commons-lang.jar
- servlet-2.3.jar

- -

To compile and run the tests, you will need to add junit-3.8.1.jar or later.

- -

This version of Atom4J (v0.1) supports the AtomAPI as of 09/01/2003, currently at version 0.7. - For more information refer to the following urls:
- The Atom wiki
- Busy developers guide
- The AtomAPI RFC
- The RFC wiki

- -

Atom4J jars, with and without sourcecode, can be found in the - releases directory. - Please report errors or lapses in the - JIRA - account for Atom4J.

- -

-Lance Lavandowska

-
-
-
- - - diff --git a/dormant/atom4j/project.xml b/dormant/atom4j/project.xml deleted file mode 100644 index 16b09752..00000000 --- a/dormant/atom4j/project.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - 3 - - atom4j - atom4j - - 0.1 - - - OSJava - http://www.osjava.org - http://www.osjava.org/images/osjava.gif - - 2003 - - org.osjava.atom4j - - http://www.osjava.org/images/1x1.gif - - - - - - - http://www.osjava.org/atom4j/ - - - - - - osjava-users - http://lists.flamefew.net/mailman/listinfo/osjava-users - http://lists.flamefew.net/mailman/listinfo/osjava-users - http://lists.flamefew.net/mailman/private/osjava-users/ - - - - - - - servletapi - servletapi - 2.3 - - - commons-beanutils - 1.6 - - - commons-codec - 1.1 - - - commons-collections - 2.1 - - - commons-digester - 1.5 - - - commons-lang - 1.0 - - - commons-logging - 1.0.3 - - - log4j - 1.2.7 - - - - - - src - - tests - - - - **/*Test.java - - - - - - - maven-jxr-plugin - maven-javadoc-plugin - maven-license-plugin - maven-changes-plugin - - - diff --git a/dormant/atom4j/src/org/osjava/atom4j/Atom4J.java b/dormant/atom4j/src/org/osjava/atom4j/Atom4J.java deleted file mode 100644 index ff168333..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/Atom4J.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j; - -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * http://atomenabled.org - * http://www.imc.org/atom-syntax/index.html - * http://www.intertwingly.net/wiki/pie/FrontPage - * - * Created on Aug 29, 2003 - * - * @author llavandowska - */ -public abstract class Atom4J -{ - public static String xmlns = "http://purl.org/atom/ns#"; - - // doesn't work with the Z on the end - public static SimpleDateFormat READ_ISO8601_FORMAT = - new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); - - public static SimpleDateFormat WRITE_ISO8601_FORMAT = - new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - - public static String formatIso8601(Date date) - { - if (date == null) return ""; - - return WRITE_ISO8601_FORMAT.format(date); - } - - public static String simpleTag(Object value, String tagName) - { - if (value == null) value = ""; - return "<" + tagName + ">" + value.toString() + "\n"; - } - - public static String dateTag(Date date, String tagName) - { - return "<" + tagName + ">" + Atom4J.formatIso8601(date) + "\n"; - } -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/digester/ContentParser.java b/dormant/atom4j/src/org/osjava/atom4j/digester/ContentParser.java deleted file mode 100644 index 4f1046ad..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/digester/ContentParser.java +++ /dev/null @@ -1,112 +0,0 @@ - -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.digester; - -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.DefaultHandler; - -/** - * Grabs all the contents from the beginning of the Rule to the - * position of the closingTag. This class can be reused by - * specifying the closingTag in the constructor (default - * is "</content>". - * - * Created on Aug 28, 2003 - * @author lance - */ -public class ContentParser extends DefaultHandler -{ - ContentHandler oldHandler; - XMLReader xmlReader; - String closingTag = ""; - String value = ""; - String contentType; - - /** - * @param oldHandler - * @param reader - */ - public ContentParser(ContentHandler handler, XMLReader reader, String endTag) - { - oldHandler = handler; - xmlReader = reader; - if (endTag != null) closingTag = endTag; - } - - public String getValue() - { - return value; - } - - /** - * Must account for multipart/alternative Content, - * that is, multiple Content nodes nested inside - * another Content node. - */ - public void characters(char[] ch, int start, int length) throws SAXException - { - String full = String.valueOf(ch); - - // if it is multipart it should contain more Content, - // and thus we have to look for the last in - // this entry. - if (contentType != null && contentType.equals("multipart/alternative")) - { - // find the first nested Content - int nextContent = full.indexOf(" 0 && nextContent < lastIndex) - { - // we found the next tag, get content up to that point - lastIndex = nextContent; - } - - try - { - value = full.substring(start, lastIndex); - } - catch (IndexOutOfBoundsException e) - { - // there was no lastIndex found - bad - } - } - // it isn't multipart, so find next occurence of closingTag. - else - { - int endContent = full.indexOf(closingTag, start); - if (endContent > 0) - value += full.substring(start, endContent); - } - - xmlReader.setContentHandler(oldHandler); - } - - /* - * We need to capture the value of the attribute 'type'. - */ - public void getContentType(Attributes attributes) - throws SAXException - { - contentType = attributes.getValue("type"); - } - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/digester/ContentRule.java b/dormant/atom4j/src/org/osjava/atom4j/digester/ContentRule.java deleted file mode 100644 index 79792f8b..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/digester/ContentRule.java +++ /dev/null @@ -1,64 +0,0 @@ - -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.digester; - -import org.apache.commons.digester.Rule; -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; - -import org.osjava.atom4j.pojo.Content; - -/** - * Created on Aug 28, 2003 - * @author lance - */ -public class ContentRule extends Rule -{ - ContentParser saxValueParser; - private String closingTag = null; - - public ContentRule() {} - - public void begin(String namespace, String name, Attributes attributes) - throws java.lang.Exception - { - closingTag = ""; - - // Set up a new content handler to work in these situations.. - // The content handler will be responsible for setting back the current - // content handler so we can resume the normally scheduled program - ContentHandler oldHandler = - getDigester().getXMLReader().getContentHandler(); - saxValueParser = - new ContentParser(oldHandler, getDigester().getXMLReader(), closingTag); - this.getDigester().getXMLReader().setContentHandler(saxValueParser); - - // get the value of 'type' if present - saxValueParser.getContentType(attributes); - - super.begin(namespace, name, attributes); - } - - public void end(String namespace, String name) throws java.lang.Exception - { - Content content = (Content) digester.peek(); - - content.setText( saxValueParser.getValue()); - } - - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/digester/ContentRuleSet.java b/dormant/atom4j/src/org/osjava/atom4j/digester/ContentRuleSet.java deleted file mode 100644 index 74c45ba8..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/digester/ContentRuleSet.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.digester; - -import org.apache.commons.digester.Digester; -import org.apache.commons.digester.RuleSet; -import org.apache.commons.digester.xmlrules.DigesterRulesSource; -import org.osjava.atom4j.pojo.Content; - -/** - * This class can be used to generate a RuleSet either programatically - * or through the FromXmlRuleSet parser. - * Created on Apr 8, 2004 - * @author lance.lavandowska - */ -public class ContentRuleSet implements RuleSet, DigesterRulesSource -{ - protected static String[] overriddenContentAttributeNames = {"type", "xml:lang"}; - protected static String[] overriddenContentPropertyNames = {"mimeType", "language"}; - - protected String path = ""; - protected String namespaceURI; - protected String setMethod; - - public ContentRuleSet(String path, String setMethod) - { - super(); - this.path = path; - this.setMethod = setMethod; - } - - public ContentRuleSet(String path, String setMethod, String namespace) - { - super(); - this.path = path; - this.setMethod = setMethod; - this.namespaceURI = namespace; - } - - /* - * @see org.apache.commons.digester.RuleSet#addRuleInstances(org.apache.commons.digester.Digester) - */ - public void addRuleInstances(Digester digester) - { - digester.addObjectCreate( path, Content.class.getName()); - digester.addSetProperties(path, - overriddenContentAttributeNames, - overriddenContentPropertyNames); - digester.addRule(path, new ContentRule()); - digester.addSetNext(path, setMethod, Content.class.getName()); - } - - /* - * @see org.apache.commons.digester.xmlrules.DigesterRulesSource#getRules(org.apache.commons.digester.Digester) - */ - public void getRules(Digester digester) - { - addRuleInstances(digester); - } - - /* - * @see org.apache.commons.digester.RuleSet#getNamespaceURI() - */ - public String getNamespaceURI() - { - return namespaceURI; - } -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/digester/GeneratorRuleSet.java b/dormant/atom4j/src/org/osjava/atom4j/digester/GeneratorRuleSet.java deleted file mode 100644 index 1c426bbd..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/digester/GeneratorRuleSet.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.digester; - -import org.apache.commons.digester.Digester; -import org.apache.commons.digester.RuleSet; -import org.apache.commons.digester.xmlrules.DigesterRulesSource; -import org.osjava.atom4j.pojo.Generator; - -/** - * This class can be used to generate a RuleSet either programatically - * or through the FromXmlRuleSet parser. - * Created on Apr 8, 2004 - * @author lance.lavandowska - */ -public class GeneratorRuleSet implements RuleSet, DigesterRulesSource -{ - private String path = ""; - private String namespaceURI; - - public GeneratorRuleSet(String path) - { - super(); - this.path = path; - } - - public GeneratorRuleSet(String path, String namespace) - { - super(); - this.path = path; - this.namespaceURI = namespace; - } - - /* - * @see org.apache.commons.digester.RuleSet#addRuleInstances(org.apache.commons.digester.Digester) - */ - public void addRuleInstances(Digester digester) - { - digester.addObjectCreate( path, Generator.class.getName()); - digester.addSetProperties(path); - digester.addCallMethod(path, "setText", 0); - digester.addSetNext(path, "setGenerator", Generator.class.getName()); - } - - /* - * @see org.apache.commons.digester.xmlrules.DigesterRulesSource#getRules(org.apache.commons.digester.Digester) - */ - public void getRules(Digester digester) - { - addRuleInstances(digester); - } - - /* - * @see org.apache.commons.digester.RuleSet#getNamespaceURI() - */ - public String getNamespaceURI() - { - return namespaceURI; - } - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/digester/LinkRuleSet.java b/dormant/atom4j/src/org/osjava/atom4j/digester/LinkRuleSet.java deleted file mode 100644 index 1728166a..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/digester/LinkRuleSet.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.osjava.atom4j.digester; - -import org.apache.commons.digester.Digester; -import org.apache.commons.digester.RuleSet; -import org.apache.commons.digester.xmlrules.DigesterRulesSource; -import org.osjava.atom4j.pojo.Link; - -/** - * Created on Apr 8, 2004 - * @author lance.lavandowska - */ -public class LinkRuleSet implements RuleSet, DigesterRulesSource -{ - private String path = ""; - private String namespaceURI; - - public LinkRuleSet(String path) { - super(); - this.path = path; - } - - public LinkRuleSet(String path, String namespace) { - super(); - this.path = path; - this.namespaceURI = namespace; - } - - /* - * @see org.apache.commons.digester.RuleSet#addRuleInstances(org.apache.commons.digester.Digester) - */ - public void addRuleInstances(Digester digester) - { - digester.addObjectCreate( path, Link.class.getName()); - digester.addSetProperties(path); - digester.addSetNext(path, "addLink", Link.class.getName()); - } - - /* - * @see org.apache.commons.digester.xmlrules.DigesterRulesSource#getRules(org.apache.commons.digester.Digester) - */ - public void getRules(Digester digester) - { - addRuleInstances(digester); - } - - /* - * @see org.apache.commons.digester.RuleSet#getNamespaceURI() - */ - public String getNamespaceURI() - { - return namespaceURI; - } -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/digester/PersonRuleSet.java b/dormant/atom4j/src/org/osjava/atom4j/digester/PersonRuleSet.java deleted file mode 100644 index 1dccc72c..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/digester/PersonRuleSet.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.digester; - -import org.apache.commons.digester.Digester; -import org.apache.commons.digester.RuleSet; -import org.apache.commons.digester.xmlrules.DigesterRulesSource; -import org.osjava.atom4j.pojo.Person; - -/** - * This class can be used to generate a RuleSet either programatically - * or through the FromXmlRuleSet parser. - * Created on Apr 8, 2004 - * @author lance.lavandowska - */ -public class PersonRuleSet implements RuleSet, DigesterRulesSource -{ - private String path = ""; - private String namespaceURI; - private String setMethod; - - public PersonRuleSet(String path, String setMethod) - { - super(); - this.path = path; - this.setMethod = setMethod; - } - - public PersonRuleSet(String path, String setMethod, String namespace) - { - super(); - this.path = path; - this.setMethod = setMethod; - this.namespaceURI = namespace; - } - - /* - * @see org.apache.commons.digester.RuleSet#addRuleInstances(org.apache.commons.digester.Digester) - */ - public void addRuleInstances(Digester digester) - { - digester.addObjectCreate(path, Person.class.getName()); - digester.addCallMethod(path + "/name", "setName", 0); - digester.addCallMethod(path + "/url", "setUrl", 0); - digester.addCallMethod(path + "/email","setEmail", 0); - digester.addSetNext(path, setMethod, Person.class.getName()); - } - - /* - * @see org.apache.commons.digester.xmlrules.DigesterRulesSource#getRules(org.apache.commons.digester.Digester) - */ - public void getRules(Digester digester) - { - addRuleInstances(digester); - } - - /* - * @see org.apache.commons.digester.RuleSet#getNamespaceURI() - */ - public String getNamespaceURI() - { - return namespaceURI; - } -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/pojo/Author.java b/dormant/atom4j/src/org/osjava/atom4j/pojo/Author.java deleted file mode 100644 index de39f098..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/pojo/Author.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.pojo; - -/** - * Created on Aug 22, 2003 - * @author llavandowska - */ -public class Author -{ - private String name; - private String url = null; - private String email = null; - /** - * @return - */ - public String getUrl() - { - return url; - } - - /** - * @return - */ - public String getName() - { - return name; - } - - /** - * @return - */ - public String getEmail() - { - return email; - } - - /** - * @param string - */ - public void setUrl(String string) - { - url= string; - } - - /** - * @param string - */ - public void setName(String string) - { - name= string; - } - - /** - * @param string - */ - public void setEmail(String string) - { - email= string; - } - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/pojo/Content.java b/dormant/atom4j/src/org/osjava/atom4j/pojo/Content.java deleted file mode 100644 index 9d8fbfc1..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/pojo/Content.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.pojo; - -import java.util.ArrayList; -import java.util.Collection; - -/** - * Created on Aug 22, 2003 - * @author llavandowska - */ -public class Content -{ - public static final String XML = "xml"; - public static final String BASE64 = "base64"; - public static final String ESCAPED = "escaped"; - public static final String MULTIPART = "multipart/alternative"; - - private String mimeType = "text/plain"; - private String language = "en-us"; - private String text; - private String mode = "xml"; - private Collection multipart; - - /** - * @return - */ - public String getLanguage() - { - return language; - } - - /** - * @return - */ - public String getMimeType() - { - return mimeType; - } - - /** - * @return - */ - public String getText() - { - return text; - } - - /** - * @param string - */ - public void setLanguage(String string) - { - language= string; - } - - /** - * @param string - */ - public void setMimeType(String string) - { - mimeType= string; - } - - /** - * @param string - */ - public void setText(String string) - { - text= string; - } - - /** - * @return Returns the mode. - */ - public String getMode() - { - return this.mode; - } - - /** - * @param mode The mode to set. - */ - public void setMode(String mode) - { - this.mode = mode; - } - - public void addContent(Content content) - { - if (multipart == null) multipart = new ArrayList(); - multipart.add(content); - } - - /** - * @return - */ - public Collection getMultipart() - { - return multipart; - } - - /** - * @param collection - */ - public void setMultipart(Collection collection) - { - multipart = collection; - } - - /** - * Since Content can represent several elements of an Atom - * feed, it is necessary to abstract the generation of the - * tag. The actual tag name is taken as an argument. - * - * @param string tag - the label of the tag to generate - */ - public String toString(String tag) - { - StringBuffer buf = new StringBuffer("<").append(tag); - if (mimeType != null) buf.append(" type=\"").append(mimeType).append("\""); - if (language != null) buf.append(" xml:lang=\"").append(language).append("\""); - if (mode != null) buf.append(" mode=\"").append(mode).append("\""); - buf.append(">"); - if (multipart != null) - { - if (text != null) buf.append(text); - java.util.Iterator it = multipart.iterator(); - while (it.hasNext()) - { - Content _content = (Content)it.next(); - buf.append(_content.toString("content")); - } - } - else if (text != null) - { - buf.append(text); - } - buf.append("\n"); - return buf.toString(); - } - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/pojo/Entry.java b/dormant/atom4j/src/org/osjava/atom4j/pojo/Entry.java deleted file mode 100644 index ddec9772..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/pojo/Entry.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.pojo; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osjava.atom4j.Atom4J; - -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; - -/** - * Created on Aug 22, 2003 - * @author llavandowska - */ -public class Entry -{ - private String id; - private Content title; - private Content summary; - private Content content; - private Person author = new Person(); - private Collection contributors; - private Collection links; - // Link for editing GET/PUT/DELETE - service.edit - // Link for POSTing a Comment - service.post - // Links for GETting next/prev/start entries - - private Date issued; - private Date created; - private Date modified; - - private static Log logger = - LogFactory.getFactory().getInstance(Entry.class); - - public void setIssued(String str) - { - try - { - issued = Atom4J.READ_ISO8601_FORMAT.parse(str); - } - catch (ParseException e) - { - logger.warn( e ); - } - } - - public void setCreated(String str) - { - try - { - created = Atom4J.READ_ISO8601_FORMAT.parse(str); - } - catch (ParseException e) - { - logger.warn( e ); - } - } - - public void setModified(String str) - { - try - { - modified = Atom4J.READ_ISO8601_FORMAT.parse(str); - } - catch (ParseException e) - { - logger.warn( e ); - } - } - - /** - * @return - */ - public Person getAuthor() - { - return author; - } - - /** - * @return - */ - public Content getContent() - { - return content; - } - - /** - * @return - */ - public Date getCreated() - { - return created; - } - - /** - * @return - */ - public String getId() - { - return id; - } - - /** - * @return - */ - public Date getIssued() - { - return issued; - } - - /** - * @return - */ - public Date getModified() - { - return modified; - } - - /** - * @return - */ - public Content getSummary() - { - return summary; - } - - /** - * @return - */ - public Content getTitle() - { - return title; - } - - /** - * @param author - */ - public void setAuthor(Person author) - { - this.author= author; - } - - /** - * @param content - */ - public void setContent(Content content) - { - this.content= content; - } - - /** - * @param date - */ - public void setCreated(Date date) - { - created= date; - } - - /** - * @param string - */ - public void setId(String string) - { - id= string; - } - - /** - * @param date - */ - public void setIssued(Date date) - { - issued= date; - } - - /** - * @param date - */ - public void setModified(Date date) - { - modified= date; - } - - /** - * @param string - */ - public void setSummary(Content content) - { - summary= content; - } - - /** - * @param string - */ - public void setTitle(Content content) - { - title= content; - } - - public static String noNull(String str) - { - if (str == null) return ""; - return str; - } - - public Collection getContributors() - { - return contributors; - } - - public void setContributors(Collection persons) - { - contributors = persons; - } - - public void addContributor(Person person) - { - if (contributors == null) contributors = new ArrayList(); - contributors.add(person); - } - - public void addLink(Link link) - { - if (links == null) links = new ArrayList(); - links.add(link); - } - - public Collection getLinks() - { - return links; - } - - public void setLinks(Collection _links) - { - links = _links; - } - - /** - * Pretty output. - */ - public String toString() - { - StringBuffer buf = new StringBuffer("\n"); - - if (id != null) buf.append(" ").append(Atom4J.simpleTag(id, "id")); - if (title != null) buf.append(" ").append(title.toString("title")); - if (summary != null) buf.append(" ").append(summary.toString("summary")); - - // generate Author and Contributor tags - if (author != null) - { - buf.append(" ").append(author.toString("author")); - } - if (contributors != null) - { - java.util.Iterator it = contributors.iterator(); - while (it.hasNext()) - { - Person _person = (Person)it.next(); - buf.append(" ").append(_person.toString("contributor")); - } - } - - if (links != null) - { - java.util.Iterator it = links.iterator(); - while (it.hasNext()) - { - Link _link = (Link)it.next(); - buf.append(" ").append(_link.toString()); - } - } - - // generate date tags - if (issued != null) - buf.append(" ").append(Atom4J.dateTag(issued, "issued")); - if (created != null) - buf.append(" ").append(Atom4J.dateTag(created, "created")); - if (modified != null) - buf.append(" ").append(Atom4J.dateTag(modified, "modified")); - - // generate Content - buf.append(" ").append(content.toString("content")); - - // close entry - buf.append("\n"); - - return buf.toString(); - } -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/pojo/Feed.java b/dormant/atom4j/src/org/osjava/atom4j/pojo/Feed.java deleted file mode 100644 index 160f4550..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/pojo/Feed.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.pojo; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osjava.atom4j.Atom4J; - -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; - -/** - * Created on Feb 14, 2004 - * @author Lance - */ -public class Feed -{ - private String id; - private Collection entries; - private String version; - private String lang; - private Content title; - private Person author; - private Collection contributors; - private Content tagline; - private Generator generator; - private Content copyright; - private Content info; - private Date modified; - private Collection links; - // Link for POSTing new Entry - service.post - // Link for GETting list of services & feed link - service.feed - // Link to HTML page - alternate - // Link for the XML feed, can contain next/prev/start links - feed - - private static Log logger = - LogFactory.getFactory().getInstance(Feed.class); - - public void addEntry(Entry entry) - { - if (entries == null) entries = new ArrayList(); - entries.add(entry); - } - - public Collection getEntries() - { - return entries; - } - - public void setEntries(Collection collection) - { - entries = collection; - } - - public void addContributor(Person person) - { - if (contributors == null) contributors = new ArrayList(); - contributors.add(person); - } - - public Collection getContributors() - { - return contributors; - } - - public void setContributors(Collection persons) - { - contributors = persons; - } - - public void addLink(Link link) - { - if (links == null) links = new ArrayList(); - links.add(link); - } - - public Collection getLinks() - { - return links; - } - - public void setLinks(Collection _links) - { - links = _links; - } - - public Person getAuthor() - { - return author; - } - - public Content getCopyright() - { - return copyright; - } - - public Generator getGenerator() - { - return generator; - } - - public String getId() - { - return id; - } - - public Content getInfo() - { - return info; - } - - public String getLang() - { - return lang; - } - - public Date getModified() - { - return modified; - } - - public Content getTagline() - { - return tagline; - } - - public Content getTitle() - { - return title; - } - - public String getVersion() - { - return version; - } - - public void setAuthor(Person person) - { - author = person; - } - - public void setCopyright(Content content) - { - copyright = content; - } - - public void setGenerator(Generator generator) - { - this.generator = generator; - } - - public void setId(String string) - { - id = string; - } - - public void setInfo(Content content) - { - info = content; - } - - public void setLang(String string) - { - lang = string; - } - - public void setModified(Date date) - { - modified = date; - } - - public void setTagline(Content content) - { - tagline = content; - } - - public void setTitle(Content content) - { - title = content; - } - - public void setVersion(String string) - { - version = string; - } - - /* - * Set modified with a String. - */ - public void setModified(String str) - { - try - { - modified = Atom4J.READ_ISO8601_FORMAT.parse(str); - } - catch (ParseException e) - { - logger.warn( e ); - } - } - - public String toString() - { - StringBuffer buf = new StringBuffer("\n"); - - if (id != null) buf.append(" ").append(Atom4J.simpleTag(id, "id")); - if (title != null) buf.append(" ").append(title.toString("title")); - if (tagline != null) buf.append(" ").append(tagline.toString("tagline")); - if (info != null) buf.append(" ").append(info.toString("info")); - if (copyright != null) buf.append(" ").append(copyright.toString("copyright")); - if (generator != null) buf.append(" ").append(generator.toString()); - if (modified != null) - buf.append(" ").append(Atom4J.dateTag(modified, "modified")); - - // generate Author and Contributor tags - if (author != null) - { - buf.append(" ").append(author.toString("author")); - } - if (contributors != null) - { - java.util.Iterator it = contributors.iterator(); - while (it.hasNext()) - { - Person _person = (Person)it.next(); - buf.append(" ").append(_person.toString("contributor")); - } - } - - if (links != null) - { - java.util.Iterator it = links.iterator(); - while (it.hasNext()) - { - Link _link = (Link)it.next(); - buf.append(" ").append(_link.toString()); - } - } - - // generate Entries - if (entries != null) - { - java.util.Iterator it = entries.iterator(); - while (it.hasNext()) - { - Entry _entry = (Entry)it.next(); - buf.append(" ").append(_entry.toString()); - } - } - - buf.append(""); - return buf.toString(); - } -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/pojo/Generator.java b/dormant/atom4j/src/org/osjava/atom4j/pojo/Generator.java deleted file mode 100644 index 8cd0cba0..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/pojo/Generator.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.pojo; - -/** - * Created on Feb 14, 2004 - * @author Lance - */ -public class Generator -{ - private String text; - private String url; - private String version; - - public String getText() - { - return text; - } - - public String getUrl() - { - return url; - } - - public String getVersion() - { - return version; - } - - public void setText(String string) - { - text = string; - } - - public void setUrl(String string) - { - url = string; - } - - public void setVersion(String string) - { - version = string; - } - - public String toString() - { - StringBuffer buf = new StringBuffer(""); - if (text != null) buf.append(text); - buf.append("\n"); - return buf.toString(); - } -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/pojo/Introspection.java b/dormant/atom4j/src/org/osjava/atom4j/pojo/Introspection.java deleted file mode 100644 index bb07905a..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/pojo/Introspection.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.pojo; - -import org.osjava.atom4j.Atom4J; - -/** - * @deprecated - * - * Created on Aug 29, 2003 - * @author llavandowska - */ -public class Introspection -{ - private String baseURL = ""; - private boolean createEntry; - private boolean deleteEntry; - private boolean editEntry; - private boolean searchEntries; - private boolean comment; - private boolean userPrefs; - private boolean editTemplate; - private boolean categories; - - public String toString() - { - StringBuffer buf = new StringBuffer(" "); - if (createEntry) - buf.append(" " + baseURL + "/atom/USER/entry/"); - if (deleteEntry) - buf.append(" " + baseURL + "/atom/USER/entry/id"); - if (editEntry) - buf.append(" " + baseURL + "/atom/USER/entry/id"); - if (userPrefs) - buf.append(" " + baseURL + "/atom/USER/prefs"); - if (searchEntries) - buf.append(" " + baseURL + "/atom/USER/search"); - if (editTemplate) - buf.append(" " + baseURL + "/atom/USER/findTemplates"); - if (categories) - buf.append(" " + baseURL + "/atom/USER/categories"); - if (comment) - buf.append(" " + baseURL + "/atom/USER/comment/id"); - buf.append(""); - return buf.toString(); - } - - /** - * @return - */ - public boolean allowsCategories() - { - return categories; - } - - /** - * @return - */ - public boolean allowsCreateEntry() - { - return createEntry; - } - - /** - * @return - */ - public boolean allowsDeleteEntry() - { - return deleteEntry; - } - - /** - * @return - */ - public boolean allowsEditEntry() - { - return editEntry; - } - - /** - * @return - */ - public boolean allowsEditTemplate() - { - return editTemplate; - } - - /** - * @return - */ - public boolean allowsSearchEntries() - { - return searchEntries; - } - - /** - * @return - */ - public boolean allowsUserPrefs() - { - return userPrefs; - } - - /** - * @param b - */ - public void setCategories(boolean b) - { - categories= b; - } - - /** - * @param b - */ - public void setCreateEntry(boolean b) - { - createEntry= b; - } - - /** - * @param b - */ - public void setDeleteEntry(boolean b) - { - deleteEntry= b; - } - - /** - * @param b - */ - public void setEditEntry(boolean b) - { - editEntry= b; - } - - /** - * @param b - */ - public void setEditTemplate(boolean b) - { - editTemplate= b; - } - - /** - * @param b - */ - public void setSearchEntries(boolean b) - { - searchEntries= b; - } - - /** - * @param b - */ - public void setUserPrefs(boolean b) - { - userPrefs= b; - } - - /** - * @return - */ - public String getBaseURL() - { - return baseURL; - } - - /** - * @param string - */ - public void setBaseURL(String string) - { - baseURL= string; - } - - /** - * @return - */ - public boolean allowsComment() - { - return comment; - } - - /** - * @param b - */ - public void setComment(boolean b) - { - comment= b; - } - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/pojo/Link.java b/dormant/atom4j/src/org/osjava/atom4j/pojo/Link.java deleted file mode 100644 index e36e4f76..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/pojo/Link.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.pojo; - -/** - * Created on Feb 14, 2004 - * @author Lance - */ -public class Link -{ - public static final String ALTERNATE = "alternate"; // link to HTML format (or other) - public static final String FEED = "feed"; // link to Atom Syndication Format - public static final String START = "start"; - public static final String NEXT = "next"; - public static final String PREV = "prev"; - public static final String SERVICE_POST = "service.post"; - public static final String SERVICE_EDIT = "service.edit"; - public static final String SERVICE_FEED = "service.feed"; // list other service.x links - - private String href; - private String rel; - private String title; - private String type = "application/x.atom+xml"; - - public String getHref() - { - return href; - } - - public String getRel() - { - return rel; - } - - public String getTitle() - { - return title; - } - - public String getType() - { - return type; - } - - public void setHref(String string) - { - href = string; - } - - public void setRel(String string) - { - rel = string; - } - - public void setTitle(String string) - { - title = string; - } - - public void setType(String string) - { - type = string; - } - - public String toString() - { - StringBuffer buf = new StringBuffer("\n"); - return buf.toString(); - } -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/pojo/Person.java b/dormant/atom4j/src/org/osjava/atom4j/pojo/Person.java deleted file mode 100644 index 7bb1fe0d..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/pojo/Person.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.pojo; - -import org.osjava.atom4j.Atom4J; - -/** - * Created on Aug 22, 2003 - * @author llavandowska - */ -public class Person -{ - private String name; - private String url = null; - private String email = null; - /** - * @return - */ - public String getUrl() - { - return url; - } - - /** - * @return - */ - public String getName() - { - return name; - } - - /** - * @return - */ - public String getEmail() - { - return email; - } - - /** - * @param string - */ - public void setUrl(String string) - { - url= string; - } - - /** - * @param string - */ - public void setName(String string) - { - name= string; - } - - /** - * @param string - */ - public void setEmail(String string) - { - email= string; - } - - /** - * @param string tag could be "author" or "contributor" - * @return - */ - public String toString(String tag) - { - StringBuffer buf = new StringBuffer("<").append(tag).append(">\n"); - if (name != null) buf.append(" ").append(Atom4J.simpleTag(name, "name")); - if (email != null) buf.append(" ").append(Atom4J.simpleTag(email, "email")); - if (url != null) buf.append(" ").append(Atom4J.simpleTag(url, "url")); - buf.append("\n"); - return buf.toString(); - } - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/pojo/Template.java b/dormant/atom4j/src/org/osjava/atom4j/pojo/Template.java deleted file mode 100644 index 7f422f89..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/pojo/Template.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.pojo; - -/** - * Created on Aug 29, 2003 - * @author llavandowska - */ -public class Template -{ - private String baseURL = ""; - - /** - * The title of the template is for readability - * purposes only. - */ - private String title; - - /** - * Uniquely identifies this Template for your application. - * This will be used to return the contents of the template. - */ - private String id; - - public String toString() - { - StringBuffer buf = new StringBuffer(""); - buf.append(" " + title + ""); - buf.append(" " + baseURL + "/atom/USER/template/" + id + ""); - buf.append(""); - return buf.toString(); - } - - /** - * @return - */ - public String getBaseURL() - { - return baseURL; - } - - /** - * @return - */ - public String getId() - { - return id; - } - - /** - * @return - */ - public String getTitle() - { - return title; - } - - /** - * @param string - */ - public void setBaseURL(String string) - { - baseURL= string; - } - - /** - * @param string - */ - public void setId(String string) - { - id= string; - } - - /** - * @param string - */ - public void setTitle(String string) - { - title= string; - } - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/pojo/UserPreferences.java b/dormant/atom4j/src/org/osjava/atom4j/pojo/UserPreferences.java deleted file mode 100644 index 8978b19a..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/pojo/UserPreferences.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.pojo; - -import org.osjava.atom4j.Atom4J; - -/** - * @deprecated - * - * Created on Aug 23, 2003 - * @author llavandowska - */ -public class UserPreferences -{ - private String name; - private String id; - private String email; - - public String toString() - { - StringBuffer buf = new StringBuffer("\n"); - buf.append(" Reilly\n"); - buf.append(" 1234\n"); - buf.append(" reilly@example.org\n"); - buf.append("\n"); - return buf.toString(); - } - - /** - * @return - */ - public String getEmail() - { - return email; - } - - /** - * @return - */ - public String getId() - { - return id; - } - - /** - * @return - */ - public String getName() - { - return name; - } - - /** - * @param string - */ - public void setEmail(String string) - { - email= string; - } - - /** - * @param string - */ - public void setId(String string) - { - id= string; - } - - /** - * @param string - */ - public void setName(String string) - { - name= string; - } - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/reader/AtomReader.java b/dormant/atom4j/src/org/osjava/atom4j/reader/AtomReader.java deleted file mode 100644 index 87b62711..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/reader/AtomReader.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.reader; - -import org.apache.commons.digester.Digester; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osjava.atom4j.digester.ContentRuleSet; -import org.osjava.atom4j.digester.LinkRuleSet; -import org.osjava.atom4j.digester.PersonRuleSet; -import org.osjava.atom4j.pojo.Entry; -import org.xml.sax.SAXException; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * Created on Aug 23, 2003 - * @author llavandowska - */ -public abstract class AtomReader -{ - protected Digester digester = null; - protected InputStream input = null; - - protected static Log logger = - LogFactory.getFactory().getInstance(AtomReader.class); - - /** - * Instantiate AtomReader from a String containing XML. - * - * @param xml - */ - public AtomReader(String xml) - { - input = new ByteArrayInputStream(xml.getBytes()); - initDigester(); - } - - /** - * Instantiate AtomReader from an InputStream. - * - * @param xml - */ - public AtomReader(InputStream in) - { - input = in; - initDigester(); - } - - /* - * Set XML to be parsed. - */ - public void setXML(String xml) - { - input = new ByteArrayInputStream(xml.getBytes()); - if (digester == null) initDigester(); - } - - /* - * Set InputStream to be parsed. - */ - public void setInputStream(InputStream in) - { - input = in; - if (digester == null) initDigester(); - } - - protected abstract void initDigester(); - - /** - * Parse the InputStream according the rules set up in initDigester(). - * - * @param input - */ - protected void parse() - { - try - { - digester.parse(input); - } - catch (NullPointerException e) - { - if (digester == null) - logger.error("Digester was null", e); - if (input == null) - logger.error("input was null", e); - } - catch (IOException e) - { - // huh? Why is this happening? - logger.info(e); - } - catch (SAXException e) - { - logger.error(e); - } - } - - /** - * Configure digester to parse Entries, based on the parent path. - * - * @param digester - * @param parent - */ - protected void configureEntryDigester(Digester digester, String parent ) - { - String entryPath = parent + "entry"; - digester.addObjectCreate(entryPath, Entry.class.getName()); - - digester.addRuleSet(new ContentRuleSet(entryPath + "/title", "setTitle")); - - digester.addCallMethod(entryPath + "/issued", "setIssued", 0); - digester.addCallMethod(entryPath + "/created", "setCreated", 0); - digester.addCallMethod(entryPath + "/modified", "setModified", 0); - - digester.addBeanPropertySetter(entryPath + "/id"); - - digester.addRuleSet(new LinkRuleSet(entryPath + "/link")); - - digester.addRuleSet(new PersonRuleSet(entryPath + "/author", "setAuthor")); - - digester.addRuleSet(new PersonRuleSet(entryPath + "/contributor", "addContributor")); - - digester.addRuleSet(new ContentRuleSet(entryPath + "/content", "setContent")); - digester.addRuleSet(new ContentRuleSet(entryPath + "/content/content", "addContent")); - - digester.addRuleSet(new ContentRuleSet(entryPath + "/summary", "setSummary")); - - digester.addSetNext(entryPath, "addEntry", Entry.class.getName()); - } - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/reader/EntryReader.java b/dormant/atom4j/src/org/osjava/atom4j/reader/EntryReader.java deleted file mode 100644 index 7f9a3b2a..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/reader/EntryReader.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.reader; - -import org.apache.commons.digester.Digester; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osjava.atom4j.pojo.Entry; - -import java.io.InputStream; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; - -/** - * The intent of this class is for it to be used to read in the - * XML posted to the Atom API for inserting & updating Atom entries. - * - * Created on Aug 22, 2003 - * @author llavandowska - */ -public class EntryReader extends AtomReader -{ - private Collection entries = new LinkedList(); - - private static Log logger = - LogFactory.getFactory().getInstance(EntryReader.class); - - protected void initDigester() - { - digester = new Digester(); - digester.push(this); - //digester.setDebug(0); - digester.setValidating(false); - configureEntryDigester(digester, ""); - } - - /** - * Instantiate EntryReader from a String containing XML. - * - * @param xml - */ - public EntryReader(String xml) - { - super(xml); - parse(); - } - - /** - * Instantiate EntryReader from an InputStream. - * - * @param xml - */ - public EntryReader(InputStream in) - { - super(in); - parse(); - } - - public void addEntry(Entry entry) - { - entries.add(entry); - } - - /** - * @return - */ - public Collection getEntries() - { - return entries; - } - - /** - * @param collection - */ - public void setEntries(Collection collection) - { - entries= collection; - } - - /** - * Pretty test output. - */ - public String toString() - { - StringBuffer buf = new StringBuffer(); - Iterator iter = entries.iterator(); - while (iter.hasNext()) - { - Entry entry = (Entry)iter.next(); - buf.append(entry.toString()); - } - return buf.toString(); - } - - public static void main(String[] args) - { - String entryXML = "" + - " " + - "My First Entry " + - "In which a newbie learns to blog... " + - "A very boring entry... " + - "" + - " " + - " Bob B. Bobbington " + - " " + - "" + - "2003-02-05T12:29:29 " + - "2003-02-05T14:10:58Z " + - "2003-02-05T14:10:58Z " + - ""+ - "http://example.org/reilly/2003/02/05#My_First_Entry " + - "urn:example.org:reilly:1 " + - "" + - " " + - "Testing123

Hello, weblog world! 2 < 4!

" + - "
" + - "
"; - System.out.println(new EntryReader(entryXML)); - } - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/reader/FeedReader.java b/dormant/atom4j/src/org/osjava/atom4j/reader/FeedReader.java deleted file mode 100644 index a447b800..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/reader/FeedReader.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.reader; - -import org.apache.commons.digester.Digester; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osjava.atom4j.digester.ContentRuleSet; -import org.osjava.atom4j.digester.GeneratorRuleSet; -import org.osjava.atom4j.digester.LinkRuleSet; -import org.osjava.atom4j.digester.PersonRuleSet; -import org.osjava.atom4j.pojo.Feed; - -import java.io.InputStream; - -/** - * Created on Feb 14, 2004 - * @author Lance - */ -public class FeedReader extends AtomReader -{ - private static Log logger = - LogFactory.getFactory().getInstance(FeedReader.class); - - private Feed feed = null; - public void setFeed(Feed _feed) - { - feed = _feed; - } - public Feed getFeed() - { - return feed; - } - - protected void initDigester() - { - digester = new Digester(); - digester.push(this); - //digester.setDebug(0); - digester.setValidating(false); - - configureFeedDigester(); - } - - /** - * @return - */ - protected void configureFeedDigester() - { - String feedPath = "feed"; - digester.addObjectCreate(feedPath, Feed.class.getName()); - - digester.addBeanPropertySetter(feedPath + "/id"); - - digester.addCallMethod(feedPath + "/modified", "setModified", 0); - - digester.addRuleSet(new ContentRuleSet(feedPath + "/title", "setTitle")); - - digester.addRuleSet(new LinkRuleSet(feedPath + "/link")); - - digester.addRuleSet(new PersonRuleSet(feedPath + "/author", "setAuthor")); - - digester.addRuleSet(new PersonRuleSet(feedPath + "/contributor", "addContributor")); - - digester.addRuleSet(new ContentRuleSet(feedPath + "/tagline", "setTagline")); - - digester.addRuleSet(new GeneratorRuleSet(feedPath + "/generator")); - - digester.addRuleSet(new ContentRuleSet(feedPath + "/copyright", "setCopyright")); - - digester.addRuleSet(new ContentRuleSet(feedPath + "/info", "setInfo")); - - // add Entry reading rules to this Feed digester - configureEntryDigester(digester, feedPath + "/"); - - digester.addSetNext(feedPath, "setFeed", Feed.class.getName()); - } - - /** - * @param xml - */ - public FeedReader(String xml) - { - super(xml); - parse(); - } - - /** - * @param in - */ - public FeedReader(InputStream in) - { - super(in); - parse(); - } - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/reader/PrefsReader.java b/dormant/atom4j/src/org/osjava/atom4j/reader/PrefsReader.java deleted file mode 100644 index 908747d8..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/reader/PrefsReader.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.reader; - -import java.io.InputStream; - -import org.apache.commons.digester.Digester; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.osjava.atom4j.pojo.UserPreferences; - -/** - * - * Reilly - * 1234 - * reilly@example.org - * - * - * @deprecated - * - * Created on Aug 23, 2003 - * @author llavandowska - */ -public class PrefsReader extends AtomReader -{ - private static Log logger = - LogFactory.getFactory().getInstance(EntryReader.class); - - private UserPreferences userPrefs = null; - - protected void initDigester() - { - digester = new Digester(); - digester.push(this); - //digester.setDebug(0); - digester.setValidating(false); - digester.addObjectCreate("userprefs", "org.osjava.atom4j.pojo.UserPreferences"); - digester.addCallMethod("userprefs/name", "setName", 0); - digester.addCallMethod("userprefs/id", "setId", 0); - digester.addCallMethod("userprefs/email", "setEmail", 0); - digester.addSetNext("userprefs", "setUserPrefs", "org.osjava.atom4j.pojo.UserPreferences"); - } - - /** - * Instantiate EntryReader from a String containing XML. - * - * @param xml - */ - public PrefsReader(String xml) - { - super(xml); - parse(); - } - - /** - * Instantiate EntryReader from an InputStream. - * - * @param xml - */ - public PrefsReader(InputStream input) - { - super(input); - parse(); - } - - /** - * @return UserPreferences - */ - public UserPreferences getUserPrefs() - { - return userPrefs; - } - - public void setUserPrefs(UserPreferences prefs) - { - userPrefs = prefs; - } - - public String toString() - { - if (userPrefs == null) return "null"; - return userPrefs.toString(); - } - -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/servlet/AtomServlet.java b/dormant/atom4j/src/org/osjava/atom4j/servlet/AtomServlet.java deleted file mode 100644 index e5a800b4..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/servlet/AtomServlet.java +++ /dev/null @@ -1,961 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.servlet; - -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osjava.atom4j.Atom4J; -import org.osjava.atom4j.pojo.Entry; -import org.osjava.atom4j.pojo.Feed; -import org.osjava.atom4j.pojo.Template; -import org.osjava.atom4j.reader.EntryReader; -import org.osjava.atom4j.reader.FeedReader; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * http://bitworking.org/news/AtomAPI_Quick_Reference - * http://atomenabled.org/developers/api/atom-api-spec.php - * - * All requests should have a URL format - * /atom/username/ACTION[/args] - * - * GET Feed PathInfo: /USER/feed[/id] - include id for multiple feeds per user - * GET Entry PathInfo: /USER/entry/id - * DELETE Entry PathInfo: /USER/delete/id - * CREATE Entry PathInfo: /USER/entry - * UPDATE Entry PathInfo: /USER/entry/id - * - * -- No Longer Specified -- - * CREATE Comment PathInfo: /USER/comment/entry-id - * - * -- No Longer Specified -- - * GET Template PathInfo: /USER/template/id - * UPDATE Template PathInfo: /USER/template/id - * DELETE Template PathInfo: /USER/template/id - * GET Templates PathInfo: /USER/findTemplates - * - * -- No Longer Specified -- - * SEARCH PathInfo: /USER/search/?? - * Queries: ?atom-last=20 - * ?atom-all=y - * ?atom-start-range=0&atom-end-range=10 - * - * Created on Aug 21, 2003 - * @author llavandowska - * - * @ web.servlet name="AtomServlet" - * @ web.servlet-mapping url-pattern="/atom" - */ -public abstract class AtomServlet extends HttpServlet -{ - private static Log logger = - LogFactory.getFactory().getInstance(AtomServlet.class); - - protected static String baseURL = null; - - private static final byte[] XML_HEADER = - "".getBytes(); - - private String introspectionXML = null; - - /* (non-Javadoc) - * @see javax.servlet.GenericServlet#init() - */ - public void init() throws ServletException - { - super.init(); - } - - /** - * Return the PathInfo from the request. Convenience method. - * - * @param request - * @return - */ - protected String[] getPathInfo(HttpServletRequest request) - { - String mPathInfo = request.getPathInfo(); - mPathInfo = (mPathInfo!=null) ? mPathInfo : ""; - return StringUtils.split(mPathInfo,"/"); - } - - /** - * Write the "result" bytes to the response. Convenience method. - * - * @param response - * @param result - * @throws IOException - */ - private void writeResults(HttpServletResponse response, byte[] result) - throws IOException - { - response.setStatus( HttpServletResponse.SC_OK ); - response.setContentType("application/x.atom+xml"); - - if (result.length > 0) - { - response.setContentLength(XML_HEADER.length + result.length); - OutputStream output = response.getOutputStream(); - output.write(XML_HEADER); - output.write(result); - output.flush(); - } - else - { - response.setContentLength(0); - } - } - - /** - * Authenticate user based on information in request. - */ - protected boolean authorized(HttpServletRequest request) - { - // for now, we do WSSE as do Typepad and Blogger.com - return wsseAuthentication(request); - } - - /** - * Get password for specified user name. - */ - public abstract String getPassword(String userName) throws Exception; - - /** - * Perform WSSE authentication based on information in request. - */ - protected boolean wsseAuthentication(HttpServletRequest request) - { - return wsseAuthentication(request.getHeader("X-WSSE")); - } - - /** - * Authenticate based on WSSE header string, public for unit testing purposes. - */ - public boolean wsseAuthentication(String wsseHeader) - { - boolean ret = false; - Base64 base64 = new Base64(); - String userName = null; - String created = null; - String nonce = null; - String passwordDigest = null; - String[] tokens = wsseHeader.split(","); - for (int i = 0; i < tokens.length; i++) - { - int index = tokens[i].indexOf('='); - if (index != -1) - { - String key = tokens[i].substring(0, index).trim(); - String value = tokens[i].substring(index + 1).trim(); - value = value.replaceAll("\"", ""); - if (key.startsWith("UsernameToken")) - { - userName = value; - } - else if (key.equalsIgnoreCase("nonce")) - { - nonce = value; - } - else if (key.equalsIgnoreCase("passworddigest")) - { - passwordDigest = value; - } - else if (key.equalsIgnoreCase("created")) - { - created = value; - } - } - } - String digest = null; - try - { - digest = WSSEUtilities.generateDigest( - WSSEUtilities.base64Decode(nonce), - created.getBytes("UTF-8"), - getPassword(userName).getBytes("UTF-8")); - ret = digest.equals(passwordDigest); - } - catch (Exception e) - { - logger.warn("ERROR in wsseAuthenticataion: " + e.getMessage()); - } - return ret; - } - - /** - * Invalid request, return error message. - * - * @param request - * @param response - */ - private void error(HttpServletRequest request, HttpServletResponse response, - String errorTitle, String errorBody) throws IOException - { - if (errorTitle == null) errorTitle = "Something Bad Happened"; - if (errorBody == null) errorBody = "Something bad happened"; - String title = "" + errorTitle + "\n"; - String description = "" + errorBody + "\n"; - byte[] result = ("\n"+title+description+"").getBytes(); - response.setStatus( HttpServletResponse.SC_BAD_REQUEST ); - response.setContentType("application/x.atom+xml"); - - response.setContentLength(XML_HEADER.length + result.length); - OutputStream output = response.getOutputStream(); - output.write(XML_HEADER); - output.write(result); - output.flush(); - } - - /** - * All uses of doDelete must be authorized! - * - * @see javax.servlet.http.HttpServlet#doDelete(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) - */ - public void doDelete(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException - { - String[] pathInfo = getPathInfo(request); - if (pathInfo.length < 2) - { - error(request, response, "Invalid Request", "Insufficient Information to Process Request."); - return; - } - - if (authorized(request)) - { - if ("entry".equals(pathInfo[1])) - { - deleteEntry(pathInfo, request, response); - } - /* - else if ("template".equals(pathInfo[1])) - { - deleteTemplate(pathInfo, request, response); - } - */ - } - else - { - error(request, response, "Unauthorized", "You are not authorized for this Action."); - return; - } - } - - /* (non-Javadoc) - * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) - */ - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException - { - String[] pathInfo = getPathInfo(request); - if (pathInfo.length < 2) - { - error(request, response, "Invalid Request.", "Insufficient Information to Process Request."); - return; - } - - // first the options that don't require authorization - boolean authorized = authorized(request); - if ("entry".equals(pathInfo[1])) - { - getEntry(pathInfo, request, response); - } - else if ("feed".equals(pathInfo[1])) - { - getFeed(pathInfo, request, response); - } - /* - else if ("search".equals(pathInfo[1])) - { - search(pathInfo, request, response); - } - */ - // now check for those that do require authorization - else if (authorized) - { - if ("delete".equals(pathInfo[1])) - { - deleteEntry(pathInfo, request, response); - } - /* - else if ("findTemplates".equals(pathInfo[1])) - { - findTemplates(pathInfo, request, response); - } - else if ("template".equals(pathInfo[1])) - { - getTemplate(pathInfo, request, response); - } - */ - } - else if (!authorized) - { - error(request, response, "Authorization Failure.", "You are not authorized for this Action."); - } - else - { - error(request, response, "No Action was requested.", "Your request did not contain an Action."); - } - } - - /* (non-Javadoc) - * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) - */ - public void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException - { - String[] pathInfo = getPathInfo(request); - if (pathInfo.length < 2) - { - error(request, response, "Invalid Request.", "Insufficient Information to Process Request."); - return; - } - - boolean authorized = authorized(request); - if (authorized && "entry".equals(pathInfo[1])) - { - postEntry(pathInfo, request, response); - } - else if ("comment".equals(pathInfo[1])) - { - postComment(pathInfo, request, response); - } - else if (!authorized) - { - error(request, response, "Authorization Failure.", "You are not authorized for this Action."); - } - else - { - error(request, response, "No Action was requested.", "Your request did not contain an Action."); - } - } - - - /* (non-Javadoc) - * @see javax.servlet.http.HttpServlet#doPut(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) - */ - public void doPut(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException - { - String[] pathInfo = getPathInfo(request); - if (pathInfo.length < 2) - { - error(request, response, "Invalid Request.", "Insufficient Information to Process Request."); - return; - } - - if (authorized(request)) - { - if ("entry".equals(pathInfo[1])) - { - updateEntry(pathInfo, request, response); - } - /* - else if ("template".equals(pathInfo[1])) - { - updateTemplate(pathInfo, request, response); - } - */ - else - { - error(request, response, "No Action was requested.", "Your request did not contain an Action."); - return; - } - } - else - { - error(request, response, "Unauthorized", "You are not authorized for the requested Action."); - return; - } - } - - /** - * PathInfo: /USER/feed/id - * - * @param pathInfo - * @param request - * @param response - */ - private void getFeed(String[] pathInfo, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - if (pathInfo.length > 0) - { - Feed feed = null; - try - { - feed = getFeed(pathInfo); - } - catch (Exception e) - { - logger.error(e); - throw new ServletException(e); - } - - if (feed != null) - { - writeResults(response, feed.toString().getBytes()); - } - else - { - error(request, response, "No Feed Found", "No Feed Found for " + pathInfo[0]); - } - } - else - { - error(request, response, "Invalid Request.", "Insufficient Information to Process Request."); - } - } - - /** - * @param pathInfo - * @return - */ - protected abstract Feed getFeed(String[] pathInfo) throws Exception; - - /** - * PathInfo: /USER/entry/id - * - * @param pathInfo - * @param request - * @param response - */ - protected void getEntry(String[] pathInfo, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - if (pathInfo.length > 2) - { - try - { - Entry entry = getEntry(pathInfo); - writeResults(response, entry.toString().getBytes()); - } - catch (Exception e) - { - throw new ServletException(e); - } - } - else - { - error(request, response, "Invalid Request.", "Insufficient Information to Process Request."); - } - } - - /** - * @param pathInfo - * @return - */ - protected abstract Entry getEntry(String[] pathInfo) throws Exception; - - /** - * PathInfo: /USER/delete/id - * - * @param request - */ - protected void deleteEntry(String[] pathInfo, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - if (pathInfo.length > 2) - { - try - { - deleteEntry(pathInfo); - writeResults(response, "".getBytes()); - } - catch (Exception e) - { - throw new ServletException(e); - } - } - else - { - error(request, response, "Invalid Request.", "Insufficient Information to Process Request."); - } - } - - /** - * @param pathInfo - */ - protected abstract void deleteEntry(String[] pathInfo) throws Exception; - - /** - * Create a new Entry. The jury is still out on whether AtomAPI will - * support the creation of more than one Entry at a time. The API - * does specify, however, that creating an Entry will return a - * Location header containing the Atom URL to that Entry. For now - * Atom4J is returning the address of the last Entry created. - * - * PathInfo: /USER/entry - * - * @param request - */ - protected void postEntry(String[] pathInfo, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - Collection entries = null; - // is this a wrapped around several 's ? - FeedReader feedReader = new FeedReader( request.getInputStream() ); - if (feedReader.getFeed() != null) - { - entries = feedReader.getFeed().getEntries(); - } - else - { - // or is it really just one Entry? - EntryReader reader = new EntryReader( request.getInputStream() ); - entries = reader.getEntries(); - } - if (entries == null || entries.size() < 1) - { - error(request, response, "No Entry Found", "No entry was found in the supplied information."); - return; - } - - Entry entry = null; - Iterator iter = entries.iterator(); - while (iter.hasNext()) - { - entry = (Entry)iter.next(); - try - { - saveNewEntry(entry); - } - catch (Exception e) - { - ServletException se = new ServletException(e); - se.fillInStackTrace(); - throw se; - } - } - - if (entry != null) - { - String entryLoc = new StringBuffer(baseURL).append("/atom/") - .append(pathInfo[0]) - .append("/entry/") - .append(entry.getId()).toString(); - response.setHeader("Location", entryLoc); - //response.setStatus( HttpServletResponse.SC_CREATED ); - response.setStatus( HttpServletResponse.SC_SEE_OTHER ); - } - } - - /** - * @param entry - */ - protected abstract void saveNewEntry(Entry entry) throws Exception; - - /** - * Update the Entry (save changes). - * - * PathInfo: /USER/entry/id - * - * @param request - */ - protected void updateEntry(String[] pathInfo, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - EntryReader reader = new EntryReader( request.getInputStream() ); - List entries = (List)reader.getEntries(); - if (entries == null || entries.size() < 1) - { - error(request, response, "No Entry Found For Update.", "Unable to locate entry submitted for update."); - return; - } - - if (pathInfo.length > 2) - { - // find the Entry to be edited - Entry entry = (Entry)entries.get(0); - - if (entry != null) - { - try - { - updateEntry(entry, pathInfo); - - response.setStatus( HttpServletResponse.SC_RESET_CONTENT ); - } - catch (Exception e) - { - throw new ServletException(e); - } - } - } - else - { - error(request, response, "Invalid request.", "Insufficient Information to Process Request."); - } - } - - /** - * @param entry - */ - protected abstract void updateEntry(Entry entry, String[] pathInfo) throws Exception; - - /** - * Create a new comment. - * The spec no longer defines Commenting, except to say that - * Comments are Entries. No relationship between an Entry and - * its Comments is described. - * - * PathInfo: /USER/comment/id - * id = entry's id - * - * @param request - */ - protected void postComment(String[] pathInfo, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - try - { - Entry entry = getEntry(pathInfo); - if (entry != null) - { - Iterator iter = new EntryReader(request.getInputStream()).getEntries().iterator(); - Entry comment = (Entry)iter.next(); - if (comment != null) - postComment(entry, comment, pathInfo); - } - } - catch (Exception e) - { - throw new ServletException(e); - } - } - - - /** - * The spec no longer defines Commenting, except to say that - * Comments are Entries. No relationship between an Entry and - * its Comments is described. - * - * @param entry - * @param comment - * @param pathInfo - */ - protected abstract void postComment(Entry entry, Entry comment, String[] pathInfo) throws Exception; - - /** - * Return the Search Results. - * This is no longer a part of the Atom spec, but I'm leaving it - * in anticipation of future spec changes. - * - * PathInfo: /USER/search/?? - * Queries: ?atom-last=20 - * ?atom-all=y - * ?atom-start-range=0&atom-end-range=10 - * - * @param request - * @deprecated - */ - protected void search(String[] pathInfo, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - List entries = null; - int maxEntries = 10; - - try - { - // search by keyword(s) - if (pathInfo.length > 2) - { - entries = entryKeywordSearch(pathInfo); - } - // get entries in range - else if (request.getParameter("atom-start-range") != null && - request.getParameter("atom-end-range") != null ) - { - try - { - int startRange = Integer.valueOf( - request.getParameter("atom-start-range")).intValue(); - int endRange = Integer.valueOf( - request.getParameter("atom-end-range")).intValue(); - if (startRange >= 0 && endRange > startRange) - { - entries = getEntryRange(startRange, endRange, pathInfo); - } - } - catch (NumberFormatException e) - { - // Not A Number : ignore - } - - } - // get the most recent X-number of entries - else if (request.getParameter("atom-last") != null || - request.getParameter("atom-recent") != null) - { - String maxStr = request.getParameter("atom-last"); - if (maxStr == null) maxStr = request.getParameter("atom-recent"); - try - { - maxEntries = Integer.valueOf( maxStr ).intValue(); - } - catch (NumberFormatException e) - { - // Not A Number : ignore - } - } - else if (request.getParameter("atom-all") != null) - { - entries = allEntries(pathInfo); - } - - // if atom-last or no 'search' was specified, - // or a number-format exception default to this. - if (entries == null) - { - entries= getLatestEntries(pathInfo[0], maxEntries); - } - } - catch (Exception e) - { - throw new ServletException(e); - } - - StringBuffer buf = new StringBuffer(""); - Iterator iter = entries.iterator(); - while (iter.hasNext()) - { - Entry entry = (Entry)iter.next(); - // T O D O : Improve generation of "search results" - buf.append("").append(entry.getTitle()) - .append("").append(baseURL).append("/atom/") - .append(pathInfo[0]).append("/entry/") - .append(entry.getId()).append("\n"); - } - buf.append(""); - - writeResults(response, buf.toString().getBytes()); - - } - - /** - * Search is no longer a part of the Atom spec, but I'm leaving it - * in anticipation of future spec changes. - * @param pathInfo - * @deprecated - */ - protected abstract List allEntries(String[] pathInfo) throws Exception; - - /** - * Search is no longer a part of the Atom spec, but I'm leaving it - * in anticipation of future spec changes. - * @param startRange - * @param endRange - * @param pathInfo - * @deprecated - */ - protected abstract List getEntryRange(int startRange, int endRange, String[] pathInfo) throws Exception; - - /** - * Search is no longer a part of the Atom spec, but I'm leaving it - * in anticipation of future spec changes. - * @param pathInfo - * @deprecated - */ - protected abstract List entryKeywordSearch(String[] pathInfo) throws Exception; - - /** - * Helper method. - * @param maxEntries - * @deprecated - */ - protected abstract List getLatestEntries(String username, int maxEntries) - throws Exception; - - /** - * Return list of Templates. - * This is no longer a part of the Atom spec, but I'm leaving it - * in anticipation of future spec changes. - * - * PathInfo: /USER/findTemplates - * - * @param request - * @deprecated - */ - protected void findTemplates(String[] pathInfo, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - StringBuffer buf = new StringBuffer(""); - List templates = null; - try - { - templates= findTemplates(pathInfo); - } - catch (Exception e) - { - throw new ServletException(e); - } - Iterator iter = templates.iterator(); - while (iter.hasNext()) - { - Template template = (Template) iter.next(); - buf.append(template.toString()); - } - buf.append(""); - writeResults(response, buf.toString().getBytes()); - } - - /** - * This must return a List of Template objects. - * This is no longer a part of the Atom spec, but I'm leaving it - * in anticipation of future spec changes. - * - * @param pathInfo - * @deprecated - */ - protected abstract List findTemplates(String[] pathInfo) throws Exception; - - /** - * Return the requested template. - * This is no longer a part of the Atom spec, but I'm leaving it - * in anticipation of future spec changes. - * - * PathInfo: /USER/template/id - * - * @param request - * @deprecated - */ - protected void getTemplate(String[] pathInfo, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - if (pathInfo.length > 2) - { - try - { - byte[] template = getTemplate(pathInfo); - writeResults(response, template); - } - catch (Exception e) - { - throw new ServletException(e); - } - } - else - { - error(request, response, "Invalid Request.", "Insufficient Information to Process Request."); - } - } - - /** - * Return the contents of the template (HTML or what-have-you) - * as a byte array. - * This is no longer a part of the Atom spec, but I'm leaving it - * in anticipation of future spec changes. - * - * @param pathInfo - * @deprecated - */ - protected abstract byte[] getTemplate(String[] pathInfo) throws Exception; - - /** - * Update the template (save changes). - * This is no longer a part of the Atom spec, but I'm leaving it - * in anticipation of future spec changes. - * - * PathInfo: /USER/template/id - * - * @param request - * @deprecated - */ - protected void updateTemplate(String[] pathInfo, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - try - { - java.io.BufferedReader streamReader = - new java.io.BufferedReader( - new java.io.InputStreamReader( - request.getInputStream())); - - StringBuffer buf = new StringBuffer(); - String dataLine; - while((dataLine = streamReader.readLine()) != null){ - buf.append(dataLine); - }//end while loop - streamReader.close(); - - updateTemplate(buf.toString() , pathInfo ); - writeResults(response, "".getBytes()); - } - catch (Exception e) - { - throw new ServletException(e); - } - } - - /** - * This is no longer a part of the Atom spec, but I'm leaving it - * in anticipation of future spec changes. - * @param stream - * @param pathInfo - * @deprecated - */ - protected abstract void updateTemplate(String template, String[] pathInfo) throws Exception; - - /** - * Delete the template. - * This is no longer a part of the Atom spec, but I'm leaving it - * in anticipation of future spec changes. - * - * PathInfo: /USER/template/id - * - * @param pathInfo - * @param request - * @param response - * @deprecated - */ - protected void deleteTemplate(String[] pathInfo, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - try - { - byte[] result = deleteTemplate(pathInfo); - writeResults(response, result); - } - catch (Exception e) - { - throw new ServletException(e); - } - } - - - /** - * This is no longer a part of the Atom spec, but I'm leaving it - * in anticipation of future spec changes. - * @param pathInfo - * @deprecated - */ - protected abstract byte[] deleteTemplate(String[] pathInfo) throws Exception; -} diff --git a/dormant/atom4j/src/org/osjava/atom4j/servlet/WSSEUtilities.java b/dormant/atom4j/src/org/osjava/atom4j/servlet/WSSEUtilities.java deleted file mode 100644 index 94bebc1e..00000000 --- a/dormant/atom4j/src/org/osjava/atom4j/servlet/WSSEUtilities.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Created on Jul 16, 2004 - */ -package org.osjava.atom4j.servlet; - -import java.io.IOException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import org.apache.commons.codec.binary.Base64; - -/** - * Utilties to support WSSE authentication. - * @author Dave Johnson - */ -public class WSSEUtilities -{ - public static synchronized String generateDigest( - byte[] nonce, byte[] created, byte[] password) throws Exception - { - String result = null; - try - { - MessageDigest digester = MessageDigest.getInstance("SHA-1"); - digester.reset(); - digester.update(nonce); - digester.update(created); - digester.update(password); - byte[] digest = digester.digest(); - result = new String(base64Encode(digest)); - } - catch (NoSuchAlgorithmException e) - { - result = null; - } - return result; - } - - public static byte[] base64Decode(String value) throws IOException - { - Base64 base64 = new Base64(); - return Base64.decodeBase64(value.getBytes("UTF-8")); - } - - public static String base64Encode(byte[] value) - { - Base64 base64 = new Base64(); - return new String(Base64.encodeBase64(value)); - } -} diff --git a/dormant/atom4j/tests/org/osjava/atom4j/reader/EntryReaderTest.java b/dormant/atom4j/tests/org/osjava/atom4j/reader/EntryReaderTest.java deleted file mode 100644 index 08d3a05b..00000000 --- a/dormant/atom4j/tests/org/osjava/atom4j/reader/EntryReaderTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.reader; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import org.osjava.atom4j.Atom4J; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Created on Aug 23, 2003 - * @author llavandowska - */ -public class EntryReaderTest extends TestCase -{ - String entryXML = "" + - " " + - "My First Entry " + - "In which a newbie learns to blog... " + - "A very boring entry... " + - "" + - " " + - " Bob B. Bobbington " + - " " + - "" + - "2003-02-05T12:29:29 " + - "2003-02-05T14:10:58Z " + - "2003-02-05T14:10:58Z " + - ""+ - "http://example.org/reilly/2003/02/05#My_First_Entry " + - "urn:example.org:reilly:1 " + - "" + - "" + - "Start here

Hello, weblog world! 2 < 4!

" + - "
" + - "
"; - - String expected = - "\n" + - " My First Entry\n" + - " A very boring entry...\n" + - //" In which a newbie learns to blog...\n" + - " \n" + - " Bob B. Bobbington\n" + - " \n" + - " 2003-02-05T12:29:29Z\n" + - " 2003-02-05T14:10:58Z\n" + - " 2003-02-05T14:10:58Z\n" + - " http://example.org/reilly/2003/02/05#My_First_Entry\n" + - " \n" + - " urn:example.org:reilly:1\n" + - " " + - "Start here

Hello, weblog world! 2 < 4!

" + - "
\n" + - "
\n"; - - public static Test suite() - { - return new TestSuite(EntryReaderTest.class); - } - - public void testEntryReaderXML() - { - EntryReader reader = new EntryReader(entryXML); - assertEquals(expected, reader.toString()); - } - - public void testEntryReaderInputStream() - { - InputStream input = new ByteArrayInputStream(entryXML.getBytes()); - EntryReader reader = new EntryReader(input); - assertEquals(expected, reader.toString()); - } - -} diff --git a/dormant/atom4j/tests/org/osjava/atom4j/reader/MaximumFeedTest.java b/dormant/atom4j/tests/org/osjava/atom4j/reader/MaximumFeedTest.java deleted file mode 100644 index e3200b57..00000000 --- a/dormant/atom4j/tests/org/osjava/atom4j/reader/MaximumFeedTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.reader; - -import org.osjava.atom4j.Atom4J; -import org.osjava.atom4j.pojo.Content; -import org.osjava.atom4j.pojo.Entry; -import org.osjava.atom4j.pojo.Feed; -import org.osjava.atom4j.pojo.Link; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; - -import junit.framework.TestCase; - -/** - * Created on Feb 14, 2004 - * @author Lance - */ -public class MaximumFeedTest extends TestCase -{ - String fileName = "Atom03_Max.xml"; - private InputStream stream; - private Feed feed; - - public void setUp() - { - stream = MaximumFeedTest.class.getClassLoader().getResourceAsStream(fileName); - assertNotNull("Unable to load " + fileName + ", make sure it is on Classpath.", stream); - FeedReader reader = new FeedReader(stream); - reader.parse(); - feed = reader.getFeed(); - } - public void tearDown() throws IOException - { - stream.close(); - } - - public MaximumFeedTest() - { - super(); - } - - public MaximumFeedTest(String arg0) - { - super(arg0); - } - - public void testFeed() - { - assertNotNull(feed); - assertEquals("dive into mark", feed.getTitle().getText()); - - assertNotNull(feed.getLinks()); - Link link = (Link)((ArrayList)feed.getLinks()).get(0); - assertEquals("http://example.org/", link.getHref()); - assertEquals(Link.ALTERNATE, link.getRel()); - - assertEquals(Content.ESCAPED, feed.getTagline().getMode()); - assertEquals("A <em>lot</em> of effort went into making this effortless", - feed.getTagline().getText()); - - //TODO Add more asserts. Should these be broken up into - // multiple test methods? - } - - public void testEntries() - { - assertNotNull(feed); - assertNotNull(feed.getEntries()); - assertEquals(1, feed.getEntries().size()); - - Entry entry = (Entry)feed.getEntries().iterator().next(); - assertNotNull(entry); - assertEquals("Atom 0.3 snapshot", entry.getTitle().getText()); - - assertNotNull(feed.getLinks()); - Link link = (Link)((ArrayList)feed.getLinks()).get(0); - assertEquals("text/html", link.getType()); - assertEquals(Link.ALTERNATE, link.getRel()); - - String modified = Atom4J.formatIso8601(entry.getModified()); - assertEquals("2003-12-13T18:30:02Z", modified); - - assertEquals("Mark Pilgrim", entry.getAuthor().getName()); - - assertEquals(2, entry.getContributors().size()); - - assertNotNull(entry.getContent()); - assertEquals("application/xhtml+xml", entry.getContent().getMimeType()); - - //TODO Add more asserts. Should these be broken up into - // multiple test methods? - } - -} diff --git a/dormant/atom4j/tests/org/osjava/atom4j/reader/MinimalFeedTest.java b/dormant/atom4j/tests/org/osjava/atom4j/reader/MinimalFeedTest.java deleted file mode 100644 index 6702a28e..00000000 --- a/dormant/atom4j/tests/org/osjava/atom4j/reader/MinimalFeedTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.reader; - -import org.osjava.atom4j.Atom4J; -import org.osjava.atom4j.pojo.Entry; -import org.osjava.atom4j.pojo.Feed; -import org.osjava.atom4j.pojo.Link; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; - -import junit.framework.TestCase; - -/** - * Created on Feb 14, 2004 - * @author Lance - */ -public class MinimalFeedTest extends TestCase -{ - String fileName = "Atom03_Min.xml"; - private InputStream stream; - private Feed feed; - - public void setUp() throws IOException - { - stream = MinimalFeedTest.class.getClassLoader().getResourceAsStream(fileName); - assertNotNull("Unable to load " + fileName + ", make sure it is on Classpath.", stream); - FeedReader reader = new FeedReader(stream); - reader.parse(); - stream.close(); - feed = reader.getFeed(); - } - - public MinimalFeedTest() - { - super(); - } - - public MinimalFeedTest(String arg0) - { - super(arg0); - } - - public void testFeed() - { - assertNotNull(feed); - assertEquals("dive into mark", feed.getTitle().getText()); - - //TODO Add more asserts. Should these be broken up into - // multiple test methods? - } - - public void testEntries() - { - assertNotNull(feed); - assertNotNull(feed.getEntries()); - assertEquals(1, feed.getEntries().size()); - - Entry entry = (Entry)feed.getEntries().iterator().next(); - assertNotNull(entry); - assertEquals("Atom 0.3 snapshot", entry.getTitle().getText()); - - assertNotNull(feed.getLinks()); - Link link = (Link)((ArrayList)feed.getLinks()).get(0); - assertEquals("text/html", link.getType()); - assertEquals(Link.ALTERNATE, link.getRel()); - - String modified = Atom4J.formatIso8601(entry.getModified()); - assertEquals("2003-12-13T18:30:02Z", modified); - - //TODO Add more asserts. Should these be broken up into - // multiple test methods? - } - -} diff --git a/dormant/atom4j/tests/org/osjava/atom4j/reader/MultipartFeedTest.java b/dormant/atom4j/tests/org/osjava/atom4j/reader/MultipartFeedTest.java deleted file mode 100644 index 25c94702..00000000 --- a/dormant/atom4j/tests/org/osjava/atom4j/reader/MultipartFeedTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.reader; - -import org.osjava.atom4j.Atom4J; -import org.osjava.atom4j.pojo.Content; -import org.osjava.atom4j.pojo.Entry; -import org.osjava.atom4j.pojo.Feed; -import org.osjava.atom4j.pojo.Link; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; - -import junit.framework.TestCase; - -/** - * Created on Feb 14, 2004 - * @author Lance - */ -public class MultipartFeedTest extends TestCase -{ - String fileName = "Atom03_Multipart.xml"; - private InputStream stream; - private Feed feed; - - public void setUp() throws IOException - { - stream = MultipartFeedTest.class.getClassLoader().getResourceAsStream(fileName); - assertNotNull("Unable to load " + fileName + ", make sure it is on Classpath.", stream); - FeedReader reader = new FeedReader(stream); - reader.parse(); - stream.close(); - feed = reader.getFeed(); - } - - public MultipartFeedTest() - { - super(); - } - - public MultipartFeedTest(String arg0) - { - super(arg0); - } - - public void testFeed() - { - assertNotNull(feed); - assertEquals("dive into mark", feed.getTitle().getText()); - - assertNotNull(feed.getLinks()); - Link link = (Link)((ArrayList)feed.getLinks()).get(0); - assertEquals("text/html", link.getType()); - assertEquals("http://diveintomark.org/", link.getHref()); - assertEquals(Link.ALTERNATE, link.getRel()); - - assertEquals(Content.XML, feed.getTagline().getMode()); - assertEquals("A lot of effort went into making this effortless", - feed.getTagline().getText()); - - //TODO Add more asserts. Should these be broken up into - // multiple test methods? - } - - public void testEntries() - { - assertNotNull(feed); - assertNotNull(feed.getEntries()); - assertEquals(1, feed.getEntries().size()); - - Entry entry = (Entry)feed.getEntries().iterator().next(); - assertNotNull(entry); - assertEquals("Atom 0.3 snapshot", entry.getTitle().getText()); - - assertNotNull(feed.getLinks()); - Link link = (Link)((ArrayList)feed.getLinks()).get(0); - assertEquals("text/html", link.getType()); - assertEquals(Link.ALTERNATE, link.getRel()); - - String modified = Atom4J.formatIso8601(entry.getModified()); - assertEquals("2003-12-13T18:30:02Z", modified); - - assertEquals(2, entry.getContributors().size()); - - assertEquals("The Atom 0.3 snapshot is out. Here are some sample feeds.", - entry.getSummary().getText()); - - // should be multipart - assertNotNull(entry.getContent()); - assertEquals(Content.MULTIPART, entry.getContent().getMimeType()); - assertEquals(2, entry.getContent().getMultipart().size()); - assertEquals(firstMultipart, - ((Content)entry.getContent().getMultipart().iterator().next()).getText().trim()); - - //TODO Add more asserts. Should these be broken up into - // multiple test methods? - - //System.out.println(feed.toString()); - //System.out.println("|"+entry.getContent().getText()+"|"); - } - private static String firstMultipart = "The Atom 0.3 snapshot is out. Changes from the 0.2 snapshot [http://diveintomark.org/archives/2003/08/05/atom02]: (1) MAY contain feed/info. Free-form info statement that describes the feed format. More explanation of info [http://www.shellen.com/sandbox/atom-info-proposal.html]. (2) Expanded link syntax. All links now include rel, type, and href attributes. (3) Expanded content model. feed/title, feed/tagline, feed/info, feed/copyright, entry/title, and entry/summary can now contain arbitrary data (such as HTML). You must specify the data type in the type attribute, and (for non-XML formats) the escaping mode in the mode attribute. (4) feed/generator now has url and version attributes. The child text is now the human-readable toolkit name. (5) several other changes not listed here."; - -} diff --git a/dormant/atom4j/tests/org/osjava/atom4j/reader/PrefsReaderTest.java b/dormant/atom4j/tests/org/osjava/atom4j/reader/PrefsReaderTest.java deleted file mode 100644 index fdf1b7bc..00000000 --- a/dormant/atom4j/tests/org/osjava/atom4j/reader/PrefsReaderTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.reader; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import org.osjava.atom4j.Atom4J; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Created on Aug 23, 2003 - * @author llavandowska - */ -public class PrefsReaderTest extends TestCase -{ - String inputXML = - "\n" + - " Reilly\n" + - " 1234\n" + - " reilly@example.org\n" + - "\n"; - - /** - * @return - */ - public static Test suite() - { - return new TestSuite(PrefsReaderTest.class); - } - - public void testPrefsReaderXML() - { - PrefsReader reader = new PrefsReader(inputXML); - assertEquals(inputXML, reader.toString()); - } - - public void testPrefsReaderInputStream() - { - InputStream input = new ByteArrayInputStream(inputXML.getBytes()); - PrefsReader reader = new PrefsReader(input); - assertEquals(inputXML, reader.toString()); - } - -} diff --git a/dormant/atom4j/tests/org/osjava/atom4j/reader/TestAll.java b/dormant/atom4j/tests/org/osjava/atom4j/reader/TestAll.java deleted file mode 100644 index d898ae25..00000000 --- a/dormant/atom4j/tests/org/osjava/atom4j/reader/TestAll.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2003-2004 Lance Lavandowska - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.osjava.atom4j.reader; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - - -/** - * @author llavandowska - */ -public class TestAll extends TestCase -{ - public TestAll(String testName) - { - super(testName); - } - - public static void main(String[] args) - { - String[] testCaseName = { TestAll.class.getName() }; - junit.textui.TestRunner.main(testCaseName); - } - - public static Test suite() - { - TestSuite suite = new TestSuite(); - - suite.addTest(new TestSuite(MinimalFeedTest.class)); - suite.addTest(new TestSuite(MaximumFeedTest.class)); - suite.addTest(new TestSuite(MultipartFeedTest.class)); - - return suite; - } -} \ No newline at end of file diff --git a/dormant/atom4j/tests/org/osjava/atom4j/servlet/AtomServletTest.java b/dormant/atom4j/tests/org/osjava/atom4j/servlet/AtomServletTest.java deleted file mode 100644 index b72157aa..00000000 --- a/dormant/atom4j/tests/org/osjava/atom4j/servlet/AtomServletTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Created on Jun 27, 2004 - */ -package org.osjava.atom4j.servlet; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLConnection; -import java.text.SimpleDateFormat; -import java.util.Date; - -import junit.framework.TestCase; - -/** - * Test the Atom4J servlet. - */ -public class AtomServletTest extends TestCase -{ - - public void testWsseAuthentication() throws Exception - { - MockAtomServlet servlet = new MockAtomServlet(); - - String goodHeader = generateWSSEHeader("fred", "fred"); - assertTrue(servlet.wsseAuthentication(goodHeader)); - - String badHeader = generateWSSEHeader("fred", "fred1"); - assertFalse(servlet.wsseAuthentication(badHeader)); - } - - public void testBlogger() - { - try - { - URL url = new URL("http://www.blogger.com/atom"); - String username = "test"; - String password = "test"; - /*URL url = new URL("http://localhost:8080/roller/atom/admin/feed"); - String username = "admin"; - String password = "admin";*/ - - URLConnection connection = url.openConnection(); - connection.addRequestProperty("X-WSSE", generateWSSEHeader(username, password)); - - InputStream in = null; - try - { - in = connection.getInputStream(); - } - catch (Exception e) - { - e.printStackTrace(); - in = ((HttpURLConnection) connection).getErrorStream(); - } - BufferedReader res = new BufferedReader(new InputStreamReader(in, "UTF-8")); - String inputLine; - while ((inputLine = res.readLine()) != null) - System.out.println(inputLine); - res.close(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public static String generateWSSEHeader(String username, String password) - throws Exception - { - - byte[] nonceBytes = Long.toString(new Date().getTime()).getBytes(); - String nonce = new String(WSSEUtilities.base64Encode(nonceBytes)); - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - String created = sdf.format(new Date()); - - String digest = WSSEUtilities.generateDigest( - nonceBytes, created.getBytes("UTF-8"), password.getBytes("UTF-8")); - - StringBuffer header = new StringBuffer("UsernameToken Username=\""); - header.append(username); - header.append("\", "); - header.append("PasswordDigest=\""); - header.append(digest); - header.append("\", "); - header.append("Nonce=\""); - header.append(nonce); - header.append("\", "); - header.append("Created=\""); - header.append(created); - header.append("\""); - return header.toString(); - } -} - - diff --git a/dormant/atom4j/tests/org/osjava/atom4j/servlet/MockAtomServlet.java b/dormant/atom4j/tests/org/osjava/atom4j/servlet/MockAtomServlet.java deleted file mode 100644 index 4e67e353..00000000 --- a/dormant/atom4j/tests/org/osjava/atom4j/servlet/MockAtomServlet.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Created on Jun 27, 2004 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates - */ -package org.osjava.atom4j.servlet; - -import java.util.List; - -import org.osjava.atom4j.pojo.Entry; -import org.osjava.atom4j.pojo.Feed; - -/** - * @author Dave Johnson - */ -public class MockAtomServlet extends AtomServlet -{ - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#getFeed(java.lang.String[]) - */ - protected Feed getFeed(String[] pathInfo) throws Exception - { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#getEntry(java.lang.String[]) - */ - protected Entry getEntry(String[] pathInfo) throws Exception - { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#deleteEntry(java.lang.String[]) - */ - protected void deleteEntry(String[] pathInfo) throws Exception - { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#saveNewEntry(org.osjava.atom4j.pojo.Entry) - */ - protected void saveNewEntry(Entry entry) throws Exception - { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#updateEntry(org.osjava.atom4j.pojo.Entry, - * java.lang.String[]) - */ - protected void updateEntry(Entry entry, String[] pathInfo) throws Exception - { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#postComment(org.osjava.atom4j.pojo.Entry, - * org.osjava.atom4j.pojo.Entry, java.lang.String[]) - */ - protected void postComment(Entry entry, Entry comment, String[] pathInfo) - throws Exception - { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#allEntries(java.lang.String[]) - */ - protected List allEntries(String[] pathInfo) throws Exception - { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#getEntryRange(int, int, - * java.lang.String[]) - */ - protected List getEntryRange(int startRange, int endRange, String[] pathInfo) - throws Exception - { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#entryKeywordSearch(java.lang.String[]) - */ - protected List entryKeywordSearch(String[] pathInfo) throws Exception - { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#getLatestEntries(java.lang.String, - * int) - */ - protected List getLatestEntries(String username, int maxEntries) - throws Exception - { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#findTemplates(java.lang.String[]) - */ - protected List findTemplates(String[] pathInfo) throws Exception - { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#getTemplate(java.lang.String[]) - */ - protected byte[] getTemplate(String[] pathInfo) throws Exception - { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#updateTemplate(java.lang.String, - * java.lang.String[]) - */ - protected void updateTemplate(String template, String[] pathInfo) - throws Exception - { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.osjava.atom4j.servlet.AtomServlet#deleteTemplate(java.lang.String[]) - */ - protected byte[] deleteTemplate(String[] pathInfo) throws Exception - { - // TODO Auto-generated method stub - return null; - } - - /** returns the same string that it is passed, password = userName */ - public String getPassword(String userName) throws Exception - { - return userName; - } -} \ No newline at end of file diff --git a/dormant/hibernate-taglib/META-INF/taglib.tld b/dormant/hibernate-taglib/META-INF/taglib.tld deleted file mode 100644 index c1b30598..00000000 --- a/dormant/hibernate-taglib/META-INF/taglib.tld +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - 1.0 - 2.0 - hibernate - http://www.osjava.org/taglibs/hibernate-1.0 - Hibernate in a taglib. - - find - org.osjava.hibernate.taglib.FindTag - JSP - - var - true - true - - - - param - org.osjava.hibernate.taglib.ParamTag - JSP - - value - false - true - - - type - true - true - - - - create - org.osjava.hibernate.taglib.CreateTag - JSP - - var - - true - true - - - type - true - true - - - - save - org.osjava.hibernate.taglib.SaveTag - empty - - value - true - true - - - - close - org.osjava.hibernate.taglib.CloseTag - empty - - diff --git a/dormant/hibernate-taglib/org/osjava/hibernate/taglib/CloseTag.java b/dormant/hibernate-taglib/org/osjava/hibernate/taglib/CloseTag.java deleted file mode 100644 index e8b68e70..00000000 --- a/dormant/hibernate-taglib/org/osjava/hibernate/taglib/CloseTag.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.osjava.hibernate.taglib; - -import java.io.IOException; -import java.io.StringWriter; - -import java.util.List; -import java.util.Iterator; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.Enumeration; - -import javax.servlet.ServletRequest; - -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.JspTagException; -import javax.servlet.jsp.JspWriter; -import javax.servlet.jsp.tagext.TagSupport; - -import net.sf.hibernate.Session; -import net.sf.hibernate.HibernateException; -import net.sf.hibernate.Hibernate; -import net.sf.hibernate.type.Type; - -import org.apache.commons.beanutils.BeanUtils; - -import java.lang.reflect.InvocationTargetException; - -public class CloseTag extends TagSupport { - - public CloseTag() { - } - - public int doEndTag() throws JspException { - try { - Session hSession = JspUtils.getHibernateSession(pageContext); - hSession.close(); - } catch(HibernateException he) { - he.printStackTrace(); - } - - return EVAL_PAGE; - } - -} diff --git a/dormant/hibernate-taglib/org/osjava/hibernate/taglib/CreateTag.java b/dormant/hibernate-taglib/org/osjava/hibernate/taglib/CreateTag.java deleted file mode 100644 index 0e22ffab..00000000 --- a/dormant/hibernate-taglib/org/osjava/hibernate/taglib/CreateTag.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.osjava.hibernate.taglib; - -import java.io.IOException; -import java.io.StringWriter; - -import java.util.List; -import java.util.Iterator; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.Enumeration; - -import javax.servlet.ServletRequest; - -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.JspTagException; -import javax.servlet.jsp.JspWriter; -import javax.servlet.jsp.tagext.TagSupport; - -import net.sf.hibernate.Session; -import net.sf.hibernate.HibernateException; -import net.sf.hibernate.Hibernate; -import net.sf.hibernate.type.Type; - -import org.apache.commons.beanutils.BeanUtils; - -import java.lang.reflect.InvocationTargetException; - -public class CreateTag extends TagSupport { - - private String var; - private String type; - - public CreateTag() { - } - - public String getVar() { return this.var; } - public void setVar(String var) { this.var = var; } - - public String getType() { return this.type; } - public void setType(String type) { this.type = type; } - - public int doEndTag() throws JspException { - try { - Session hSession = JspUtils.getHibernateSession(pageContext); - // construct a type - Object bean = null; - try { - bean = Class.forName(type).newInstance(); - // bean = Class.forName(type, true, this.getClass().getClassLoader()).newInstance(); - } catch(ClassNotFoundException cnfe) { - // hmmmm... - cnfe.printStackTrace(); - } catch(IllegalAccessException iae) { - // hmmmh... - iae.printStackTrace(); - } catch(InstantiationException ie) { - // hmmmh... - ie.printStackTrace(); - } - - try { - // copy values from request onto the bean - BeanUtils.populate(bean, pageContext.getRequest().getParameterMap()); - // copy values from request scope onto the bean - BeanUtils.populate(bean, attributesToMap(pageContext.getRequest())); - } catch(IllegalAccessException iae) { - // hmmmh... - iae.printStackTrace(); - } catch(InvocationTargetException ite) { - // hmmmh... - ite.printStackTrace(); - } - - hSession.save(bean); - - pageContext.setAttribute(this.var, bean); - } catch(HibernateException he) { - he.printStackTrace(); - } catch(Throwable t) { - t.printStackTrace(); - } - - return EVAL_PAGE; - } - - private Map attributesToMap(ServletRequest request) { - HashMap map = new HashMap(); - Enumeration enum = request.getAttributeNames(); - while(enum.hasMoreElements()) { - String key = (String) enum.nextElement(); - map.put( key, request.getAttribute( key ) ); - } - return map; - } - -} diff --git a/dormant/hibernate-taglib/org/osjava/hibernate/taglib/FindTag.java b/dormant/hibernate-taglib/org/osjava/hibernate/taglib/FindTag.java deleted file mode 100644 index 6da04e69..00000000 --- a/dormant/hibernate-taglib/org/osjava/hibernate/taglib/FindTag.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.osjava.hibernate.taglib; - -import java.io.IOException; -import java.io.StringWriter; - -import java.util.List; -import java.util.Iterator; -import java.util.ArrayList; - -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.JspTagException; -import javax.servlet.jsp.JspWriter; -import javax.servlet.jsp.tagext.BodyTagSupport; - -import net.sf.hibernate.Hibernate; -import net.sf.hibernate.HibernateException; -import net.sf.hibernate.Session; -import net.sf.hibernate.type.Type; - -public class FindTag extends BodyTagSupport { - - private String var; - private String expected; - - private List types = new ArrayList(); - private List parameters = new ArrayList(); - - public FindTag() { - } - - public String getVar() { return this.var; } - public void setVar(String var) { this.var = var; } - - public String getExpected() { return this.expected; } - public void setExpected(String expected) { this.expected = expected; } - -// move to doStart? - public int doEndTag() throws JspException { - if(bodyContent == null) { - return EVAL_PAGE; - } - - String query = JspUtils.getBody(bodyContent); - System.out.println("QUERY: "+query); - try { - Session hSession = JspUtils.getHibernateSession(pageContext); - List categories = null; - if(this.types.size() == 0 && - this.parameters.size() == 0) - { - categories = hSession.find(query); - } else { - categories = hSession.find( - query, - convertToHibernateValueArray(this.parameters, this.types), - convertToHibernateArray(this.types) - ); - } - if("one".equals(expected)) { - if(categories.size() == 1) { - pageContext.setAttribute(this.var, categories.get(1)); - } else { - throw new JspTagException("Only one value was expected. "); - } - } else { - pageContext.setAttribute(this.var, categories); - } - } catch(HibernateException he) { - he.printStackTrace(); - } finally { - this.types.clear(); - this.parameters.clear(); - } - - return EVAL_PAGE; - } - - // convert a list of hibernate strings to the parameters... - // bit lame, but it works... - // I think this will become a String-based API to Hibernate - private Type[] convertToHibernateArray(List types) { - ArrayList list2 = new ArrayList(); - Iterator itr = types.iterator(); - while(itr.hasNext()) { - String parameter = itr.next().toString(); - if("Hibernate.LONG".equals(parameter)) { - list2.add(Hibernate.LONG); - } - } - System.err.println("L2: "+list2); - return (Type[]) list2.toArray(new Type[0]); - } - - private Object[] convertToHibernateValueArray(List values, List types) { - ArrayList list2 = new ArrayList(); - for(int i=0; inew("xmlfile") etc. - - diff --git a/dormant/integration/configs/codehaus-integration.xml b/dormant/integration/configs/codehaus-integration.xml deleted file mode 100644 index 75abc5cb..00000000 --- a/dormant/integration/configs/codehaus-integration.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dormant/integration/configs/jakarta-commons-integration.xml b/dormant/integration/configs/jakarta-commons-integration.xml deleted file mode 100644 index c42f4759..00000000 --- a/dormant/integration/configs/jakarta-commons-integration.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dormant/integration/configs/jakarta-groups.xml b/dormant/integration/configs/jakarta-groups.xml deleted file mode 100644 index fc59b929..00000000 --- a/dormant/integration/configs/jakarta-groups.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dormant/integration/configs/osjava-integration.xml b/dormant/integration/configs/osjava-integration.xml deleted file mode 100644 index 169aedc5..00000000 --- a/dormant/integration/configs/osjava-integration.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dormant/integration/configs/test-integration.xml b/dormant/integration/configs/test-integration.xml deleted file mode 100644 index 4d127b73..00000000 --- a/dormant/integration/configs/test-integration.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/dormant/integration/cron-script.sh b/dormant/integration/cron-script.sh deleted file mode 100755 index cd5fb69a..00000000 --- a/dormant/integration/cron-script.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -export JAVA_HOME=/opt/jdk -PATH=$JAVA_HOME/bin:$PATH - -export MAVEN_HOME=/home/hen/apps/maven-1.0.1 -PATH=$MAVEN_HOME/bin:$PATH - -cd /home/hen/oss/osjava/integration -/usr/bin/svn update report/ -./integrate.pl configs/osjava-integration.xml update -/usr/bin/svn status report/ | grep '^\?' | sed 's/\? *//' | xargs /usr/bin/svn add > /dev/null -/usr/bin/svn ci -m 'publishing latest integration changes' report/ -cd - diff --git a/dormant/integration/integrate.pl b/dormant/integration/integrate.pl deleted file mode 100755 index 227c1978..00000000 --- a/dormant/integration/integrate.pl +++ /dev/null @@ -1,369 +0,0 @@ -#!/usr/bin/perl -w - -use Cwd; -use File::Path; -use XML::Simple; -use Data::Dumper; -use Time::Interval; -use File::Copy; -use Template; -use POSIX qw(strftime); -use IO::Handle; -use POSIX qw(O_CREAT); - -# TODO NOTES -# Wrap configuration behind an object? -# It should be able to generate out an email report too. -# Or is this just a text version of the front page? -# config needs an email address in it for broken builds and nightly reports. -# warning system. Or should this use PMD/Checkstyle? - -sub usage() { - print "Usage:\n"; - print " ./integrate.pl foo-integration.xml all - Will build every component specified in the given xml file. \n"; - print " ./integrate.pl foo-integration.xml all - Will build only the components specified. \n"; - print " ./integrate.pl foo-integration.xml update - Will build only components that have had a changed file since the last update. \n"; - print " ./integrate.pl foo-integration.xml update - Will build only the components specified. \n"; - exit 1; -} - -# repository methods -sub checkout { - my ($repository, $project, $tag, $directory) = @_; - if($repository =~ /svn:/) { - if($tag) { - # also change the repository over to releases - $tag = '-'.$tag; - } else { - $tag = ''; - } - $repository = substr( $repository, 4 ); - system "svn co $repository/$project $directory"; - } - elsif($repository =~ /cvs:/) { - if($tag) { - $tag = '-r '.$tag; - } else { - $tag = ''; - } - $repository = substr( $repository, 3 ); - system "cvs -qd $repository co $tag -d $directory $project"; - } else { - warn "Attempt to use unknown type of repository. \n"; - } -} - -sub update { - my ($repository, $directory) = @_; - $previousDirectory = getcwd(); - chdir $directory; - if($repository =~ /svn:/) { - $repository = substr( $repository, 4 ); - $update_info = `svn update | grep -v 'At revision'`; - } - elsif($repository =~ /cvs:/) { - $repository = substr( $repository, 3 ); - $update_info = `cvs -q update -dP | grep -v '^[?MA]'`; - } else { - warn "Attempt to use unknown type of repository. \n"; - } - chdir $previousDirectory; - return $update_info; -} -# end of repository methods - -sub xdoc2html { - my ($source, $target) = @_; - open(SOURCE, $source); - open(TARGET, ">$target"); - while() { - s/document\>/html\>/; - s/properties\>/head\>/; - s/\<\/section\>//; - s/\<\/subsection\>//; - s/\
$1\<\/h1/; - s/\$1\<\/h2/; - print TARGET $_; - } -} - -if(@ARGV < 2) { - usage(); -} - -my $conf_filename = $ARGV[0]; -my $action = $ARGV[1]; - -my @filter = (); -if(@ARGV > 2) { - @filter = @ARGV[2 .. $#ARGV]; -} - -# This is pretty ugly, need to pass CONF_FILE to XMLin somehow. -open(CONF_FILE, $conf_filename) or die("Unable to open xml configuration: $!"); -close(CONF_FILE); - -my $conf = XMLin($conf_filename, forcearray=>1); -#NOT YET#$global_repository = $conf->{'buildables'}->{'repository'}; -$reportDirectory = $conf->{'site'}[0]->{'target'}; -@projects = @{$conf->{'buildables'}[0]->{'buildable'}}; - -my @build_list = (); - -# action may be 'all', 'update' - -# loop over each component in the xml - foreach $buildable (@projects) { - $project = $buildable->{'project'}; - - $repository = $buildable->{'repository'}; - $tag = $buildable->{'tag'}; - if(not $tag) { - $directory = $project; - } else { - $directory = ${project}. '_' . $tag; - } - $buildable->{'directory'} = $directory; - $buildable->{'escapedDirectory'} = $directory; - $buildable->{'escapedDirectory'} =~ s/\//_/g; - - if(@filter) { - unless(grep (/$project/, @filter)) { - next; - } - } - - # is component there? - if(-e $directory) { - if($action eq 'all' or $action eq 'update') { - # yes: do update check. - print "Updating $directory\n"; - $updated = update($repository, $directory); - $buildable->{'updated'} = $updated; - - # if all: - if($action eq 'all') { - # put in list of ones to build - build-list - push @build_list, $buildable; - } - elsif($action eq 'update' and $updated) { - # put in list of ones to build - build-list - push @build_list, $buildable; - } - } - } else { - print "Checking out $directory\n"; - # no: checkout - checkout($repository, $project, $tag, $directory); - # put in list of ones to build - build-list - push @build_list, $buildable; - } - } - - -# check if these are really needed - unlink('LAST_BUILD'); - unlink('SCM_UPDATE'); - unlink('REASON'); - mkpath($reportDirectory); - - my $failure = 0; - - # loop over each component in build-list - foreach $buildable (@build_list) { - if( not -e $buildable->{'directory'} ) { - warn "Unable to build $buildable->{'project'} as not checked out. "; - chdir $previousDirectory; - next; - } - $previousDirectory = getcwd(); - chdir $buildable->{'directory'}; - if( not -e 'project.xml' ) { - warn "Unable to build $buildable->{'project'} as not mavenised. "; - chdir $previousDirectory; - next; - } - - unlink 'maven.log', 'velocity.log', 'ERROR.log', 'OUTPUT.log', 'DOCS-ERROR.log', 'DOCS-OUTPUT.log'; - print "Building $buildable->{'project'} in $buildable->{'directory'}/\n"; - -# Build the code - $buildable->{'build_attempted'} = 1; - # install a snapshot jar - system("maven -b clean jar:install-snapshot clean jar 2> /dev/null > /dev/null"); - # build the main jar - record build-time - my $start = time(); - system("maven -b clean jar 2> ERROR.log > OUTPUT.log"); - my $end = time(); - $buildable->{'duration'} = parseInterval(seconds => $end - $start, String => 1); - - $failure = $? >> 8; - $buildable->{'failed'} = $failure; - - -# build the site - maven + ttk - print "Building documentation\n"; - if( not -e 'LICENSE.txt' ) { - sysopen(FH, "LICENSE.txt", O_CREAT); - close(FH); - } - system("maven -b maven-simian-plugin maven-jdepend-plugin:report maven-jcoverage-plugin:report checkstyle maven-junit-report-plugin:report maven-jxr-plugin:report pmd javadoc 2> DOCS-ERROR.log > DOCS-OUTPUT.log"); - system("maven -b javadoc pmd checkstyle maven-jxr-plugin:report maven-junit-report-plugin:report 2>> DOCS-ERROR.log >> DOCS-OUTPUT.log"); - # report build-time, build-date, update-reason - - my $reportDir = "${previousDirectory}/${reportDirectory}/$buildable->{'directory'}"; - -# Pisses SVN off when the .svn files go away -# rmtree($reportDir); -`find $reportDir -type f | grep -v '\.svn' | xargs rm`; -`find $reportDir -type d | grep -v '\.svn' | xargs rmdir 2>&1 | grep -v 'Directory not empty'`; - mkpath($reportDir); - - copy "ERROR.log", "$reportDir/"; - -# TODO: Rewrite these to not need things being deleted - # deploy reports -## move "target/docs/apidocs/", "$reportDir/apidocs/"; -## move "target/docs/jcoverage/", "$reportDir/jcoverage/"; -## move "target/docs/xref/", "$reportDir/xref/"; -## move "target/docs/xref-test/", "$reportDir/xref-test/"; -## TMP: Port this to Perl - if(-d "target/docs/apidocs/") { - `mkdir -p $reportDir/apidocs/`; - `cp -r target/docs/apidocs/* $reportDir/apidocs/`; - } - if(-d "target/docs/jcoverage/") { - `mkdir -p $reportDir/jcoverage/`; - `cp -r target/docs/jcoverage/* $reportDir/jcoverage/`; - } - if(-d "target/docs/xref/") { - `mkdir -p $reportDir/xref/`; - `cp -r target/docs/xref/* $reportDir/xref/`; - } - if(-d "target/docs/xref-test/") { - `mkdir -p $reportDir/xref-test/`; - `cp -r target/docs/xref-test/* $reportDir/xref-test/`; - } - - move "target/generated-xdocs/simian-report.xml", $reportDir; - move "target/generated-xdocs/pmd-report.xml", $reportDir; - move "target/generated-xdocs/jdepend-report.xml", $reportDir; -# TODO: Search and replace the image in the checkstyle-report - move "target/generated-xdocs/checkstyle-report.xml", $reportDir; - move "target/generated-xdocs/checkstyle.rss", $reportDir; -# TODO: Search and replace the image in the junit-report - move "target/generated-xdocs/junit-report.xml", $reportDir; - - # deploy targets - -## Needs to get smarter. -# DEPLOYABLES=`ls -1 target/*.?ar 2>/dev/null` -## rm -f $reportDir/$i/builds/*.jar -# DT=`date +%Y%m%d` -# for t in $DEPLOYABLES -# do -# mkdir -p $reportDir/$i/builds/ -# file_name=`echo $t | sed 's/target\///' | sed 's/\.[^\.]*ar//'` -# file_ext=`echo $t | sed 's/target\///' | sed 's/.*\.//g'` -# mv $t $reportDir/$i/builds/${file_name}-$DT.${file_ext} -# done -# -# date +"%Y/%m/%d %k:%M" > $reportDir/$i/BUILD_TIME -# if [ -e $buildDir/SCM_UPDATE ]; -# then -# cat $buildDir/SCM_UPDATE | grep "$i " > $reportDir/$i/REASON -# fi -# if [ -e $buildDir/REASON ]; -# then -# cat $buildDir/REASON > $reportDir/$i/REASON -# fi -# echo $BUILD_DURATION > $reportDir/$i/BUILD_DURATION -# -# echo "Finished with $i" -# cd - -#done - - chdir $previousDirectory; - } - - foreach $buildable (@projects) { - # see if it was a failure - my $failure = $buildable->{'failed'}; - if(not $failure) { - if(-e "$buildable->{'directory'}/ERROR.log") { - # search the error log to see if it contains certain phrases - open(ERROR_FILE, "$buildable->{'directory'}/ERROR.log"); - while() { - if( /BUILD FAILED|build cannot continue/ ) { -# seems to then grep for [ERROR] in OUTPUT.log and put this in ERROR.log - $failure = 1; - } - } - close(ERROR_FILE); - } - } - if($failure) { - if($buildable->{'build_attempted'}) { - print "Failed to build $buildable->{'project'}\n"; - if($action eq 'update') { - `cat $buildable->{'directory'}/ERROR.log | mail -s 'Failed to build $buildable->{'project'}' bayard\@osjava.org`; - } - } - $buildable->{'failed'} = "There were errors in building $buildable->{'project'}"; - } - } - -$timestamp = strftime("%Y/%m/%e %H:%M", localtime()); - - -# REPORT SYSTEM - if(@build_list) { - print "Building front page\n"; - my $tt = Template->new(); - my $input = 'templates/group.tt'; - my $vars = { - projects => \@projects, - site => $conf->{'site'}[0], - timestamp => $timestamp, - }; - $tt->process($input, $vars, "$reportDirectory/index.html") || die $tt->error(); - - foreach $buildable (@build_list) { - print "Building report for $buildable->{'project'}\n"; - - $directory = "$buildable->{'directory'}"; - - # create report pages from xml files - my %reports; - my @xml_reports = ('checkstyle', 'pmd', 'junit', 'simian', 'jdepend'); - - foreach $xml_report (@xml_reports) { - if( -e "$reportDirectory/$directory/${xml_report}-report.xml" ) { - xdoc2html("$reportDirectory/$directory/${xml_report}-report.xml", "$reportDirectory/$directory/${xml_report}-report.html"); - $reports{$xml_report} = "$directory/${xml_report}-report.html"; - } - } - - my %sub_sites = ('apidocs' => 'javadoc', 'xref' => 'source', 'jcoverage' => 'test coverage', 'builds' => 'builds'); - while( ($key, $value) = each %sub_sites) { - if(-e "$reportDirectory/$directory/$key") { - $reports{$value} = "$directory/$key"; - } - } - - # generate a report page, with links if targets of said links are available - # TODO: Make the links unactive if not available, rather than not there - my $input = 'templates/project.tt'; - my $vars = { - project => $buildable, - site => $conf->{'site'}[0], - timestamp => $timestamp, - reports => \%reports, - build_reason => $action, - error_log_filename => "$reportDirectory/".$buildable->{'directory'}."/ERROR.log", - }; - $tt->process($input, $vars, "$reportDirectory/report_".$buildable->{'escapedDirectory'}.".html") || die $tt->error(); - } - } - -exit (scalar @build_list != 0); diff --git a/dormant/integration/integroup.pl b/dormant/integration/integroup.pl deleted file mode 100755 index f9a3c664..00000000 --- a/dormant/integration/integroup.pl +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/perl -w - -use Data::Dumper; -use XML::Simple; -use Template; -use POSIX qw(strftime); - -sub usage() { - print "Usage:\n"; - print " ./groupReport.pl groups.xml - Will build a groups report for the given file. \n"; - exit 1; -} - -sub scrapeBar { - my ($file, $target) = @_; - open(BUILDABLE_INDEX, $file) or (warn("Unable to find buildable index for $file: $!\n") and return); - # somehow scrape the bar out of it - my $bar = ""; - while() { - if(// .. /<\/p>/) { - s/href="report_/href="$target\/report_/; - $bar .= $_; - } - } - close(BUILDABLE_INDEX); - return $bar; -} - -if(@ARGV < 1) { - usage(); -} - -my $conf_filename = $ARGV[0]; - -# This is pretty ugly, need to pass CONF_FILE to XMLin somehow. -open(CONF_FILE, $conf_filename) or die("Unable to open xml configuration: $!"); -close(CONF_FILE); - -my $conf = XMLin($conf_filename, forcearray=>1); -@groups = @{$conf->{'groups'}[0]->{'group'}}; -$reportDirectory = $conf->{'site'}[0]->{'target'}; - -foreach $group (@groups) { - open(CONF_FILE, $group->{'conf'}) or die("Unable to open xml configuration for $group->{'conf'}: $!"); - close(CONF_FILE); - - my $subconf = XMLin($group->{'conf'}, forcearray=>1); - $group->{'target'} = $subconf->{'site'}[0]->{'target'}; - $group->{'target'} =~ s/^\Q$reportDirectory\E//; - - $group->{'bar'} = scrapeBar("$reportDirectory/".$group->{'target'}."/index.html", $group->{'target'}); -} - -$timestamp = strftime("%Y/%m/%e %H:%M", localtime()); - -print "Building index\n"; -my $tt = Template->new(); -my $input = 'templates/frontpage.tt'; -my $vars = { - groups => \@groups, - site => $conf->{'site'}[0], - timestamp => $timestamp, -}; -$tt->process($input, $vars, "$reportDirectory/index.html") || die $tt->error(); - diff --git a/dormant/integration/templates/frontpage.tt b/dormant/integration/templates/frontpage.tt deleted file mode 100755 index 6102e399..00000000 --- a/dormant/integration/templates/frontpage.tt +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - -[% site.label %] Integration - - - - - - - - - - - - -
-
an Integration-built site
- - -[% FOREACH group IN groups -%] - -[% END -%] -
[% group.title %][% group.bar %]
- -
- diff --git a/dormant/integration/templates/group.tt b/dormant/integration/templates/group.tt deleted file mode 100644 index b061261e..00000000 --- a/dormant/integration/templates/group.tt +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - -[% site.label %] Integration - - - - - - - - - - - - -
-
an Integration-built site
- - -

-
- -[% good_count = 0 %] -[% FOREACH project IN projects -%] - [% IF project.failed %] - -[% END -%] -
- [% ELSE %] - [% good_count = good_count + 1 %] - - [% END %] -
-
[% good_count %]/[% projects.size %]
-

- - -
- diff --git a/dormant/integration/templates/project.tt b/dormant/integration/templates/project.tt deleted file mode 100644 index 760af685..00000000 --- a/dormant/integration/templates/project.tt +++ /dev/null @@ -1,43 +0,0 @@ - - - - [% site.label %] - - - - - - - - -
an Integration-built site
- - -
Last built: [% timestamp %]
[% project.project %] build took: [% project.duration %]

- -
    -[% FOREACH key IN reports.keys -%] -
  • [% key %]
  • -[% END -%] -
- -
- - [% IF project.failed %] -
[% project.failed %]
-
-
[% INSERT $error_log_filename %]
- [% ELSE %] -
Build successful.
- [% END %] - -

Built because:

[% build_reason %]

- - [% project.updated %] - - diff --git a/dormant/logview/LogViewRunner.java b/dormant/logview/LogViewRunner.java deleted file mode 100644 index af2c3827..00000000 --- a/dormant/logview/LogViewRunner.java +++ /dev/null @@ -1,232 +0,0 @@ -//package com.generationjava.scaffolds; - -import com.generationjava.compare.*; -import com.generationjava.lang.*; -import com.generationjava.logview.builder.*; -import com.generationjava.logview.filter.*; -import com.generationjava.logview.log.*; -import com.generationjava.logview.loglet.*; -import com.generationjava.logview.renderer.*; -import com.generationjava.logview.report.*; -import com.generationjava.logview.reportlet.*; -import com.generationjava.logview.source.*; -import com.generationjava.logview.*; - -public class LogViewRunner { - - String filename; - - static public void main(String[] strs) throws Exception { - LogViewRunner lvr = new LogViewRunner(); - lvr.filename = strs[0]; - lvr.test(); - } - - public void test() throws CascadedException { - test6(); - } - - // handles a very simple csv log. Uses memory and - // prints it out, then the unique file names, then - // counts all lines, counts fields. - public void test1() throws CascadedException { - try { - FileLogSource src = new FileLogSource(this.filename); - String[] hdrs = new String[] {"file", "name", "time"}; - MemoryLog initialLog = new MemoryLog("test", - hdrs); - StringDelimiterLogBuilder builder = new StringDelimiterLogBuilder(hdrs, ",", src); - builder.fillLog(initialLog); - Renderer renderer = new HtmlRenderer(); - Reportlet reportlet = new TableReportlet(); - - Loglet loglet = new NullLoglet(); - Log log = loglet.parse(initialLog); - Report report = reportlet.report(log); - renderer.render(report); - - loglet = new UniqueLoglet("file"); - log = loglet.parse(initialLog); - report = reportlet.report(log); - renderer.render(report); - - loglet = new CountLoglet(); - log = loglet.parse(initialLog); - report = reportlet.report(log); - renderer.render(report); - - loglet = new CountFieldLoglet("fileCount", "file"); - log = loglet.parse(initialLog); - report = reportlet.report(log); - renderer.render(report); - } catch(LogViewException lve) { - throw new CascadedException("Problem analysing log: ", lve); - } - } - - // Apache CLF format again. Just prints it out, - // using a MemoryLog. - public void test2() throws CascadedException { - try { - FileLogSource src = new FileLogSource(this.filename); - FormattedLogBuilder builder = new FormattedLogBuilder("${ip:IP} ${username:STRING} ${email:EMAIL} [${date:DATE}] \"${cmd:STRING} ${filename:FILE} ${protocol:STRING}\" ${code:INTEGER} ${size:INTEGER}", src); - MemoryLog initialLog = new MemoryLog("clf-test", - builder.getHeaders()); - builder.fillLog(initialLog); - Renderer renderer = new AsciiRenderer(); - Reportlet reportlet = new TableReportlet(); - - Loglet loglet = new NullLoglet(); - Log log = loglet.parse(initialLog); - Report report = reportlet.report(log); - renderer.render(report); - } catch(LogViewException lve) { - throw new CascadedException("Problem analysing log: ", lve); - } - } - - // this test takes an apache CLF file and outputs a - // list of the Unique ip addresses. The Null loglet - // will list out the CLF file in ascii-table form, - // this is commented out. You can also do a CountField - // loglet, also commented out. - // This uses a StreamLog, ie) can handle large files. - public void test3() throws CascadedException { - try { - FileLogSource src = new FileLogSource(this.filename); - FormattedLogBuilder builder = new FormattedLogBuilder("${ip:IP} ${username:STRING} ${email:EMAIL} [${date:DATE}] \"${cmd:STRING} ${filename:FILE} ${protocol:STRING}\" ${code:INTEGER} ${size:INTEGER}", src); - Log initialLog = new StreamLog("streaming-clf-test", - builder.getHeaders(), - builder); - Renderer renderer = new AsciiRenderer(); - Reportlet reportlet = new ChartReportlet("ip", "count"); - Report report = null; - - - Loglet srcLoglet = new SourceLoglet(initialLog); - // chaining concept - Loglet loglet = new NullLoglet(); - loglet.setLoglet(srcLoglet); - Log log = loglet.parse(); - // chaining happens.... -// Report report = reportlet.report(log); -// renderer.render(report); - - loglet = new CountFieldLoglet("ip"); -// loglet = new UniqueLoglet("ip"); - loglet.setLoglet(srcLoglet); - log = loglet.parse(); - Loglet sortloglet = new SortLoglet("count", 5, new ComparableComparator()); - log = sortloglet.parse(log); - report = reportlet.report(log); - report.setLink("ip", "some-url"); - renderer.render(report); - - } catch(LogViewException lve) { - throw new CascadedException("Problem analysing log: ", lve); - } - } - - public void test4() throws CascadedException { - try { - /* XML Example: - - - - - - - - - - - - - */ - FileLogSource src = new FileLogSource(this.filename); - FormattedLogBuilder builder = new FormattedLogBuilder("${ip:IP} ${username:STRING} ${email:EMAIL} [${date:DATE}] \"${cmd:STRING} ${filename:FILE} ${protocol:STRING}\" ${code:INTEGER} ${size:INTEGER}", src); - Log initialLog = new StreamLog("streaming-clf-test", - builder.getHeaders(), - builder); -// Renderer renderer = new HtmlRenderer(); - Renderer renderer = new AsciiRenderer(); - Reportlet reportlet = new ChartReportlet("ip", "count"); - Report report = null; - - - Loglet srcLoglet = new SourceLoglet(initialLog); -// Loglet filter = new FilterLoglet("Find an IP", new ContainsFilter("ip", "195.13.79")); -// filter.setLoglet(srcLoglet); - Loglet visit = new VisitLoglet("ip","date"); -// visit.setLoglet(filter); - visit.setLoglet(srcLoglet); - Loglet count = new CountFieldLoglet("ip"); - count.setLoglet(visit); -// Loglet dns = new DnsLoglet("ip"); -// dns.setLoglet(count); -// Log log = dns.parse(); - Log log = count.parse(); - Loglet sortloglet = new SortLoglet("count", 30, new ComparableComparator()); -// Loglet dns = new DnsLoglet("ip"); -// dns.setLoglet(sortloglet); -// log = dns.parse(log); - log = sortloglet.parse(log); - report = reportlet.report(log); - renderer.render(report); - - } catch(LogViewException lve) { - throw new CascadedException("Problem analysing log: ", lve); - } - } - - // handles a p6spy spy.log. Uses memory and - // counts the number of java fields - public void test5() throws CascadedException { - try { - FileLogSource src = new FileLogSource(this.filename); - String[] hdrs = new String[] {"date", "time", "unknown", "type", "java", "sql"}; - MemoryLog initialLog = new MemoryLog("test5 - p6spy", - hdrs); - StringDelimiterLogBuilder builder = new StringDelimiterLogBuilder(hdrs, "|", src); - builder.fillLog(initialLog); - - Renderer renderer = new AsciiRenderer(); - Reportlet reportlet = new ChartReportlet("java", "count"); - Report report = null; - - Loglet srcLoglet = new SourceLoglet(initialLog); - Loglet loglet = new CountFieldLoglet("java"); - loglet.setLoglet(srcLoglet); - Log log = loglet.parse(initialLog); - report = reportlet.report(log); - renderer.render(report); - } catch(LogViewException lve) { - throw new CascadedException("Problem analysing log: ", lve); - } - } - - // as above, but an average of time for the java field - public void test6() throws CascadedException { - try { - FileLogSource src = new FileLogSource(this.filename); - String[] hdrs = new String[] {"date", "time", "unknown", "type", "java", "sql"}; - MemoryLog initialLog = new MemoryLog("test5 - p6spy", - hdrs); - StringDelimiterLogBuilder builder = new StringDelimiterLogBuilder(hdrs, "|", src); - builder.fillLog(initialLog); - - Renderer renderer = new AsciiRenderer(); - Reportlet reportlet = new ChartReportlet("java", "average"); - Report report = null; - - Loglet srcLoglet = new SourceLoglet(initialLog); - Loglet loglet = new AverageFieldLoglet("java", "time"); - loglet.setLoglet(srcLoglet); - Log log = loglet.parse(initialLog); - report = reportlet.report(log); - renderer.render(report); - } catch(LogViewException lve) { - throw new CascadedException("Problem analysing log: ", lve); - } - } -} diff --git a/dormant/logview/archive/Type.java b/dormant/logview/archive/Type.java deleted file mode 100644 index f6ea111a..00000000 --- a/dormant/logview/archive/Type.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.generationjava.logview.archive; - -public interface Type { - - /** - * Is obj1 equal to obj2, within a given error value epsilon. - */ - public boolean equals(Object obj1, Object obj2, Object epsilon); - - public void setValue(Object value); - public Object getValue(); - -} diff --git a/dormant/logview/archive/type/AbstractType.java b/dormant/logview/archive/type/AbstractType.java deleted file mode 100644 index 03d526d7..00000000 --- a/dormant/logview/archive/type/AbstractType.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.generationjava.logview.type; - -import com.generationjava.logview.Type; - -abstract public class AbstractType implements Type { - - private Object value; - - public void setValue(Object value) { - this.value = value; - } - - public Object getValue() { - return this.value; - } - - public String toString() { - return value.toString(); - } - -} diff --git a/dormant/logview/archive/type/DateType.java b/dormant/logview/archive/type/DateType.java deleted file mode 100644 index 716f02b4..00000000 --- a/dormant/logview/archive/type/DateType.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.generationjava.logview.type; - -import java.util.Date; - -public class DateType extends AbstractType { - - /** - * Is obj1 equal to obj2, within a given error value epsilon. - * - * ie) 10/5/2001 17:48 and 10/5/2001 18:02 and epsilon :20 are equal - */ - public boolean equals(Object obj1, Object obj2, Object epsilon) { - if(obj1 instanceof Date) { - if(obj2 instanceof Date) { - if(epsilon instanceof Date) { - } - } - } - return false; - } - -} diff --git a/dormant/logview/archive/type/InetType.java b/dormant/logview/archive/type/InetType.java deleted file mode 100644 index a4b5c915..00000000 --- a/dormant/logview/archive/type/InetType.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.generationjava.logview.type; - -import java.net.InetAddress; - -public class InetType extends AbstractType { - - /** - * Is obj1 equal to obj2, within a given error value epsilon. - * - * Epsilon can be: 10.*.*.* so that anything inside the 10. - * range is considered equal. - */ - public boolean equals(Object obj1, Object obj2, Object epsilon) { - if(obj1 instanceof InetAddress) { - if(obj2 instanceof InetAddress) { - if(epsilon instanceof InetAddress) { - } - } - } - return false; - } - -} diff --git a/dormant/logview/build.xml b/dormant/logview/build.xml deleted file mode 100644 index e4cff489..00000000 --- a/dormant/logview/build.xml +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dormant/logview/maven.xml b/dormant/logview/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/dormant/logview/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/dormant/logview/project.properties b/dormant/logview/project.properties deleted file mode 100644 index 4a355323..00000000 --- a/dormant/logview/project.properties +++ /dev/null @@ -1,20 +0,0 @@ -maven.repo.remote=http://www.generationjava.com/jars2/,http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory - -maven.checkstyle.properties=../hen_checkstyle.xml - -maven.javadoc.stylesheet = ../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/dormant/logview/project.xml b/dormant/logview/project.xml deleted file mode 100644 index cf1589a1..00000000 --- a/dormant/logview/project.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - 3 - logview - logview - 0.5 - - GenerationJava - http://www.generationjava.com/ - /images/logo.jpg - - 2000 - com.generationjava - /images/logview-logo.jpg - - - A log reporting and analyser framework. - - - Java log analysing framework - - http://www.generationjava.com/ - - - - - - Henri Yandell - bayard - bayard@apache.org - - - Java Developer - - - - - - - - oro - 2.0.6 - - - genjava-core - genjava-core - 1.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - genjava-j2ee - 0.2 - - http://dist.osjava.org/releases/multidoc-jnr - - - - servletapi - 2.3 - - - commons-lang - 2.0 - - - commons-collections - 3.0 - - - - - - bayard@generationjava.com - - src/java - - - - diff --git a/dormant/logview/src/java/com/generationjava/logview/Log.java b/dormant/logview/src/java/com/generationjava/logview/Log.java deleted file mode 100644 index 7f890f8a..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/Log.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.generationjava.logview; - -import java.util.Iterator; - -public interface Log extends Cloneable { - - public LogIterator iterator(); - - public String getName(); - - public Iterator iterateFieldNames(); - - public Object cloneObject() throws CloneNotSupportedException; - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/LogBuilder.java b/dormant/logview/src/java/com/generationjava/logview/LogBuilder.java deleted file mode 100644 index d2f94b01..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/LogBuilder.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.generationjava.logview; - -import com.generationjava.logview.log.MemoryLog; - -public interface LogBuilder extends Cloneable { - - public void fillLog(MemoryLog log) throws LogViewException; - public LogEvent parseLogEvent() throws LogViewException; - - public boolean hasMoreEvents(); - - public LogSource getSource(); - public void setSource(LogSource source); - - public Object cloneObject() throws CloneNotSupportedException; - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/LogEvent.java b/dormant/logview/src/java/com/generationjava/logview/LogEvent.java deleted file mode 100644 index 101164b9..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/LogEvent.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.generationjava.logview; - -import java.util.Date; -import java.util.Iterator; - -public interface LogEvent { - - public Log getLog(); - public void setLog(Log log); - - public Date getTime(); - - public String getID(); - - // of Object? - public LogField get(String fieldName); - - public Iterator iterateFieldNames(); - - // public LogType getType(String fieldName); - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/LogEventContainer.java b/dormant/logview/src/java/com/generationjava/logview/LogEventContainer.java deleted file mode 100644 index 8a868d40..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/LogEventContainer.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.generationjava.logview; - -import java.util.Iterator; - -public interface LogEventContainer { - - public LogEvent getLogEvent(String logEventName); - public void putLogEvent(LogEvent logEvent); - - public Iterator iterateLogEventNames(); - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/LogField.java b/dormant/logview/src/java/com/generationjava/logview/LogField.java deleted file mode 100644 index b1b6f6fe..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/LogField.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.generationjava.logview; - -public interface LogField { - - public LogType getType(); - - public String getName(); - - public Object getValue(); - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/LogFilter.java b/dormant/logview/src/java/com/generationjava/logview/LogFilter.java deleted file mode 100644 index 43169ec9..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/LogFilter.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.generationjava.logview; - -public interface LogFilter { - - public LogEvent filter(LogEvent event); - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/LogIterator.java b/dormant/logview/src/java/com/generationjava/logview/LogIterator.java deleted file mode 100644 index dd93efe2..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/LogIterator.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.generationjava.logview; - -import java.util.Iterator; - -public interface LogIterator extends Iterator { - - public LogEvent nextLogEvent() throws LogViewException; - - public LogEvent currentLogEvent(); - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/LogSource.java b/dormant/logview/src/java/com/generationjava/logview/LogSource.java deleted file mode 100644 index 05f1fa20..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/LogSource.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.generationjava.logview; - -import java.util.Iterator; - -public interface LogSource extends Iterator { - - public String nextEntry(); - - public String currentEntry(); - - public void reset(); - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/LogType.java b/dormant/logview/src/java/com/generationjava/logview/LogType.java deleted file mode 100644 index 107698cb..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/LogType.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.generationjava.logview; - -public interface LogType { - - public String getName(); - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/LogTypes.java b/dormant/logview/src/java/com/generationjava/logview/LogTypes.java deleted file mode 100644 index d9784e66..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/LogTypes.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.generationjava.logview; - -import com.generationjava.logview.log.SimpleLogType; - -import com.generationjava.patterns.registry.ClassRegistry; -import com.generationjava.patterns.registry.Registry; - -// has to be a class to hold the static code. Arse eh? -abstract public class LogTypes { - - static public LogType STRING = new SimpleLogType("String"); - static public LogType DATE = new SimpleLogType("Date"); - static public LogType URL = new SimpleLogType("Url"); - static public LogType EMAIL = new SimpleLogType("Email"); - static public LogType TIME = new SimpleLogType("Time"); - static public LogType INTEGER = new SimpleLogType("Integer"); - static public LogType FILENAME = new SimpleLogType("Filename"); - static public LogType IP = new SimpleLogType("IP"); - static public LogType LOGEVENT = new SimpleLogType("LogEvent"); - - // static registry - static private Registry registry = new ClassRegistry(); - - static { - registry.register("String", STRING); - registry.register("Date", DATE); - registry.register("Url", URL); - registry.register("Email", EMAIL); - registry.register("Time", TIME); - registry.register("Integer", INTEGER); - registry.register("Filename", FILENAME); - registry.register("IP", IP); - registry.register("LogEvent", LOGEVENT); - } - - static public LogType getLogType(String name) { - return (LogType)registry.get(name); - } - - static public void registerLogType(String name, LogType type) { - registry.register(name, type); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/LogViewException.java b/dormant/logview/src/java/com/generationjava/logview/LogViewException.java deleted file mode 100644 index d4d464f2..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/LogViewException.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.generationjava.logview; - -import org.apache.commons.lang.exception.NestableException;; - -public class LogViewException extends NestableException { - - public LogViewException() { - super(); - } - - public LogViewException(String msg) { - super(msg); - } - - public LogViewException(Throwable t) { - super(t); - } - - public LogViewException(String msg, Throwable t) { - super(msg,t); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/LogViewRuntimeException.java b/dormant/logview/src/java/com/generationjava/logview/LogViewRuntimeException.java deleted file mode 100644 index 95f18058..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/LogViewRuntimeException.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.generationjava.logview; - -import org.apache.commons.lang.exception.NestableRuntimeException; - -public class LogViewRuntimeException extends NestableRuntimeException { - - public LogViewRuntimeException() { - super(); - } - - public LogViewRuntimeException(String msg) { - super(msg); - } - - public LogViewRuntimeException(Throwable t) { - super(t); - } - - public LogViewRuntimeException(String msg, Throwable t) { - super(msg,t); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/Loglet.java b/dormant/logview/src/java/com/generationjava/logview/Loglet.java deleted file mode 100644 index ab01d261..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/Loglet.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.generationjava.logview; - -public interface Loglet { - - public Log parse(Loglet loglet) throws LogViewException; - public Log parse(Log log) throws LogViewException; - public Log parse() throws LogViewException; - public LogEvent parseEvent(LogIterator iterator) throws LogViewException; - public boolean hasMoreEvents(LogIterator iterator); - public void setLoglet(Loglet loglet); - - public String[] getFieldNames(); - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/Renderer.java b/dormant/logview/src/java/com/generationjava/logview/Renderer.java deleted file mode 100644 index b88adf39..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/Renderer.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.generationjava.logview; - -public interface Renderer { - - public void render(Report report); - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/Report.java b/dormant/logview/src/java/com/generationjava/logview/Report.java deleted file mode 100644 index 61926bf6..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/Report.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.generationjava.logview; - -// holds the output of a Reportlet (?) -// how to chain reportlets??? - -// ability to set a Properties of presentation options -// ability to set a Link. add new Link("some url") against column "ip" -public interface Report { - - public void setLink(String field, String link); - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/Reportlet.java b/dormant/logview/src/java/com/generationjava/logview/Reportlet.java deleted file mode 100644 index bf788098..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/Reportlet.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.generationjava.logview; - -public interface Reportlet { - - public Report report(Log log) throws LogViewException; - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/builder/AbstractLogBuilder.java b/dormant/logview/src/java/com/generationjava/logview/builder/AbstractLogBuilder.java deleted file mode 100644 index 13ef54af..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/builder/AbstractLogBuilder.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.generationjava.logview.builder; - -import com.generationjava.logview.LogBuilder; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogSource; -import com.generationjava.logview.LogViewException; -import com.generationjava.logview.LogViewRuntimeException; - -import com.generationjava.logview.log.MemoryLog; - -abstract public class AbstractLogBuilder implements LogBuilder { - - private LogSource source; - - public void setSource(LogSource src) { - this.source = src; - } - - public LogSource getSource() { - return this.source; - } - - public void fillLog(MemoryLog log) throws LogViewException { - while(getSource().hasNext()) { - LogEvent event = parseLogEvent(); - event.setLog(log); - log.append(event); - } - } - - // this assumes one event per line.... - // need to do some work probably on this. - /// TODO: Figure this out. - public boolean hasMoreEvents() { - if(getSource() == null) { - throw new LogViewRuntimeException("No LogSource available"); - } - return getSource().hasNext(); - } - - public Object clone() throws CloneNotSupportedException { - return cloneObject(); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/builder/ApacheLogBuilder.java b/dormant/logview/src/java/com/generationjava/logview/builder/ApacheLogBuilder.java deleted file mode 100644 index 5492c5e7..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/builder/ApacheLogBuilder.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.generationjava.logview.builder; - -import com.generationjava.logview.LogSource; - -// handles conversion of apache log format to logview format -// specials: combined, common, referer, agent -// LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined -// LogFormat "%h %l %u %t \"%r\" %>s %b" common -// LogFormat "%{Referer}i -> %U" referer -// LogFormat "%{User-agent}i" agent -public class ApacheLogBuilder extends FormattedLogBuilder { - - static public final String COMMON = "${h} ${l} ${u} ${t} \"${r}\" ${s} ${b}"; - static public final String COMBINED = "${h} ${l} ${u} ${t} \"${r}\" ${s} ${b} \"${Referer}\" \"${User-Agent}\""; - static public final String AGENT = "${Referer} -> ${U}"; - static public final String REFERER = "${User-agent}"; - - public ApacheLogBuilder(String format, LogSource source) { - super(format, source); - } - - public void setFormat(String format) { - if(format.charAt(0) == '$') { - super.setFormat(format); - } else { - ; // TODO: parse as an apache and convert on fly to the above - } - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/builder/FormattedLogBuilder.java b/dormant/logview/src/java/com/generationjava/logview/builder/FormattedLogBuilder.java deleted file mode 100644 index c932f34e..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/builder/FormattedLogBuilder.java +++ /dev/null @@ -1,226 +0,0 @@ -package com.generationjava.logview.builder; - -import java.util.ArrayList; - -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogSource; -import com.generationjava.logview.LogTypes; -import com.generationjava.logview.LogViewException; - -import com.generationjava.logview.log.SimpleLogEvent; -import com.generationjava.logview.log.SimpleLogField; - -import com.generationjava.logview.builder.parse.*; - -// more advanced version, takes: - -//127.0.0.1 - - [16/Sep/2001:16:08:42 -0500] "GET /tomcat.gif HTTP/1.1" 200 1934 - - -//${ip:IP} ${username:STRING} ${email:EMAIL} [${date:DATE}] "${cmd:STRING} ${filename:FILE} $protocol" ${code:INTEGER} ${size:INTEGER} - -/// TODO: -//%I %u %E [%D] ... -// [] " " - -// -// then it first preparses to build a parse tree. have a: -// ParseToken, VariableParseToken and LiteralParseToken -// parsing is a case of grabbing all up until the next -// occurence of the parse token, and sticking it in the variable. -// a future version on top of this would use regexp, ie) \w -public class FormattedLogBuilder extends AbstractLogBuilder { - - // parsing state - static private final int VOID = 0; - static private final int OPEN_VAR = 1; - static private final int IN_NAME = 2; - static private final int IN_TYPE = 3; - - private ParseToken[] tokens; - private String[] headers; - - private FormattedLogBuilder() { - } - - public FormattedLogBuilder(String format, LogSource source) { - setFormat(format); - setSource(source); - } - - public String[] getHeaders() { - return this.headers; - } - - public void setFormat(String format) { - this.tokens = parseFormat(format); -// com.generationjava.util.Debug.out.println(this.tokens); - ArrayList list = new ArrayList(); - for(int i=0; i Log - LogIterator--> LogEvent - LogField - LogType - -LogViewException (needed??) - -Log -> Loglet {, Loglet ... } -> Log -Log -> Reportlet -> Report - -Report -> Renderer => Some form of specific output - - - - -QUESTIONS? -========== - -Should Reportlet's be Pipeable? - -How would one create say a TableReport, and then sort it by a -column somehow. Would a BarChartReport or a PieChartReport be -sortable? Equally, is a BarChart different to a PieChart or Table? - - YES. BarChart is different. etc. - -Or create a TableReport with counts in it and then show it in a -percent way? THIS IS A LOGLET. PercentLoglet? - -Should a Log have a LogEvent called header? How -would a Reportlet know about this? - - diff --git a/dormant/logview/src/java/com/generationjava/logview/docs/LogDesign.pdf b/dormant/logview/src/java/com/generationjava/logview/docs/LogDesign.pdf deleted file mode 100644 index 6f28e767..00000000 Binary files a/dormant/logview/src/java/com/generationjava/logview/docs/LogDesign.pdf and /dev/null differ diff --git a/dormant/logview/src/java/com/generationjava/logview/docs/PLAN b/dormant/logview/src/java/com/generationjava/logview/docs/PLAN deleted file mode 100644 index 2a42f6da..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/docs/PLAN +++ /dev/null @@ -1,182 +0,0 @@ -Plan for World Domination - LogView 2001/09/29 -============================================== - -0) Design Log objects and a Log reporting framework. - DONE. See LogDesign.pdf and DESIGN - -1) Create a simple end to end system. Easy logs, ASCII table output. - DONE. See: LogViewScaffold.java test1() for example of end to end. - -2) Parse real Apache/Tomcat logs in a generic, definable way. - PROTOTYPE. Need to throw it at Common Log Format. - DONE. Appears to parse a proper log file fine. More work needed - to make it more useful. Buildable from CLF syntax(cf 17) and XML. - -2.5) StreamLog. MemoryLog can't handle a real file due to lack of Mem. - Peaks at 60+ Meg and dies. - Need a StreamLog which switches us to piping concepts. - This will at least require a StreamLogIterator. Pass a - LogBuilder to the StreamLog's constructor. Also - need to be able to clone a Log and a Builder. - DONE - -2.5x) Redesign to stream more. Get running end to end. - DONE - Memory now peaks at 21M and it doesn't fall over. Some - questions to be asked as the design has been whittled - to allow the expected streaming design to fully work. - -2.6) Rewrite UniqueLoglet and CountFieldLoglet. DONE. - Modify Loglet structure to fit streaming. DONE. - -2.7) Create new PDFs for current changes. - -3) Output to the Web. Output bar-charts and
tables. - Prototype DONE! - -4) Handle the concept of a Visit in a generic way. MergedFieldLoglet. - [Merging log entrys into groups based on a particular field and - an epsilon value] - Later. Too hard. Going for VisitLoglet atm. - VisitLoglet DONE. - 1 known bug/lacking concerning 1 large visit overlapping 2 - 1 feature. A visit is weak, is just hits on the same day. - smaller visits. the 2 smaller ones get merged. - todo: wtf to do with the output. a special reportlet is needed :( - Visits have added the idea of a Log which contains Logs, which - is just weird. Maybe a LogContainer interface is needed, much - as a File has a Directory. - -5) Sort logs. Hook to existing genjava bean comparator scheme?? - A Loglet thing or a Reportlet thing? SortLoglet! DONE - -6) Consider meta information about Logs etc. An empty Log should - be able to tell the 'user' what fields it has and what types they are. - -7) Figure out Links. How to make an entry of a Report be shown as a - or some other form of connection to a new page. Something - special about the Reportlet, or about the Renderer, or something - you set on the Report before rendering? - Basically DONE. Very simple solution. - -8) Add type power. Date-specific handling, etc. Some standard - type repository for all builders to use, and then all loglets/reportlets - to act upon. For example, an IP would be stored as InetAddress. - -9) Setup a server with a HTTP Header parser on it. Request hits. - PARTWAY. Need to have it save the header info in a Store - static object and return a table of current browser's - seen to the browser. - Or just do this in a Servlet? Unlikely that the servlet container - will hide headers, but who knows. LANCE Doing. - -10) Build a BrowserDetectorBean. LANCE Doing. - -11) Write a DNSLoglet. Turns ip addresses into domain-names. Give - it caching. Easy. INetAddress does this. Do we need the loglet, or - just a way to stop INetAddress doing DNS lookup?? - DnsLoglet. OverlayLogEvent created as a side effect. - DONE. Need to consider a DNS cache if performance is terrible, - as it will be :) - -12) Output to PDF, WML, Swing. Output pie-graphs as PNGs. Output PNG Bar charts. - BMP. - -13) ImageMap applet that shows geographical logging. - Really this is a separate subproject. An ImageMap which can - take data that determines the colors shown. ie) Map of the world. - Pass in the count for each domain-name. Assign each domain name - to a set of co-ords, html_imagemap style. Assign each domain - name to a url. Assign a key of numbers to html-colours. - Have the ImageMap draw out the shapes(?). - -14) Email reports out. Hook to MBoxMimeMessage code. - -15) Ensure that Log4J and Custom log taglib suffice. - -16) Produce a Log that can come from Log4J directly, and/or a - Category for Log4J that goes direct to reporting. This would - probably be the ideal situation, dynamic logging rather than - later action upon a static file. - -17) Make a specialised Apache log reader that can convert the apache - custom log formatting syntax into the Logview syntax. - -LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined -LogFormat "%h %l %u %t \"%r\" %>s %b" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - - So a ApacheLogBuilder.COMBINED, ApacheLogBuilder.COMMON, REFERER, AGENT - and ApacheLogBuilder.getLogBuilder("%h %>s %b") etc. - - -17.5) Read in XML formatted logs. - - See if any pre-existing xml format exists for logs. Would assume it does. - Mail log4j? - -18) Investigate a Logger that binds directly into Tomcat. - -19) Create a system which rotates logs(?), is able to act upon partial - logs, possibly using MemoryLog for speed on the smaller logs. - Needs a way to save a log, and then more essentially, to merge - the latest partial result into the main result. - -20) Test on varying size Log files etc. - -21) Document. - -22) Optimise. - SortedLimitedList insertIntoSort can be binaryd to improve speed. - Check last and then check middle one. Etc. - -23) Add a LoggerFilter Servlet2.3 Servlet Filter spec. Nice way to do - logging of URL stuff. - -24) Decide on how StreamingLoglets and SinkLoglets work. - A SinkLoglet is one that has to merge all the events into a set of - events in one operation. It needs to provide some standard methods - for the parseEvent. Whereas a StreamingLoglet deals with parse - overloading in a different way. - Then change existing loglets to use these. - DONE. I think. - -25) Create a SinkLoglet version of SortLoglet. - Also create HeadLoglet and TailLoglet. Maybe ReverseLoglet? - Head DONE. - Tail loglet needs to store each one it gets until a size is - hit, then once its done a full sweep, it stats doling out. So - it's really a SinkLoglet. - A reverse Loglet is similar, but far heavier on memory. - -26) GrepFilterLoglet and ReplaceFilterLoglet. Create a standard FilterLoglet - which takes a LogFilter object. - FilterLoglet and LogFilter DONE. - -27) DateFilter. Takes two dates and only says yay if a column is - in between them. - - - - - -Class Todo ----------- - -VisitLoglet. MOSTLY DONE. -(FilterLoglet) - OroRegexFilterLoglet - EqualsLoglet -ChangeLoglet - ReplaceLoglet - OroSubstituteLoglet -HeadLoglet -TailLoglet -ReverseLoglet -SortLoget(Sink version) - -HtmlRenderer. - HtmlTableRenderer - HtmlChartRenderer -PngPieChartRenderer diff --git a/dormant/logview/src/java/com/generationjava/logview/filter/ContainsFilter.java b/dormant/logview/src/java/com/generationjava/logview/filter/ContainsFilter.java deleted file mode 100644 index bfdefbc0..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/filter/ContainsFilter.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.generationjava.logview.filter; - -import com.generationjava.logview.LogField; -import com.generationjava.logview.LogFilter; -import com.generationjava.logview.LogEvent; - -public class ContainsFilter implements LogFilter { - - private String field; - private String substring; - private boolean positive; - - public ContainsFilter(String field, String substring) { - this(field, substring, true); - } - - // positive match = true/false - public ContainsFilter(String field, String substring, boolean positive) { - this.field = field; - this.substring = substring; - this.positive = positive; - } - - public LogEvent filter(LogEvent event) { - LogField logField = event.get(this.field); - String value = logField.getValue().toString(); - int index = value.indexOf(substring); - - boolean ret = true; - if(index < 0) { - ret = false; - } - - if(this.positive == false) { - ret = !ret; - } - - if(ret == true) { - return event; - } else { - return null; - } - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/filter/CutFilter.java b/dormant/logview/src/java/com/generationjava/logview/filter/CutFilter.java deleted file mode 100644 index a3883b96..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/filter/CutFilter.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.generationjava.logview.filter; - -import com.generationjava.logview.LogField; -import com.generationjava.logview.LogFilter; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.log.SimpleLogField; -import com.generationjava.logview.log.OverlayLogEvent; - -public class CutFilter implements LogFilter { - - private String field; - private int cut; - - public CutFilter(String field, int cut) { - this.field = field; - this.cut = cut; - } - - public LogEvent filter(LogEvent event) { - LogField logField = event.get(this.field); - String value = logField.getValue().toString(); - value = value.substring(0,this.cut); - - OverlayLogEvent ole = new OverlayLogEvent(event); - ole.overlay( logField.getName(), new SimpleLogField(logField.getName(), - logField.getType(), value ) - ); - - event = ole; - - return event; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/filter/RegexpFilter.java b/dormant/logview/src/java/com/generationjava/logview/filter/RegexpFilter.java deleted file mode 100644 index bb9829cf..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/filter/RegexpFilter.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.generationjava.logview.filter; - -import com.generationjava.logview.LogField; -import com.generationjava.logview.LogFilter; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogViewRuntimeException; - -import org.apache.oro.text.regex.Perl5Compiler; -import org.apache.oro.text.regex.Perl5Matcher; -import org.apache.oro.text.regex.PatternMatcher; -import org.apache.oro.text.regex.Pattern; -import org.apache.oro.text.regex.MalformedPatternException; - -public class RegexpFilter implements LogFilter { - - private String field; - private Pattern pattern; - private PatternMatcher matcher = new Perl5Matcher(); - - public RegexpFilter(String field, String regexp) { - this.field = field; - Perl5Compiler p5c = new Perl5Compiler(); - try { - this.pattern = p5c.compile(regexp); - } catch(MalformedPatternException mpe) { - throw new LogViewRuntimeException("Bad regexp: "+regexp, mpe); - } - } - - public LogEvent filter(LogEvent event) { - LogField logField = event.get(this.field); - String value = logField.getValue().toString(); - - boolean match = this.matcher.contains(value, this.pattern); - - if(match) { - return event; - } else { - return null; - } - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/AbstractLogEvent.java b/dormant/logview/src/java/com/generationjava/logview/log/AbstractLogEvent.java deleted file mode 100644 index 7a88a4e3..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/AbstractLogEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.generationjava.logview.log; - -import java.util.Date; -import java.util.Iterator; - -import com.generationjava.logview.Log; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogField; - -abstract public class AbstractLogEvent implements LogEvent { - - private Log log; - - public AbstractLogEvent() { - } - - public Log getLog() { - return this.log; - } - - public void setLog(Log log) { - this.log = log; - } - - public Date getTime() { - return (Date)get("time").getValue(); - } - - public String getID() { - return (String)get("id").getValue(); - } - - abstract public LogField get(String fieldName); - - abstract public Iterator iterateFieldNames(); - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/AbstractLogIterator.java b/dormant/logview/src/java/com/generationjava/logview/log/AbstractLogIterator.java deleted file mode 100644 index 9067ff18..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/AbstractLogIterator.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.generationjava.logview.log; - -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogViewRuntimeException; -import com.generationjava.logview.LogViewException; - -abstract public class AbstractLogIterator implements LogIterator { - - private LogEvent logevent; - - protected void setCurrentLogEvent(LogEvent le) { - this.logevent = le; - } - - public LogEvent currentLogEvent() { - return this.logevent; - } - - protected LogEvent currentLogEvent(LogEvent le) { -// System.err.println("LE:"+le); - this.logevent = le; - return this.logevent; - } - - public Object next() { - try { - return nextLogEvent(); - } catch(LogViewException lve) { - throw new LogViewRuntimeException("Exception in next()", lve); - } - } - - public void remove() { - throw new UnsupportedOperationException("Cannot remove from this iterator."); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/LazyLog.java b/dormant/logview/src/java/com/generationjava/logview/log/LazyLog.java deleted file mode 100644 index b4574ce7..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/LazyLog.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.generationjava.logview.log; - -import java.util.Iterator; - -import org.apache.commons.collections.IteratorUtils; -import com.generationjava.logview.Log; -import com.generationjava.logview.Loglet; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; -import com.generationjava.logview.LogViewRuntimeException; - -// Hold a Log in memory and dole out when wanted.. -public class LazyLog implements Log { - - private Loglet loglet; - private Log log; - private String[] headers; - - private LazyLog() { - } - - public LazyLog(Loglet wrapped, Loglet loglet, String[] headers) { - this.loglet = loglet; - this.headers = headers; - try { - log = wrapped.parse(); -// System.err.println("LOG:"+log); - } catch(LogViewException lve) { - throw new LogViewRuntimeException("Unable to parse Loglet", lve); - } - } - - /// Log interface - public LogIterator iterator() { - return new LogletLogIterator(loglet, log.iterator()); - } - - public String getName() { - return log.getName(); - } - - public Iterator iterateFieldNames() { - return IteratorUtils.arrayIterator(this.headers); - } - - public Object cloneObject() throws CloneNotSupportedException { - return clone(); - } - - protected Object clone() throws CloneNotSupportedException { - LazyLog log = new LazyLog(); - log.log = (Log)this.log.cloneObject(); - log.loglet = this.loglet; - log.headers = this.headers; - return log; - } - /// end of Log interface - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/LogEventComparator.java b/dormant/logview/src/java/com/generationjava/logview/log/LogEventComparator.java deleted file mode 100644 index 97830f61..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/LogEventComparator.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.generationjava.logview.log; - -import java.util.Comparator; - -import com.generationjava.logview.LogEvent; - -public class LogEventComparator implements Comparator { - - private String field; - private Comparator comparator; - - public LogEventComparator(String field, Comparator comparator) { - this.field = field; - this.comparator = comparator; - } - - public int compare(Object obj1, Object obj2) { - if(obj1 instanceof LogEvent) { - if(obj2 instanceof LogEvent) { - LogEvent le1 = (LogEvent)obj1; - LogEvent le2 = (LogEvent)obj2; - int i= this.comparator.compare( - le1.get(this.field).getValue(), - le2.get(this.field).getValue() ); -// System.err.println(""+le1.get(this.field).getValue()+" vs "+le2.get(this.field).getValue()+" is "+i); - return i; - } - } - return 0; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/LogletLogIterator.java b/dormant/logview/src/java/com/generationjava/logview/log/LogletLogIterator.java deleted file mode 100644 index b16cee89..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/LogletLogIterator.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.generationjava.logview.log; - -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.Loglet; -import com.generationjava.logview.LogViewException; - -public class LogletLogIterator extends AbstractLogIterator { - - private Loglet loglet; - private LogIterator iterator; - - public LogletLogIterator(Loglet loglet, LogIterator iterator) { - this.loglet = loglet; - this.iterator = iterator; - } - - public LogEvent nextLogEvent() throws LogViewException { - LogEvent logevent = this.loglet.parseEvent(this.iterator); - return currentLogEvent(logevent); - } - - public boolean hasNext() { -// System.err.println(""+iterator+":"+iterator.hasNext()); - return this.loglet.hasMoreEvents(this.iterator); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/MemoryLog.java b/dormant/logview/src/java/com/generationjava/logview/log/MemoryLog.java deleted file mode 100644 index a75ba0d9..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/MemoryLog.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.generationjava.logview.log; - -import java.util.ArrayList; -import java.util.List; -import java.util.Iterator; - -import org.apache.commons.collections.IteratorUtils; -import com.generationjava.logview.Log; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogIterator; - -// Hold a Log in memory and dole out when wanted.. -public class MemoryLog implements Log { - - private String name; - private List logs; - private String[] headers; - - public MemoryLog(String name, String[] headers) { - this(name, headers, new ArrayList()); - } - - public MemoryLog(String name, String[] headers, List logs) { - this.name = name; - this.headers = headers; - this.logs = logs; - } - - /// Log interface - public void clear() { - logs.clear(); - } - - public void append(LogEvent log) { - logs.add(log); - } - - public LogIterator iterator() { -// System.err.println("ITR:"+count()); - return new SimpleLogIterator(this.logs.iterator()); - } - - public String getName() { - return this.name; - } - - public Iterator iterateFieldNames() { - return IteratorUtils.arrayIterator(this.headers); - } - /// end of Log interface - - public int count() { - return this.logs.size(); - } - - public Object cloneObject() throws CloneNotSupportedException { - return clone(); - } - - protected Object clone() throws CloneNotSupportedException { - MemoryLog log = new MemoryLog(name, headers); - log.logs = new ArrayList( logs ); - return log; - } - - public String toString() { - return ""+this.logs; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/OverlayLogEvent.java b/dormant/logview/src/java/com/generationjava/logview/log/OverlayLogEvent.java deleted file mode 100644 index cd88379c..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/OverlayLogEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.generationjava.logview.log; - -import java.util.Iterator; -import java.util.Map; -import java.util.HashMap; - -import com.generationjava.logview.Log; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogField; - -public class OverlayLogEvent extends AbstractLogEvent { - - private LogEvent event; - private Map overlays; - - public OverlayLogEvent(LogEvent event) { - this.event = event; - this.overlays = new HashMap(); - } - - public Log getLog() { - return this.event.getLog(); - } - - public void setLog(Log log) { - this.event.setLog(log); - } - - public LogField get(String fieldName) { - if(this.overlays.containsKey(fieldName)) { - return (LogField)this.overlays.get(fieldName); - } else { - return this.event.get(fieldName); - } - } - - public Iterator iterateFieldNames() { - return this.event.iterateFieldNames(); - } - - public void overlay(String fieldName, LogField value) { - this.overlays.put(fieldName, value); - } -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/SimpleLogEvent.java b/dormant/logview/src/java/com/generationjava/logview/log/SimpleLogEvent.java deleted file mode 100644 index bae7fe08..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/SimpleLogEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.generationjava.logview.log; - -import java.util.Iterator; -import java.util.Map; -import java.util.HashMap; - -import com.generationjava.logview.LogField; - -public class SimpleLogEvent extends AbstractLogEvent { - - private Map fields = new HashMap(); - - public SimpleLogEvent() { - } - - public LogField get(String fieldName) { - return (LogField)fields.get(fieldName); - } - - public Iterator iterateFieldNames() { - return fields.keySet().iterator(); - } - - public void set(LogField field) { - this.set(field.getName(), field); - } - - public void set(String name, LogField field) { - fields.put(name, field); - } - - public String toString() { - return ""+fields; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/SimpleLogField.java b/dormant/logview/src/java/com/generationjava/logview/log/SimpleLogField.java deleted file mode 100644 index 47fb376b..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/SimpleLogField.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.generationjava.logview.log; - -import com.generationjava.logview.LogField; -import com.generationjava.logview.LogType; -import com.generationjava.logview.LogTypes; - -public class SimpleLogField implements LogField { - - private Object value; - private LogType type; - private String name; - - public SimpleLogField(String name, Object value) { - this(name, LogTypes.STRING, value); - } - - public SimpleLogField(String name, LogType type, Object value) { - this.name = name; - this.type = type; - this.value = value; - } - - public String getName() { - return this.name; - } - - public LogType getType() { - return this.type; - } - - public Object getValue() { - return this.value; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/SimpleLogIterator.java b/dormant/logview/src/java/com/generationjava/logview/log/SimpleLogIterator.java deleted file mode 100644 index 4de455a4..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/SimpleLogIterator.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.generationjava.logview.log; - -import java.util.Iterator; - -import com.generationjava.logview.LogEvent; - -public class SimpleLogIterator extends AbstractLogIterator { - - private Iterator iterator; - - public SimpleLogIterator(Iterator iterator) { - this.iterator = iterator; - } - - public LogEvent nextLogEvent() { - LogEvent logevent = (LogEvent)this.iterator.next(); - return currentLogEvent( logevent ); - } - - public boolean hasNext() { -// System.err.println("zip"); - return this.iterator.hasNext(); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/SimpleLogType.java b/dormant/logview/src/java/com/generationjava/logview/log/SimpleLogType.java deleted file mode 100644 index e0d75443..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/SimpleLogType.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.generationjava.logview.log; - -import com.generationjava.logview.LogType; -import com.generationjava.lang.Constant; - -public class SimpleLogType extends Constant implements LogType { - - public SimpleLogType(String name) { - super(name); - } - - public String getName() { - return (String)getValue(); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/StreamLog.java b/dormant/logview/src/java/com/generationjava/logview/log/StreamLog.java deleted file mode 100644 index 792abf2f..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/StreamLog.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.generationjava.logview.log; - -import java.util.Iterator; - -import org.apache.commons.collections.IteratorUtils; -import com.generationjava.logview.Log; -import com.generationjava.logview.LogBuilder; -import com.generationjava.logview.LogIterator; - -// A log which can stream the log-events through the system. -public class StreamLog implements Log { - - private String name; - private String[] headers; - private LogBuilder builder; - - public StreamLog(String name, String[] headers, LogBuilder builder) { - this.name = name; - this.headers = headers; - this.builder = builder; - } - - /// Log interface - public LogIterator iterator() { - try { - return new StreamingLogIterator( (LogBuilder)builder.cloneObject() ); - } catch(CloneNotSupportedException cnse) { -// System.err.println("ARGH"); - return null; - } - } - - public String getName() { - return this.name; - } - - public Iterator iterateFieldNames() { - return IteratorUtils.arrayIterator(this.headers); - } - - protected Object clone() throws CloneNotSupportedException { - return new StreamLog( this.name, this.headers, (LogBuilder)builder.cloneObject() ); - } - - /// end of Log interface - - public Object cloneObject() throws CloneNotSupportedException { - return clone(); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/log/StreamingLogIterator.java b/dormant/logview/src/java/com/generationjava/logview/log/StreamingLogIterator.java deleted file mode 100644 index 9c7113ed..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/log/StreamingLogIterator.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.generationjava.logview.log; - -import com.generationjava.logview.LogBuilder; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogViewException; - -public class StreamingLogIterator extends AbstractLogIterator { - - private LogBuilder builder; - - public StreamingLogIterator(LogBuilder builder) { - this.builder = builder; - } - - public LogEvent nextLogEvent() throws LogViewException { - return currentLogEvent( builder.parseLogEvent() ); - } - - public boolean hasNext() { - return this.builder.hasMoreEvents(); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/AbstractLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/AbstractLoglet.java deleted file mode 100644 index df84a0f4..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/AbstractLoglet.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.generationjava.logview.loglet; - -import com.generationjava.logview.Log; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.Loglet; -import com.generationjava.logview.LogViewException; - -import com.generationjava.logview.log.LazyLog; - -abstract public class AbstractLoglet implements Loglet { - - private Loglet loglet; - private String name; - - public AbstractLoglet(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - - public Log parse(Log log) throws LogViewException { - setLoglet(new SourceLoglet(log)); - return parse(); - } - - public Log parse(Loglet loglet) throws LogViewException { - setLoglet(loglet); - return parse(); - } - - // really for a StreamLoglet, but works fine for a SinkLoglet - // too. Possibly have SinkLoglet do some kind of MemoryLog - // returning nonsense. - // TODO abvoe. - public Log parse() throws LogViewException { - return new LazyLog(getLoglet(), this, getFieldNames()); - } - - public void setLoglet(Loglet loglet) { - this.loglet = loglet; - } - - public Loglet getLoglet() { - return this.loglet; - } - - public String[] getFieldNames() { - return loglet.getFieldNames(); - } - - public boolean hasMoreEvents(LogIterator logIt) { - return logIt.hasNext(); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/AverageFieldLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/AverageFieldLoglet.java deleted file mode 100644 index 1fc44ccc..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/AverageFieldLoglet.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.generationjava.logview.loglet; - -import java.util.Iterator; - -import java.util.HashMap; - -import com.generationjava.math.Average; -import org.apache.commons.lang.NumberUtils; - -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogField; -import com.generationjava.logview.LogTypes; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; - -import com.generationjava.logview.log.MemoryLog; -import com.generationjava.logview.log.SimpleLogEvent; -import com.generationjava.logview.log.SimpleLogField; - -// Takes the average of a field based on another field. So like -// CountField except that it does different maths. These -// therefore need refactoring into a 'GroupByThisMaths'Loglet -public class AverageFieldLoglet extends SinkLoglet { - - private String field; - private String numberField; - - // hold result in so it can be dolled out one at a time - private LogIterator myIterator; - - // iterator we're currently working on - private LogIterator argIterator; - - public AverageFieldLoglet(String field, String numberField) { - this("Average-"+field, field, numberField); - } - public AverageFieldLoglet(String name, String field, String numberField) { - super(name); - this.field = field; - this.numberField = numberField; - } - - public String[] getFieldNames() { - return new String[] { this.field, "average" }; - } - - public boolean hasMoreEvents(LogIterator logIt) { - if(myIterator == null) { - return logIt.hasNext(); - } else { - return myIterator.hasNext(); - } - } - - public LogEvent parseEvent(LogIterator logIt) throws LogViewException { - if( (myIterator != null) && (logIt == argIterator) ) { - if(myIterator.hasNext()) { - return myIterator.nextLogEvent(); - } else { - return null; - } - } - - this.argIterator = logIt; - - LogEvent event = null; - LogField logfield = null; - HashMap map = new HashMap(); - HashMap fieldsMap = new HashMap(); - - while(logIt.hasNext()) { - event = logIt.nextLogEvent(); - logfield = event.get(this.field); - if(logfield != null) { - Object value = logfield.getValue(); - - // just save this for later. - fieldsMap.put(value, logfield); - - LogField numberLogField = event.get(this.numberField); - if(numberLogField == null) { - System.err.println("Had null numberLogField. Treat as non-existent. "); - continue; - } - Object numberValue = numberLogField.getValue(); - if(!(numberValue instanceof Number)) { - numberValue = NumberUtils.createNumber(numberValue.toString()); - } - int num = ((Number)numberValue).intValue(); - Object obj = (Object)map.get( value ); - if(obj == null) { - map.put(value, new Average(num)); - } else { - Average avg = (Average)obj; - avg.add(num); - } - } else { - // throw exception... - System.err.println("Had null field: " +this.field); - } - } - - // now have a map of value to its average - // so we turn this into a log to pass on - - MemoryLog ml = new MemoryLog(getName(), getFieldNames()); - - Iterator iterator = map.keySet().iterator(); - while(iterator.hasNext()) { - SimpleLogEvent newevent = new SimpleLogEvent(); - newevent.setLog( ml ); - Object key = iterator.next(); - Average avg = (Average)map.get(key); - logfield = new SimpleLogField( - "average", - LogTypes.INTEGER, - new Integer( avg.average() ) ); - newevent.set(logfield); - newevent.set((LogField)fieldsMap.get(key)); - - ml.append( newevent ); - } - this.myIterator = ml.iterator(); - - return parseEvent(argIterator); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/CountFieldLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/CountFieldLoglet.java deleted file mode 100644 index a6782199..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/CountFieldLoglet.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.generationjava.logview.loglet; - -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.collections.MultiMap; -import org.apache.commons.collections.MultiHashMap; -import org.apache.commons.collections.SequencedHashMap; - -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogField; -import com.generationjava.logview.LogTypes; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; - -import com.generationjava.logview.log.MemoryLog; -import com.generationjava.logview.log.SimpleLogEvent; -import com.generationjava.logview.log.SimpleLogField; - -public class CountFieldLoglet extends SinkLoglet { - - private String field; - - // hold result in so it can be dolled out one at a time - private LogIterator myIterator; - - // iterator we're currently working on - private LogIterator argIterator; - - public CountFieldLoglet(String field) { - this("Count-"+field, field); - } - public CountFieldLoglet(String name, String field) { - super(name); - this.field = field; - } - - public String[] getFieldNames() { - return new String[] { this.field, "count", "total" }; - } - - public boolean hasMoreEvents(LogIterator logIt) { - if(myIterator == null) { - return logIt.hasNext(); - } else { - return myIterator.hasNext(); - } - } - - public LogEvent parseEvent(LogIterator logIt) throws LogViewException { -// System.err.println("bing"); - if( (myIterator != null) && (logIt == argIterator) ) { - if(myIterator.hasNext()) { -// System.err.println("bing1"); - return myIterator.nextLogEvent(); - } else { -// System.err.println("bing2"); - return null; - } - } - - this.argIterator = logIt; - - LogEvent event = null; - LogField logfield = null; - MultiMap map = new MultiHashMap(new SequencedHashMap()); - int sz = 0; - - while(logIt.hasNext()) { - event = logIt.nextLogEvent(); - logfield = event.get(this.field); - if(logfield != null) { - map.put( logfield.getValue(), logfield ); - sz++; - } else { - System.err.println("Had null logfield."); - } - } - - MemoryLog ml = new MemoryLog(getName(), getFieldNames()); - - SimpleLogField total = new SimpleLogField( "total", LogTypes.INTEGER, - new Integer(sz) ); - - Iterator iterator = map.values().iterator(); - while(iterator.hasNext()) { - SimpleLogEvent newevent = new SimpleLogEvent(); - newevent.setLog( ml ); - Object obj = iterator.next(); - - if(obj instanceof List) { - logfield = new SimpleLogField( - "count", - LogTypes.INTEGER, - new Integer( ((List)obj).size() ) ); - newevent.set(logfield); - newevent.set( (LogField)((List)obj).get(0) ); - } else { - logfield = new SimpleLogField( - "count", - LogTypes.INTEGER, - new Integer(1) ); - newevent.set(logfield); - newevent.set( (LogField)obj ); - } - newevent.set( total ); - ml.append( newevent ); -//sz++; - } -//System.err.println("SZ:"+sz); - this.myIterator = ml.iterator(); - - return parseEvent(argIterator); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/CountLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/CountLoglet.java deleted file mode 100644 index cf7d9c2a..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/CountLoglet.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.generationjava.logview.loglet; - -import com.generationjava.logview.Log; -import com.generationjava.logview.LogTypes; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; - -import com.generationjava.logview.log.MemoryLog; -import com.generationjava.logview.log.SimpleLogEvent; -import com.generationjava.logview.log.SimpleLogField; - -public class CountLoglet extends SinkLoglet { - - public CountLoglet() { - this("Count"); - } - public CountLoglet(String name) { - super(name); - } - - public String[] getFieldNames() { - return new String[] { "count" }; - } - - public Log parse(Log log) throws LogViewException { - int sz = 0; - if(log instanceof MemoryLog) { - sz = ( (MemoryLog)log ).count(); - } else { - LogIterator logIt = log.iterator(); - while(logIt.hasNext()) { - logIt.next(); - sz++; - } - } - - // create a very simple Log object - MemoryLog ml = new MemoryLog(getName(), getFieldNames()); - - SimpleLogEvent event = new SimpleLogEvent(); - event.setLog( ml ); - SimpleLogField field = new SimpleLogField( "count", LogTypes.INTEGER, new Integer(sz)); - event.set("count", field); - ml.append( event ); - - return ml; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/DnsLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/DnsLoglet.java deleted file mode 100644 index be31f9fd..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/DnsLoglet.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.generationjava.logview.loglet; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogField; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; - -import com.generationjava.logview.log.OverlayLogEvent; -import com.generationjava.logview.log.SimpleLogField; - -public class DnsLoglet extends SinkLoglet { - - private String field; - - public DnsLoglet(String field) { - this("Nslookup-"+field, field); - } - public DnsLoglet(String name, String field) { - super(name); - this.field = field; - } - - public LogEvent parseEvent(LogIterator logIt) throws LogViewException { - LogEvent event = logIt.nextLogEvent(); - String logfield = event.get(this.field).getValue().toString(); - try { - InetAddress inet = InetAddress.getByName(logfield); - if(inet.getHostName().equals(inet.getHostAddress())) { - return event; - } - OverlayLogEvent overlay = new OverlayLogEvent(event); - LogField logField = new SimpleLogField(this.field, inet.getHostName()); - overlay.overlay(this.field, logField); - return overlay; - } catch(UnknownHostException uhe) { - System.err.println("Non-existant IP: "+logfield); - return event; - } - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/FilterLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/FilterLoglet.java deleted file mode 100644 index f7aea5d7..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/FilterLoglet.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.generationjava.logview.loglet; - -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogFilter; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; - -public class FilterLoglet extends StreamLoglet { - - private LogFilter filter; - private LogEvent cache; - - public FilterLoglet(LogFilter filter) { - this("Filter", filter); - } - public FilterLoglet(String name, LogFilter filter) { - super(name); - this.filter = filter; - } - - public boolean hasMoreEvents(LogIterator logIt) { - if(!logIt.hasNext()) { - return false; - } - - try { - cache = parseEvent(logIt); - } catch(LogViewException lve) { - lve.printStackTrace(); - } - - return (cache != null); - - } - - public LogEvent parseEvent(LogIterator logIt) throws LogViewException { - LogEvent event; - - if(cache != null) { - event = cache; - cache = null; - return event; - } else { - event = logIt.nextLogEvent(); - } - - while(true) { - event = this.filter.filter(event); - if(event != null) { - return event; - } else - if(logIt.hasNext()) { - event = logIt.nextLogEvent(); - } else { - break; - } - } - - return null; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/HeadLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/HeadLoglet.java deleted file mode 100644 index 2af2a273..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/HeadLoglet.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.generationjava.logview.loglet; - -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; - -public class HeadLoglet extends StreamLoglet { - - private int count; - - public HeadLoglet(int count) { - this("Head", count); - } - public HeadLoglet(String name, int count) { - super(name); - this.count = count; - } - - public boolean hasMoreEvents(LogIterator logIt) { - return (this.count != 0); - } - - public LogEvent parseEvent(LogIterator logIt) throws LogViewException { - if(this.count != 0) { - this.count--; - return logIt.nextLogEvent(); - } - - return null; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/NullLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/NullLoglet.java deleted file mode 100644 index 8f10e261..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/NullLoglet.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.generationjava.logview.loglet; - -import com.generationjava.logview.Log; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; - -public class NullLoglet extends AbstractLoglet { - - public NullLoglet() { - this("Null"); - } - - public NullLoglet(String name) { - super(name); - } - - public Log parse() throws LogViewException { - return getLoglet().parse(); - } - - public LogEvent parseEvent(LogIterator iterator) throws LogViewException { - return getLoglet().parseEvent(iterator); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/SinkLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/SinkLoglet.java deleted file mode 100644 index 77badac5..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/SinkLoglet.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.generationjava.logview.loglet; - -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; - -// A Loglet that Sinks all the LogEvents. -abstract public class SinkLoglet extends AbstractLoglet { - - private LogIterator cache; - - public SinkLoglet(String name) { - super(name); - } - - public LogEvent parseEvent(LogIterator iterator) throws LogViewException { - if(cache == null) { - cache = parse().iterator(); - } - - if(cache.hasNext()) { - return cache.nextLogEvent(); - } else { - return null; - } - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/SortLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/SortLoglet.java deleted file mode 100644 index 75c383aa..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/SortLoglet.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.generationjava.logview.loglet; - -import java.util.Comparator; -import java.util.List; - -import com.generationjava.collections.CollectionsW; -import com.generationjava.collections.SortedLimitedList; - -import com.generationjava.logview.Log; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; - -import com.generationjava.logview.log.LogEventComparator; -import com.generationjava.logview.log.MemoryLog; - -public class SortLoglet extends SinkLoglet { - - private String field; - private int capacity; - private Comparator comparator; - - public SortLoglet(String field, int capacity, Comparator comparator) { - this("Sorted-by-"+field, field, capacity, comparator); - } - public SortLoglet(String name, String field, int capacity, Comparator comparator) { - super(name); - this.field = field; - this.capacity = capacity; - this.comparator = comparator; - } - - public Log parse(Log log) throws LogViewException { - LogEvent event; - - List sllist = new SortedLimitedList(this.capacity, new LogEventComparator(this.field, this.comparator)); - - - LogIterator logIt = log.iterator(); - // sorting happens here - while(logIt.hasNext()) { - event = logIt.nextLogEvent(); - sllist.add(event); - } - - MemoryLog ml = new MemoryLog(getName(), (String[])CollectionsW.iteratorToArray(log.iterateFieldNames(), new String[0]), sllist); - - return ml; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/SourceLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/SourceLoglet.java deleted file mode 100644 index 01e3fe93..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/SourceLoglet.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.generationjava.logview.loglet; - -import com.generationjava.collections.CollectionsW; - -import com.generationjava.logview.Log; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; - -public class SourceLoglet extends AbstractLoglet { - - private Log log; - - public SourceLoglet(Log log) { - this("Source", log); - } - - public SourceLoglet(String name, Log log) { - super(name); - this.log = log; - } - - public Log parse() { - return this.log; - } - - public String[] getFieldNames() { - return (String[])CollectionsW.iteratorToArray( log.iterateFieldNames(), new String[0] ); - } - - public LogEvent parseEvent(LogIterator iterator) throws LogViewException { - if(iterator.hasNext()) { - return iterator.nextLogEvent(); - } else { - throw new LogViewException("Used iterator passed in."); - } - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/StreamLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/StreamLoglet.java deleted file mode 100644 index fa8937a2..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/StreamLoglet.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.generationjava.logview.loglet; - -abstract public class StreamLoglet extends AbstractLoglet { - - public StreamLoglet(String name) { - super(name); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/UniqueLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/UniqueLoglet.java deleted file mode 100644 index d69af7da..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/UniqueLoglet.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.generationjava.logview.loglet; - -import java.util.HashMap; - -import com.generationjava.logview.Log; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogField; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; - -import com.generationjava.logview.log.MemoryLog; -import com.generationjava.logview.log.SimpleLogEvent; - -public class UniqueLoglet extends AbstractLoglet { - - private String field; - private HashMap map; - - public UniqueLoglet(String field) { - this("Unique", field); - } - public UniqueLoglet(String name, String field) { - super(name); - this.field = field; - map = new HashMap(); - } - - public String[] getFieldNames() { - return new String[] { this.field }; - } - - public Log parse() throws LogViewException { - MemoryLog ml = new MemoryLog(getName(), getFieldNames()); - LogEvent event = null; - - LogIterator logIt = getLoglet().parse().iterator(); - while(hasMoreEvents(logIt)) { - event = parseEvent(logIt); - if(event != null) { - ml.append(event); - event.setLog( ml ); - } - } - - return ml; - } - - public LogEvent parseEvent(LogIterator logIt) throws LogViewException { - LogEvent event = logIt.nextLogEvent(); - LogField logfield = event.get(this.field); - - if(map.containsKey( logfield.getValue() )) { - return null; - } else { - SimpleLogEvent newevent = new SimpleLogEvent(); - newevent.set(this.field, logfield); - map.put( logfield.getValue(), logfield ); - - return newevent; - } - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/loglet/VisitLoglet.java b/dormant/logview/src/java/com/generationjava/logview/loglet/VisitLoglet.java deleted file mode 100644 index 719ff631..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/loglet/VisitLoglet.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.generationjava.logview.loglet; - -import java.util.ArrayList; -import java.util.HashMap; - -import org.apache.commons.collections.SequencedHashMap; - -import org.apache.commons.lang.StringUtils; - -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogTypes; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; - -import com.generationjava.logview.log.SimpleLogEvent; -import com.generationjava.logview.log.SimpleLogField; - -/// A very specialised Loglet. a MergedFieldLoglet would be nice, -/// but it's hard to genericise to that point in a sensible way. -/// TODO: fix bug with 1 large visit overlapping 2 small visits -public class VisitLoglet extends AbstractLoglet { - - private String ipField; - private String dateField; - private String[] fieldNames; - - private HashMap currentIpMap = new HashMap(); - private SequencedHashMap queueMap = new SequencedHashMap(); - - // is the log iterator dead? - - public VisitLoglet(String ipField, String dateField) { - this("Visit", ipField, dateField); - } - public VisitLoglet(String name, String ipField, String dateField) { - super(name); - this.ipField = ipField; - this.dateField = dateField; - this.fieldNames = new String[] { dateField, ipField, "logevent" }; - } - - public String[] getFieldNames() { - return this.fieldNames; - } - - public boolean hasMoreEvents(LogIterator logIt) { - return logIt.hasNext() || !queueMap.isEmpty(); - } - - public LogEvent parseEvent(LogIterator logIt) throws LogViewException { - String ip; - String lastDate; - - if(queueMap.isEmpty()) { - // get next event - LogEvent event = logIt.nextLogEvent(); - ip = event.get(this.ipField).getValue().toString(); - lastDate = event.get(this.dateField).getValue().toString(); - lastDate = StringUtils.getPrechomp(lastDate, ":"); - - SimpleLogEvent newIpEvent = new SimpleLogEvent(); - ArrayList events = new ArrayList(); - events.add(event); - newIpEvent.set(new SimpleLogField("logevent", LogTypes.LOGEVENT, events)); - newIpEvent.set(new SimpleLogField(this.dateField, LogTypes.DATE, lastDate)); - newIpEvent.set(new SimpleLogField(this.ipField, LogTypes.IP, ip)); - queueMap.put(ip, lastDate); - // what to put in here as the value??? used to be MultiMap - currentIpMap.put(ip, newIpEvent); - } else { - ip = (String)queueMap.get(0); - lastDate = (String)queueMap.get(ip); - } -// System.err.println("Considering: "+ip+","+lastDate); - - if(!logIt.hasNext()) { - // iterator finished, return from cache - LogEvent event = (LogEvent)currentIpMap.get(ip); - currentIpMap.remove(ip); - queueMap.remove(0); - return event; - } - - while(true) { - if(!logIt.hasNext()) { - // iterator empty, start to empty cache - LogEvent event = (LogEvent)currentIpMap.get(ip); - currentIpMap.remove(ip); - queueMap.remove(0); - return event; - } - - LogEvent event = logIt.nextLogEvent(); - String tmpIp = event.get(this.ipField).getValue().toString(); - String tmpDate = event.get(this.dateField).getValue().toString(); - boolean sameVisit = equalsEpsilon(lastDate, tmpDate); - tmpDate = StringUtils.getPrechomp(tmpDate, ":"); - - if(ip.equals(tmpIp)) { - if(!sameVisit) { - // return the entry in the currentIpMap - // remove from head of queue map - // remove from currentIpMap - SimpleLogEvent ipEvent = (SimpleLogEvent)currentIpMap.get(ip); - ArrayList events = new ArrayList(); - events.add(event); - SimpleLogEvent newIpEvent = new SimpleLogEvent(); - newIpEvent.set(new SimpleLogField("logevent", LogTypes.LOGEVENT, events)); - newIpEvent.set(new SimpleLogField(this.dateField, LogTypes.DATE, tmpDate)); - newIpEvent.set(new SimpleLogField(this.ipField, LogTypes.IP, ip)); - currentIpMap.remove(ip); - queueMap.remove(0); - queueMap.put(ip, tmpDate); - currentIpMap.put(ip, newIpEvent); - return ipEvent; - } else { - // add event onto its list of events for this visit - SimpleLogEvent ipEvent = (SimpleLogEvent)currentIpMap.get(ip); - ArrayList events = (ArrayList)ipEvent.get("logevent").getValue(); - events.add(event); - } - } else { - // different ip. put in the map properly for the future - SimpleLogEvent ipEvent; - ArrayList events; - if(!queueMap.containsKey(tmpIp)) { - ipEvent = new SimpleLogEvent(); - events = new ArrayList(); - ipEvent.set(new SimpleLogField("logevent", LogTypes.LOGEVENT, events)); - ipEvent.set(new SimpleLogField(this.dateField, LogTypes.DATE, tmpDate)); - ipEvent.set(new SimpleLogField(this.ipField, LogTypes.IP, tmpIp)); - queueMap.put(tmpIp, tmpDate); - currentIpMap.put(tmpIp, ipEvent); - } else { - ipEvent = (SimpleLogEvent)currentIpMap.get(tmpIp); - events = (ArrayList)ipEvent.get("logevent").getValue(); - // should be checking if its the sameVisit and somehow - // creating a new one on the end... - // so queueMap needs to be able to have duplicate keys. - } - events.add(event); - - // is this new diff log outside of our epsilon? - // if so then we assume log is sorted and skip out - if(!sameVisit) { - ipEvent = (SimpleLogEvent)currentIpMap.get(ip); - currentIpMap.remove(ip); - queueMap.remove(0); - return ipEvent; - } - } - } - } - - // very simple to begin with - // is it on the same day. - // date1 has already been prechomped - public boolean equalsEpsilon(String date1, String date2) { - String day1 = date1; - String day2 = StringUtils.getPrechomp(date2, ":"); - return day1.equals(day2); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/package.html b/dormant/logview/src/java/com/generationjava/logview/package.html deleted file mode 100644 index c0d2cedc..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/package.html +++ /dev/null @@ -1,8 +0,0 @@ - - -

- A format-generic log reporting system. Quite nice, finished, just needs - loglets to be added. -

- - diff --git a/dormant/logview/src/java/com/generationjava/logview/renderer/AbstractRenderer.java b/dormant/logview/src/java/com/generationjava/logview/renderer/AbstractRenderer.java deleted file mode 100644 index c96a06b7..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/renderer/AbstractRenderer.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.generationjava.logview.renderer; - -import com.generationjava.logview.Renderer; -import com.generationjava.logview.Report; - -import com.generationjava.logview.report.TableReport; -import com.generationjava.logview.report.ChartReport; - -abstract public class AbstractRenderer implements Renderer { - - public void render(Report report) { - if(report instanceof TableReport) { - System.out.println( renderTable((TableReport)report) ); - } else - if(report instanceof ChartReport) { - System.out.println( renderChart((ChartReport)report) ); - } - } - - abstract public String renderTable(TableReport report); - abstract public String renderChart(ChartReport report); - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/renderer/AsciiRenderer.java b/dormant/logview/src/java/com/generationjava/logview/renderer/AsciiRenderer.java deleted file mode 100644 index 13d84628..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/renderer/AsciiRenderer.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.generationjava.logview.renderer; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.apache.commons.lang.StringUtils; - -import com.generationjava.logview.report.ChartReport; -import com.generationjava.logview.report.TableReport; - -public class AsciiRenderer extends AbstractRenderer { - - public String renderTable(TableReport table) { - StringBuffer buffer = new StringBuffer(); - buffer.append(":"); - buffer.append(table.getHeader()); - buffer.append(":\n"); - buffer.append( StringUtils.repeat("=", table.getHeader().length()+2 ) ); - buffer.append("\n"); - Iterator iterator = table.iterator(); - while(iterator.hasNext()) { - Iterator sub = ((ArrayList)iterator.next()).iterator(); - buffer.append(":"); - if(sub.hasNext()) { - while(sub.hasNext()) { - buffer.append(sub.next()); - buffer.append(":"); - } - } else { - buffer.append(":"); - } - buffer.append("\n"); - } - return buffer.toString(); - } - - public String renderChart(ChartReport chart) { - // assume yField is a number - Iterator iterator = chart.iterateKeys(); - StringBuffer buffer = new StringBuffer(); - float ratio = 40F / chart.getYMax(); - - String xField = chart.getXField(); - - buffer.append(xField); - if(chart.getLink(xField) != null) { - buffer.append("[cf."); - buffer.append(chart.getLink(xField)); - buffer.append("]"); - } - buffer.append("\t"); - buffer.append(chart.getYField()); - buffer.append("\n"); - while(iterator.hasNext()) { - Object key = iterator.next(); - - Number value = (Number)chart.getData(key); - int count = value.intValue(); - buffer.append(key); - buffer.append("\t"); - count *= ratio; - for(int i=count; i>0; i--) { - buffer.append("*"); - } - for(int i=count; i<40; i++) { - buffer.append(" "); - } - buffer.append("\t"); - buffer.append(value.intValue()); - buffer.append("\n"); - } - - return buffer.toString(); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/renderer/HtmlRenderer.java b/dormant/logview/src/java/com/generationjava/logview/renderer/HtmlRenderer.java deleted file mode 100644 index 84b023c4..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/renderer/HtmlRenderer.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.generationjava.logview.renderer; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.apache.commons.lang.StringUtils; - -import com.generationjava.logview.report.ChartReport; -import com.generationjava.logview.report.TableReport; - -public class HtmlRenderer extends AbstractRenderer { - - public String renderTable(TableReport table) { - StringBuffer buffer = new StringBuffer(); - buffer.append("
\n"); - String ret = StringUtils.join(table.getHeaders(), ""); - } - Iterator iterator = table.iterator(); - while(iterator.hasNext()) { - Iterator sub = ((ArrayList)iterator.next()).iterator(); - buffer.append(""); - if(sub.hasNext()) { - while(sub.hasNext()) { - buffer.append("\n"); - } - } else { - buffer.append(""); - } - buffer.append("\n"); - } - buffer.append("
"); - if( (ret != null) && (ret != "")) { - buffer.append("
"); - buffer.append(ret); - buffer.append("
"); - buffer.append(sub.next()); - buffer.append(" 
\n"); - return buffer.toString(); - } - - public String renderChart(ChartReport chart) { - // assume yField is a number - Iterator iterator = chart.iterateKeys(); - StringBuffer buffer = new StringBuffer(); - float ratio = 400F / chart.getYMax(); - - String xField = chart.getXField(); - - buffer.append(""); - buffer.append("\n"); - while(iterator.hasNext()) { - Object key = iterator.next(); - - Number value = (Number)chart.getData(key); - int count = value.intValue(); - buffer.append("\n"); - } - buffer.append("
"); - if(chart.getLink(xField) != null) { - buffer.append(""); - buffer.append(chart.getLink(xField)); - buffer.append(""); - } else { - buffer.append(xField); - } - buffer.append(""); - buffer.append(chart.getYField()); - buffer.append("
"); - buffer.append(key); - buffer.append(""); - count *= ratio; - - // width of count - buffer.append(""); - // width of 400 - count - buffer.append(""); - - buffer.append(""); - buffer.append(value.intValue()); - buffer.append("
\n"); - - return buffer.toString(); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/report/AbstractReport.java b/dormant/logview/src/java/com/generationjava/logview/report/AbstractReport.java deleted file mode 100644 index 4d6f0015..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/report/AbstractReport.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.generationjava.logview.report; - -import java.util.Properties; - -import com.generationjava.logview.Report; - -abstract public class AbstractReport implements Report { - - private Properties links; - - public AbstractReport() { - links = new Properties(); - } - - public void setLink(String field, String link) { - links.put(field, link); - } - - public String getLink(String field) { - return links.getProperty(field); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/report/ChartReport.java b/dormant/logview/src/java/com/generationjava/logview/report/ChartReport.java deleted file mode 100644 index b4573701..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/report/ChartReport.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.generationjava.logview.report; - -import java.util.Iterator; - -import org.apache.commons.collections.SequencedHashMap; -import org.apache.commons.lang.NumberUtils; - -/// TODO: -/// Needs the ability to set the origin value? the maximum value? -/// ie) If percentages, need to go to 100%? -/// Also, some form of width/height number? Unit size? -/// Ability to pass a set of presentation properties in -public class ChartReport extends AbstractReport { - - private String xField; - private String yField; - private SequencedHashMap data = new SequencedHashMap(); - private int yMax = 0; - - public ChartReport(String xField, String yField) { - this.xField = xField; - this.yField = yField; - } - - public void addData(Object xValue, Object yValue) { - if(!(yValue instanceof Number)) { - try { - yValue = NumberUtils.createNumber(yValue.toString()); - } catch(NumberFormatException nfe) { - System.err.println("Bad number: "+yValue+" for "+xValue); - } - } - Number value = (Number)yValue; - if(value.intValue() > yMax) { - yMax = value.intValue(); - } - data.put(xValue, value); - } - - public Iterator iterateKeys() { - return data.keySet().iterator(); - } - - public int getYMax() { - return this.yMax; - } - - public String getXField() { - return this.xField; - } - - public String getYField() { - return this.yField; - } - - public Object getData(Object key) { - return data.get(key); - } - - // deprecated - public String toString() { - // assume yField is a number - Iterator iterator = this.data.keySet().iterator(); - StringBuffer buffer = new StringBuffer(); - float ratio = 40F / this.yMax; - - buffer.append(xField); - if(getLink(xField) != null) { - buffer.append("[cf."); - buffer.append(getLink(xField)); - buffer.append("]"); - } - buffer.append("\t"); - buffer.append(yField); - buffer.append("\n"); - while(iterator.hasNext()) { - Object key = iterator.next(); - - Number value = (Number)data.get(key); - int count = value.intValue(); - buffer.append(key); - buffer.append("\t"); - count *= ratio; - for(int i=count; i>0; i--) { - buffer.append("*"); - } - for(int i=count; i<40; i++) { - buffer.append(" "); - } - buffer.append("\t"); - buffer.append(value.intValue()); - buffer.append("\n"); - } - - return buffer.toString(); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/report/TableReport.java b/dormant/logview/src/java/com/generationjava/logview/report/TableReport.java deleted file mode 100644 index f5aa055a..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/report/TableReport.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.generationjava.logview.report; - -import java.util.ArrayList; -import java.util.Iterator; - -import com.generationjava.collections.CollectionsW; -import org.apache.commons.lang.StringUtils; - -public class TableReport extends AbstractReport { - - private String[] headers; - private ArrayList table = new ArrayList(); - private ArrayList list; - - public TableReport(Iterator headers) { - this.headers = (String[])CollectionsW.iteratorToArray(headers, new String[0]); - } - - public void addField(Object obj) { - if(list == null) { - list = new ArrayList(); - table.add(list); - } - list.add(obj); - } - - public void endRow() { - list = null; - } - - public Iterator iterator() { - return table.iterator(); - } - - public String getHeader() { - return StringUtils.join(this.headers, " : "); - } - - public String[] getHeaders() { - return this.headers; - } - - // deprecated - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append(":"); - buffer.append(getHeader()); - buffer.append(":\n"); - buffer.append( StringUtils.repeat("=", getHeader().length()+2 ) ); - buffer.append("\n"); - Iterator iterator = table.iterator(); - while(iterator.hasNext()) { - Iterator sub = ((ArrayList)iterator.next()).iterator(); - buffer.append(":"); - if(sub.hasNext()) { - while(sub.hasNext()) { - buffer.append(sub.next()); - buffer.append(":"); - } - } else { - buffer.append(":"); - } - buffer.append("\n"); - } - return buffer.toString(); - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/reportlet/ChartReportlet.java b/dormant/logview/src/java/com/generationjava/logview/reportlet/ChartReportlet.java deleted file mode 100644 index 8a6d25c3..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/reportlet/ChartReportlet.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.generationjava.logview.reportlet; - -import com.generationjava.logview.Log; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogField; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; -import com.generationjava.logview.Reportlet; -import com.generationjava.logview.Report; - -import com.generationjava.logview.report.ChartReport; - -public class ChartReportlet implements Reportlet { - - private String xField; - private String yField; - - public ChartReportlet(String xField, String yField) { - this.xField = xField; - this.yField = yField; - } - - public Report report(Log log) throws LogViewException { - ChartReport chart = new ChartReport(xField, yField); - - LogIterator logIt = log.iterator(); - - while(logIt.hasNext()) { - LogEvent event = logIt.nextLogEvent(); - LogField xLog = event.get(xField); - LogField yLog = event.get(yField); - if(xLog == null) { - throw new LogViewException("Unable to view column: "+xField); - } - if(yLog == null) { - throw new LogViewException("Unable to view column: "+yField); - } -// System.err.println("xLog["+xLog+"] yLog["+yLog+"]"); - chart.addData( xLog.getValue(), yLog.getValue() ); - } - return chart; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/reportlet/TableReportlet.java b/dormant/logview/src/java/com/generationjava/logview/reportlet/TableReportlet.java deleted file mode 100644 index 53cf5b56..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/reportlet/TableReportlet.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.generationjava.logview.reportlet; - -import java.util.Iterator; - -import com.generationjava.logview.Log; -import com.generationjava.logview.LogEvent; -import com.generationjava.logview.LogField; -import com.generationjava.logview.LogIterator; -import com.generationjava.logview.LogViewException; -import com.generationjava.logview.Reportlet; -import com.generationjava.logview.Report; - -import com.generationjava.logview.report.TableReport; - -public class TableReportlet implements Reportlet { - - public Report report(Log log) throws LogViewException { - TableReport table = new TableReport(log.iterateFieldNames()); - - LogIterator logIt = log.iterator(); -// System.err.println(""+logIt); - while(logIt.hasNext()) { - LogEvent event = logIt.nextLogEvent(); - if(event == null) { - continue; - } - Iterator iterator = log.iterateFieldNames(); - while(iterator.hasNext()) { - String fieldName = (String)iterator.next(); - LogField field = event.get(fieldName); - if(field == null) { - table.addField(null); - } else { - table.addField(field.getValue()); - } - } - table.endRow(); - } - return table; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/source/FileLogSource.java b/dormant/logview/src/java/com/generationjava/logview/source/FileLogSource.java deleted file mode 100644 index 36bb90b0..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/source/FileLogSource.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.generationjava.logview.source; - -import org.apache.commons.collections.ResettableIterator; -import org.apache.commons.collections.IteratorUtils; -import com.generationjava.io.FileW; -import org.apache.commons.lang.StringUtils; -import com.generationjava.logview.LogSource; - -public class FileLogSource implements LogSource { - - private ResettableIterator src; - private String current; - - public FileLogSource(String filename) { - String contents = FileW.loadFile(filename); - contents = StringUtils.chopNewline(contents); - String[] lines = StringUtils.split(contents, "\n"); - src = IteratorUtils.arrayIterator(lines); - } - - public void reset() { - src.reset(); - } - - public void remove() { - src.remove(); - } - - public Object next() { - return src.next(); - } - - public boolean hasNext() { - return src.hasNext(); - } - - public String nextEntry() { - this.current = (String)next(); - return this.current; - } - - public String currentEntry() { - return this.current; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/taglib/LinkTag.java b/dormant/logview/src/java/com/generationjava/logview/taglib/LinkTag.java deleted file mode 100644 index 7bcb7a1b..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/taglib/LinkTag.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.generationjava.logview.taglib; - -import com.generationjava.taglib.AbstractBodyTag; - -/** - * - * - * @author bayard@generationjava.com - * @version 0.1, 20011030 - */ -public class LinkTag extends AbstractBodyTag { - - private String field; - private String link; - - /** - * Empty constructor. - */ - public LinkTag() { - super(); - } - - public String getField() { - return this.field; - } - - public void setField(String field) { - this.field = field; - } - - public String getLink() { - return this.link; - } - - public void setLink(String link) { - this.link = link; - } - - /** - * Initialise any properties to default values. - */ - public void initAttributes() { - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/taglib/LogTag.java b/dormant/logview/src/java/com/generationjava/logview/taglib/LogTag.java deleted file mode 100644 index b22414af..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/taglib/LogTag.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.generationjava.logview.taglib; - -import com.generationjava.taglib.AbstractBodyTag; - -/** - * - * Default for type is 'file'. - * - * This tag loads a SourceLoglet into the session. The tag creates - * a LogBuilder which wraps a LogSource. Said LogBuilder is then put - * behind a SourceLoglet, and all further work just treats the - * in memory Loglet as the face of the chain. - * - * @author bayard@generationjava.com - * @version 0.1, 20011028 - */ -public class LogTag extends AbstractBodyTag { - - private String source; - private String type; - private String format; - - /** - * Empty constructor. - */ - public LogTag() { - super(); - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - } - - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - public String getFormat() { - return this.format; - } - - public void setFormat(String format) { - this.format = format; - } - - /** - * Initialise any properties to default values. - */ - public void initAttributes() { - this.type = "com.generationjava.logview.source.FileLogSource"; - this.format = "common"; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/taglib/LogletTag.java b/dormant/logview/src/java/com/generationjava/logview/taglib/LogletTag.java deleted file mode 100644 index 8f7de514..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/taglib/LogletTag.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.generationjava.logview.taglib; - -import com.generationjava.taglib.AbstractBodyTag; - -/** - * - * - * This tag creates the specified Loglet and gets the current Loglet - * from the session, wraps this, and puts the new Loglet back in. - * - * The param tag can be used inside this one to pass in special - * parameters. - * - * @author bayard@generationjava.com - * @version 0.1, 20011030 - */ -public class LogletTag extends AbstractBodyTag { - - private String type; - - /** - * Empty constructor. - */ - public LogletTag() { - super(); - } - - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - /** - * Initialise any properties to default values. - */ - public void initAttributes() { - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/taglib/ParamTag.java b/dormant/logview/src/java/com/generationjava/logview/taglib/ParamTag.java deleted file mode 100644 index a14e101b..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/taglib/ParamTag.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.generationjava.logview.taglib; - -import com.generationjava.taglib.AbstractBodyTag; - -/** - * - * - * @author bayard@generationjava.com - * @version 0.1, 20011030 - */ -public class ParamTag extends AbstractBodyTag { - - private String name; - private String value; - - /** - * Empty constructor. - */ - public ParamTag() { - super(); - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.value = value; - } - - /** - * Initialise any properties to default values. - */ - public void initAttributes() { - } - -} diff --git a/dormant/logview/src/java/com/generationjava/logview/taglib/ReportTag.java b/dormant/logview/src/java/com/generationjava/logview/taglib/ReportTag.java deleted file mode 100644 index b4f18a49..00000000 --- a/dormant/logview/src/java/com/generationjava/logview/taglib/ReportTag.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.generationjava.logview.taglib; - -import com.generationjava.taglib.AbstractBodyTag; - -/** - * - * - * Output a report, currently based on type and format. - * Probably make it so you can pass param tags in - * for things like titles etc. - * - * @author bayard@generationjava.com - * @version 0.1, 20011028 - */ -public class ReportTag extends AbstractBodyTag { - - private String type; - private String format; - - /** - * Empty constructor. - */ - public ReportTag() { - super(); - } - - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - public String getFormat() { - return this.format; - } - - public void setFormat(String format) { - this.format = format; - } - - /** - * Initialise any properties to default values. - */ - public void initAttributes() { - this.format = "common"; - } - -} diff --git a/dormant/logview/src/java/com/generationjava/math/Average.java b/dormant/logview/src/java/com/generationjava/math/Average.java deleted file mode 100644 index 236f87d9..00000000 --- a/dormant/logview/src/java/com/generationjava/math/Average.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.generationjava.math; - -// extend Number? -public class Average { - - private int sum; - private int num; - - public Average() { - } - - public Average(int start) { - add(start); - } - - public void add(int val) { - sum += val; - num++; - } - - public int average() { - return sum/num; - } - -} diff --git a/dormant/multidoc/TODO b/dormant/multidoc/TODO deleted file mode 100644 index 61cfe70e..00000000 --- a/dormant/multidoc/TODO +++ /dev/null @@ -1,56 +0,0 @@ - -Create a single multidoc that wraps anything that has a vaguely javadoc style to it. - -Usage would be something like: - -java -jar multidoc.jar multidocs.conf target/multidocs - -Does: xref, xref-tests, javadoc, jcoverage, clover, jdiff - -Multidoc is the front end. It is given, via the conf file, a list of document types to multidoc, and a file containing -urls for each one. - -For each document type, it asks a factory for a loader and a site creator - -The loader returns a DocumentSite object, which is added to a collection - -The site-creator is given a collection of DocumentSites - -The site-creator uses N page-creators to output a site? - -DocumentSites contain DocumentPackages - ----- -Wishlist - - -c) Scrape index. Merge into uber-index. 1 page per letter. - -d) Create dynamic searcher. ( :( ). Perl CGI. Uses uber-index? - -e) Maintain separate versions of data so they can be rejoined later on. ie) When Lang 2.1 replaces 2.0. - -g) Write JavaScript to load more than one frame at a time. - -h) Mode to replace an existing one, rather than rebuild the entire system. - - -==== - -Long term Design: - -mdoc-load 'Commons Lang' -mdoc-unload 'Commons Lang' -mdoc-reload 'Commons Lang' (calls remove then add) -mdoc-generate - -Store: - -store/Commons_Lang/index/a.dbhtml - packages.dbhtml - classes.dbhtml - meta.dbhtml - - -DBHTML is a HTML viewable DB file. Basically a Table I suspect, ordered by the first column. Column-headers DO exist. - diff --git a/dormant/multidoc/codehaus-release.cfg b/dormant/multidoc/codehaus-release.cfg deleted file mode 100644 index a33741f4..00000000 --- a/dormant/multidoc/codehaus-release.cfg +++ /dev/null @@ -1,53 +0,0 @@ - - - http://wadi.codehaus.org/apidocs - http://qdox.codehaus.org/apidocs - http://plexus.codehaus.org/apidocs - http://modello.codehaus.org/apidocs - http://metaclass.codehaus.org/apidocs - http://loom.codehaus.org/apidocs - http://jmock.codehaus.org/apidocs - http://jaxen.codehaus.org/apidocs - http://ivory.codehaus.org/apidocs - http://groovy.codehaus.org/apidocs - http://dna.codehaus.org/apidocs - http://dataforge.codehaus.org/apidocs - http://classworlds.codehaus.org/apidocs - http://blissed.codehaus.org/apidocs - http://aspectwerkz.codehaus.org/apidocs - - - http://wadi.codehaus.org/xref - http://qdox.codehaus.org/xref - http://plexus.codehaus.org/xref - http://modello.codehaus.org/xref - http://metaclass.codehaus.org/xref - http://loom.codehaus.org/xref - http://jmock.codehaus.org/xref - http://jaxen.codehaus.org/xref - http://ivory.codehaus.org/xref - http://groovy.codehaus.org/xref - http://dna.codehaus.org/xref - http://dataforge.codehaus.org/xref - http://classworlds.codehaus.org/xref - http://blissed.codehaus.org/xref - http://aspectwerkz.codehaus.org/xref - - - http://wadi.codehaus.org/xref-test - http://qdox.codehaus.org/xref-test - http://plexus.codehaus.org/xref-test - http://modello.codehaus.org/xref-test - http://metaclass.codehaus.org/xref-test - http://loom.codehaus.org/xref-test - http://jmock.codehaus.org/xref-test - http://jaxen.codehaus.org/xref-test - http://ivory.codehaus.org/xref-test - http://groovy.codehaus.org/xref-test - http://dna.codehaus.org/xref-test - http://dataforge.codehaus.org/xref-test - http://classworlds.codehaus.org/xref-test - http://blissed.codehaus.org/xref-test - http://aspectwerkz.codehaus.org/xref-test - - diff --git a/dormant/multidoc/commons-release.cfg b/dormant/multidoc/commons-release.cfg deleted file mode 100644 index c4c6e468..00000000 --- a/dormant/multidoc/commons-release.cfg +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dormant/multidoc/docs/blank.html b/dormant/multidoc/docs/blank.html deleted file mode 100644 index c0c0ffe1..00000000 --- a/dormant/multidoc/docs/blank.html +++ /dev/null @@ -1 +0,0 @@ -  diff --git a/dormant/multidoc/docs/index.html b/dormant/multidoc/docs/index.html deleted file mode 100644 index dff6c3de..00000000 --- a/dormant/multidoc/docs/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - -Multidoc - - - - - - - - - - - - - -<H2>Frame Alert</H2> - -<P> -This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. -<BR> -Link to<A HREF="menu.html">Non-frame version.</A> - - - diff --git a/dormant/multidoc/docs/multidoc.js b/dormant/multidoc/docs/multidoc.js deleted file mode 100644 index fad29c58..00000000 --- a/dormant/multidoc/docs/multidoc.js +++ /dev/null @@ -1,5 +0,0 @@ -function load() { - for(var i=0; i < arguments.length; i+=2) { - parent.frames[arguments[i]].location.href=arguments[i+1]; - } -} diff --git a/dormant/multidoc/maven.xml b/dormant/multidoc/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/dormant/multidoc/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/dormant/multidoc/osjava.cfg b/dormant/multidoc/osjava.cfg deleted file mode 100644 index aa72f3bc..00000000 --- a/dormant/multidoc/osjava.cfg +++ /dev/null @@ -1,82 +0,0 @@ - - - http://www.osjava.org/mudclient/apidocs - http://www.osjava.org/charlotte/apidocs - http://www.osjava.org/TigThreads/apidocs - http://www.osjava.org/genjava/multiproject/gj-config/apidocs - http://www.osjava.org/genjava/multiproject/gj-scrape/apidocs - http://www.osjava.org/genjava/multiproject/gj-servlet/apidocs - http://www.osjava.org/genjava/multiproject/gj-beans/apidocs - http://www.osjava.org/genjava/multiproject/gj-tools/apidocs - http://www.osjava.org/genjava/multiproject/gj-core/apidocs - http://www.osjava.org/genjava/multiproject/gj-find/apidocs - http://www.osjava.org/genjava/multiproject/gj-mail/apidocs - http://www.osjava.org/genjava/multiproject/gj-csv/apidocs - http://www.osjava.org/genjava/multiproject/gj-gui/apidocs - http://www.osjava.org/genjava/multiproject/gj-xml/apidocs - http://www.osjava.org/trail-taglib/apidocs - http://www.osjava.org/oscube/apidocs - http://www.osjava.org/norbert/apidocs - http://www.osjava.org/scraping-engine/apidocs - http://www.osjava.org/simple-jndi/apidocs - http://www.osjava.org/payload/apidocs - http://www.osjava.org/xmlwriter/apidocs - - - http://www.osjava.org/mudclient/xref - http://www.osjava.org/charlotte/xref - http://www.osjava.org/TigThreads/xref - http://www.osjava.org/genjava/multiproject/gj-config/xref - http://www.osjava.org/genjava/multiproject/gj-scrape/xref - http://www.osjava.org/genjava/multiproject/gj-servlet/xref - http://www.osjava.org/genjava/multiproject/gj-beans/xref - http://www.osjava.org/genjava/multiproject/gj-tools/xref - http://www.osjava.org/genjava/multiproject/gj-core/xref - http://www.osjava.org/genjava/multiproject/gj-find/xref - http://www.osjava.org/genjava/multiproject/gj-mail/xref - http://www.osjava.org/genjava/multiproject/gj-csv/xref - http://www.osjava.org/genjava/multiproject/gj-gui/xref - http://www.osjava.org/genjava/multiproject/gj-xml/xref - http://www.osjava.org/trail-taglib/xref - http://www.osjava.org/oscube/xref - http://www.osjava.org/norbert/xref - http://www.osjava.org/scraping-engine/xref - http://www.osjava.org/simple-jndi/xref - http://www.osjava.org/payload/xref - http://www.osjava.org/xmlwriter/xref - - - http://builds.osjava.org/mudclient/jcoverage - http://builds.osjava.org/charlotte/jcoverage - http://builds.osjava.org/TigThreads/jcoverage - http://builds.osjava.org/genjava/gj-config/jcoverage - http://builds.osjava.org/genjava/gj-scrape/jcoverage - http://builds.osjava.org/genjava/gj-servlet/jcoverage - http://builds.osjava.org/genjava/gj-beans/jcoverage - http://builds.osjava.org/genjava/gj-tools/jcoverage - http://builds.osjava.org/genjava/gj-core/jcoverage - http://builds.osjava.org/genjava/gj-find/jcoverage - http://builds.osjava.org/genjava/gj-mail/jcoverage - http://builds.osjava.org/genjava/gj-csv/jcoverage - http://builds.osjava.org/genjava/gj-gui/jcoverage - http://builds.osjava.org/genjava/gj-xml/jcoverage - http://builds.osjava.org/trail-taglib/jcoverage - http://builds.osjava.org/oscube/jcoverage - http://builds.osjava.org/norbert/jcoverage - http://builds.osjava.org/scraping-engine/jcoverage - http://builds.osjava.org/simple-jndi/jcoverage - http://builds.osjava.org/payload/jcoverage - http://builds.osjava.org/xmlwriter/jcoverage - - - http://www.osjava.org/charlotte/xref-test - http://www.osjava.org/genjava/multiproject/gj-scrape/xref-test - http://www.osjava.org/genjava/multiproject/gj-core/xref-test - http://www.osjava.org/genjava/multiproject/gj-find/xref-test - http://www.osjava.org/genjava/multiproject/gj-csv/xref-test - http://www.osjava.org/genjava/multiproject/gj-xml/xref-test - http://www.osjava.org/norbert/xref-test - http://www.osjava.org/simple-jndi/xref-test - http://www.osjava.org/xmlwriter/xref-test - - diff --git a/dormant/multidoc/project.properties b/dormant/multidoc/project.properties deleted file mode 100644 index 219ba336..00000000 --- a/dormant/multidoc/project.properties +++ /dev/null @@ -1,20 +0,0 @@ -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.jar.mainclass=org.osjava.multidoc.Multidoc - -maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory - -maven.checkstyle.properties=../hen_checkstyle.xml - -maven.javadoc.stylesheet = ../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/dormant/multidoc/project.xml b/dormant/multidoc/project.xml deleted file mode 100644 index 62c8b023..00000000 --- a/dormant/multidoc/project.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - 3 - multidoc - multidoc - 0.1 - - OSJava - http://www.osjava.org/ - http://www.osjava.org/images/osjava.gif - - 2004 - org.osjava.multidoc - http://www.osjava.org/images/1x1.gif - - - A documentation site that wraps other javadoc-style documentation sites. - - - Wrapper for javadoc-style sites - - http://www.osjava.org/multidoc/ - http://issues.osjava.org:8080/jira/browse/BrowseProject.jspa?id=10060 - www.osjava.org/multidoc - /sites/org/osjava/www/multidoc/ - /sites/org/osjava/www/releases/official/ - - - scm:subversion:http:/svn.osjava.org/svn/osjava/trunk/multidoc/ - - - - - osjava-users - http://lists.osjava.org/mailman/listinfo/osjava-users - http://lists.osjava.org/mailman/listinfo/osjava-users - http://lists.osjava.org/mailman/private/osjava-users/ - - - - - - - Henri Yandell - hen - bayard@generationjava.com - GenerationJava - - Java Developer - - - - - - - - genjava - gj-scrape - 2.0.1 - - http://dist.osjava.org/releases/multidoc-jnr - - - - genjava - gj-core - 3.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - genjava - gj-xml - 1.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - commons-collections - 3.0 - - - commons-lang - 2.0 - - - - - - bayard@www.generationjava.com - - src/java - - src/test - - - - **/*Test.java - - - - - - - maven-jxr-plugin - maven-javadoc-plugin - maven-license-plugin - maven-changes-plugin - - - - diff --git a/dormant/multidoc/run.sh b/dormant/multidoc/run.sh deleted file mode 100755 index 93d7a357..00000000 --- a/dormant/multidoc/run.sh +++ /dev/null @@ -1,2 +0,0 @@ -java -classpath /Users/hen/osj/trunk/genjava/gj-scrape/target/gj-scrape-2.0.1.jar:/Users/hen/.maven/repository/genjava/jars/gj-core-3.0.jar:/Users/hen/.maven/repository/commons-lang/jars/commons-lang-2.0.jar:/Users/hen/.maven/repository/genjava/jars/gj-xml-1.0.jar:/Users/hen/.maven/repository/commons-collections/jars/commons-collections-3.0.jar:target/multidoc-0.1.jar org.osjava.multidoc.Multidoc $* -cp docs/* $2 diff --git a/dormant/multidoc/src/java/org/osjava/multidoc/Document.java b/dormant/multidoc/src/java/org/osjava/multidoc/Document.java deleted file mode 100644 index 61ac4045..00000000 --- a/dormant/multidoc/src/java/org/osjava/multidoc/Document.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.osjava.multidoc; - -import java.util.List; -import java.util.ArrayList; - -public class Document { - - private String type; - private String name; - private List projects = new ArrayList(); - - public Document(String type, String name) { - this.type = type; - this.name = name; - } - - public String getType() { - return this.type; - } - - public String getName() { - return this.name; - } - - public List getProjects() { - return this.projects; - } - - public void addProject(DocumentProject project) { - this.projects.add(project); - } - - public String toString() { - return "["+type+" "+name+"];"+projects; - } - -} - diff --git a/dormant/multidoc/src/java/org/osjava/multidoc/DocumentCreator.java b/dormant/multidoc/src/java/org/osjava/multidoc/DocumentCreator.java deleted file mode 100644 index 70060037..00000000 --- a/dormant/multidoc/src/java/org/osjava/multidoc/DocumentCreator.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.osjava.multidoc; - -import java.io.IOException; - -public interface DocumentCreator { - - Document create(String url) throws IOException; - -} diff --git a/dormant/multidoc/src/java/org/osjava/multidoc/DocumentPackage.java b/dormant/multidoc/src/java/org/osjava/multidoc/DocumentPackage.java deleted file mode 100644 index 72efe46a..00000000 --- a/dormant/multidoc/src/java/org/osjava/multidoc/DocumentPackage.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.osjava.multidoc; - -public class DocumentPackage { - - private String name; - private String url; - private String description; - - public DocumentPackage(String name, String url, String description) { - this.name = name; - this.url = url; - this.description = description; - } - - public String getName() { - return this.name; - } - - public String getUrl() { - return this.url; - } - - public String getDescription() { - return this.description; - } - - public String toString() { - return this.name + " - '" + this.description + "'"; - } - - public boolean equals(Object obj) { - if(obj instanceof DocumentPackage) { - DocumentPackage dp = (DocumentPackage)obj; - return (this.name == dp.name); - } else { - return false; - } - } - - public int hashCode() { - return this.name.hashCode(); - } - -} diff --git a/dormant/multidoc/src/java/org/osjava/multidoc/DocumentProject.java b/dormant/multidoc/src/java/org/osjava/multidoc/DocumentProject.java deleted file mode 100644 index e627849b..00000000 --- a/dormant/multidoc/src/java/org/osjava/multidoc/DocumentProject.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.osjava.multidoc; - -import java.util.List; -import java.util.ArrayList; - -public class DocumentProject { - - private String url; - private String title; - private List packages = new ArrayList(); -// private boolean singlePackage; - - public DocumentProject(String url, String title) { - this.url = url; - this.title = title; - } - - public String getUrl() { - return this.url; - } - - public String getTitle() { - return this.title; - } - - public void setTitle(String title) { - this.title = title; - } - - public List getPackages() { - return this.packages; - } - - public void addPackage(DocumentPackage pckge) { - this.packages.add(pckge); - } - - public boolean isSinglePackaged() { - return packages.size() == 1; - } - - /* - public void setSinglePackage(boolean b) { - this.singlePackage = b; - } - */ - - public String toString() { - return "["+title+" "+url+(isSinglePackaged()?"/single":"")+"];"+packages; - } - -} - diff --git a/dormant/multidoc/src/java/org/osjava/multidoc/DocumentProjectCreator.java b/dormant/multidoc/src/java/org/osjava/multidoc/DocumentProjectCreator.java deleted file mode 100644 index bb7dfbf0..00000000 --- a/dormant/multidoc/src/java/org/osjava/multidoc/DocumentProjectCreator.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.osjava.multidoc; - -import java.io.IOException; - -public interface DocumentProjectCreator { - - DocumentProject create(String url) throws IOException; - -} diff --git a/dormant/multidoc/src/java/org/osjava/multidoc/DocumentSite.java b/dormant/multidoc/src/java/org/osjava/multidoc/DocumentSite.java deleted file mode 100644 index a6eff9df..00000000 --- a/dormant/multidoc/src/java/org/osjava/multidoc/DocumentSite.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.osjava.multidoc; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.collections.map.ListOrderedMap; - -public class DocumentSite { - - private String url; - private String title; - private String stylesheet; - private Map documents = ListOrderedMap.decorate(new HashMap()); - - public DocumentSite(String url, String title, String stylesheet) { - this.url = url; - this.title = title; - this.stylesheet = stylesheet; - } - - public String getUrl() { - return this.url; - } - - public String getTitle() { - return this.title; - } - - public String getStylesheet() { - return this.stylesheet; - } - - public Document getDocument(String name) { - return (Document) this.documents.get(name); - } - - public Collection getNames() { - return this.documents.keySet(); - } - - public void addDocument(String name, Document document) { - this.documents.put(name, document); - } - - public String toString() { - return "["+title+" "+url+" "+stylesheet+"];"+documents; - } - -} - diff --git a/dormant/multidoc/src/java/org/osjava/multidoc/Multidoc.java b/dormant/multidoc/src/java/org/osjava/multidoc/Multidoc.java deleted file mode 100644 index 12c8cfb2..00000000 --- a/dormant/multidoc/src/java/org/osjava/multidoc/Multidoc.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.osjava.multidoc; - -import java.io.*; -import java.util.*; - -import com.generationjava.io.xml.*; -import com.generationjava.web.*; - -import org.apache.commons.lang.StringUtils; - -public class Multidoc { - - // multidoc multidoc.conf target/multidoc - public static void main(String[] args) throws IOException { - - FileReader reader = new FileReader(args[0]); - XMLParser parser = new XMLParser(); - XMLNode node = parser.parseXML(new BufferedReader(reader)); - // node is - String siteName = node.getAttr("name"); - String style = node.getAttr("style"); - String url = node.getAttr("url"); - System.out.println("Multidocing for "+siteName); - DocumentSite site = new DocumentSite(url, siteName, style); - Enumeration docEnum = node.enumerateNode("document"); - // hacked to do just the first one - while(docEnum.hasMoreElements()) { - XMLNode subnode = (XMLNode) docEnum.nextElement(); - String type = subnode.getAttr("type"); - String name = subnode.getAttr("name"); - Document document = new Document(type, name); - site.addDocument(name, document); - DocumentProjectCreator creator = Multidoc.getCreator(type); - Enumeration projectEnum = subnode.enumerateNode("project"); - while(projectEnum.hasMoreElements()) { - XMLNode projectNode = (XMLNode) projectEnum.nextElement(); - String uri = projectNode.getAttr("uri"); - String title = projectNode.getAttr("title"); - System.out.println("Loading: "+title+" from "+uri); - DocumentProject project = creator.create(uri); - if(project == null) { - System.err.println("WARN: null project found: "+uri); - continue; - } - if(title != null) { - project.setTitle(title); - } - document.addProject(project); - } - } - - // target directory - File target = new File(args[1]); - target.mkdirs(); - - Collection names = site.getNames(); - Iterator iterator = names.iterator(); - while(iterator.hasNext()) { - String name = (String) iterator.next(); - Document document = site.getDocument(name); - MultidocGenerator generator = getGenerator(document.getType()); - File subtarget = new File(target, name); - subtarget.mkdirs(); - System.out.println("Generating for: "+name); - generator.generate( subtarget, site, document ); - } - - System.out.println("Generating frontpage"); - generateFrontPage( target, site ); - System.out.println("Generating menu"); - generateMenu( target, site ); - System.out.println("Generating about"); - generateAbout( target, site ); - System.out.println("Generating configuration"); - generateConfiguration( target, site, node ); - - } - - public static DocumentProjectCreator getCreator(String type) { - if("Javadoc".equals(type)) { - return new org.osjava.multidoc.creators.JavadocCreator(); - } - if("XRef".equals(type)) { - return new org.osjava.multidoc.creators.XRefCreator(); - } - if("JCoverage".equals(type)) { - return new org.osjava.multidoc.creators.JCoverageCreator(); - } - return null; - } - - public static MultidocGenerator getGenerator(String type) { - if("Javadoc".equals(type)) { - return new org.osjava.multidoc.generators.JavadocMultidocGenerator(); - } - if("XRef".equals(type)) { - return new org.osjava.multidoc.generators.JavadocMultidocGenerator(); - } - if("JCoverage".equals(type)) { - return new org.osjava.multidoc.generators.JavadocMultidocGenerator(); - } - return null; - } - - public static void generateMenu(File targetDirectory, DocumentSite site) throws IOException { - FileWriter fw = new FileWriter( new File( targetDirectory, "menu.html") ); - fw.write("\n"); - fw.write("\n"); - fw.write("\n"); - fw.write("\n
\n"); - fw.write("\n"); - fw.close(); - } - - public static void generateAbout(File targetDirectory, DocumentSite site) throws IOException { - FileWriter fw = new FileWriter( new File( targetDirectory, "about.html") ); - fw.write("\n"); - fw.write("About Multidoc\n"); - fw.write("\n"); - fw.write("\n"); - fw.write("\n"); - fw.write("\n"); - fw.write("
\n"); - fw.write("
\n"); - fw.write("

This is a Multidoc system. It consists of a wrapper around a set of javadocs.

\n"); - fw.write("
\n"); - fw.write("

First and foremost, to put all of Jakarta Commons into a single javadoc, possibly all of Apache/Jakarta if desired. Also should be useful for other locations; osjava, codehaus etc.

\n"); - fw.write("
\n"); - fw.write("

The current version scrapes from a list of documentation urls and collates a small set of pages around those pages. The exact urls used are available on the configuration page.

\n"); - fw.write("
\n"); - fw.write("
    \n"); - fw.write("
  • Add a categorization scheme so all of Apache fits. Projects should be able to be in multiple categories.
  • \n"); - fw.write("
  • Needs to maintain a state so it doesn't have to keep downloading all pages just because a new one is added.
  • \n"); - fw.write("
  • It would be nice if it would also pull down and collate an index.
  • \n"); - fw.write("
  • It would be very nice to integrate a search into the project-frame.
  • \n"); - fw.write("
  • Improve the HTML as the current one is quite hacked from the javadoc style.
  • \n"); - fw.write("
  • Integrate Clover
  • \n"); - fw.write("
  • Mavenise and produce an executable jar
  • \n"); - fw.write("
  • Release on osjava.org
  • \n"); - fw.write("
\n"); - fw.write("\n"); - fw.write("\n"); - fw.close(); - } - - public static void generateConfiguration(File targetDirectory, DocumentSite site, XMLNode root) throws IOException { - FileWriter fw = new FileWriter( new File( targetDirectory, "configuration.html") ); - String xml = root.toString(); - String font = ""; - xml = StringUtils.replace(xml, "<", font+"<"); - xml = StringUtils.replace(xml, ">", ">"); - xml = StringUtils.replace(xml, " ", "  "); - xml = StringUtils.replace(xml, "=\"", "=\""); - xml = StringUtils.replace(xml, "\" ", font+"\" "); - xml = StringUtils.replace(xml, "\">", font+"\">"); - xml = HtmlW.nl2br(xml); - fw.write(xml); - fw.close(); - } - - public static void generateFrontPage(File targetDirectory, DocumentSite site) throws IOException { - FileWriter fw = new FileWriter( new File( targetDirectory, "frontpage.html") ); - fw.write(""); - fw.write(""); - fw.write("

Multidoc

\n"); - fw.write("

This is a multidoc system for "); - fw.write(site.getTitle()); - fw.write(". To use it, use the document-types listed in the menu-frame above.

"); - fw.write(""); - fw.close(); - } -} diff --git a/dormant/multidoc/src/java/org/osjava/multidoc/MultidocGenerator.java b/dormant/multidoc/src/java/org/osjava/multidoc/MultidocGenerator.java deleted file mode 100644 index e5878407..00000000 --- a/dormant/multidoc/src/java/org/osjava/multidoc/MultidocGenerator.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.osjava.multidoc; - -import java.io.IOException; -import java.io.Writer; -import java.io.File; - -public interface MultidocGenerator { - - void generate(File targetDirectory, DocumentSite site, Document document) throws IOException; - // remove these write ones? - void writeProjectFrame(Writer writer, DocumentSite site, Document document) throws IOException; - void writePackagesFrame(Writer writer, DocumentSite site, Document document) throws IOException; - void writeOverviewFrame(Writer writer, DocumentSite site, Document document) throws IOException; - -} diff --git a/dormant/multidoc/src/java/org/osjava/multidoc/creators/JCoverageCreator.java b/dormant/multidoc/src/java/org/osjava/multidoc/creators/JCoverageCreator.java deleted file mode 100644 index bbbfce12..00000000 --- a/dormant/multidoc/src/java/org/osjava/multidoc/creators/JCoverageCreator.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.osjava.multidoc.creators; - -import org.osjava.multidoc.*; - -import com.generationjava.scrape.HtmlScraper; -import com.generationjava.net.UrlW; -import com.generationjava.web.XmlW; -import com.generationjava.web.HtmlW; - -import org.apache.commons.lang.StringUtils; - -import java.io.IOException; - -public class JCoverageCreator implements DocumentProjectCreator { - - public DocumentProject create(String urlbase) throws IOException { - HtmlScraper scraper = new HtmlScraper(); - try { - scraper.scrape( ""+UrlW.getContent(urlbase+"/overview-summary.html") ); - DocumentProject project = scrapeOverview(scraper, urlbase); - return project; - } catch(IOException ioe) { - return null; - } - } - - private DocumentProject scrapeOverview(HtmlScraper scraper, String urlbase) throws IOException { - - // JCoverage has no title, so let's use the urlbase - String title = urlbase.replaceFirst("/[^/]*$",""); //.replaceAll("[^/]*/+",""); - title = StringUtils.substringAfterLast(title, "/"); - - - DocumentProject project = new DocumentProject(urlbase, title); - - scraper.moveToTagWith("class","reportText"); // skip the Project header - while(scraper.moveToTagWith("class","reportText")) { - String cellPackage = scraper.get("a"); - String cellAnchor = scraper.get("a[href]"); - project.addPackage( new DocumentPackage( cellPackage, cellAnchor, "") ); - } - - return project; - } - -} diff --git a/dormant/multidoc/src/java/org/osjava/multidoc/creators/JavadocCreator.java b/dormant/multidoc/src/java/org/osjava/multidoc/creators/JavadocCreator.java deleted file mode 100644 index 136bdbcd..00000000 --- a/dormant/multidoc/src/java/org/osjava/multidoc/creators/JavadocCreator.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.osjava.multidoc.creators; - -import org.osjava.multidoc.*; - -import com.generationjava.scrape.HtmlScraper; -import com.generationjava.net.UrlW; -import com.generationjava.web.XmlW; -import com.generationjava.web.HtmlW; - -import java.io.IOException; - -public class JavadocCreator implements DocumentProjectCreator { - - public DocumentProject create(String urlbase) throws IOException { - HtmlScraper scraper = new HtmlScraper(); - try { - scraper.scrape( ""+UrlW.getContent(urlbase+"/overview-summary.html") ); - DocumentProject project = scrapeOverview(scraper, urlbase); - return project; - } catch(IOException ioe) { - // assume it means that overview-summary is not available - String pckge = ""+UrlW.getContent(urlbase+"/package-list"); - String path = pckge.replaceAll("\\.","/"); - DocumentProject project = new DocumentProject( urlbase, pckge ); - project.addPackage( new DocumentPackage(pckge, "/"+path+"/package-summary.html", "") ); - return project; - } - } - - private DocumentProject scrapeOverview(HtmlScraper scraper, String urlbase) throws IOException { - // bit of a hack. two types of possible comment noticed so far - if(!scraper.moveToComment("=========== END OF NAVBAR ===========")) { - scraper.moveToComment("========= END OF TOP NAVBAR ========="); - } - - // also a hack. TOP variant uses a h1. - String title = scraper.get("h2").trim(); - if("".equals(title)) { - title = scraper.get("h1").trim(); - } - - // hack for Commons APIs that have

in their title - title = XmlW.removeXml(title); - - // title seems to have ' API' on the end - title = title.replaceFirst(" API$", ""); - - DocumentProject project = new DocumentProject(urlbase, title); - - scraper = scraper.scrapeTag("TABLE"); - scraper.move("TD"); // skip the Packages header - while(scraper.move("TD")) { - String cellPackage = scraper.get("A"); - String cellAnchor = scraper.get("A[HREF]"); - if(null == cellAnchor || "".equals(cellAnchor)) { continue; } // HACK: Bug in scraper I think - scraper.move("TD"); - String cellDescription = scraper.get("TD").trim(); - project.addPackage( new DocumentPackage( cellPackage, cellAnchor, cellDescription ) ); - } - - return project; - } - -} diff --git a/dormant/multidoc/src/java/org/osjava/multidoc/creators/XRefCreator.java b/dormant/multidoc/src/java/org/osjava/multidoc/creators/XRefCreator.java deleted file mode 100644 index 1fc6377c..00000000 --- a/dormant/multidoc/src/java/org/osjava/multidoc/creators/XRefCreator.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.osjava.multidoc.creators; - -import org.osjava.multidoc.*; - -import com.generationjava.scrape.HtmlScraper; -import com.generationjava.net.UrlW; -import com.generationjava.web.XmlW; -import com.generationjava.web.HtmlW; - -import java.io.IOException; - -public class XRefCreator implements DocumentProjectCreator { - - public DocumentProject create(String urlbase) throws IOException { - HtmlScraper scraper = new HtmlScraper(); - try { - scraper.scrape( ""+UrlW.getContent(urlbase+"/overview-summary.html") ); - DocumentProject project = scrapeOverview(scraper, urlbase); - return project; - } catch(IOException ioe) { - return null; - } - } - - private DocumentProject scrapeOverview(HtmlScraper scraper, String urlbase) throws IOException { - scraper.move("center"); - - // also a hack. TOP variant uses a h1. - String title = scraper.get("h2").trim(); - if("".equals(title)) { - title = scraper.get("h1").trim(); - } - // xref has Reference a lot - title = title.replaceFirst(" Reference$", ""); - - DocumentProject project = new DocumentProject(urlbase, title); - - scraper = scraper.scrapeTag("TABLE"); - scraper.move("TD"); // skip the Packages header - while(scraper.move("TD")) { - String cellPackage = scraper.get("A"); - String cellAnchor = scraper.get("A[HREF]"); - if(null == cellAnchor || "".equals(cellAnchor)) { continue; } // HACK: Bug in scraper I think - project.addPackage( new DocumentPackage( cellPackage, cellAnchor, "") ); - } - - return project; - } - -} diff --git a/dormant/multidoc/src/java/org/osjava/multidoc/generators/JavadocMultidocGenerator.java b/dormant/multidoc/src/java/org/osjava/multidoc/generators/JavadocMultidocGenerator.java deleted file mode 100644 index 4ce8cfba..00000000 --- a/dormant/multidoc/src/java/org/osjava/multidoc/generators/JavadocMultidocGenerator.java +++ /dev/null @@ -1,162 +0,0 @@ -package org.osjava.multidoc.generators; - -import org.osjava.multidoc.*; - -import java.util.*; -import java.io.*; - -public class JavadocMultidocGenerator implements MultidocGenerator { - - public void generate(File targetDirectory, DocumentSite site, Document document) throws IOException { - // create pages - FileWriter fw = new FileWriter( new File( targetDirectory, "project-frame.html") ); - writeProjectFrame(fw, site, document); - fw.close(); - fw = new FileWriter( new File( targetDirectory, "overview-frame.html") ); - writePackagesFrame(fw, site, document); - fw.close(); - fw = new FileWriter( new File( targetDirectory, "overview-summary.html") ); - writeOverviewFrame(fw, site, document); - fw.close(); - } - - - // move to Velocity or something - public void writeProjectFrame(Writer writer, DocumentSite site, Document document) throws IOException { - writer.write("\n"); -// writer.write("
\n"); -// writer.write("

\n"); -// writer.write("
\n"); - writer.write("

"); - writer.write(document.getName()); - writer.write("

"); - writer.write("

All Packages

\n"); - writer.write("Projects
\n"); - Iterator iterator = document.getProjects().iterator(); - while(iterator.hasNext()) { - DocumentProject project = (DocumentProject) iterator.next(); - writer.write(""); - } else { - writer.write("'packageListFrame','"); - writer.write(project.getUrl()); - writer.write("/overview-frame.html','packageFrame','"); - writer.write(project.getUrl()); - writer.write("/allclasses-frame.html')\">"); - } - writer.write(project.getTitle()); - writer.write("
\n"); - } - writer.write("\n"); - } - - public void writePackagesFrame(Writer writer, DocumentSite site, Document document) throws IOException { - writer.write("MetaOverview (Jakarta)\n"); - writer.write("\n"); - writer.write("\n"); - writer.write("\n"); -// writer.write("All Classes\n"); - writer.write("

Packages
\n"); - - Iterator iterator = document.getProjects().iterator(); - while(iterator.hasNext()) { - DocumentProject project = (DocumentProject) iterator.next(); - writer.write(""); - List packages = project.getPackages(); - Iterator pckgIterator = packages.iterator(); - while(pckgIterator.hasNext()) { - DocumentPackage pckg = (DocumentPackage) pckgIterator.next(); - writer.write(""); - writer.write(pckg.getName()); - writer.write("
\n"); - } - } - - writer.write("

\n"); - } - - public void writeOverviewFrame(Writer writer, DocumentSite site, Document document) throws IOException { - writer.write("Overview (Multidoc)\n"); - writer.write("\n"); - writer.write("\n"); - writer.write("\n"); -// writer.write("
\n"); - writer.write("

\n"); - writer.write("


"); - writer.write(site.getTitle()); - writer.write(" packages

\n"); - - writer.write("\n"); - writer.write("\n"); - writer.write("\n"); - writer.write("\n"); - Iterator iterator = document.getProjects().iterator(); - while(iterator.hasNext()) { - DocumentProject project = (DocumentProject) iterator.next(); - writer.write("\n"); - List packages = project.getPackages(); - Iterator pckgIterator = packages.iterator(); - while(pckgIterator.hasNext()) { - DocumentPackage pckg = (DocumentPackage) pckgIterator.next(); - writer.write("\n"); - writer.write("\n\n"); - } - } - writer.write("
\n"); - writer.write("Packages
"); - } else { - writer.write("/overview-summary.html'>"); - } - writer.write(project.getTitle()); - writer.write("
"); - writer.write(pckg.getName()); - writer.write(""); - writer.write(pckg.getDescription()); - writer.write("
\n"); - -// writer.write("


Copyright © 2000-2004 The Apache Software Foundation. All Rights Reserved.

"); - writer.write("\n"); - } - -} - diff --git a/dormant/multidoc/test.cfg b/dormant/multidoc/test.cfg deleted file mode 100644 index fd2d4079..00000000 --- a/dormant/multidoc/test.cfg +++ /dev/null @@ -1,18 +0,0 @@ - - - http://www.osjava.org/simple-jndi/apidocs - http://www.osjava.org/xmlwriter/apidocs - - - http://www.osjava.org/simple-jndi/xref - http://www.osjava.org/xmlwriter/xref - - - http://builds.osjava.org/xmlwriter/jcoverage - http://builds.osjava.org/genjava/gj-core/jcoverage - - - http://www.osjava.org/simple-jndi/xref-test - http://www.osjava.org/xmlwriter/xref-test - - diff --git a/dormant/multidoc/xdocs/HowTo.xml b/dormant/multidoc/xdocs/HowTo.xml deleted file mode 100644 index 778f5343..00000000 --- a/dormant/multidoc/xdocs/HowTo.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - Henri Yandell - How to use Multidoc - - - -
-

Using Multidoc is currently done by copying the examples in SVN.

-

Assuming a unix-like shell, the following will multidoc Jakarta Commons:
- ./run.sh commons-release.cfg commons-multidoc/
- The first argument is the configuration file, the second is the target directory - to put values in. Note that the run.sh script copies everything from docs/ into - the target directory as well, though this is increasingly getting smaller.

-

To multidoc your own system, just copy one of the included configuration files and - customise it to fit your needs. It is hopefully quite obvious in use.

-
- - -
diff --git a/dormant/multidoc/xdocs/changes.xml b/dormant/multidoc/xdocs/changes.xml deleted file mode 100644 index e8131a24..00000000 --- a/dormant/multidoc/xdocs/changes.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Henri Yandell - Changes - - - - - - - diff --git a/dormant/multidoc/xdocs/images/1x1.gif b/dormant/multidoc/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/dormant/multidoc/xdocs/images/1x1.gif and /dev/null differ diff --git a/dormant/multidoc/xdocs/images/osjava.gif b/dormant/multidoc/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/dormant/multidoc/xdocs/images/osjava.gif and /dev/null differ diff --git a/dormant/multidoc/xdocs/index.xml b/dormant/multidoc/xdocs/index.xml deleted file mode 100644 index 9310df18..00000000 --- a/dormant/multidoc/xdocs/index.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - Henri Yandell - Multidoc - - - - -
-

Multidoc is a simple tool that outputs a wrapping-site for existing javadoc-style sites. It depends on a bunch of jars, so make sure you aquire these. Multidoc currently supports: -

    -
  • Javadoc
  • -
  • XRef (source code in HTML)
  • -
  • JCoverage (test coverage)
  • -
-

-
- - -
diff --git a/dormant/multidoc/xdocs/navigation.xml b/dormant/multidoc/xdocs/navigation.xml deleted file mode 100644 index 6d723ab1..00000000 --- a/dormant/multidoc/xdocs/navigation.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - multidoc - - - - - - - - - - - - - - - - - - - - - - diff --git a/dormant/openjar/JarCreator.java b/dormant/openjar/JarCreator.java deleted file mode 100644 index ce01a6de..00000000 --- a/dormant/openjar/JarCreator.java +++ /dev/null @@ -1,31 +0,0 @@ -import java.util.jar.*; - -public class JarCreator { - - public static void main(String[] args) throws IOException { - String[] targets = new String[args.length - 1]; - System.arraycopy(args, 1, targets, 0, targets.length); - new JarCreator(false).create(args[0], targets); - } - - private boolean verbose; - - public JarCreator() { - } - - public JarCreator(boolean verbose) { - this.verbose = verbose; - } - - public void create(String target, String[] filenames) throws IOException { - File[] files = new File[filenames.length]; - for(int i=0; i 1 ) { - System.err.println("Expected only one of the following flags 'c', 't', 'x' or 'u'. "); - System.exit(1); - } - - // always accept vf - int vCount = count(flags, 'v'); - int fCount = count(flags, 'f'); - - if(fCount > 1) { - // TODO: error - } - if(vCount > 1) { - // TODO: error - } - - if(vCount == 1) { - verbose = true; - } - - if(fCount == 0) { - in = System.in; - } else { - // next argument, in correct order with manifest - in = args[1]; - } - - if(cCount == 1) { - // if c: m, 0, M, i are legal - int mCount = count(flags, 'm'); - int zeroCount = count(flags, '0'); - int MCount = count(flags, 'M'); - int iCount = count(flags, 'i'); - - // -C is a later flag - } - - // if x: - - // if t: - - // if u: C is legal, later on - - // various options are focused on: - // creating jars - // including a manifest - // no compression - // no Manifest - // change to specified directory - // generate index information - // listing jars - // extracting jars - // updating in jars - // change to specified directory - // globals: - // verbose output - // specify jar name - } - - // API - // create - // list (Writer) - // enumerate - // update - - private int count(String str, int char) { - char[] chars = str.charArray(); - int count = 0; - for(int i=0; i - - - - - - - - - - - diff --git a/genjava/gj-beans/pom.xml b/genjava/gj-beans/pom.xml deleted file mode 100755 index 77aa7753..00000000 --- a/genjava/gj-beans/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - genjava - genjava - UNUSED - - 4.0.0 - gj-beans - GenJava-Beans - 1.0.1 - 2002 - - - BeanViewer. Similar to Jakarta BeanUtils and thus deprecated in favour of that code. - - - - - - - gj-core - genjava - 3.2 - - - - commons-lang - commons-lang - 2.0 - - - - commons-collections - commons-collections - 2.1 - - - - - - diff --git a/genjava/gj-beans/project.properties b/genjava/gj-beans/project.properties deleted file mode 100644 index d0f1d722..00000000 --- a/genjava/gj-beans/project.properties +++ /dev/null @@ -1,18 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.checkstyle.properties=../../hen_checkstyle.xml - -maven.javadoc.stylesheet=../../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/genjava/gj-beans/project.xml b/genjava/gj-beans/project.xml deleted file mode 100755 index 8ff2d9e7..00000000 --- a/genjava/gj-beans/project.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - ../project.xml - gj-beans - GenJava-Beans - 1.0.1 - 2002 - - - BeanViewer. Similar to Jakarta BeanUtils and thus deprecated in favour of that code. - - - BeanViewer - - - - gj-core - genjava - 3.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - commons-lang - 2.0 - http://jakarta.apache.org/commons/lang.html - - - commons-collections - 2.1 - http://jakarta.apache.org/commons/collections.html - - - - - diff --git a/genjava/gj-beans/src/java/com/generationjava/beans/AbstractBeanViewer.java b/genjava/gj-beans/src/java/com/generationjava/beans/AbstractBeanViewer.java deleted file mode 100644 index cfd91ea6..00000000 --- a/genjava/gj-beans/src/java/com/generationjava/beans/AbstractBeanViewer.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.beans; - -import java.util.List; -import java.util.Enumeration; -import java.util.Iterator; - -import org.apache.commons.collections.CollectionUtils; - -/** - * Helps us deal with such wonderful things as array notation - * and object notation. Array notation may use associative array notation. - * - * @date 2001-06-14 - */ -abstract public class AbstractBeanViewer { - - /** - * Get the property of myBean with the name of the key's toString. - * - * The key may use dotted notation to imply a property in a property - * and array notation to get the nth property in a list of propertys. - */ - public Object get(Object key, Object myBean) { - if( key == null ) { - return null; - } - - if(myBean == null) { - return null; - } - - String name = key.toString(); - - BeanViewRuntime runtime = new BeanViewRuntime(); - runtime.pushObject(myBean); - - int idx = 0; - Object obj = myBean; - while( (idx = name.indexOf('.', idx)) != -1) { - String pre = name.substring(0, idx); - name = name.substring(idx+1); - if(obj != null) { - obj = handleGet(runtime, obj, pre); - runtime.pushObject(obj); - } else { - return null; - } - } - - return handleGet(runtime, obj, name); - } - - /** - * Give a bean, and a String name, get the property with that name - * from the bean. - * Does not handle dot notation, but does handle array notation - * and associative array notation. - */ - public Object handleGet(BeanViewRuntime runtime, Object bean, String name) { - // deal with array - int i = name.indexOf('['); - Object index = null; - if(i != -1) { - String pre = name.substring(i+1); - if(pre.endsWith("]")) { - pre = pre.substring(0, pre.length() -1); - } - try { - index = Integer.valueOf(pre); - } catch(NumberFormatException nfe) { - index = pre; - } - name = name.substring(0,i); - } - - // shouldn't be null - if(name.equals("")) { - return CollectionUtils.index(bean, index); - } else { - return invokeGet( runtime, bean, name, index ); - } - } - - /** - * Get a value from a bean with the specified name. - * If the bean is indexed, an int index is passed. Else it is -1. - * It is recommmended that implementors of this method use the - * index method to handle the array notation. - */ - abstract public Object invokeGet(BeanViewRuntime runtime, Object bean, String name, Object idx); - - public Object set(Object key, Object bean, Object value) { - if(key == null) { - return null; - } - - if(bean == null) { - return null; - } - - String name = key.toString(); - - int idx = name.lastIndexOf("."); - if(idx != -1) { - String pre = name.substring(0, idx); - String post = name.substring(idx+1); - Object parent = get(pre, bean); -// TODO: remove [] notation from name. -// equally, need to pass idx as an Object, so implies that -// invokeGet shuld have Object idx and so should index. - bean = parent; - name = post; - } - // call invokeGet to get the current value, then - // call invokeSet - invokeSet(null, bean, name, null, value); - - // return old value - return null; - } - - abstract public void invokeSet(BeanViewRuntime runtime, Object bean, String name, Object idx, Object value); - -} diff --git a/genjava/gj-beans/src/java/com/generationjava/beans/BeanImplProxy.java b/genjava/gj-beans/src/java/com/generationjava/beans/BeanImplProxy.java deleted file mode 100644 index 64b5cde0..00000000 --- a/genjava/gj-beans/src/java/com/generationjava/beans/BeanImplProxy.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.generationjava.beans; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; - -import com.generationjava.namespace.Namespace; -import com.generationjava.namespace.SimpleNamespace; - -import org.apache.commons.lang.StringUtils; - -public class BeanImplProxy implements InvocationHandler { - - public static Object newInstance(Class intfce) { - BeanImplProxy handler = new BeanImplProxy(intfce); - Class proxyClass = Proxy.getProxyClass( - intfce.getClassLoader(), - new Class[] { intfce } - ); - try { - return proxyClass.getConstructor( new Class[] { InvocationHandler.class } - ).newInstance(new Object[] { handler }); - } catch(NoSuchMethodException nsme) { - nsme.printStackTrace(); - } catch(SecurityException se) { - se.printStackTrace(); - } catch(InstantiationException ie) { - ie.printStackTrace(); - } catch(IllegalAccessException iae) { - iae.printStackTrace(); - } catch(InvocationTargetException ite) { - ite.printStackTrace(); - } - return null; - } - - private Class type; - private Namespace namespace; - - private BeanImplProxy(Class type) { - this.type = type; - this.namespace = new SimpleNamespace(); - } - - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - Class returnType = method.getReturnType(); - String name = method.getName(); - if(returnType == Void.TYPE) { - // test this - if(name.startsWith("set")) { - if(args.length == 1) { - String property = StringUtils.uncapitalise(name.substring(3)); - this.namespace.putValue(property, args[0]); - } - } - return null; - } - if(returnType == Class.class) { - if("getClass".equals(name)) { - // pretend to be this - return this.type; - } - } - if("toString".equals(name)) { - // try to output nicely - return BeansW.beanToString(proxy); - } - if(name.startsWith("get")) { - String property = StringUtils.uncapitalise(name.substring(3)); - return this.namespace.getValue(property); - } - return null; // ?? - } - -} diff --git a/genjava/gj-beans/src/java/com/generationjava/beans/BeanViewRuntime.java b/genjava/gj-beans/src/java/com/generationjava/beans/BeanViewRuntime.java deleted file mode 100644 index 82eda0ab..00000000 --- a/genjava/gj-beans/src/java/com/generationjava/beans/BeanViewRuntime.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.beans; - -import java.util.LinkedList; -import java.util.Iterator; - -public class BeanViewRuntime { - - private LinkedList list; - - public BeanViewRuntime() { - list = new LinkedList(); - } - - public Iterator iterateUpwards() { - return list.iterator(); - } - - public void pushObject(Object obj) { - list.addFirst(obj); - } - - public Object parentObject() { - return list.getFirst(); - } - - public Object parentObject(int n) { - return list.get(n); - } - -} diff --git a/genjava/gj-beans/src/java/com/generationjava/beans/BeansW.java b/genjava/gj-beans/src/java/com/generationjava/beans/BeansW.java deleted file mode 100644 index 56916b86..00000000 --- a/genjava/gj-beans/src/java/com/generationjava/beans/BeansW.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.beans; - -import java.beans.BeanInfo; -import java.beans.Introspector; -import java.beans.IntrospectionException; -import java.beans.PropertyDescriptor; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; - -import com.generationjava.lang.ClassW; -import org.apache.commons.lang.NumberUtils; - -public class BeansW { - - static private java.text.DateFormat format = new java.text.SimpleDateFormat(); - - static public Object convert(Object value, Class toClass) { - if(toClass.equals(value.getClass())) { - return value; - } else - if(ClassW.classInstanceOf(toClass, "java.lang.String")) { - return value; - } else - if(ClassW.classInstanceOf(toClass, "java.lang.Integer") || - Integer.TYPE.equals(toClass) - ) { - return NumberUtils.createInteger(value.toString()); - } else - if(ClassW.classInstanceOf(toClass, "java.lang.Long") || - Long.TYPE.equals(toClass) - ) { - return NumberUtils.createLong(value.toString()); - } else - if(ClassW.classInstanceOf(toClass, "java.lang.Double") || - Double.TYPE.equals(toClass) - ) { - return NumberUtils.createDouble(value.toString()); - } else - if(ClassW.classInstanceOf(toClass, "java.lang.Number")) { - return NumberUtils.createNumber(value.toString()); - } else - if(ClassW.classInstanceOf(toClass, "java.util.Date")) { -// return DateW.parseString(value.toString()); - try { - return format.parse( value.toString() ); - } catch(java.text.ParseException pe) { - return value; - } - } else { - return value; - } - } - - static public String beanToString(Object bean) { - if(bean == null) { - return null; - } - Class clss = bean.getClass(); - StringBuffer text = new StringBuffer(); - try { - BeanInfo beaninfo = Introspector.getBeanInfo(clss); - PropertyDescriptor[] pd = beaninfo.getPropertyDescriptors(); - for(int i=0; i - -

-Provides reflective ability on JavaBeans. BeanComparator in com.generationjava.compare uses this and is very nice. com.generationjava.collections.BeanMap is also nice. -

-

-Jakarta Commons BeanUtils is pretty much the same as all this. This is cuter I think, but less mature. -

- - diff --git a/genjava/gj-beans/src/java/com/generationjava/collections/BeanMap.java b/genjava/gj-beans/src/java/com/generationjava/collections/BeanMap.java deleted file mode 100644 index 44fa5797..00000000 --- a/genjava/gj-beans/src/java/com/generationjava/collections/BeanMap.java +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.collections; - -import java.beans.BeanInfo; -import java.beans.Introspector; -import java.beans.IntrospectionException; -import java.beans.PropertyDescriptor; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import java.util.Map; -import java.util.HashMap; -import java.util.Collection; -import java.util.Set; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.apache.commons.collections.CollectionUtils; - -import com.generationjava.beans.AbstractBeanViewer; -import com.generationjava.beans.BeanViewRuntime; - -/** - * A Map which wraps a JavaBean. - * - * @date 2001-05-11 - */ -public class BeanMap extends AbstractBeanViewer implements Map { - - private Object myBean = null; - private Map pdCache = new HashMap(); - - /** - * Construct a BeanMap around the supplied Java Bean. - */ - public BeanMap(Object bean) { - myBean = bean; - try { - BeanInfo info = Introspector.getBeanInfo( myBean.getClass() ); - PropertyDescriptor[] pds = info.getPropertyDescriptors(); - for(int i=0; i 1) { - name += name.substring(1); - } - -/* - methodName = "get"+methodName; - - Method getMethod = null; - Class[] clss0 = new Class[0]; - Class[] clss = null; - try { - if(idx != -1) { - clss = new Class[1]; - clss[0] = Integer.TYPE; - } else { - clss = clss0; - } - getMethod = bean.getClass().getMethod(methodName, clss); - } catch(SecurityException se) { - } catch(NoSuchMethodException nsme) { - try { - if(clss != clss0) { - getMethod = bean.getClass().getMethod(methodName, clss0); - } - arrayLike = false; - } catch(SecurityException se2) { - } catch(NoSuchMethodException nsme2) { - } - } - - if(getMethod == null) { - return null; - } - try { - Object[] param = null; - if(arrayLike) { - param = new Object[1]; - param[0] = new Integer(idx); - } else { - param = new Object[0]; - } - Object obj = getMethod.invoke( bean, param ); -* / - Object obj = invokeGet( bean, name, index ); - obj = CollectionUtils.index(obj, index); - return obj; - /* - if( (obj instanceof Map) && (pre != null) ) { - return ((Map)obj).get(pre); - } else - if( (obj instanceof List) && (idx != -1) ) { - return ((List)obj).get(idx); - } else - if( (obj instanceof Object[]) && (idx != -1) ) { - return ((Object[])obj)[idx]; - } else { - return obj; - } - */ -/* - } catch(IllegalAccessException iae) { - return null; - } catch(IllegalArgumentException iae) { - return null; - } catch(InvocationTargetException ite) { - return null; - } -* / - } -*/ - /** - * Returns bean.get[idx] - */ - public Object invokeGet(BeanViewRuntime runtime, Object bean, String methodName, Object index) { - int idx = -1; - boolean arrayLike = (index instanceof Integer); - if(arrayLike) { - idx = ((Integer)index).intValue(); - } - methodName = "get"+methodName; - - Method getMethod = null; - Class[] clss0 = new Class[0]; - Class[] clss = null; - try { - if(arrayLike) { - clss = new Class[1]; - clss[0] = Integer.TYPE; - } else { - clss = clss0; - } - getMethod = bean.getClass().getMethod(methodName, clss); - } catch(SecurityException se) { - } catch(NoSuchMethodException nsme) { - try { - if(clss != clss0) { - getMethod = bean.getClass().getMethod(methodName, clss0); - } - arrayLike = false; - } catch(SecurityException se2) { - } catch(NoSuchMethodException nsme2) { - } - } - - if(getMethod == null) { - return null; - } - try { - Object[] param = null; - if(arrayLike) { - param = new Object[1]; - param[0] = new Integer(idx); - } else { - param = new Object[0]; - } - Object obj = getMethod.invoke( bean, param ); - obj = CollectionUtils.index(obj, idx); - - return obj; -// if( (obj instanceof Map) && (pre != null) ) { -// return ((Map)obj).get(pre); -// } else -// if( (obj instanceof List) && (idx != -1) ) { -// return ((List)obj).get(idx); -// } else -// if( (obj instanceof Object[]) && (idx != -1) ) { -// return ((Object[])obj)[idx]; -// } else { -// return obj; -// } - } catch(IllegalAccessException iae) { - return null; - } catch(IllegalArgumentException iae) { - return null; - } catch(InvocationTargetException ite) { - return null; - } - } - - public void invokeSet(BeanViewRuntime runtime, Object bean, String name, Object idx, Object value) { - } -} diff --git a/genjava/gj-beans/src/java/com/generationjava/compare/BeanComparator.java b/genjava/gj-beans/src/java/com/generationjava/compare/BeanComparator.java deleted file mode 100644 index fd7bc629..00000000 --- a/genjava/gj-beans/src/java/com/generationjava/compare/BeanComparator.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.compare; - -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; -import java.util.Iterator; - -import com.generationjava.beans.ReflectionBeanViewer; - -/** - * A Comparator for JavaBeans. Provide the name of the property to - * be compared with, and BeanComparator will deal with finding the - * property and comparing on it using ObjectComparator. - * - * Some examples are: - * "person" -> getPerson() - * "person.name" -> getPerson().getName() - * "person.addressMap.fred" -> getPerson().getAddressMap().get("fred") - * "person.phone[3]" -> getPerson().getPhone()[3] and - * getPerson().getPhone().get(3) (array and List) - */ -public class BeanComparator implements Comparator { - - static private Map beanComparatorRegistry = new HashMap(); - - /** - * Get a BeanComparator for the specified property. - */ - static public BeanComparator getInstance(String attrib) { - Object obj = beanComparatorRegistry.get(attrib); - if(obj == null) { - obj = new BeanComparator(attrib); - beanComparatorRegistry.put(attrib, obj); - } - return (BeanComparator)obj; - } - - private String attribute; - private HashMap cache; - private ReflectionBeanViewer bv = new ReflectionBeanViewer(); - private Comparator oc = new ObjectComparator(); - - public BeanComparator(String attrib) { - this.attribute = attrib; - } - - public void setComparator(Comparator comp) { - this.oc = comp; - } - - /** - * Do a Schwartzian transform precompile of all the values. - * Pattern from Perl. - */ - public void precompile(Collection col) { - caching(true); - Iterator iterator = col.iterator(); - while(iterator.hasNext()) { - Object bean = iterator.next(); - Object ret = bv.get(this.attribute, bean); - cache.put(bean, ret); - } - } - - /** - * Turn on caching. Akin to Perl's Orcish maneuver. - * Recalling this method will reset caching. - */ - public boolean caching(boolean b) { - boolean b2 = caching(); - this.cache = b?new HashMap():null; - return b2; - } - - /** - * Is caching on? - */ - public boolean caching() { - return (this.cache != null); - } - - public int compare(Object o1, Object o2) { - if(o1 == null) { - return 1; - } else - if(o2 == null) { - return -1; - } - - Object ret1 = null; - Object ret2 = null; - if(caching()) { - ret1 = cache.get(o1); - ret2 = cache.get(o2); - } - if(ret1 == null) { - ret1 = bv.get(this.attribute, o1); - } - if(ret2 == null) { - ret2 = bv.get(this.attribute, o2); - } - - return oc.compare(ret1, ret2); - } -} - diff --git a/genjava/gj-beans/src/java/com/generationjava/namespace/BeanNamespace.java b/genjava/gj-beans/src/java/com/generationjava/namespace/BeanNamespace.java deleted file mode 100644 index e0b2eace..00000000 --- a/genjava/gj-beans/src/java/com/generationjava/namespace/BeanNamespace.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.namespace; - -import java.util.Iterator; - -import com.generationjava.beans.ReflectionBeanViewer; - -/** - * A Bean namespace. It gets its value from a java-bean. - */ -public class BeanNamespace extends AbstractNamespace { - - private ReflectionBeanViewer myViewer; - private Object myBean; - - public BeanNamespace(Object bean) { - this.myViewer = new ReflectionBeanViewer(); - this.myBean = bean; - } - - public Object getBean() { - return this.myBean; - } - - /** - * Get a property from a bean. Dotted notation, array notation - * and associative array notation all apply. - */ - public Object getValue(String name) { - return myViewer.get(name,myBean); - } - - /** - * Unimplemented. - */ - public void putValue(String name, Object info) { - // bean-namespace's are read only for the moment. - } - - public Iterator iterateNames() { - // return the names - return null; - } - -} diff --git a/genjava/gj-beans/xdocs/changes.xml b/genjava/gj-beans/xdocs/changes.xml deleted file mode 100644 index adc3c280..00000000 --- a/genjava/gj-beans/xdocs/changes.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Henri Yandell - Release Notes - - - - - - - diff --git a/genjava/gj-beans/xdocs/images/1x1.gif b/genjava/gj-beans/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/genjava/gj-beans/xdocs/images/1x1.gif and /dev/null differ diff --git a/genjava/gj-beans/xdocs/images/osjava.gif b/genjava/gj-beans/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/genjava/gj-beans/xdocs/images/osjava.gif and /dev/null differ diff --git a/genjava/gj-beans/xdocs/navigation.xml b/genjava/gj-beans/xdocs/navigation.xml deleted file mode 100644 index ae46a44a..00000000 --- a/genjava/gj-beans/xdocs/navigation.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - genjava - - - - - - - - - - - - - - - diff --git a/genjava/gj-config/LICENSE.txt b/genjava/gj-config/LICENSE.txt deleted file mode 100644 index 2a616f94..00000000 --- a/genjava/gj-config/LICENSE.txt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003-2004, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of OSJava nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/genjava/gj-config/maven.xml b/genjava/gj-config/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/genjava/gj-config/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/genjava/gj-config/pom.xml b/genjava/gj-config/pom.xml deleted file mode 100644 index 4cd27aa3..00000000 --- a/genjava/gj-config/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - genjava - genjava - UNUSED - - 4.0.0 - gj-config - GenJava-Config - 2.0 - 2003 - - - Simple configuration system, mainly for use with a JNDI implementation such as simple-jndi. - - - - - - diff --git a/genjava/gj-config/project.properties b/genjava/gj-config/project.properties deleted file mode 100644 index d0f1d722..00000000 --- a/genjava/gj-config/project.properties +++ /dev/null @@ -1,18 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.checkstyle.properties=../../hen_checkstyle.xml - -maven.javadoc.stylesheet=../../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/genjava/gj-config/project.xml b/genjava/gj-config/project.xml deleted file mode 100644 index cc94eb6f..00000000 --- a/genjava/gj-config/project.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - ../project.xml - gj-config - GenJava-Config - 2.0 - 2003 - - - Simple configuration system, mainly for use with a JNDI implementation such as simple-jndi. - - - Simple configuration system - - - diff --git a/genjava/gj-config/src/java/com/generationjava/config/AbstractConfig.java b/genjava/gj-config/src/java/com/generationjava/config/AbstractConfig.java deleted file mode 100644 index a2242daa..00000000 --- a/genjava/gj-config/src/java/com/generationjava/config/AbstractConfig.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of OSJava nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.config; - -import java.util.ArrayList; -import java.util.List; -import java.util.Date; - -public abstract class AbstractConfig implements Config { - - private String context = ""; - - protected abstract Object getValue(String key); - - public Object get(String key) { - return getValue( getContext()+key ); - } - - public boolean has(String key) { - return (get(key) != null); - } - - public Object getAbsolute(String key) { - return getValue(key); - } - - public String getString(String key) { - return (String)get(key); - } - - public Date getDate(String key) { - try { - return java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT).parse(key); - } catch(java.text.ParseException pe) { - return null; - } - } - - // rely on simple-jndi's type - public int getInt(String key) { - try { - return Integer.parseInt( getString(key) ); - } catch(NumberFormatException nfe) { - return 0; - } - } - - public double getDouble(String key) { - try { - return Double.parseDouble( getString(key) ); - } catch(NumberFormatException nfe) { - return 0.0; - } - } - - public List getList(String key) { - Object obj = get(key); - if(!(obj instanceof List)) { - List list = new ArrayList(1); - list.add(obj); - obj = list; - } - return (List)obj; - } - - public void setContext(String context) { - this.context = context; - } - - public void pushToContext(String contextElement) { - this.context = this.context + contextElement; - } - - public void popFromContext(String contextElement) { - if(this.context.endsWith(contextElement)) { - this.context = this.context.substring(0, this.context.length() - contextElement.length()); - } else { - throw new IllegalArgumentException("Context does not end with: "+contextElement); - } - } - - public String getContext() { - return this.context; - } - - public Config cloneConfig() { - try { - return (Config)this.clone(); - } catch(CloneNotSupportedException cnse) { - // ignore - throw new RuntimeException("Cloning of a Config failed. This should be impossible. "); - } - } - -} diff --git a/genjava/gj-config/src/java/com/generationjava/config/Config.java b/genjava/gj-config/src/java/com/generationjava/config/Config.java deleted file mode 100644 index 33a008b1..00000000 --- a/genjava/gj-config/src/java/com/generationjava/config/Config.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of OSJava nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.config; - -import java.util.List; -import java.util.Date; - -public interface Config extends Cloneable { - - public Object get(String key); - public boolean has(String key); - public Object getAbsolute(String key); - public String getString(String key); - public int getInt(String key); - public double getDouble(String key); - public Date getDate(String key); - public List getList(String key); - public void setContext(String context); - public void pushToContext(String contextElement); - public void popFromContext(String contextElement); - public String getContext(); - public Config cloneConfig(); - -} diff --git a/genjava/gj-config/src/java/com/generationjava/config/JndiConfig.java b/genjava/gj-config/src/java/com/generationjava/config/JndiConfig.java deleted file mode 100644 index e1c401b0..00000000 --- a/genjava/gj-config/src/java/com/generationjava/config/JndiConfig.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of OSJava nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.config; - -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import java.util.List; - -public class JndiConfig extends AbstractConfig { - - private Context ctxt; - - public JndiConfig() throws NamingException { - this.ctxt = new InitialContext(); - } - - public JndiConfig(Context ctxt) { - this.ctxt = ctxt; - } - - protected Object getValue(String key) { - try { - return ctxt.lookup(key); - } catch(NamingException ne) { - return null; - } - } - - public String toString() { - return ""+this.ctxt; - } - -} diff --git a/genjava/gj-config/src/java/com/generationjava/config/MapConfig.java b/genjava/gj-config/src/java/com/generationjava/config/MapConfig.java deleted file mode 100644 index b9155c78..00000000 --- a/genjava/gj-config/src/java/com/generationjava/config/MapConfig.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of OSJava nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.config; - -import java.util.Map; - -public class MapConfig extends AbstractConfig { - - private Map map; - - public MapConfig(Map map) { - this.map = map; - } - - protected Object getValue(String key) { - return this.map.get(key); - } - - public String toString() { - return ""+this.map; - } - -} diff --git a/genjava/gj-config/xdocs/changes.xml b/genjava/gj-config/xdocs/changes.xml deleted file mode 100644 index 8649d9ed..00000000 --- a/genjava/gj-config/xdocs/changes.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Henri Yandell - Changes - - - - - Changed the package from org.osjava.jndi.config to com.generationjava.config. - - - JNDI configuration implementation as used in Scraping-Engine with simple-jndi - Memory/Map configuration implementation - - - diff --git a/genjava/gj-config/xdocs/images/1x1.gif b/genjava/gj-config/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/genjava/gj-config/xdocs/images/1x1.gif and /dev/null differ diff --git a/genjava/gj-config/xdocs/images/osjava.gif b/genjava/gj-config/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/genjava/gj-config/xdocs/images/osjava.gif and /dev/null differ diff --git a/genjava/gj-config/xdocs/navigation.xml b/genjava/gj-config/xdocs/navigation.xml deleted file mode 100644 index ae46a44a..00000000 --- a/genjava/gj-config/xdocs/navigation.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - genjava - - - - - - - - - - - - - - - diff --git a/genjava/gj-core/LICENSE.txt b/genjava/gj-core/LICENSE.txt deleted file mode 100644 index 38aecf65..00000000 --- a/genjava/gj-core/LICENSE.txt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/genjava/gj-core/maven.xml b/genjava/gj-core/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/genjava/gj-core/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/genjava/gj-core/pom.xml b/genjava/gj-core/pom.xml deleted file mode 100644 index 7cfcfb15..00000000 --- a/genjava/gj-core/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - genjava - genjava - UNUSED - - 4.0.0 - gj-core - GenJava-Core - 3.3-SNAPSHOT - 2000 - - - A re-usable library of Java classes. Originally stand-alone, many of the classes have since gone into various parts of the Jakarta Commons project, and thus this package contains various dependencies. - - - - - commons-lang - commons-lang - 2.3 - - - commons-collections - commons-collections - 3.2 - - - commons-io - commons-io - 1.4 - - - - - diff --git a/genjava/gj-core/project.properties b/genjava/gj-core/project.properties deleted file mode 100644 index d0f1d722..00000000 --- a/genjava/gj-core/project.properties +++ /dev/null @@ -1,18 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.checkstyle.properties=../../hen_checkstyle.xml - -maven.javadoc.stylesheet=../../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/genjava/gj-core/project.xml b/genjava/gj-core/project.xml deleted file mode 100644 index 0cfcfcc0..00000000 --- a/genjava/gj-core/project.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - ../project.xml - gj-core - GenJava-Core - 3.3-SNAPSHOT - 2000 - - - A re-usable library of Java classes. Originally stand-alone, many of the classes have since gone into various parts of the Jakarta Commons project, and thus this package contains various dependencies. - - - Core code - - - - commons-lang - 2.3 - - - commons-collections - 3.2 - - - commons-io - 1.4 - - - - - diff --git a/genjava/gj-core/src/java/com/generationjava/collections/Alias.java b/genjava/gj-core/src/java/com/generationjava/collections/Alias.java deleted file mode 100644 index c6b5dd12..00000000 --- a/genjava/gj-core/src/java/com/generationjava/collections/Alias.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.collections; - -/** - * An Alias for use in the AliasedMap - */ -public interface Alias { - public Object getAlias(); -} diff --git a/genjava/gj-core/src/java/com/generationjava/collections/AliasedMap.java b/genjava/gj-core/src/java/com/generationjava/collections/AliasedMap.java deleted file mode 100644 index 09c6a40b..00000000 --- a/genjava/gj-core/src/java/com/generationjava/collections/AliasedMap.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.collections; - -import java.util.Map; -import java.util.HashMap; -import java.util.Collection; -import java.util.Set; -import java.util.Iterator; -import java.util.LinkedList; - -/** - * A Map in which some key's values may point to another key. - * A process coined as 'aliasing'. - * - * @date 2000-05-14 - */ -public class AliasedMap implements Map { - - // this is not lazy instantiation. One MUST be - // constructed in a constructor. - private Map myMap = null; - - public AliasedMap(Map m) { - myMap = m; - } - - public AliasedMap() { - this(new HashMap()); - } - - /** - * Alias an existing key with an aliased key. The existing key may - * be an alias. - * - * @param aliaskey Object new alias - * @param existingkey Object existing key - */ - public void alias(Object aliaskey,Object existingkey) { - // enforce existing key? - Alias alias = new SimpleAlias(existingkey); - myMap.put(aliaskey,alias); - } - - /** - * Get all aliases. - */ - public Collection aliases() { - Collection values = myMap.values(); - if(values == null) { - return null; - } - - LinkedList ret = new LinkedList(); - - Iterator it = values.iterator(); - while(it.hasNext()) { - Object obj = it.next(); - if(obj instanceof Alias) { - ret.add(obj); - } - } - - return ret; - } - -/* - /** - * Creates a new AliasedMap with the existing aliases linked to their - * true values. - * / - public AliasedMap newMapWithAliases() { - return (AliasedMap)fillMapWithAliases(new AliasedMap()); - } - /** - * Fills a Map with the existing aliases linked to their - * true values. - * / - public Map fillMapWithAliases(Map ret) { - Collection aliases = aliases(); - if(aliases != null) { - Iterator it = aliases.iterator(); - while(it.hasNext()) { - Alias alias = (Alias)it.next(); - ret.put(alias,alias.getAlias()); - } - } - return ret; - } -*/ - - - /* map interface */ - - /** - * Removes all mappings from this map. - */ - public void clear() { - myMap.clear(); - } - - /** - * Returns true if this map contains a mapping for the specified key. - */ - public boolean containsKey(Object key) { - return myMap.containsKey(key); - } - - /** - * Returns true if this map maps one or more keys to the specified value. - */ - public boolean containsValue(Object value) { - // QUERY: What if the value is an alias? Do we deny aliasing? - return myMap.containsValue(value); - } - - /** - * Returns a set view of the mappings contained in this map. - */ - public Set entrySet() { - // FIX : Make this actually work. - return myMap.entrySet(); - } - - /** - * Compares the specified object with this map for equality. - */ - public boolean equals(Object o) { - // QUERY: Is this right? - return myMap.equals(o); - } - - /** - * Returns the value to which this map maps the specified key. - */ - public Object get(Object key) { - Object ob = myMap.get(key); - if(ob instanceof Alias) { - return get( ((Alias)ob).getAlias() ); - } else { - return ob; - } - } - - /** - * Returns the hash code value for this map. - */ - public int hashCode() { - // QUERY: Is this right? - return myMap.hashCode(); - } - - /** - * Returns true if this map contains no key-value mappings. - */ - public boolean isEmpty() { - // TODO : Make it ignore aliases. - return myMap.isEmpty(); - } - - /** - * Returns a set view of the keys contained in this map. - */ - public Set keySet() { - return myMap.keySet(); - } - - /** - * Associates the specified value with the specified key in this map . - */ - public Object put(Object key, Object value) { - // TODO : Make it return the value aliased, rather than the alias. - return myMap.put(key,value); - } - - /** - * Copies all of the mappings from the specified map to this map. - */ - public void putAll(Map t) { - myMap.putAll(t); - } - - /** - * Removes the mapping for this key from this map if present. - */ - public Object remove(Object key) { - // QUERY: Should it return value aliased, as it is doing now? - Object ob = get(key); - myMap.remove(key); - return ob; - } - - /** - * Returns the number of key-value mappings in this map. - */ - public int size() { - // QUERY: This is okay I think. - return myMap.size(); - } - - /** - * Returns a collection view of the values contained in this map. - */ - public Collection values() { - // TODO : Remove aliases. - return myMap.values(); - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/collections/BlockIterator.java b/genjava/gj-core/src/java/com/generationjava/collections/BlockIterator.java deleted file mode 100644 index c7a6f771..00000000 --- a/genjava/gj-core/src/java/com/generationjava/collections/BlockIterator.java +++ /dev/null @@ -1,66 +0,0 @@ -// BlockIterator.java -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.collections; - -import java.util.Iterator; -import java.util.ArrayList; - -public class BlockIterator implements Iterator { - - private Iterator iterator; - private int size; - - public BlockIterator(int size, Iterator iterator) { - this.size = size; - this.iterator = iterator; - } - - public boolean hasNext() { - return this.iterator.hasNext(); - } - - public Object next() { - ArrayList list = new ArrayList(size); - int loop = this.size; - while( (loop > 0) && (this.iterator.hasNext()) ) { - list.add(this.iterator.next()); - loop--; - } - return list; - } - - public void remove() { - // - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/collections/CachingIterator.java b/genjava/gj-core/src/java/com/generationjava/collections/CachingIterator.java deleted file mode 100644 index a7f36281..00000000 --- a/genjava/gj-core/src/java/com/generationjava/collections/CachingIterator.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.collections; - -import java.util.Iterator; -import java.util.LinkedList; - -/** - * A piping Iterator which caches all objects that pass through it. - * When reset is called, it returns to the start of its cache. - * This however only allows for one version of the iterator at a time - * to be used. It gets used again and again. - * The alternative is to use the static cache method, or the iterate - * method. Both of which may be used to get a new Iterator over the - * same data. - * - * @date 2001-12-01 - */ -public class CachingIterator implements ResetableIterator { - - static Iterator cache(Iterator iterator) { - if(iterator instanceof CachingIterator) { - return ((CachingIterator)iterator).iterate(); - } else { - return new CachingIterator(iterator); - } - } - - private Iterator iterator; - private LinkedList cacheList; - private Iterator cacheIterator; - private boolean caching; - - public CachingIterator(Iterator iterator) { - this.iterator = iterator; - this.cacheList = new LinkedList(); - } - - public Object next() { - if(this.caching) { - return this.cacheIterator.next(); - } else { - Object tmp = iterator.next(); - this.cacheList.add(tmp); - return tmp; - } - } - - public boolean hasNext() { - if(this.caching) { - boolean tmp = this.cacheIterator.hasNext(); - return tmp; - } else { - boolean tmp = iterator.hasNext(); - if(!tmp) { - this.caching = true; - reset(); - } - return tmp; - } - } - - public void remove() { - if(this.caching) { - throw new UnsupportedOperationException("Not possible to remove "+ - "from the Iterator once it has begun to cache. "); - } else { - this.iterator.remove(); - } - } - - /** - * Force a loading of the wrapped iterator into cache. - */ - public void loadCache() { - if(!this.caching) { - while(this.iterator.hasNext()) { - this.cacheList.add(this.iterator.next()); - } - } - } - - public void reset() { - this.cacheIterator = iterate(); - } - - public Iterator iterate() { - loadCache(); - return this.cacheList.iterator(); - } -} diff --git a/genjava/gj-core/src/java/com/generationjava/collections/ClassMap.java b/genjava/gj-core/src/java/com/generationjava/collections/ClassMap.java deleted file mode 100644 index 4d1637b3..00000000 --- a/genjava/gj-core/src/java/com/generationjava/collections/ClassMap.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.collections; - -import java.util.Map; -import org.apache.commons.collections.ProxyMap; - -/** - * A map which stores objects by a key Class. - * When obtaining the object, it will check inheritence and - * interface trees to see if the Class matches. - */ -public class ClassMap extends ProxyMap { - - public ClassMap(Map m) { - super(m); - } - - /** - * Get the object from the map. If the key is not - * a Class object, then it uses the Class of the object. - */ - public Object get(Object key) { - if(key == null) { - return null; - } - Class clss = null; - - if(key instanceof Class) { - clss = (Class)key; - } else { - clss = key.getClass(); - } - - Object obj = super.get(clss); - - if(obj == null) { - - // if this is null, let's go up the inheritence tree - obj = getInterfaces(clss); - - if(obj == null) { - obj = getSuperclass(clss); - } - } - - return obj; - } - - private Object getInterfaces(Class clss) { - if(clss == null) { - return null; - } - Object obj = null; - Class[] interfaces = clss.getInterfaces(); - for(int i=0; i i2.intValue() ) { - return 1; - } else { - return 0; - } - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/collections/Grouper.java b/genjava/gj-core/src/java/com/generationjava/collections/Grouper.java deleted file mode 100644 index bf2d3b87..00000000 --- a/genjava/gj-core/src/java/com/generationjava/collections/Grouper.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.collections; - -/** - * A marker interface for Groupers. - */ -public interface Grouper { - -} diff --git a/genjava/gj-core/src/java/com/generationjava/collections/IteratorGrouper.java b/genjava/gj-core/src/java/com/generationjava/collections/IteratorGrouper.java deleted file mode 100644 index 4f0357f3..00000000 --- a/genjava/gj-core/src/java/com/generationjava/collections/IteratorGrouper.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.collections; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.ArrayList; - -import org.apache.commons.collections.IteratorUtils; - -/** - * Take an enumeration of different types of objects. - * Pass them into this object and then get them out by classname. - */ -public class IteratorGrouper implements Grouper { - - static private Iterator nullIterator = IteratorUtils.EMPTY_ITERATOR; - - private HashMap map = new HashMap(); - - public IteratorGrouper(Iterator iterator) { - addIterator(iterator); - } - - /** - * Add this enumeration to the grouper. - */ - public void addIterator(Iterator iterator) { - while(iterator.hasNext()) { - Object obj = iterator.next(); - String classname = obj.getClass().getName(); - Object list = map.get(classname); - if(list == null) { - list = new ArrayList(); - map.put(classname, list); - } - ((List)list).add(obj); - } - } - - /** - * Get an enumeration of all the Classes of type classname. - */ - public Iterator iterateGroup(String classname) { - Object list = map.get(classname); - if(list instanceof List) { - return ((List)list).iterator(); - } else { - return nullIterator; - } - } - - /** - * Enumerate over the types this group contains. - */ - public Iterator iterateTypes() { - return map.keySet().iterator(); - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/collections/LimitedList.java b/genjava/gj-core/src/java/com/generationjava/collections/LimitedList.java deleted file mode 100644 index 802169e8..00000000 --- a/genjava/gj-core/src/java/com/generationjava/collections/LimitedList.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.collections; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.apache.commons.collections.list.AbstractListDecorator; - -/** - * Only allows N elements in. Once size N is reached, all - * new adds are ignored and inserts mean the one on the end - * of the list is removed. - */ -public class LimitedList extends AbstractListDecorator { - - private int capacity; - - public LimitedList(int capacity) { - this(new ArrayList(), capacity); - } - - public LimitedList(List list, int capacity) { - super(list); - this.capacity = capacity; - } - - public boolean isFull() { - return (this.capacity == size()); - } - - public boolean add(Object obj) { - if(isFull()) { - return false; - } else { - return super.add(obj); - } - } - - public boolean addAll(Collection coll) { - if(this.capacity <= size() + coll.size()) { - return false; - } else { - return super.addAll(coll); - } - } - - public boolean addAll(int i, Collection coll) { - if(this.capacity <= size() + coll.size()) { - return false; - } else { - return super.addAll(i,coll); - } - } - - /// TODO - public boolean retainAll(Collection coll) { - return super.retainAll(coll); - } - - public void add(int i, Object obj) { - if(this.capacity == i) { - return; - } else - if(isFull()) { - super.remove(this.capacity-1); - super.add(i,obj); - } else { - super.add(i,obj); - } - } - - public String toString() { - return super.toString(); - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/collections/MultiKeyedMap.java b/genjava/gj-core/src/java/com/generationjava/collections/MultiKeyedMap.java deleted file mode 100644 index b944a3a4..00000000 --- a/genjava/gj-core/src/java/com/generationjava/collections/MultiKeyedMap.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.collections; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; -import java.util.Set; -import java.util.HashSet; - -import com.generationjava.lang.ClassW; - -/** - * A Map in which multiple keys are used, ie) an Object array - * of keys. - * - * @author bayard@generationjava.com - * @date 2001-12-19 - */ -/// Pass in: { "key1", "key2", "key3" } and a value. -public class MultiKeyedMap implements Map { - - // this is not lazy instantiation. One MUST be - // constructed in a constructor. - private Map myMap = null; - - public MultiKeyedMap(Map m) { - myMap = m; - } - - public MultiKeyedMap() { - this(new HashMap()); - } - - /* map interface */ - - // Removes all mappings from this map (optional operation) {. - public void clear() { - myMap.clear(); - } - - // Returns true if this map contains a mapping for the specified key. - public boolean containsKey(Object key) { - return get(key) != null; - } - - // Returns true if this map maps one or more keys to the specified value. - public boolean containsValue(Object value) { - return this.containsValue(this.myMap, value); - } - - private boolean containsValue(Map map, Object value) { - Iterator values = map.values().iterator(); - while(values.hasNext()) { - Object obj = values.next(); - if(obj instanceof Map) { - if(containsValue((Map)obj, value) ) { - return true; - } - } - if(value == obj) { - return true; - } - if(value.equals(obj)) { - return true; - } - } - - return false; - } - - // Returns a set view of the mappings contained in this map. - public Set entrySet() { - // FIX : Make this actually work. - return myMap.entrySet(); - } - - // Compares the specified object with this map for equality. - public boolean equals(Object o) { - return myMap.equals(o); - } - - // Returns the value to which this map maps the specified key. - public Object get(Object key) { - if(key instanceof Object[]) { - Object[] keys = (Object[])key; - Map map = this.myMap; - int szLessOne = keys.length - 1; - for(int i=0; i-1; i--) { - if(comparator.compare(obj, get(i)) > 0) { - continue; - } else { - break; - } - } - super.add(i+1, obj); - } - - public boolean addAll(Collection coll) { - return super.addAll(coll); - } - - public boolean addAll(int i, Collection coll) { - return super.addAll(i,coll); - } - - /// TODO - public boolean retainAll(Collection coll) { - return super.retainAll(coll); - } - - public void add(int i, Object obj) { - super.add(i,obj); - } - - public String toString() { - return super.toString(); - } -} diff --git a/genjava/gj-core/src/java/com/generationjava/collections/package.html b/genjava/gj-core/src/java/com/generationjava/collections/package.html deleted file mode 100644 index b339b709..00000000 --- a/genjava/gj-core/src/java/com/generationjava/collections/package.html +++ /dev/null @@ -1,9 +0,0 @@ - - -

- Generic collections. Some have gone to Apache Commons Collections, others - are already replicated there. At some point the ones which are at Apache - will need to be dropped. -

- - diff --git a/genjava/gj-core/src/java/com/generationjava/compare/NumericStringComparator.java b/genjava/gj-core/src/java/com/generationjava/compare/NumericStringComparator.java deleted file mode 100644 index 327aba1d..00000000 --- a/genjava/gj-core/src/java/com/generationjava/compare/NumericStringComparator.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.compare; - -import java.util.Comparator; - -/** - * A Comparator which deals with alphabet characters 'naturally', but - * deals with numerics numerically. Leading 0's are ignored numerically, - * but do come into play if the number is equal. Thus aaa119yyyy comes before - * aaa0119xxxx regardless of x or y. - * - * The comparison should be very performant as it only ever deals with - * issues at a character level and never tries to consider the - * numerics as numbers. - * - * @author bayard@generationjava.com - */ -public class NumericStringComparator implements Comparator { - - public NumericStringComparator() { - } - - public int compare(Object o1, Object o2) { -// System.out.println("Comparing: "+o1+" and "+o2); - if(o1 == null) { - return 1; - } else - if(o2 == null) { - return -1; - } - - String s1 = o1.toString(); - String s2 = o2.toString(); - - // find the first digit. - int idx1 = getFirstDigitIndex(s1); - int idx2 = getFirstDigitIndex(s2); - - if( ( idx1 == -1 ) || - ( idx2 == -1 ) || - ( !s1.substring(0,idx1).equals(s2.substring(0,idx2)) ) - ) - { -// System.out.println("Shortcutted. "); - return s1.compareTo(s2); - } - - // find the last digit - int edx1 = getLastDigitIndex(s1, idx1); - int edx2 = getLastDigitIndex(s2, idx2); - - String sub1 = null; - String sub2 = null; - - if(edx1 == -1) { - sub1 = s1.substring(idx1); - } else { - sub1 = s1.substring(idx1, edx1); - } - - if(edx2 == -1) { - sub2 = s2.substring(idx2); - } else { - sub2 = s2.substring(idx2, edx2); - } - - // deal with zeros at start of each number - int zero1 = countZeroes(sub1); - int zero2 = countZeroes(sub2); - - sub1 = sub1.substring(zero1); - sub2 = sub2.substring(zero2); - - // if equal, then recurse with the rest of the string - // need to deal with zeroes so that 00119 appears after 119 - if(sub1.equals(sub2)) { - int ret = 0; - if(zero1 > zero2) { - ret = 1; - } else - if(zero1 < zero2) { - ret = -1; - } -// System.out.println("EDXs: "+edx1+" & "+edx2); - if(edx1 == -1) { - s1 = ""; - } else { - s1 = s1.substring(edx1); - } - if(edx2 == -1) { - s2 = ""; - } else { - s2 = s2.substring(edx2); - } - - int comp = compare(s1, s2); - if(comp != 0) { - ret = comp; - } -// System.out.println("Dealt with rest of string: "+ret); - return ret; - } else { - // if a numerical string is smaller in length than another - // then it must be less. - if(sub1.length() != sub2.length()) { -// System.out.println("Ahah, different length. "); - return ( sub1.length() < sub2.length() ) ? -1 : 1; - } - } - - - // now we get to do the string based numerical thing :) - // going to assume that the individual character for the - // number has the right order. ie) '9' > '0' - // possibly bad in i18n. - char[] chr1 = sub1.toCharArray(); - char[] chr2 = sub2.toCharArray(); - - int sz = chr1.length; - for(int i=0; i - -

- Comparators. Some are at Apache Commons Collections. BeanComparator is very - nice. -

- - diff --git a/genjava/gj-core/src/java/com/generationjava/io/CommandLine.java b/genjava/gj-core/src/java/com/generationjava/io/CommandLine.java deleted file mode 100644 index b56ddf01..00000000 --- a/genjava/gj-core/src/java/com/generationjava/io/CommandLine.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.io; - -import java.io.IOException; -import java.io.BufferedReader; -import java.io.Reader; -import java.io.InputStreamReader; -import java.io.InputStream; - -/** - * Read lines from a Command Line. - * This allows the code that deals with the commands to be independent - * of the command-reading. - */ -public class CommandLine { - - private BufferedReader br = null; - private CommandLineListener myListener = null; - private String prompt = ""; - - /** - * Create a CommandLine with the InputStream to read commands - * from and the CommandLineListener to send commands to. - */ - public CommandLine(InputStream is, CommandLineListener cll) { - this( new InputStreamReader(is), cll); - } - - /** - * Create a CommandLine with the Reader to read commands - * from and the CommandLineListener to send commands to. - */ - public CommandLine(Reader rdr, CommandLineListener cll) { - br = new BufferedReader(rdr); - myListener = cll; - } - - /** - * Set a prompt to ignore. - */ - public void setPrompt(String s) { - prompt = s; - } - - /** - * Get the prompt which will be ignored by the CommandLine. - */ - public String getPrompt() { - return prompt; - } - - /** - * Start the CommandLine. - */ - public void startReading() throws IOException { - if(myListener == null) { - throw new IOException("No CommandLineListener set. "); - } - - String cmd = null; - while(true) { - cmd = br.readLine(); - if(cmd.startsWith(prompt)) { - cmd = cmd.substring(prompt.length()); - } - myListener.cmdEntered(cmd); - } - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/io/CommandLineListener.java b/genjava/gj-core/src/java/com/generationjava/io/CommandLineListener.java deleted file mode 100644 index c2eec352..00000000 --- a/genjava/gj-core/src/java/com/generationjava/io/CommandLineListener.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.io; - -/** - * Listens to a CommandLine and gets informed when commands have - * been entered. - */ -public interface CommandLineListener { - public void cmdEntered(String cmd); -} - diff --git a/genjava/gj-core/src/java/com/generationjava/io/FileEvent.java b/genjava/gj-core/src/java/com/generationjava/io/FileEvent.java deleted file mode 100644 index 2e1989dd..00000000 --- a/genjava/gj-core/src/java/com/generationjava/io/FileEvent.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.io; - -import java.util.EventObject; - -public class FileEvent extends EventObject { - - public FileEvent(Object obj) { - super(obj); - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/io/FilePoller.java b/genjava/gj-core/src/java/com/generationjava/io/FilePoller.java deleted file mode 100644 index cd14ed06..00000000 --- a/genjava/gj-core/src/java/com/generationjava/io/FilePoller.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.io; - -import java.io.File; - -import java.util.LinkedList; -import java.util.Iterator; - -public class FilePoller implements Runnable { - - static public void main(String[] strs) { - pollFile(strs[0]); - } - - static public void pollFile(String filename) { - File file = new File(filename); - FilePoller fp = new FilePoller(); - fp.addListener( new PollListener() { - public void fileChanged(FileEvent fe) { - System.err.println("File changed. "); - } - } ); - fp.setFile(file); - fp.setDelay(1L); - Thread t = new Thread(fp); - t.start(); - } - - private File file; - private long delay; - private StringBuffer buffer; - - private LinkedList listeners; - - public void setFile(File file) { - this.file = file; - } - - public void setDelay(long delay) { - this.delay = delay; - } - - public void addListener(PollListener listener) { - if(listeners == null) { - listeners = new LinkedList(); - } - listeners.add(listener); - } - - private void notifyListeners() { - if(listeners == null) { - return; - } - FileEvent fe = new FileEvent(this); - Iterator iterator = listeners.iterator(); - while(iterator.hasNext()) { - PollListener pl = (PollListener)iterator.next(); - pl.fileChanged(fe); - } - } - - public void run() { - long length = file.length(); - long lastMod = file.lastModified(); -// try { - while(true) { - if( (length != file.length()) || - (lastMod != file.lastModified()) - ) - { - notifyListeners(); - } - length = file.length(); - lastMod = file.lastModified(); - try { - Thread.sleep(this.delay); - } catch(InterruptedException ie) { - } - } -// } catch(IOException ioe) { -// ioe.printStackTrace(); -// } - } - - private void append(char ch) { - if(buffer == null) { - buffer = new StringBuffer(); - } - buffer.append(ch); - } - - public String getData() { - return buffer.toString(); - } - - public void clearData() { - buffer = null; - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/io/FileW.java b/genjava/gj-core/src/java/com/generationjava/io/FileW.java deleted file mode 100644 index b491e7be..00000000 --- a/genjava/gj-core/src/java/com/generationjava/io/FileW.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.io; - -import java.io.File; -import java.io.IOException; -import java.io.FileReader; -import java.io.Reader; -import java.io.InputStream; - -import java.io.Writer; -import java.io.FileWriter; - -import java.net.URL; - -import java.util.LinkedList; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.FilenameUtils; - -/** - * Provides useful, standard behaviour for dealing with java.io.Files. - */ -final public class FileW { - - static public String loadFromClasspath(String file) { - return loadFromClasspath(file, ClassLoader.getSystemClassLoader()); - } - static public String loadFromClasspath(String file, Object instance) { - return loadFromClasspath(file, instance.getClass().getClassLoader()); - } - static public String loadFromClasspath(String file, ClassLoader loader) { - if(loader == null) { - return null; - } - - URL url = loader.getResource(file); - if(url == null) { - url = loader.getResource("/"+file); - } - if(url == null) { - return null; - } - try { - return FileUtils.readFileToString(FileUtils.toFile(url)); - } catch(IOException ioe) { - throw new RuntimeException("Unexpected IOException", ioe); - } - } - - /** - * What is the full classname of this file. - * - * @param file File to find classname of - * - * @return String class name - */ - static public String getClassName(File file) { - String path = file.getPath(); - path = removePwd( path ); - return dottify( FilenameUtils.removeExtension(path) ); - } - - /** - * Removes the present working directory of a filename - * - * @param in String pathname - * - * @return String relative pathname - */ - static public String removePwd(String in) { - if(in == null) { - return null; - } - - String pwd = System.getProperty("user.dir"); - - if(pwd.length() == in.length()) { - return in; - } - - int idx = in.indexOf(pwd); - if(idx == 0) { - in = in.substring(pwd.length()+1); - } - - return in; - } - - // change bob/jim/fred to bob.jim.fred - // change /bob/jim/fred to bob.jim.fred - // change bob/jim/fred/ to bob.jim.fred - // change //// to empty string - // change null to null - /** - * Changes File.separator to dots in a pathname. - * - * @param in String pathname - * - * @return String pathname with dots instead of file separators. - */ - static public String dottify(String in) { - if(in == null) { - return null; - } - - int idx = in.indexOf( java.io.File.separator ); - while(idx != -1) { - if(in.length() == 1) { - return ""; // or null? - } else - if(idx == 0) { - in = in.substring(1); - } else - if(idx == in.length()) { - in = in.substring(0,in.length()-1); - } else { - in = in.substring(0,idx)+"."+in.substring(idx+1); - } - idx = in.indexOf("/"); - } - - return in; - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/io/FixedWidthReader.java b/genjava/gj-core/src/java/com/generationjava/io/FixedWidthReader.java deleted file mode 100644 index 4bb462cc..00000000 --- a/genjava/gj-core/src/java/com/generationjava/io/FixedWidthReader.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.io; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.Reader; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.NumberUtils; - -/// TODO: Have it do ConvertUtils stuff. "1:,2%,3$" etc. -public class FixedWidthReader { - - private BufferedReader rdr; - private int[] widths; - private String trim; - private int minWidth; - private boolean hasGlob; - - public FixedWidthReader(Reader rdr) { - if( !(rdr instanceof BufferedReader) ) { - rdr = new BufferedReader(rdr); - } - this.rdr = (BufferedReader)rdr; - } - - public void setWidths(int[] widths) { - this.widths = widths; - calcSizeCondition(); - } - - - - public void setWidths(String widths) { - String[] nums = StringUtils.split(widths, ","); - int sz = nums.length; - this.widths = new int[sz]; - - for(int i=0; i this.minWidth) { - return null; - } - } - - - int sz = widths.length; - String[] fields = new String[widths.length]; - - boolean reverse = false; - int idx = 0; - int i = 0; // we hang on to this in case it's needed in the j loop - - for(i=0; ii; j--) { - rev -= this.widths[j]; - fields[j] = line.substring(rev, rev+this.widths[j]); - } - fields[i] = line.substring(idx, rev); - } - - if(this.trim != null) { - for(int index=0; index width) { - width = wd; - } - int[] wds = row.getColumnSizes(); - - if(wds.length > colwidths.length) { - // expand the array. - int[] old = colwidths; - colwidths = new int[wds.length]; - System.arraycopy(old,0,colwidths,0,old.length); - for(int i=colwidths.length;i colwidths[i]) { - colwidths[i]=wds[i]; - } - } - } - - /** - * Used to iterate over the table. - */ - public boolean hasNext() { - if(myIterator == null) { - myIterator = table.iterator(); - } - return myIterator.hasNext(); - } - - /** - * Get the next value from the table. - */ - public Object next() { - if(myIterator == null) { - myIterator = table.iterator(); - } - ptr++; - return myIterator.next(); - } - - /** - * Reset the iterator. - */ - public void reset() { - myIterator = null; - } - - /** - * Iterator interface. - * Unimplemented. - */ - public void remove() {} - - /** - * Are we currently on the first row? - */ - public boolean firstRow() { - return (ptr<2); - } - - /** - * Are we on the last row? - */ - public boolean lastRow() { - return (ptr==getNumberOfRows()); - } - - /** - * Number of rows in this table. - */ - public int getNumberOfRows() { - return table.size(); - } - - /** - * Number of columns in this table. - */ - public int getNumberOfColumns() { - return width; - } - - /** - * Get the width of all the columns added together. - */ - public int getWidth() { - if(totalwidth == -1) { - totalwidth = 0; - for(int i=0;i value.length()) { - value = chr+value; - } - return value; - } - - public int getPrintedWidth() { - int sz = width; - sz += getVerticalBorder().length()*(numCols+1); - sz += getColumnSeparator().length()*(numCols-1); - return sz; - } - public void printBottom(StringBuffer buffer) { - printTop(buffer); - } - public void printTop(StringBuffer buffer) { - int count = 1; - int sz = getPrintedWidth(); - for(int i=0;i 0) { - buffer.append(getCornerBorder()); - continue; - } - } else - if(columnLocations != null) { - if(columnLocations[count] == i) { - buffer.append(getIntersectionBorder()); - count++; - continue; - } - } - - buffer.append(getHorizontalBorder()); - } - buffer.append(getRowSeparator()); - } - - //public void setHeight // How many rows can fit in?? - //public void setWidth // How many columns can squeeze in. - //public void setDrawTable // uses chars in above - - public String getHorizontalBorder() { - return "-"; - } - public String getIntersectionBorder() { - return "+"; - } - public String getCornerBorder() { - return "."; - } - public String getVerticalBorder() { - return "|"; - } - - public void setHeader(String[] strs) { - header = strs; - } - public void setFooter(String[] strs) { - footer = strs; - } - public void setRowSeparator(String sep) { - rowSep = sep; - } - public void setColumnSeparator(String sep) { - colSep = sep; - } - - public String getRowSeparator() { - return rowSep; - } - public String getColumnSeparator() { - return colSep; - } - public String[] getHeader() { - return header; - } - public String[] getFooter() { - return footer; - } -} diff --git a/genjava/gj-core/src/java/com/generationjava/io/ZipW.java b/genjava/gj-core/src/java/com/generationjava/io/ZipW.java deleted file mode 100644 index 629acad8..00000000 --- a/genjava/gj-core/src/java/com/generationjava/io/ZipW.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.io; - -import java.util.zip.ZipOutputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.io.IOException; -import java.io.OutputStream; - -/** - * Makes creating Zip files easier. - */ -final public class ZipW { - - private ZipOutputStream zipout = null; - - /** - * Provide the OutputStream that this Zip will be written to. - */ - public ZipW(OutputStream out) { - this.zipout = new ZipOutputStream( out ); - } - - /** - * Add the passed in String data to the Zip under the specified - * filename. - */ - public boolean addFile(String filename, String contents) { - // test if this dir has been written to yet? - try { - ZipEntry entry = new ZipEntry(filename); - entry.setTime(System.currentTimeMillis()); - entry.setSize(contents.length()); // *2? - zipout.putNextEntry(entry); - - zipout.write(contents.getBytes()); - - zipout.closeEntry(); - return true; - } catch(ZipException ze) { - ze.printStackTrace(); - return false; - } catch(IOException ioe) { - ioe.printStackTrace(); - return false; - } - - } - - /** - * Close the zip file. - */ - public void close() { - try { - zipout.close(); - } catch(ZipException ze) { - ze.printStackTrace(); - return; - } catch(IOException ioe) { - ioe.printStackTrace(); - return; - } - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/io/package.html b/genjava/gj-core/src/java/com/generationjava/io/package.html deleted file mode 100644 index a27e1c6f..00000000 --- a/genjava/gj-core/src/java/com/generationjava/io/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -

- Standard io code. Also see Apache Commons IO. [sandbox]. -

- - diff --git a/genjava/gj-core/src/java/com/generationjava/jdbc/JdbcW.java b/genjava/gj-core/src/java/com/generationjava/jdbc/JdbcW.java deleted file mode 100644 index b00039ea..00000000 --- a/genjava/gj-core/src/java/com/generationjava/jdbc/JdbcW.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.jdbc; - -import java.sql.DatabaseMetaData; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.SQLWarning; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.lang.StringUtils; - -public final class JdbcW { - - static public String[] getColumnNames(ResultSet rs) throws SQLException { - ResultSetMetaData rsmd = rs.getMetaData(); - int sz = rsmd.getColumnCount(); - String[] names = new String[sz]; - for(int i=0; i - -

- Wrappers and Helpers for JDBC. -

- - diff --git a/genjava/gj-core/src/java/com/generationjava/lang/BigIntegerUtils.java b/genjava/gj-core/src/java/com/generationjava/lang/BigIntegerUtils.java deleted file mode 100644 index 64a6ed0a..00000000 --- a/genjava/gj-core/src/java/com/generationjava/lang/BigIntegerUtils.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.lang; - -import java.math.BigInteger; - -// NOTE: A BigInteger runs counter-intuitive possible. For an integer made -// of the bits: 11010101 the first two bits are '01' and not 11. -// That is, the indexing starts from the right and goes left. -public class BigIntegerUtils { - - public static float extractFloat(BigInteger bi, int start, int end, int decimal) { - int intpart = extractInt(bi, start+decimal, end); - int decpart = extractInt(bi, start, start+decimal); - float decf = decpart; - while(decf >= 1.0) { - decf = decf / 10; - } - float ret = intpart + decf; - return ret; - } - public static int extractInt(BigInteger bi, int start, int end) { - bi = bi.shiftRight(start); - int foo = (int)Math.pow(2, end - start) - 1; - BigInteger mask = BigInteger.valueOf(foo); - bi = bi.and(mask); - return bi.intValue(); - } - public static boolean extractBoolean(BigInteger bi, int index) { - return bi.testBit(index); - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/lang/ClassConstantsReflector.java b/genjava/gj-core/src/java/com/generationjava/lang/ClassConstantsReflector.java deleted file mode 100644 index 6bf58f85..00000000 --- a/genjava/gj-core/src/java/com/generationjava/lang/ClassConstantsReflector.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -// hacked out of org.cyberiantiger's lovely class object model -package com.generationjava.lang; - -import org.apache.commons.lang.StringUtils; - -import java.util.*; -import java.io.*; - -/** - * A cut down copy of org.cyberiantiger's class object model. - * It provides a List of all the classes that a class file immediately - * depends on. - */ -public class ClassConstantsReflector { - - static public void main(String[] args) throws Throwable { - ClassConstantsReflector c = new ClassConstantsReflector(); - for(int i=0; i= constantPool.size() || - super_class == 0 || super_class >= constantPool.size() ) { - throw new RuntimeException("Invalid Constant Pool Reference"); - } - - Object ob = constantPool.get(this_class); - if(!(ob instanceof C7) ) { - throw new RuntimeException("Wrong type of object at reference in constant pool"); - } - thisClass = (C7) ob; - ob = constantPool.get(super_class); - if(!(ob instanceof C7) ) { - throw new RuntimeException("Wrong type of object at reference in constant pool"); - } - superClass = (C7) ob; - } - - class C1 { - String value; - C1() {} - C1(String value) { - this.value = value; - } - public byte getType() { return UTF8; } - public String getValue() { return value; } - public void readFrom(DataInputStream in) throws IOException { - value = in.readUTF(); - } - public boolean equals(Object obj) { - return (obj instanceof C1) && ((C1)obj).value.equals(value); - } - public int hashCode() { return value.hashCode(); } - public String toString() { return value; } - } - - class C7 { - int index; - C1 name; - public byte getType() { return CLASS; } - public C1 getClassName() { return name; } - public void readFrom(DataInputStream in) throws IOException { - index = in.readUnsignedShort(); - } - public void resolve() { - if(index == 0) { - throw new RuntimeException("Invalid Constant Pool Reference: "+index); - } - if(index >= constantPool.size()) { - throw new RuntimeException("Invalid Constant Pool Reference: "+index+"/"+constantPool.size()); - } - Object ob = constantPool.get(index); - if( !(ob instanceof C1) ) { - throw new RuntimeException("Wrong type of object at reference in constant pool"); - } - name = (C1) ob; - } - public boolean equals(Object obj) { - return (obj instanceof C7) && ((C7)obj).name.equals(name); - } - public int hashCode() { return name.hashCode(); } - public String toString() { return name.toString().replace('/','.');} - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/lang/ClassW.java b/genjava/gj-core/src/java/com/generationjava/lang/ClassW.java deleted file mode 100644 index 43909790..00000000 --- a/genjava/gj-core/src/java/com/generationjava/lang/ClassW.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.lang; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.apache.commons.lang.ArrayUtils; - -/** - * A set of static utilities for use with Classes. - * - * @author bayard@generationjava.com - * @date 2001-05-19 - */ -final public class ClassW { - - /** - * Create an object from the classname. Must have an empty constructor. - * - * @param classname String name of the class - * - * @return Object instance of the class or null - */ - static public Object createObject(String classname) { - Class tmpClass = null; - - tmpClass = getClass(classname); - - if(tmpClass == null) { -// System.err.println("No class for: "+classname); - return null; - } - - - return createObject(tmpClass); - } - - /** - * Create an object from a class. - * - * @param clss Class object to instantiate - * - * @return Object instance of the class or null - */ - static public Object createObject(Class clss) { - if(clss == null) { -// System.err.println("Null class passed in. "); - return null; - } - - try { - return clss.newInstance(); - } catch (IllegalAccessException iae) { -// System.err.println("Cant instantiate " + clss.getName() + " because " + -// iae.getMessage()); - } catch (InstantiationException ie) { -// System.err.println("Cant instantiate " + clss.getName() + " because " + -// ie.getMessage()); - } - - return null; - } - - /** - * Is this Class in the CLASSPATH - * - * @param classname String of the class - * - * @return boolean exists or not. - */ - static public boolean classExists(String classname) { - Class tmpClass = null; - - /* try and load class */ - try { -// tmpClass = Class.forName(classname); - tmpClass = Thread.currentThread().getContextClassLoader().loadClass(classname); - } catch (ClassNotFoundException cnfe) { - return false; - } catch (IllegalArgumentException iae) { - return false; - } - - return true; - } - - /** - * Get the Class object for a classname. - * - * @param classname String of the class - * - * @return Class instance for the class. - */ - static public Class getClass(String classname) { - Class tmpClass = null; - - /* try an load class */ - try { -// tmpClass = Class.forName(classname); - tmpClass = Thread.currentThread().getContextClassLoader().loadClass(classname); - } catch (ClassNotFoundException cnfe) { -// System.err.println("Can not resolve classname " + classname); - } catch (IllegalArgumentException iae) { -// System.err.println("Can nott resolve " + tmpClass.getName() + " because " + iae.getMessage()); - } - - return tmpClass; - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/lang/Notifier.java b/genjava/gj-core/src/java/com/generationjava/lang/Notifier.java deleted file mode 100644 index 30a690f7..00000000 --- a/genjava/gj-core/src/java/com/generationjava/lang/Notifier.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.lang; - -import java.util.ArrayList; -import java.util.EventObject; -import java.util.Iterator; - -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; - -public class Notifier { - - private ArrayList listeners = new ArrayList(); - private Method listenerMethod; - private String methodName; - private Class clss; - - public Notifier(Class listener) { - if(listener == null) { - throw new IllegalArgumentException("Illegal to have a null listener Class. "); - } - - this.clss = listener; - // now we check methods, if only one of them, then - // let's set it - Method[] meths = clss.getDeclaredMethods(); - if(meths.length == 0) { - this.listenerMethod = meths[0]; - } - } - - /** - *

Construct with the class and the name of the method to - * call upon the listeners.

- */ - public Notifier(Class clss, String name) { - if(clss == null) { - throw new IllegalArgumentException("Illegal to have a null Listener Class. "); - } - if(name == null) { - throw new IllegalArgumentException("Illegal to have a null method name. "); - } - this.clss = clss; - this.methodName = name; - try { - // then we get the Method object - this.listenerMethod = this.clss.getDeclaredMethod(name, new Class[] { EventObject.class} ); - } catch(NoSuchMethodException nsme) { - throw new IllegalArgumentException("Method not on Class. "); - } - } - - public void addListener(Object not) { - this.listeners.add(not); - } - - public void removeListener(Object not) { - this.listeners.remove(not); - } - - public ArrayList getListeners() { - ArrayList cloned = new ArrayList(); - cloned.addAll(listeners); - return cloned; - } - - - /** - *

Convenience method for when a listener has a single method.

- * - *

Currently this method needs to be called, but it's possible - * that by providing the interface class, it can be assumed as - * to what the listening method is.

- */ - public void notify(EventObject event) throws NotifierException { - if(this.clss == null) { - notify(this.methodName, event); - } else { - notify(this.listenerMethod, event); - } - } - - /** - *

Notify the listeners of a certain event, to a certain method.

- * - *

This is usable when a Listener has more than one method and - * a single Notifier wants to be shared.

- */ - private void notify(Method listenerMethod, EventObject event) throws NotifierException { - Iterator itr = getListeners().iterator(); - while(itr.hasNext()) { - try { - Object listener = itr.next(); - listenerMethod.invoke( listener, new Object[] { event } ); - } catch(SecurityException se) { - throw new NotifierException(se); - } catch(IllegalAccessException iae) { - throw new NotifierException(iae); - } catch(IllegalArgumentException iae) { - throw new NotifierException(iae); - } catch(InvocationTargetException ite) { - throw new NotifierException(ite); - } - } - } - - /** - *

Notify the listeners of a certain event, to a certain method.

- * - *

This is usable when a Listener has more than one method and - * a single Notifier wants to be shared.

- */ - public void notify(String methodName, EventObject event) throws NotifierException { - Iterator itr = getListeners().iterator(); - while(itr.hasNext()) { - try { - Object listener = itr.next(); - Class clss = listener.getClass(); - Method method = clss.getMethod(methodName, new Class[] { event.getClass() } ); - method.invoke( listener, new Object[] { event } ); - } catch(SecurityException se) { - throw new NotifierException(se); - } catch(NoSuchMethodException nsme) { - throw new NotifierException(nsme); - } catch(IllegalAccessException iae) { - throw new NotifierException(iae); - } catch(IllegalArgumentException iae) { - throw new NotifierException(iae); - } catch(InvocationTargetException ite) { - throw new NotifierException(ite); - } - } - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/lang/NotifierException.java b/genjava/gj-core/src/java/com/generationjava/lang/NotifierException.java deleted file mode 100644 index 2f634144..00000000 --- a/genjava/gj-core/src/java/com/generationjava/lang/NotifierException.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.lang; - -/** - *

Exception thrown when something goes wrong in notifying.

- * - * @author Henri Yandell - * @since 2.0 - * @version $Id$ - */ -public class NotifierException extends Exception { - - /** - *

Constructs a new NotifierException without specified - * detail message.

- */ - public NotifierException() { - super(); - } - - /** - *

Constructs a new NotifierException with specified - * detail message.

- * - * @param msg the error message. - */ - public NotifierException(String msg) { - super(msg); - } - - /** - *

Constructs a new NotifierException with specified - * nested Throwable root cause.

- * - * @param rootCause the Exception or Error that - * caused this exception to be thrown. - */ - public NotifierException(Throwable rootCause) { - super(rootCause); - } - - /** - *

Constructs a new NotifierException with specified - * detail message and nested Throwable root cause.

- * - * @param msg the error message. - * @param rootCause the Exception or Error that - * caused this exception to be thrown. - */ - public NotifierException(String msg, Throwable rootCause) { - super(msg, rootCause); - } - -} - diff --git a/genjava/gj-core/src/java/com/generationjava/lang/ProxyListener.java b/genjava/gj-core/src/java/com/generationjava/lang/ProxyListener.java deleted file mode 100644 index a847f21d..00000000 --- a/genjava/gj-core/src/java/com/generationjava/lang/ProxyListener.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.lang; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; - -/// Usage: -/// this.addActionListener( ProxyListener.newInstance( -/// ActionListener.class, this, "flipColor" -/// ) ); -/// where flipColor is the name of a method - -public class ProxyListener implements InvocationHandler { - - public static Object newInstance(Class intfce, Object target, String listenerMethod) { - ProxyListener handler = new ProxyListener(); - handler.listenerMethod = listenerMethod; - handler.target = target; - Class proxyClass = Proxy.getProxyClass( - intfce.getClassLoader(), - new Class[] { intfce } - ); - try { - return proxyClass.getConstructor( new Class[] { InvocationHandler.class } - ).newInstance(new Object[] { handler }); - } catch(NoSuchMethodException nsme) { - nsme.printStackTrace(); - } catch(SecurityException se) { - se.printStackTrace(); - } catch(InstantiationException ie) { - ie.printStackTrace(); - } catch(IllegalAccessException iae) { - iae.printStackTrace(); - } catch(InvocationTargetException ite) { - ite.printStackTrace(); - } - return null; - } - - private String listenerMethod; - private Object target; - - private ProxyListener() { - } - - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - // can't do this line as proxy can't handle toString yet - /// TODO: Add a toString handler bit. - //System.err.println(""+proxy); - Class clss = target.getClass(); - - // it really should be a single array with an EventObject extension, - // but who knows. - Class[] sig = new Class[args.length]; - for(int i=0; i - -

- Wrappers and helpers for classes in java.lang. Also see Apache Commons Lang. -

- - diff --git a/genjava/gj-core/src/java/com/generationjava/math/Interval.java b/genjava/gj-core/src/java/com/generationjava/math/Interval.java deleted file mode 100644 index f8331fc0..00000000 --- a/genjava/gj-core/src/java/com/generationjava/math/Interval.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -// @file Interval.java -// @author bayard@generationjava.com -// @create 2001-02-04 - -package com.generationjava.math; - - -/** - * A continuous range between two doubles. - */ -public class Interval { - - private double lower; - private double upper; - - /** - * Create an Interval between two doubles. - */ - public Interval(double lower, double upper) { - this.lower = lower; - this.upper = upper; - } - - /** - * Make an Interval with the specified center and difference from the - * center. - */ - static public Interval makeIntervalCenterWidth(double center, double difference) { - return new Interval(center - difference, center + difference); - } - - /** - * Make an Interval with the specified center and the specified - * percentage difference from the center. - */ - static public Interval makeIntervalCenterPercentage(double center, float percentage) { - return new Interval(center - (center*percentage/100), center + (center*percentage/100)); - } - - /** - * Add this Interval to another one. - */ - public Interval add(Interval i) { - return new Interval(i.lower + this.lower, i.upper + this.upper); - } - - /** - * Multiple this Interval by another one. - */ - public Interval mul(Interval i) { - double p1 = i.lower * this.lower; - double p2 = i.lower * this.upper; - double p3 = i.upper * this.lower; - double p4 = i.upper * this.upper; - return new Interval( min(p1,p2,p3,p4), max(p1,p2,p3,p4) ); - } - - /** - * Divide this interval by another. - */ - public Interval div(Interval i) { - return mul( new Interval( 1/i.upper, 1/i.lower ) ); - } - - /** - * Subtract an Interval from this Interval. - */ - public Interval sub(Interval i) { - return add( new Interval( -i.upper, -i.lower ) ); - } - - /** - * Find the minimum of 4 values. - */ - private double min(double d1, double d2, double d3, double d4) { - double tmp = d1; - if(d2 < tmp) { - tmp = d2; - } - if(d3 < tmp) { - tmp = d3; - } - if(d4 < tmp) { - tmp = d4; - } - return tmp; - } - - /** - * Find the maximum of 4 values. - */ - private double max(double d1, double d2, double d3, double d4) { - double tmp = d1; - if(d2 > tmp) { - tmp = d2; - } - if(d3 > tmp) { - tmp = d3; - } - if(d4 > tmp) { - tmp = d4; - } - return tmp; - } - - public String toString() { - return this.lower+" - "+this.upper; - } - - public boolean equals(Object obj) { - if(obj instanceof Interval) { - Interval ivl = (Interval)obj; - return ( (this.lower == ivl.lower) && (this.upper == ivl.upper) ); - } else { - return false; - } - } - - public int hashCode() { - return (int) ((this.lower + this.upper) % Integer.MAX_VALUE); - } -} diff --git a/genjava/gj-core/src/java/com/generationjava/namespace/AbstractNamespace.java b/genjava/gj-core/src/java/com/generationjava/namespace/AbstractNamespace.java deleted file mode 100644 index 7aab5f16..00000000 --- a/genjava/gj-core/src/java/com/generationjava/namespace/AbstractNamespace.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.namespace; - -import java.util.Iterator; - -/** - * Abstract representation of an namespace. - */ -abstract public class AbstractNamespace implements Namespace { - - /** - * Get the value in this namespace under the specified name. - */ - abstract public Object getValue(String name); - - /** - * Does the namespace have a value under the specified name. - */ - public boolean hasValue(String name) { - return (getValue(name) != null); - } - - /** - * Put a value in this namespace, under the specified name. - */ - abstract public void putValue(String name, Object info); - - /** - * The names in a Namespace - */ - abstract public Iterator iterateNames(); - -} diff --git a/genjava/gj-core/src/java/com/generationjava/namespace/Namespace.java b/genjava/gj-core/src/java/com/generationjava/namespace/Namespace.java deleted file mode 100644 index 1c6080b6..00000000 --- a/genjava/gj-core/src/java/com/generationjava/namespace/Namespace.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.namespace; - -import java.io.Serializable; - -import java.util.Iterator; - -/** - * A namespace. - */ -public interface Namespace extends Serializable { - - /** - * Get a value from the namespace under the specified name. - */ - public Object getValue(String name); - - /** - * Does the namespace have a value under the specified name. - */ - public boolean hasValue(String name); - - /** - * Put a value in the namespace, under the specified name. - */ - public void putValue(String name, Object info); - - /** - * The names in a Namespace - */ - public Iterator iterateNames(); - -} diff --git a/genjava/gj-core/src/java/com/generationjava/namespace/SimpleNamespace.java b/genjava/gj-core/src/java/com/generationjava/namespace/SimpleNamespace.java deleted file mode 100644 index 70ec535c..00000000 --- a/genjava/gj-core/src/java/com/generationjava/namespace/SimpleNamespace.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.namespace; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -/** - * A simple implementation of a Namespace. It uses a Map to - * store the values. - */ -public class SimpleNamespace extends AbstractNamespace { - - private Map myInfo = null; - - /** - * Construct with a default implementation of a HashMap. The - * HashMap instantiation is lazy. - */ - public SimpleNamespace() { - } - - public SimpleNamespace(Map map) { - this.myInfo = map; - } - - private void initMap() { - this.myInfo = new HashMap(); - } - - public Object getValue(String name) { - if(myInfo == null) { - return null; - } - return myInfo.get(name); - } - - public void putValue(String name, Object info) { - if(myInfo == null) { - initMap(); - } - myInfo.put(name, info); - } - - public Iterator iterateNames() { - if(myInfo.keySet() == null) { - return null; - } else { - return myInfo.keySet().iterator(); - } - } - -} diff --git a/genjava/gj-core/src/java/com/generationjava/namespace/package.html b/genjava/gj-core/src/java/com/generationjava/namespace/package.html deleted file mode 100644 index 27c65fab..00000000 --- a/genjava/gj-core/src/java/com/generationjava/namespace/package.html +++ /dev/null @@ -1,8 +0,0 @@ - - -

- A generic concept of a namespace. Needs to have scope added at some point - so that scope may be added and removed in a stack like way. -

- - diff --git a/genjava/gj-core/src/java/com/generationjava/net/UrlW.java b/genjava/gj-core/src/java/com/generationjava/net/UrlW.java deleted file mode 100644 index f71beda3..00000000 --- a/genjava/gj-core/src/java/com/generationjava/net/UrlW.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -// UrlW.java -package com.generationjava.net; - -import java.io.BufferedOutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; - -import java.net.URL; -import java.net.URLConnection; -import java.net.MalformedURLException; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.io.IOUtils; - -public class UrlW { - - static public InputStream openUrlStream(String urlStr) throws IOException { - URL url = makeUrl(urlStr); - return openUrlStream(url); - } - - static public URL makeUrl(String urlStr) throws MalformedURLException { - if(urlStr.indexOf("://") == -1) { - urlStr = "http://"+urlStr; - } - return new URL(urlStr); - } - - static public InputStream openUrlStream(URL url) throws IOException { - return url.openStream(); - } - - static public Object getContent(String urlStr) throws IOException { - URL url = makeUrl(urlStr); - return getContent(url); - } - - static public Object getContent(URL url) throws IOException { - URLConnection conn = url.openConnection(); - Object obj = conn.getContent(); - if(obj instanceof InputStream) { - obj = getContent((InputStream)obj); - } - return obj; - } - - static public Object getContent(InputStream in) throws IOException { - String str = IOUtils.toString(in); - str = StringUtils.chopNewline(str); - str = StringUtils.chopNewline(str); - return str; - } - - static public InputStream doPost(String urlStr, String data) throws IOException { - URL url = new URL(urlStr); - URLConnection uc = url.openConnection(); - uc.setDoOutput(true); - - OutputStream raw = uc.getOutputStream(); - Writer writer = new OutputStreamWriter(new BufferedOutputStream(raw), "8859_1"); - writer.write(data); - writer.write("\r\n"); - writer.flush(); - writer.close(); - - return uc.getInputStream(); - } -} diff --git a/genjava/gj-core/src/java/com/generationjava/net/package.html b/genjava/gj-core/src/java/com/generationjava/net/package.html deleted file mode 100644 index 2263e81a..00000000 --- a/genjava/gj-core/src/java/com/generationjava/net/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -

- Wrappers and helpers for java.net. Also see Apache Commons Net. -

- - diff --git a/genjava/gj-core/src/java/com/generationjava/random/RandomBean.java b/genjava/gj-core/src/java/com/generationjava/random/RandomBean.java deleted file mode 100644 index b0da91c5..00000000 --- a/genjava/gj-core/src/java/com/generationjava/random/RandomBean.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.random; - -import java.beans.BeanInfo; -import java.beans.Introspector; -import java.beans.IntrospectionException; -import java.beans.PropertyDescriptor; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; - -import com.generationjava.lang.ClassW; - -public class RandomBean implements RandomMaker { - - public RandomBean() { - } - - public Object makeInstance(Class clss) { - Object instance = null; - if(clss.isInterface()) { - return RandomBeanProxy.newInstance(clss); - } - - instance = ClassW.createObject(clss); - if(instance == null) { - return null; - } - - RandomObject rndMaker = new RandomObject(); - Object[] args = new Object[1]; // reuse this array in loop - - /// fill in values - try { - BeanInfo beaninfo = Introspector.getBeanInfo(clss); - PropertyDescriptor[] pd = beaninfo.getPropertyDescriptors(); - for(int i=0; i - -

- Util classes. -

- - diff --git a/genjava/gj-core/src/test/com/generationjava/collections/AliasedMapTest.java b/genjava/gj-core/src/test/com/generationjava/collections/AliasedMapTest.java deleted file mode 100644 index 3fd47db9..00000000 --- a/genjava/gj-core/src/test/com/generationjava/collections/AliasedMapTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.generationjava.collections; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -public class AliasedMapTest extends TestCase { - - public AliasedMapTest(String name) { - super(name); - } - - //----------------------------------------------------------------------- - // To test: - // put(Object, Object) / alias(Object, Object) / get(Object) - - // TODO: Need a generic Map test. Check Collections. - public void test() { - AliasedMap map = new AliasedMap(); - map.put("Eric","Cartman"); - map.put("Stan","Marsh"); - map.put("Kyle","Browkalski"); - map.put("Kenny","McCormack"); - map.alias("fatkid","Eric"); - map.alias("jewkid","Kyle"); - map.alias("poorkid","Kenny"); - map.alias("yankkid","Stan"); - - assertEquals("Cartman", map.get("Eric") ); - assertEquals("Marsh", map.get("Stan") ); - assertEquals("Browkalski", map.get("Kyle") ); - assertEquals("McCormack", map.get("Kenny") ); - assertEquals("Cartman", map.get("fatkid") ); - assertEquals("Browkalski", map.get("jewkid") ); - assertEquals("McCormack", map.get("poorkid") ); - assertEquals("Marsh", map.get("yankkid") ); - } - - public void testNull() { - AliasedMap map = new AliasedMap(); - assertEquals(null, map.get("foo")); - map.alias("foo", "bar"); - assertEquals(null, map.get("foo")); - assertEquals(null, map.get("bar")); - } - -} diff --git a/genjava/gj-core/src/test/com/generationjava/collections/FQMapTest.java b/genjava/gj-core/src/test/com/generationjava/collections/FQMapTest.java deleted file mode 100644 index e0993e0a..00000000 --- a/genjava/gj-core/src/test/com/generationjava/collections/FQMapTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.generationjava.collections; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -import java.beans.Beans; - -import java.util.Map; - -public class FQMapTest extends TestCase { - - public FQMapTest(String name) { - super(name); - } - - //----------------------------------------------------------------------- - // To test: - - public void testFQ() { - Map map = new FQMap(); - map.put("hey","you"); - map.put("well.you","hmmm"); - map.put(this,this); - - assertEquals("you", map.get("hey")); - assertEquals(this, map.get(this)); - assertEquals("hmmm", map.get("well.you")); - assertEquals(true, Beans.isInstanceOf(map.get("well"), java.util.Map.class)); - assertEquals(3, map.size()); - } -} diff --git a/genjava/gj-core/src/test/com/generationjava/collections/MultiKeyedMapTest.java b/genjava/gj-core/src/test/com/generationjava/collections/MultiKeyedMapTest.java deleted file mode 100644 index 65e9de12..00000000 --- a/genjava/gj-core/src/test/com/generationjava/collections/MultiKeyedMapTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.generationjava.collections; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -import com.generationjava.lang.ClassW; -import java.util.Map; - -public class MultiKeyedMapTest extends TestCase { - - public MultiKeyedMapTest(String name) { - super(name); - } - - //----------------------------------------------------------------------- - // To test: - - public void testMultiKeyes() { - Map map = new MultiKeyedMap(); - String[] strs = new String[] { "com", "generationjava" }; - map.put(strs, "GJ!"); - strs = new String[] { "com", "smallcogs" }; - map.put(strs, "STEVE!"); - strs = new String[] { "com", "flamefew", "www" }; - map.put(strs, "Ff-www"); - strs = new String[] { "com", "flamefew", "log" }; - map.put(strs, "Ff-log"); - map.put("fred", "foo"); - - assertEquals("STEVE!", map.get(new String[] { "com", "smallcogs" } ) ); - assertEquals("Ff-www", ((Map)map.get(new String[] { "com", "flamefew" } )).get("www") ); - assertEquals("foo", map.get("fred")); - assertEquals("foo", map.get(new String[] { "fred" } )); - assertEquals(true, map.containsValue("Ff-log")); - assertEquals(false, map.containsValue("Ff-dns")); - } -} diff --git a/genjava/gj-core/src/test/com/generationjava/collections/SimpleAliasTest.java b/genjava/gj-core/src/test/com/generationjava/collections/SimpleAliasTest.java deleted file mode 100644 index 318aa3d5..00000000 --- a/genjava/gj-core/src/test/com/generationjava/collections/SimpleAliasTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.generationjava.collections; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -public class SimpleAliasTest extends TestCase { - - public SimpleAliasTest(String name) { - super(name); - } - - //----------------------------------------------------------------------- - // To test: - // SimpleAlias(Object) -> getAlias() - - public void testNull() { - SimpleAlias alias = new SimpleAlias(null); - assertEquals(null, alias.getAlias()); - } - - public void test() { - SimpleAlias alias = new SimpleAlias("value"); - assertEquals("value", alias.getAlias()); - } - -} diff --git a/genjava/gj-core/src/test/com/generationjava/compare/NumericStringComparatorTest.java b/genjava/gj-core/src/test/com/generationjava/compare/NumericStringComparatorTest.java deleted file mode 100644 index 7b6ba557..00000000 --- a/genjava/gj-core/src/test/com/generationjava/compare/NumericStringComparatorTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.generationjava.compare; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -public class NumericStringComparatorTest extends TestCase { - - public NumericStringComparatorTest(String name) { - super(name); - } - - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - TestSuite suite = new TestSuite(NumericStringComparatorTest.class); - suite.setName("NumericStringComparatorTest Tests"); - return suite; - } - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - //----------------------------------------------------------------------- - - public void test1() { - compare(".0004306 - Orlando Inventory", ".4306", 1); - } - - public void test2() { - compare("2a", "2", 1); - compare("2", "2a", -1); - } - - public void test3() { - compare("2a", "aa2b3", -1); - } - - public void test4() { - compare("Brak1A", "Brak1B", -1); - compare("Brak1", "Brak1B", -1); - } - - private void compare(String str1, String str2, int expected) { - NumericStringComparator nsc = new NumericStringComparator(); - int cmp = nsc.compare(str1, str2); - if(cmp != 0) { - cmp = cmp / Math.abs(cmp); - } - assertTrue( str1+" and "+str2+" should compare as "+expected+" and not "+cmp, cmp == expected); - } - - public void testBug() { - compare("aaa1.bbb1 + ge-3/0/0/0", "aaa1.bbb1 + ge-3/0/0", 1); - compare("aaa1.bbb1 + ge-3/0/0", "aaa1.bbb1 + ge-3/0/0/0", -1); - } - -} diff --git a/genjava/gj-core/src/test/com/generationjava/io/FixedWidthReaderTest.java b/genjava/gj-core/src/test/com/generationjava/io/FixedWidthReaderTest.java deleted file mode 100644 index f9bf7352..00000000 --- a/genjava/gj-core/src/test/com/generationjava/io/FixedWidthReaderTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.generationjava.io; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -import java.io.IOException; -import java.io.StringReader; - -public class FixedWidthReaderTest extends TestCase { - - public FixedWidthReaderTest(String name) { - super(name); - } - - //----------------------------------------------------------------------- - // To test: - // SimpleAlias(Object) -> getAlias() - - public void testRead() { - try { - String test = "hello*one*ant*8*beer***amonggrass**"; - StringReader rdr = new StringReader(test); - FixedWidthReader fwr = new FixedWidthReader(rdr); - // fwr.setWidths( new int[] {5,5,4,2,0,5,7} ); - String widths = "5,5,4,2,*,5,7"; - fwr.setWidths( widths ); - fwr.setTrim( "*" ); - Object[] objs = null; - while( (objs = fwr.readLine()) != null ) { - assertEquals("hello", objs[0]); - assertEquals("one", objs[1]); - assertEquals("ant", objs[2]); - assertEquals("8", objs[3]); - assertEquals("beer", objs[4]); - assertEquals("among", objs[5]); - assertEquals("grass", objs[6]); - } - } catch(IOException ioe) { - ioe.printStackTrace(); - } - } - -} diff --git a/genjava/gj-core/src/test/com/generationjava/lang/BigIntegerUtilsTest.java b/genjava/gj-core/src/test/com/generationjava/lang/BigIntegerUtilsTest.java deleted file mode 100644 index 8b71fd8c..00000000 --- a/genjava/gj-core/src/test/com/generationjava/lang/BigIntegerUtilsTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.generationjava.lang; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -import java.math.BigInteger; - -public class BigIntegerUtilsTest extends TestCase { - - public BigIntegerUtilsTest(String name) { - super(name); - } - - //----------------------------------------------------------------------- - private BigInteger bi = BigInteger.valueOf(25L); // 11001 - - // need to test extractInt extractBoolean extractFloat - public void testExtractInt() { - assertEquals("11001[2,4]=2 failure", 2, BigIntegerUtils.extractInt(bi, 2, 4) ); - } - - public void testExtractFloat() { - assertEquals("11001[0,4:2.2]= failure", 2.1F, BigIntegerUtils.extractFloat(bi, 0, 4, 2), 0 ); - } - - public void testExtractBoolean() { - assertEquals("11001[0]=true failure", true, BigIntegerUtils.extractBoolean(bi, 0) ); - assertEquals("11001[1]=false failure", false, BigIntegerUtils.extractBoolean(bi, 1) ); - assertEquals("11001[2]=false failure", false, BigIntegerUtils.extractBoolean(bi, 2) ); - assertEquals("11001[3]=true failure", true, BigIntegerUtils.extractBoolean(bi, 3) ); - assertEquals("11001[4]=true failure", true, BigIntegerUtils.extractBoolean(bi, 4) ); - } - -} diff --git a/genjava/gj-core/src/test/com/generationjava/lang/ClassWTest.java b/genjava/gj-core/src/test/com/generationjava/lang/ClassWTest.java deleted file mode 100644 index 826d3e77..00000000 --- a/genjava/gj-core/src/test/com/generationjava/lang/ClassWTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.generationjava.lang; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -// used in tests -import java.util.HashMap; - -public class ClassWTest extends TestCase { - - public ClassWTest(String name) { - super(name); - } - - //----------------------------------------------------------------------- - // To test: - // Object createObject(String) { - // Object createObject(Class) { - // boolean classExists(String) { - // Class getClass(String) { - // void callMain(String[]) { - // void callMain(String, String[]) { - // Object callStatic(String, String, Class[], Object[]) - // Object callStatic(Class, String, Class[], Object[]) - - public void testCreateObject() { - assertEquals("Unable to make a new HashMap", new HashMap(), ClassW.createObject("java.util.HashMap") ); - assertEquals("Unable to make a new HashMap", new HashMap(), ClassW.createObject(HashMap.class) ); - } - - public void testClassExists() { - assertEquals("java.util.HashMap does not exist", true, ClassW.classExists("java.util.HashMap") ); - assertEquals("java.boo.Ghost exists", false, ClassW.classExists("java.boo.Ghost") ); - } - - public void testGetClass() { - assertEquals("Unable to get String.class", String.class, ClassW.getClass("java.lang.String") ); - } - -} diff --git a/genjava/gj-core/xdocs/changes.xml b/genjava/gj-core/xdocs/changes.xml deleted file mode 100644 index 05db2e5b..00000000 --- a/genjava/gj-core/xdocs/changes.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Henri Yandell - Release Notes - - - - - Added a very basic datasource implementation for prototyping - Documentation fixed in ByteArray, ClassW - Bug in Numerical String comparison, foo1 and foo1a - Moved ClassIndex class to gj-find - - - Many deprecated classes and methods removed. - - - Added first set of unit tests. - Added a RunMain class which runs main(String[]) methods in a new Thread. - Deprecated various classes and methods and made various other small improvements. - Republished under OSJava site. - - - diff --git a/genjava/gj-core/xdocs/images/1x1.gif b/genjava/gj-core/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/genjava/gj-core/xdocs/images/1x1.gif and /dev/null differ diff --git a/genjava/gj-core/xdocs/images/osjava.gif b/genjava/gj-core/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/genjava/gj-core/xdocs/images/osjava.gif and /dev/null differ diff --git a/genjava/gj-core/xdocs/navigation.xml b/genjava/gj-core/xdocs/navigation.xml deleted file mode 100644 index ae46a44a..00000000 --- a/genjava/gj-core/xdocs/navigation.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - genjava - - - - - - - - - - - - - - - diff --git a/genjava/gj-csv/LICENSE.txt b/genjava/gj-csv/LICENSE.txt deleted file mode 100644 index 38aecf65..00000000 --- a/genjava/gj-csv/LICENSE.txt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/genjava/gj-csv/maven.xml b/genjava/gj-csv/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/genjava/gj-csv/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/genjava/gj-csv/pom.xml b/genjava/gj-csv/pom.xml deleted file mode 100755 index 6b720b82..00000000 --- a/genjava/gj-csv/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - genjava - genjava - UNUSED - - 4.0.0 - gj-csv - GenJava-CSV - 1.0 - 2002 - - - CSV component of GenJava-Core. Reads and writes CSV files. - - - - - - diff --git a/genjava/gj-csv/project.properties b/genjava/gj-csv/project.properties deleted file mode 100644 index d0f1d722..00000000 --- a/genjava/gj-csv/project.properties +++ /dev/null @@ -1,18 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.checkstyle.properties=../../hen_checkstyle.xml - -maven.javadoc.stylesheet=../../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/genjava/gj-csv/project.xml b/genjava/gj-csv/project.xml deleted file mode 100755 index 9a63b0bf..00000000 --- a/genjava/gj-csv/project.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - ../project.xml - gj-csv - GenJava-CSV - 1.0 - 2002 - - - CSV component of GenJava-Core. Reads and writes CSV files. - - - CSV Reader/Writers - - - diff --git a/genjava/gj-csv/src/java/com/generationjava/io/Csv.java b/genjava/gj-csv/src/java/com/generationjava/io/Csv.java deleted file mode 100644 index 37eacc55..00000000 --- a/genjava/gj-csv/src/java/com/generationjava/io/Csv.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -// Csv.java -package com.generationjava.io; - -import java.io.IOException; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Properties; -import java.util.Set; - -public class Csv { - - static public char FIELD_DELIMITER = ','; - static public char BLOCK_DELIMITER = '\n'; - - private LinkedList list = new LinkedList(); - private String[] headers; - - public Csv(CsvReader reader) throws IOException { - if(reader == null) { - throw new NullPointerException("Must be given a com.generationjava.io.CsvReader instance. "); - } - this.headers = reader.readLine(); - - String[] line = null; - - // suck in the file. - // TODO: What's the optimal structure for this - while( (line = reader.readLine()) != null) { - list.add(line); - } - } - - // get all of the unique fields for this header - public String[] getAll(String header) { - HashSet values = new HashSet(); - int idx = getHeaderIndex(header); - Iterator iterator = list.iterator(); - while(iterator.hasNext()) { - values.add( ((String[])iterator.next())[idx]); - } - return (String[])values.toArray(new String[0]); - } - - private int getHeaderIndex(String header) { - for(int i=0;i - - - - Henri Yandell - Release Notes - - - - - - - diff --git a/genjava/gj-csv/xdocs/images/1x1.gif b/genjava/gj-csv/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/genjava/gj-csv/xdocs/images/1x1.gif and /dev/null differ diff --git a/genjava/gj-csv/xdocs/images/osjava.gif b/genjava/gj-csv/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/genjava/gj-csv/xdocs/images/osjava.gif and /dev/null differ diff --git a/genjava/gj-csv/xdocs/navigation.xml b/genjava/gj-csv/xdocs/navigation.xml deleted file mode 100644 index ae46a44a..00000000 --- a/genjava/gj-csv/xdocs/navigation.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - genjava - - - - - - - - - - - - - - - diff --git a/genjava/gj-find/LICENSE.txt b/genjava/gj-find/LICENSE.txt deleted file mode 100644 index 99c95095..00000000 --- a/genjava/gj-find/LICENSE.txt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2004, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of OSJava nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/genjava/gj-find/maven.xml b/genjava/gj-find/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/genjava/gj-find/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/genjava/gj-find/pom.xml b/genjava/gj-find/pom.xml deleted file mode 100644 index af02f432..00000000 --- a/genjava/gj-find/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - genjava - genjava - UNUSED - - 4.0.0 - gj-find - GenJava-Find - 0.1 - 2004 - - - Similar to 'find' in UNIX. - - - - - - - gj-core - genjava - 3.0 - - - - - - diff --git a/genjava/gj-find/project.properties b/genjava/gj-find/project.properties deleted file mode 100644 index d0f1d722..00000000 --- a/genjava/gj-find/project.properties +++ /dev/null @@ -1,18 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.checkstyle.properties=../../hen_checkstyle.xml - -maven.javadoc.stylesheet=../../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/genjava/gj-find/project.xml b/genjava/gj-find/project.xml deleted file mode 100644 index fad1ba53..00000000 --- a/genjava/gj-find/project.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - ../project.xml - gj-find - GenJava-Find - 0.1 - 2004 - - - Similar to 'find' in UNIX. - - - UNIX find-like, but in Java - - - diff --git a/genjava/gj-find/src/java/com/generationjava/io/find/FileFinder.java b/genjava/gj-find/src/java/com/generationjava/io/find/FileFinder.java deleted file mode 100644 index ed438d35..00000000 --- a/genjava/gj-find/src/java/com/generationjava/io/find/FileFinder.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.io.find; - -import java.io.File; -import java.util.List; -import java.util.LinkedList; -import java.util.Iterator; -import java.util.Map; - -/** - * Finds Files in a file system. - * - * Informs FindListeners whenever a Find is made, and returns the - * finds to the user. - */ -public class FileFinder implements Finder { - - // helper methods to handle options in String->whatever - private static int toInt(Object obj) { - if(obj == null) { - return 0; - } else - if(obj instanceof Number) { - return ((Number)obj).intValue(); - } else { - String str = obj.toString(); - try { - return Integer.parseInt(str.toString()); - } catch(NumberFormatException nfe) { - throw new IllegalArgumentException("String argument "+str+" must be parseable as an integer. "); - } - } - } - private static boolean toBoolean(Object obj) { - if(obj == null) { - return false; - } else - if(obj instanceof Boolean) { - return ((Boolean)obj).booleanValue(); - } else - if(obj instanceof Number) { - return ((Number)obj).intValue() != 0; - } else { - String str = obj.toString(); - return new Boolean(str).booleanValue(); - } - } - - private List findListeners; - - /** - * Find all files in the specified directory. - */ - public File[] find(File directory) { - return find(directory, new java.util.HashMap()); - } - - // add maxdepth and mindepth somehow - public File[] find(File directory, Map options) { - notifyDirectoryStarted(directory); - - boolean depthFirst = toBoolean(options.get(Finder.DEPTH)); - - // to implement - int maxDepth = toInt(options.get(Finder.MAXDEPTH)); - int minDepth = toInt(options.get(Finder.MINDEPTH)); - boolean ignoreHiddenDirs = toBoolean(options.get(Finder.IGNORE_HIDDEN_DIRS)); - - FindingFilter filter = new FindingFilter(options); - List list = find(directory, filter, depthFirst); - if(filter.accept(directory)) { - if(depthFirst) { - list.add( directory ); - } else { - list.add( 0, directory ); - } - } - File[] files = (File[]) list.toArray(new File[0]); - notifyDirectoryFinished(directory, files); - return files; - } - - private List find(File directory, FindingFilter filter, boolean depthFirst) { - - // we can't use listFiles(filter) here, directories don't work correctly - File[] list = directory.listFiles(); - - if (list == null) { - return null; - } - - List retlist = new LinkedList(); - int sz = list.length; - - for (int i = 0; i < sz; i++) { - File tmp = list[i]; - if(!depthFirst && filter.accept(tmp)) { - retlist.add(tmp); - notifyFileFound(directory,tmp); - } - if (tmp.isDirectory()) { - notifyDirectoryStarted(tmp); - List sublist = find(tmp, filter, depthFirst); - int subsz = sublist.size(); - for (int j = 0; j < subsz; j++) { - retlist.add(sublist.get(j)); - } - notifyDirectoryFinished(tmp, (File[]) sublist.toArray(new File[0])); - } - if(depthFirst && filter.accept(tmp)) { - retlist.add(tmp); - notifyFileFound(directory,tmp); - } - } - - return retlist; - } - - /** - * Add a FindListener. - */ - public void addFindListener(FindListener fl) { - if(findListeners == null) { - findListeners = new LinkedList(); - } - findListeners.add(fl); - } - - /** - * Remove a FindListener. - */ - public void removeFindListener(FindListener fl) { - if(findListeners != null) { - findListeners.remove(fl); - } - } - - /** - * Notify all FindListeners that a directory is being started. - */ - public void notifyDirectoryStarted(File directory) { - if(!directory.isDirectory()) { - return; - } - if(findListeners != null) { - FindEvent fe = new FindEvent(this,"directoryStarted",directory); - Iterator itr = findListeners.iterator(); - while(itr.hasNext()) { - FindListener findListener = (FindListener)itr.next(); - findListener.directoryStarted( fe ); - } - } - } - - /** - * Notify all FindListeners that a directory has been finished. - * Supplying the filenames that have been found. - */ - public void notifyDirectoryFinished(File directory, File[] files) { - if(!directory.isDirectory()) { - return; - } - if(findListeners != null) { - FindEvent fe = new FindEvent(this,"directoryFinished",directory,files); - Iterator itr = findListeners.iterator(); - while(itr.hasNext()) { - FindListener findListener = (FindListener)itr.next(); - findListener.directoryFinished( fe ); - } - } - } - - /** - * Notify FindListeners that a file has been found. - */ - public void notifyFileFound(File directory, File file) { - if(file.isDirectory()) { - return; - } - if(findListeners != null) { - FindEvent fe = new FindEvent(this,"fileFound",directory,file); - Iterator itr = findListeners.iterator(); - while(itr.hasNext()) { - FindListener findListener = (FindListener)itr.next(); - findListener.fileFound( fe ); - } - } - } - -} diff --git a/genjava/gj-find/src/java/com/generationjava/io/find/FindEvent.java b/genjava/gj-find/src/java/com/generationjava/io/find/FindEvent.java deleted file mode 100644 index 8f93b380..00000000 --- a/genjava/gj-find/src/java/com/generationjava/io/find/FindEvent.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -// @file FindEvent.java -// @author bayard@generationjava.com -// @create 2001-01-27 - -package com.generationjava.io.find; - -import java.io.File; - -/** - * Event upon which notification is made to a FindListener. - * It contains references to the Finder and the Directory in which - * the event occured. - * Depending on the particular occasion, it may also contain - * a set of files or a file. - */ -public class FindEvent { - - private File directory; - private Finder finder; - private File file; - private File[] files; - private String type; - - public FindEvent(Finder finder, String type, File directory) { - this.finder = finder; - this.directory = directory; - this.type = type; - } - - public FindEvent(Finder finder, String type, File directory, File file) { - this.finder = finder; - this.directory = directory; - this.file = file; - this.type = type; - } - - public FindEvent(Finder finder, String type, File directory, File[] files) { - this.finder = finder; - this.directory = directory; - this.files = files; - this.type = type; - } - - public File getDirectory() { - return this.directory; - } - - public Finder getFinder() { - return this.finder; - } - - /** - * File found. - */ - public File getFile() { - return this.file; - } - - /** - * Files found in a directory. - */ - public File[] getFiles() { - return this.files; - } - - public String getType() { - return this.type; - } - - public String toString() { - String str = "FindEvent - "+this.type+"; dir="+this.directory+", file="+this.file; - if(this.files != null) { - str += ", files="+java.util.Arrays.asList(this.files); - } - return str; - } - -} diff --git a/genjava/gj-find/src/java/com/generationjava/io/find/FindListener.java b/genjava/gj-find/src/java/com/generationjava/io/find/FindListener.java deleted file mode 100644 index f73c9973..00000000 --- a/genjava/gj-find/src/java/com/generationjava/io/find/FindListener.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -// @file FindListener.java -// @author bayard@generationjava.com -// @create 2001-01-27 - -package com.generationjava.io.find; - -public interface FindListener { - - /** - * A directory has begun to be looked at by a Finder. - */ - public void directoryStarted(FindEvent findEvent); - - /** - * A directory has been finished. The FindEvent will - * contain an array of the filenames found. - */ - public void directoryFinished(FindEvent findEvent); - - /** - * A file has been found. The FindEvent will contain the - * filename found. - */ - public void fileFound(FindEvent findEvent); -// public void entryFound(FindEvent findEvent); - -} diff --git a/genjava/gj-find/src/java/com/generationjava/io/find/Finder.java b/genjava/gj-find/src/java/com/generationjava/io/find/Finder.java deleted file mode 100644 index c8e2fb4c..00000000 --- a/genjava/gj-find/src/java/com/generationjava/io/find/Finder.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -// @file Finder.java -// @author bayard@generationjava.com -// @create 2001-03-25 - -package com.generationjava.io.find; - -import java.io.File; -import java.util.Map; - -/** - * A Finder of Files. Though the structure the files are in is unspecified. - */ -public interface Finder { - - // MODIFIER - /** Add to other options to negate them. */ - public static final String NOT = "NOT_"; - - // OPTIONS - /** Do not include the current time in date calculations - Unimplemented*/ - public static final String DAYSTART = "DAYSTART"; - /** */ - public static final String DEPTH = "DEPTH"; - /** How far down the directory structure to start searching at - Unimplemented */ - public static final String MAXDEPTH = "MAXDEPTH"; - /** How many directories to search down - Unimplemented */ - public static final String MINDEPTH = "MINDEPTH"; - /** Don't follow hidden directories */ - public static final String IGNORE_HIDDEN_DIRS = "IGNORE_HIDDEN_DIRS"; - - // Time based tests - /** How many minutes old the file's last modified time must be at most [BUG: Bases on current time and not the time the finder started */ - public static final String MIN = "MIN"; - /** Is a file newer than the File argument to this option */ - public static final String NEWER = "NEWER"; - /** How many days old the file's last modified time must be at most */ - public static final String TIME = "TIME"; - - // size based tests - /** Whether the file is empty */ - public static final String EMPTY = "EMPTY"; - /** Whether the file equals a particular multiple of 512. TODO: Needs more work and to handle suffixes so we don't have to exist in a world of 512 blocks. */ - public static final String SIZE = "SIZE"; - - // name based tests - /** Whether the name is a case sensitive wildcard match */ - public static final String NAME = "NAME"; - /** Whether the name is a case insensitive wildcard match */ - public static final String INAME = "INAME"; - /** Whether the path is a case sensitive wildcard match */ - public static final String PATH = "PATH"; - /** Whether the path is a case insensitive wildcard match */ - public static final String IPATH = "IPATH"; - /** Whether the path is a case sensitive regex match */ - public static final String REGEX = "REGEX"; - /** Whether the path is a case sensitive regex match */ - public static final String IREGEX = "IREGEX"; - - // type of file - /** Type of file. Supports "d" and "f" */ - public static final String TYPE = "TYPE"; // supports 'd' and 'f' - /** Hidden file */ - public static final String HIDDEN = "HIDDEN"; - - // permission replacements - /** Whether the user running the JVM can read the file */ - public static final String CAN_READ = "CAN_READ"; - /** Whether the user running the JVM can write the file */ - public static final String CAN_WRITE = "CAN_WRITE"; - - /** - * Use the Event/Notification part of the system. - * Useful when you want to pipeline things because - * there are a large number of files. - */ - public void addFindListener(FindListener fl); - /** - * Stop using the Event/Notification part of the system. - */ - public void removeFindListener(FindListener fl); - - /** - * Find all files and directories under a particular root directory. - */ - public File[] find(File root); - /** - * Find all files and directories under a particular root directory and - * based on a particular set of filter options. - */ - public File[] find(File root, Map options); - -} diff --git a/genjava/gj-find/src/java/com/generationjava/io/find/FinderException.java b/genjava/gj-find/src/java/com/generationjava/io/find/FinderException.java deleted file mode 100644 index 019e9cb6..00000000 --- a/genjava/gj-find/src/java/com/generationjava/io/find/FinderException.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.io.find; - - -/** - * Something went wrong in the finding. - */ -public class FinderException extends RuntimeException { - - public FinderException() { - super(); - } - - public FinderException(String msg) { - super(msg); - } - - public FinderException(Throwable t) { - super(t); - } - - public FinderException(String msg, Throwable t) { - super(msg,t); - } - -} diff --git a/genjava/gj-find/src/java/com/generationjava/io/find/FindingFilter.java b/genjava/gj-find/src/java/com/generationjava/io/find/FindingFilter.java deleted file mode 100644 index 53e69063..00000000 --- a/genjava/gj-find/src/java/com/generationjava/io/find/FindingFilter.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Copyright (c) 2004, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.generationjava.io.find; - -import java.util.Collection; -import java.io.File; -import java.io.FileFilter; -import java.util.Map; -import java.util.List; -import java.util.LinkedList; -import java.util.Iterator; -import java.util.regex.Pattern; -import java.util.regex.Matcher; - -import com.generationjava.util.WildcardUtils; - -/** - * This is where most of the find functionality occurs. Nearly every option - * to find is mapped to a FileFilter, which are then chained together inside - * this class. - */ -public class FindingFilter implements FileFilter { - - private Map options; - private List filters = new LinkedList(); - private boolean daystart; - - public FindingFilter(Map options) { - this.options = options; - Collection entries = options.entrySet(); - Iterator itr = entries.iterator(); - while(itr.hasNext()) { - Map.Entry entry = (Map.Entry)itr.next(); - if( entry.getKey().equals(Finder.DAYSTART) ) { - this.daystart = true; - continue; - } - // knows that the key is a String - filters.add( createFilter(entry.getKey().toString(), entry.getValue()) ); - } - } - - private FileFilter createFilter(String option, Object argument) { - - boolean invert = false; - if( option.startsWith(Finder.NOT) ) { - invert = true; - // knows that option is a String. Bad. Needs an Enum? - option = option.substring(Finder.NOT.length()); - } - if( option.equals(Finder.MIN) ) { - return new MinFilter(option, argument, invert, this); - } - if( option.equals(Finder.NEWER) ) { - return new NewerFilter(option, argument, invert); - } - if( option.equals(Finder.TIME) ) { - return new TimeFilter(option, argument, invert, this); - } - if( option.equals(Finder.EMPTY) ) { - return new EmptyFilter(option, argument, invert); - } - if( option.equals(Finder.SIZE) ) { - return new SizeFilter(option, argument, invert); - } - if( option.equals(Finder.NAME) ) { - return new NameFilter(option, argument, invert, false); - } - if( option.equals(Finder.INAME) ) { - return new NameFilter(option, argument, invert, true); - } - if( option.equals(Finder.PATH) ) { - return new PathFilter(option, argument, invert, false); - } - if( option.equals(Finder.IPATH) ) { - return new PathFilter(option, argument, invert, true); - } - if( option.equals(Finder.REGEX) ) { - return new RegexFilter(option, argument, invert, false); - } - if( option.equals(Finder.IREGEX) ) { - return new RegexFilter(option, argument, invert, true); - } - if( option.equals(Finder.TYPE) ) { - return new TypeFilter(option, argument, invert); - } - if( option.equals(Finder.HIDDEN) ) { - return new HiddenFilter(option, argument, invert); - } - if( option.equals(Finder.CAN_READ) ) { - return new CanReadFilter(option, argument, invert); - } - if( option.equals(Finder.CAN_WRITE) ) { - return new CanWriteFilter(option, argument, invert); - } - return null; - } - - public boolean accept(File file) { - Iterator itr = filters.iterator(); - while(itr.hasNext()) { - FileFilter filter = (FileFilter) itr.next(); - if(filter == null) { - continue; - } - boolean result = filter.accept(file); - if(result == false) { - return false; - } - } - return true; - } - - public boolean isDaystartConfigured() { - return this.daystart; - } - - // helper method to make the inverting easier. - // possibly the Filters should be inner classes. - // possibly there should be an abstract FindFilter class. - static boolean invert(boolean invert, boolean answer) { - if(invert) { - answer = !answer; - } - return answer; - } - -} - - // need to implement the daystart bits - class MinFilter implements FileFilter { - private Object option; - private boolean invert; - private int argument; - private FindingFilter parent; - public MinFilter(Object option, Object argument, boolean invert, FindingFilter parent) { - this.option = option; - this.invert = invert; - try { - this.argument = Integer.parseInt(argument.toString()); - } catch(NumberFormatException nfe) { - throw new IllegalArgumentException("Argument "+argument+" must be an integer. "); - } - this.parent = parent; - } - public boolean accept(File file) { - boolean daystart = this.parent.isDaystartConfigured(); - return FindingFilter.invert( this.invert, file.lastModified() > System.currentTimeMillis() - this.argument * 60000 ); - } - } - - class NewerFilter implements FileFilter { - private Object option; - private boolean invert; - private File argument; - public NewerFilter(Object option, Object argument, boolean invert) { - this.option = option; - this.invert = invert; - this.argument = new File(argument.toString()); - } - public boolean accept(File file) { - return FindingFilter.invert( this.invert, file.lastModified() > this.argument.lastModified() ); - } - } - - // implement daystart - class TimeFilter implements FileFilter { - private Object option; - private boolean invert; - private int argument; - private FindingFilter parent; - public TimeFilter(Object option, Object argument, boolean invert, FindingFilter parent) { - this.option = option; - this.invert = invert; - try { - this.argument = Integer.parseInt(argument.toString()); - } catch(NumberFormatException nfe) { - throw new IllegalArgumentException("Argument "+argument+" must be an integer. "); - } - this.parent = parent; - } - public boolean accept(File file) { - boolean daystart = this.parent.isDaystartConfigured(); - return FindingFilter.invert( this.invert, file.lastModified() > System.currentTimeMillis() - this.argument * 60000*60*24 ); - } - } - - class EmptyFilter implements FileFilter { - private Object option; - private boolean invert; - private boolean argument; - public EmptyFilter(Object option, Object argument, boolean invert) { - this.option = option; - this.invert = invert; - this.argument = new Boolean(argument.toString()).booleanValue(); - } - public boolean accept(File file) { - return FindingFilter.invert( this.invert, (file.length() == 0) == this.argument ); - } - } - - // needs to handle +5 for > 5 and -5 for < 5. Also needs - // to handle k, m, g, as suffixes. - class SizeFilter implements FileFilter { - private Object option; - private boolean invert; - private int argument; - public SizeFilter(Object option, Object argument, boolean invert) { - this.option = option; - this.invert = invert; - try { - this.argument = Integer.parseInt(argument.toString()); - } catch(NumberFormatException nfe) { - throw new IllegalArgumentException("Argument "+argument+" must be an integer. "); - } - } - public boolean accept(File file) { - return FindingFilter.invert( this.invert, (int)(file.length()/512) == this.argument ); - } - } - - class NameFilter implements FileFilter { - private Object option; - private boolean invert; - private Object argument; - private boolean ignoreCase; - public NameFilter(Object option, Object argument, boolean invert, boolean ignoreCase) { - this.option = option; - this.invert = invert; - this.argument = argument; - this.ignoreCase = ignoreCase; - } - public boolean accept(File file) { - if(this.ignoreCase) { - return FindingFilter.invert( this.invert, WildcardUtils.match(file.getName().toLowerCase(), this.argument.toString().toLowerCase()) ); - } else { - return FindingFilter.invert( this.invert, WildcardUtils.match(file.getName(), this.argument.toString()) ); - } - } - } - - class PathFilter implements FileFilter { - private Object option; - private boolean invert; - private Object argument; - private boolean ignoreCase; - public PathFilter(Object option, Object argument, boolean invert, boolean ignoreCase) { - this.option = option; - this.invert = invert; - this.argument = argument; - this.ignoreCase = ignoreCase; - } - public boolean accept(File file) { - if(this.ignoreCase) { - return FindingFilter.invert( this.invert, WildcardUtils.match(file.getPath().toLowerCase(), this.argument.toString().toLowerCase()) ); - } else { - return FindingFilter.invert( this.invert, WildcardUtils.match(file.getPath(), this.argument.toString()) ); - } - } - } - - class RegexFilter implements FileFilter { - private Object option; - private boolean invert; - private Object argument; - private boolean ignoreCase; - public RegexFilter(Object option, Object argument, boolean invert, boolean ignoreCase) { - this.option = option; - this.invert = invert; - this.argument = argument; - this.ignoreCase = ignoreCase; - } - public boolean accept(File file) { - if(this.ignoreCase) { - Pattern pattern = Pattern.compile(this.argument.toString(), Pattern.CASE_INSENSITIVE); - Matcher matcher = pattern.matcher(file.getPath()); - return FindingFilter.invert( this.invert, matcher.matches() ); - } else { - return FindingFilter.invert( this.invert, file.getPath().matches(this.argument.toString()) ); - } - } - } - - class TypeFilter implements FileFilter { - private Object option; - private boolean invert; - private Object argument; - public TypeFilter(Object option, Object argument, boolean invert) { - this.option = option; - this.invert = invert; - if(!"d".equals(argument) && !"f".equals(argument)) { - throw new IllegalArgumentException("Type option must be 'f' or 'd'. "); - } - this.argument = argument; - } - public boolean accept(File file) { - if("d".equals(argument)) { - return FindingFilter.invert( this.invert, file.isDirectory() ); - } else - if("f".equals(argument)) { - return FindingFilter.invert( this.invert, !file.isDirectory() ); - } else { - throw new IllegalArgumentException("Type option must be 'f' or 'd'. "); - } - } - } - - class HiddenFilter implements FileFilter { - private Object option; - private boolean invert; - private boolean argument; - public HiddenFilter(Object option, Object argument, boolean invert) { - this.option = option; - this.invert = invert; - this.argument = new Boolean(argument.toString()).booleanValue(); - } - public boolean accept(File file) { - return FindingFilter.invert( this.invert, file.isHidden() == this.argument ); - } - } - - class CanReadFilter implements FileFilter { - private Object option; - private boolean invert; - private boolean argument; - public CanReadFilter(Object option, Object argument, boolean invert) { - this.option = option; - this.invert = invert; - this.argument = new Boolean(argument.toString()).booleanValue(); - } - public boolean accept(File file) { - return FindingFilter.invert( this.invert, file.canRead() == this.argument ); - } - } - - class CanWriteFilter implements FileFilter { - private Object option; - private boolean invert; - private boolean argument; - public CanWriteFilter(Object option, Object argument, boolean invert) { - this.option = option; - this.invert = invert; - this.argument = new Boolean(argument.toString()).booleanValue(); - } - public boolean accept(File file) { - return FindingFilter.invert( this.invert, file.canWrite() == this.argument ); - } -} - diff --git a/genjava/gj-find/src/java/com/generationjava/io/find/ZipFinder.java b/genjava/gj-find/src/java/com/generationjava/io/find/ZipFinder.java deleted file mode 100644 index e6185312..00000000 --- a/genjava/gj-find/src/java/com/generationjava/io/find/ZipFinder.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -// @file ZipFinder.java -// @author bayard@generationjava.com -// @create 2000-11-18 -// @modify 2001-05-27 - -package com.generationjava.io.find; - -import java.io.File; -import java.util.List; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.Iterator; -import java.util.Enumeration; -import java.util.Map; -import java.util.zip.ZipFile; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.io.IOException; - -/** - * A Finder which finds files inside a Zip file. - * Will also work for jar files. - */ -public class ZipFinder implements Finder { - - private List findListeners; - - public File[] find(File zip) { - return find(zip, new java.util.HashMap()); - } - - public File[] find(File zipfile, Map options) { - String extension = null; - if(options.containsKey(Finder.NAME)) { - extension = options.get(Finder.NAME).toString(); - } - List retlist = new ArrayList(); - - try { - ZipFile zip = new ZipFile(zipfile); - Enumeration enum = zip.entries(); - while(enum.hasMoreElements()) { - ZipEntry entry = (ZipEntry)enum.nextElement(); - if(extension != null) { - if(entry.getName().endsWith(extension)) { - addFile(retlist, entry.getName()); - } - } else { - addFile(retlist, entry.getName()); - } - } - } catch(ZipException ze) { - throw new FinderException(ze); - } catch(IOException ioe) { - throw new FinderException(ioe); - } - - return (File[]) retlist.toArray(new File[0]); - } - - private void addFile(List list, String file) { - if(file.endsWith("/")) { - // directory - file = file.substring(0, file.length() - 1); - int idx = file.lastIndexOf("/"); - if(idx != -1) { - file = file.substring(idx+1); - } - return; - } - - int idx = file.lastIndexOf("/"); - String directory = ""; - if(idx != -1) { - directory = file.substring(0,idx); - file = file.substring(idx+1); - } - notifyFileFound(new File(directory), new File(directory, file)); - list.add(file); - } - - public void addFindListener(FindListener fl) { - if(findListeners == null) { - findListeners = new LinkedList(); - } - findListeners.add(fl); - } - - public void removeFindListener(FindListener fl) { - if(findListeners != null) { - findListeners.remove(fl); - } - } - - public void notifyDirectoryStarted(File directory) { - if(findListeners != null) { - FindEvent fe = new FindEvent(this,"directoryStarted",directory); - Iterator itr = findListeners.iterator(); - while(itr.hasNext()) { - FindListener findListener = (FindListener)itr.next(); - findListener.directoryStarted( fe ); - } - } - } - - public void notifyDirectoryFinished(File directory, File[] files) { - if(findListeners != null) { - FindEvent fe = new FindEvent(this,"directoryFinished",directory,files); - Iterator itr = findListeners.iterator(); - while(itr.hasNext()) { - FindListener findListener = (FindListener)itr.next(); - findListener.directoryFinished( fe ); - } - } - } - - public void notifyFileFound(File directory, File file) { - if(findListeners != null) { - FindEvent fe = new FindEvent(this,"fileFound",directory,file); - Iterator itr = findListeners.iterator(); - while(itr.hasNext()) { - FindListener findListener = (FindListener)itr.next(); - findListener.fileFound( fe ); - } - } - } - -} diff --git a/genjava/gj-find/src/java/com/generationjava/util/ClassIndex.java b/genjava/gj-find/src/java/com/generationjava/util/ClassIndex.java deleted file mode 100644 index 10adf51f..00000000 --- a/genjava/gj-find/src/java/com/generationjava/util/ClassIndex.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.util; - -import java.io.File; - -import java.util.Collection; -import java.util.HashMap; - -import com.generationjava.collections.FQMap; - -import com.generationjava.io.find.Finder; -import com.generationjava.io.find.FileFinder; -import com.generationjava.io.find.ZipFinder; -import com.generationjava.io.find.FindListener; -import com.generationjava.io.find.FindEvent; - -/** - * Indexes a class path. - */ -public class ClassIndex implements FindListener { - - private FQMap map = null; - - /** - * Create an index of the runtime classpath. - */ - public ClassIndex() { - this(System.getProperty("java.class.path")); - } - - /** - * Creates an index of the given classpath. - */ - public ClassIndex(String classpath) { - map = new FQMap(); - int idx = -1; - int current = 0; - while( (idx = classpath.indexOf(File.pathSeparatorChar, idx)) != -1 ) { - String path = classpath.substring(current, idx); - - File file = new File(path); - Finder finder = null; - if(file.isDirectory()) { - // find all .class files. - finder = new FileFinder(); - } else { - // assume it's a zip/jar - // open and find all .class files - finder = new ZipFinder(); - } - finder.addFindListener(this); - HashMap options = new HashMap(); - options.put(Finder.NAME, "class"); - finder.find(file, options); - - idx++; - current = idx; - } - - } - - /** - * Get the package that a given classname is in. - */ - public String getPackage(String classname) { - return (String)map.get(classname); - } - - public Collection getRootClasses() { - return getClassesIn(""); - } - public Collection getClassesIn(String packagename) { - FQMap tmp = map; - if(!"".equals(packagename)) { - tmp = (FQMap)map.get(packagename); - } - Collection[] colls = tmp.getSeparatedValues(); - return colls[1]; - } - - public Collection getRootPackages() { - return getPackagesIn(""); - } - public Collection getPackagesIn(String packagename) { - FQMap tmp = map; - if(!"".equals(packagename)) { - tmp = (FQMap)map.get(packagename); - } - Collection[] colls = tmp.getSeparatedValues(); - return colls[0]; - } - - public void directoryStarted(FindEvent findEvent) { - // ignore - } - - public void directoryFinished(FindEvent findEvent) { - // ignore - } - - public void fileFound(FindEvent findEvent) { - File file = findEvent.getFile(); - String filename = file.getName(); - - // ignore inner classes - if(filename.indexOf("$") != -1) { - return; - } - - filename = filename.substring(0,filename.length()-6); - - if(map.get(filename) != null) { - // simulate the import method of getting the first one - return; - } - - String pck = findEvent.getDirectory().getPath(); - pck = pck.replace('/','.'); - while(pck.startsWith(".")) { - pck = pck.substring(1); - } - - map.put(filename, pck); - } - -} - diff --git a/genjava/gj-find/src/java/com/generationjava/util/WildcardUtils.java b/genjava/gj-find/src/java/com/generationjava/util/WildcardUtils.java deleted file mode 100644 index f58adc98..00000000 --- a/genjava/gj-find/src/java/com/generationjava/util/WildcardUtils.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2003-2004, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.util; - -import java.util.ArrayList; - -/** - * An implementation of Wildcard logic, as seen on command lines - * on UNIX and DOS. - */ -public class WildcardUtils { - - /** - * See if a particular piece of text, often a filename, - * matches to a specified wildcard. - * - * @param String text to search upon - * @param String wildcard to use in the search - * - * @return boolean whether the wildcard matched the text or not - */ - public static boolean match(String text, String wildcard) { - // split wildcard on ? and * - // for each element of the array, find a matching block in text - // earliest matching block counts - String[] wcs = splitOnTokens(wildcard); - int textIdx = 0; - for(int i=0; i - - - - Henri Yandell - Changes - - - - - Added many UNIX find-like parameters in the form of hidden FileFilters. They may be accessed via an options Map. - Event/Listener system talks in terms of Lists now and not File[]. - ZipFinder is non-functional, look for this to be fixed in the next release. - - - diff --git a/genjava/gj-find/xdocs/images/1x1.gif b/genjava/gj-find/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/genjava/gj-find/xdocs/images/1x1.gif and /dev/null differ diff --git a/genjava/gj-find/xdocs/images/osjava.gif b/genjava/gj-find/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/genjava/gj-find/xdocs/images/osjava.gif and /dev/null differ diff --git a/genjava/gj-find/xdocs/navigation.xml b/genjava/gj-find/xdocs/navigation.xml deleted file mode 100644 index ae46a44a..00000000 --- a/genjava/gj-find/xdocs/navigation.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - genjava - - - - - - - - - - - - - - - diff --git a/genjava/gj-gui/LICENSE.txt b/genjava/gj-gui/LICENSE.txt deleted file mode 100644 index 38aecf65..00000000 --- a/genjava/gj-gui/LICENSE.txt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/genjava/gj-gui/maven.xml b/genjava/gj-gui/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/genjava/gj-gui/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/genjava/gj-gui/pom.xml b/genjava/gj-gui/pom.xml deleted file mode 100644 index 01680df8..00000000 --- a/genjava/gj-gui/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - genjava - genjava - UNUSED - - 4.0.0 - gj-gui - GenJava-GUI - 0.1.1 - 2002 - - - AWT/Swing Components - - - - - - - commons-lang - commons-lang - 2.0 - - - - commons-collections - commons-collections - 2.1 - - - - gj-core - genjava - 3.0 - - - - gj-beans - genjava - 1.0 - - - - - - diff --git a/genjava/gj-gui/project.properties b/genjava/gj-gui/project.properties deleted file mode 100644 index d0f1d722..00000000 --- a/genjava/gj-gui/project.properties +++ /dev/null @@ -1,18 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.checkstyle.properties=../../hen_checkstyle.xml - -maven.javadoc.stylesheet=../../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/genjava/gj-gui/project.xml b/genjava/gj-gui/project.xml deleted file mode 100644 index 24c355df..00000000 --- a/genjava/gj-gui/project.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - ../project.xml - gj-gui - GenJava-GUI - 0.1.1 - 2002 - - - AWT/Swing Components - - - AWT/Swing Components - - - - commons-lang - 2.0 - http://jakarta.apache.org/commons/lang.html - - - commons-collections - 2.1 - http://jakarta.apache.org/commons/collections.html - - - gj-core - genjava - 3.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - gj-beans - genjava - 1.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - - - diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/BasicApplication.java b/genjava/gj-gui/src/java/com/generationjava/awt/BasicApplication.java deleted file mode 100644 index 8ef45fe3..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/BasicApplication.java +++ /dev/null @@ -1,455 +0,0 @@ -package com.generationjava.awt; - -import com.generationjava.awt.GJMenuItem; -import com.generationjava.awt.ReportEvent; -import com.generationjava.awt.RequestEvent; -import com.generationjava.awt.MulticastRequestEvent; -import com.generationjava.awt.InformationListener; - -import java.awt.Frame; -import java.awt.event.WindowListener; -import java.awt.event.WindowEvent; -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; - -import java.awt.MenuBar; -import java.awt.MenuItem; -import java.awt.Menu; -import java.awt.MenuShortcut; - -import java.awt.FileDialog; - -import java.util.Hashtable; -import java.util.Vector; -import java.util.Enumeration; - -import org.apache.commons.lang.StringUtils; - -/** - * A simple framework which allows files to be opened and - * many files be in an open state. Thus files may also be closed. - */ - // TODO: Add createCompassPanel - // TODO: Refactor menu options so they're more easily to clone. ie) open url - // TODO: About/Help/Licence. These should open a popup if contain newlines. - // TODO: inform(String) that uses getTitle as old -public abstract class BasicApplication extends Frame implements WindowListener, ActionListener { - - private String currentDir; - private Object currentObj; - private Hashtable openList; - private Menu openMenu; - - private Vector listeners; - private Hashtable menus; - - public BasicApplication(String title) { - super(title); - openList = new Hashtable(); - menus = new Hashtable(); - MenuBar bar = new MenuBar(); - this.setMenuBar(bar); - - registerMenuItem("File", "Open", "O"); - registerMenuItem("File","Close","W"); - createNewBlock("File",0); - registerMenuItem("File","Exit","E"); - openMenu = (Menu)registerMenu("Opened"); - bar.setHelpMenu((Menu)registerMenu("Help")); - registerMenuItem("Help","About","Shift-A"); - registerMenuItem("Help","Licence","Shift-L"); - registerMenuItem("Help","QuickHelp","Shift-H"); - - } - - // Menu Handling Code - // Ported back from JBasicApplication - private void addTopLevelMenu(Menu menu) { - // push after help menu - getMenuBar().add(menu); - } - // will not return null - private Menu getMenu(String fqname) { - Menu m = (Menu)menus.get(fqname); - if(m == null) { - m = createMenu(getLabel(getMenuName(fqname))); - - String parentName = StringUtils.substringBefore(fqname,"."); - if(parentName.equals(fqname)) { - parentName = ""; - } - if("".equals(parentName)) { - addTopLevelMenu(m); - } else { - Menu parent = getMenu(parentName); - // parent can't be null - parent.add(m); - } - menus.put(fqname,m); - } - return m; - } - private String getMenuName(String fqname) { - if(fqname.indexOf(".") == -1) { - return fqname; - } else { - return StringUtils.substringAfter(fqname,"."); - } - } - // basically inserts a separator - protected void createNewBlock(String menuName, int block) { - Menu menu = getMenu(menuName); - int idx = getBlockIndex(menu, block); - menu.insertSeparator(idx); - } - // Creates a sub-menu. If menuName is "", then goes in root. - protected Object registerMenu(String subMenuName, char mnemonic) { - Menu menu = getMenu(subMenuName); - menu.setShortcut( new MenuShortcut((int)mnemonic) ); - return menu; - } - protected Object registerMenu(String subMenuName) { - return getMenu(subMenuName); - } - protected Object registerMenu(String menuName, String subMenuName, String mnemonic) { - return registerMenu(menuName, subMenuName, -2, null); - } - protected Object registerMenu(String menuName, String subMenuName, int block, String mnemonic) { - Menu parent = getMenu(menuName); - int idx = getBlockIndex(parent,block); - Menu menu = createMenu( getLabel(subMenuName) ); - if(mnemonic != null) { - menu.setShortcut( new MenuShortcut((int)mnemonic.charAt(0))); - } - parent.insert(menu, idx); - return menu; - } - private Menu createMenu(String menuName) { - Menu menu = new Menu( menuName); - menu.setShortcut( new MenuShortcut((int)menuName.charAt(0)) ); - return menu; - } - protected Object registerMenuItem(String menuName, String itemName) { - return registerMenuItem(menuName, itemName, -2, null); - } - protected Object registerMenuItem(String menuName, String itemName, String ch) { - return registerMenuItem(menuName, itemName, -2, ch); - } - protected Object registerMenuItem(String menuName, String itemName, int block) { - return registerMenuItem(menuName, itemName, -2, null); - } - protected Object registerMenuItem(String menuName, String itemName, int block, String ch) { - String label = getLabel(itemName); - MenuItem mi = new GJMenuItem( label, itemName ); - // set up accelerator? - if(ch != null) { - int mask = 0; - if(ch.indexOf("Shift") != -1) { - mask |= ActionEvent.SHIFT_MASK; - } - /* Not in AWT. - if(true) { - mask |= ActionEvent.CTRL_MASK; - } - */ - int key = (int)ch.charAt(ch.length()-1); -// mi.setAccelerator( KeyStroke.getKeyStroke(key, mask) ); - mi.setShortcut( new MenuShortcut( key, (mask != 0) ) ); - } - mi.addActionListener(this); - return registerMenuItem(menuName, mi, block); - } - protected Object registerMenuItem(String menuName, MenuItem item, int block) { - Menu m = (Menu)getMenu(menuName); - int idx = getBlockIndex(m, block); - m.insert(item,idx); - return m; - } - - // -2 implies the end, -1 means right at the front - private int getBlockIndex(Menu menu, int block) { - if(block == -1) { - return 0; - } - /* Not available in AWT. Need to clone functionality here - Component[] comps = menu.getMenuComponents(); - if(block == -2) { - return comps.length; - } - int i; - int sz = comps.length; - for(i=0; i 0) { - w += (w * xsWidth / required.width); - } - - c.setBounds(x,y,w,h); - x += (w + getHorizontalGap()); - } - } - } -} diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/ImageCanvas.java b/genjava/gj-gui/src/java/com/generationjava/awt/ImageCanvas.java deleted file mode 100644 index 8a542f6e..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/ImageCanvas.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.generationjava.awt; - -import java.awt.Image; -import java.awt.Canvas; -import java.awt.Graphics; -import java.awt.Dimension; -import java.awt.MediaTracker; -import java.awt.Toolkit; - -/** - * Provides a Canvas on wihch an Image is drawn. - * Originally this functionality was encased in a swing class - * called ImagePanel, however this version was taken - * from the David Geary AWT book. - */ -public class ImageCanvas extends Canvas implements ImageSource { - - private Image image; - private ImageSource source; - - public ImageCanvas(String file) { - setImage( load( file ) ); - } - public ImageCanvas(Image image) { - waitForImage(image); - this.image = image; - } - - public ImageCanvas(ImageSource source) { - this.source = source; - } - - public void paint(Graphics g) { - g.drawImage( getImage(), 0, 0, this); - } - - public void update(Graphics g) { - paint(g); - } - - public Dimension getPreferredSize() { - return new Dimension( getImage().getWidth(this), getImage().getHeight(this) ); - } - - public Image load(String file) { - Image img = Toolkit.getDefaultToolkit().getImage(file); - waitForImage(img); - return img; - } - - private void waitForImage(Image img) { - MediaTracker mt = new MediaTracker(this); - mt.addImage(img,0); - try { - mt.waitForID(0); - } catch(Exception e) { - e.printStackTrace(); - } - } - - public void setImage(Image image) { - this.image = image; - this.source = null; - this.invalidate(); - this.repaint(); - } - - public Image getImage() { - if( source != null ) { - return this.source.getImage(); - } else { - return this.image; - } - } - - public void setImage(ImageSource source) { - this.source = source; - this.image = null; - } - -} diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/ImageLoaderFacade.java b/genjava/gj-gui/src/java/com/generationjava/awt/ImageLoaderFacade.java deleted file mode 100644 index c2c92129..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/ImageLoaderFacade.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.generationjava.awt; - -import java.awt.Image; -import java.awt.Toolkit; -import java.awt.MediaTracker; -import java.io.File; -import java.net.URL; -import java.awt.image.ImageProducer; - -/** - * This provides a standard way of loading an image in as a resource. - * - * // TODO: Provide a way of informing the person that is loaded. - */ -public class ImageLoaderFacade extends java.awt.Panel { - - static private ImageLoaderFacade myObj = null; // singleton variable - - /** - * Singleton class therefore no access to this method - */ - private ImageLoaderFacade() { } - - /** - * Get the singleton object. - * - * @return ImageLoaderFacade singleton object. - */ - static public ImageLoaderFacade getInstance() { - if(myObj == null) myObj = new ImageLoaderFacade(); - return myObj; - } - - /** - * Get an image. - * - * @param imgstr String resource name of the image. - * Delimited by '.'s. - * - * @return Image desired. - */ - public Image getImage(String imgstr) { - Toolkit tk = Toolkit.getDefaultToolkit(); - - //URL url = getClass().getResource(imgstr); - MediaTracker mt = new MediaTracker(this); - Image img = tk.getImage(imgstr); // or use url - - mt.addImage(img,0); - - try { - mt.waitForAll(); - } catch(InterruptedException ie) { - ie.printStackTrace(); - } - - return img; - - //return tk.createImage(imgstr); - } - - /** - * Get an image. - * - * @param file File containing the image. - * - * @return Image desired. - */ - public Image getImage(File file) { - return getImage(file.getAbsolutePath()); - } - - /** - * Get an image. - * - * @param ip ImageProducer that will provide the image. - * - * @return Image desired. - */ - public Image getImage(ImageProducer ip) { - Toolkit tk = Toolkit.getDefaultToolkit(); - - MediaTracker mt = new MediaTracker(this); - Image img = tk.createImage(ip); - - mt.addImage(img,0); - - try { - mt.waitForAll(); - } catch(InterruptedException ie) { - ie.printStackTrace(); - } - - return img; - } - - - /** - * Get an image. - * - * @param imgstr String file name, using File.separator. - * @param ext String ext extension, for example 'gif' - * - * @return Image desired. - */ - public Image getImage(String imgstr, String ext) { - imgstr = imgstr.replace(".".charAt(0),File.separator.charAt(0)); - return getImage(imgstr+"."+ext); - } - - static public Image loadImage(String name) { - ClassLoader loader = ClassLoader.getSystemClassLoader(); - - if(loader != null) { - URL url = loader.getResource(name); - if(url == null) { - url = loader.getResource("/"+name); - } - if(url != null) { - Toolkit tk = Toolkit.getDefaultToolkit(); - Image img = tk.getImage(url); - return img; - } - } - - return null; - } - -} diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/ImageSource.java b/genjava/gj-gui/src/java/com/generationjava/awt/ImageSource.java deleted file mode 100644 index 1e3a7e46..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/ImageSource.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.generationjava.awt; - -import java.awt.Image; - -public interface ImageSource { - - public Image getImage(); - - // has the image changed, ie) we should stop caching - // this is either of two things. - // 1) The image's variables have changed and it - // needs regenerating. - // 2) It's been regenerated, but the user of this - // source has yet to - //public boolean isModified(Image img); - -} \ No newline at end of file diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/ImageW.java b/genjava/gj-gui/src/java/com/generationjava/awt/ImageW.java deleted file mode 100644 index 9c479831..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/ImageW.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.generationjava.awt; - -import java.awt.Image; - -public class ImageW { - - private String name; - private Image image; - - public ImageW(String name, Image image) { - this.name = name; - this.image = image; - } - - public String toString() { - return this.name; - } - - public Image getImage() { - return this.image; - } - - public void close() { - this.image.flush(); - } - -} \ No newline at end of file diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/InformationListener.java b/genjava/gj-gui/src/java/com/generationjava/awt/InformationListener.java deleted file mode 100644 index 8438b2bd..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/InformationListener.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.generationjava.awt; - -public interface InformationListener { - - public void report(ReportEvent re); - - public Object request(RequestEvent re); - - // when lots of components are involved, we need - // to only multicast to those interested, not all. - // however this is overkill in a simple system, - // broadcast is best. - // the best way seems to be for each listener to - // offer up a list of the messages they are interested - // in. Then the central app may decide whether to - // deal with these or lump them all in together. -// public Vector getConcerns(); - -} \ No newline at end of file diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/InputView.java b/genjava/gj-gui/src/java/com/generationjava/awt/InputView.java deleted file mode 100644 index 4e8ab5d4..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/InputView.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.generationjava.awt; - -import java.awt.TextArea; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.io.IOException; -import java.io.InputStream; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.SystemUtils; - -/** - * Allows a TextArea to be used as the STDIN. It is generic enough - * that it may be used as another InputStream than STDIN. - * Works via newline characters, so it's possible to hit newline and - * not be on the last line of the text-area. - * Possibly refactor this so that it only works if you goto the end and - * hit return. Maybe even shift-return a la Mathematica. - * - * @author bayard@generationjava.com - */ -public class InputView extends TextArea { - - private InputStream stream; - - public InputView(String name, int i, int j) { - super(name,i,j); - stream = new StringInputStream(this); - setEditable(true); - } - - public InputStream getStream() { - return this.stream; - } - - public void redirectIn() { - System.setIn( this.stream ); - } - -} - -// needs refactoring to make more useful. but not nice anyway. -// now with buffering, and optimisation for byte[] -class StringInputStream extends InputStream implements KeyListener { - - private InputView view; - private byte[] buffer; - private int idx = -1; - - public StringInputStream(InputView view) { - this.view = view; // bad to do this? caches the source of textevent - view.addKeyListener(this); - } - - public void keyPressed(KeyEvent ke) { - } - public void keyReleased(KeyEvent ke) { - } - // listen for new lines. read whenever newline appears - public void keyTyped(KeyEvent ke) { - if(ke.getKeyCode() != KeyEvent.VK_ENTER) { - return; - } - String txt = view.getText(); - - String line = StringUtils.chomp(txt); - // TODO: Handle the fact the separator isn't returned here - line = StringUtils.substringAfterLast(line, SystemUtils.LINE_SEPARATOR); - line = StringUtils.stripStart(line, SystemUtils.LINE_SEPARATOR); - byte[] newbuffer = line.getBytes(); - if(idx != -1) { - byte[] tmp = new byte[newbuffer.length+buffer.length-idx]; - System.arraycopy(buffer, idx, tmp, 0, buffer.length - idx); - System.arraycopy(newbuffer, 0, tmp, buffer.length - idx, newbuffer.length); - newbuffer = tmp; - } - idx = 0; - buffer = newbuffer; - } - - public int read(byte[] b, int off, int len) { - if(idx == -1) { - return -1; - } - int avail = buffer.length - idx - 1; - if(avail > len) { - avail = len; - } - System.arraycopy(buffer, idx, b, off, avail); - idx += avail; - return avail; - } - - public int read() throws IOException { - if(idx == -1) { - return -1; - } - if(idx == buffer.length) { - idx = -1; - buffer = null; - return -1; - } - return buffer[idx++]; - } - -} diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/MultiPanel.java b/genjava/gj-gui/src/java/com/generationjava/awt/MultiPanel.java deleted file mode 100644 index 5e63928d..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/MultiPanel.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.generationjava.awt; - -import java.awt.Panel; -import java.util.Hashtable; - -public class MultiPanel extends Panel implements PanelFactory { - - private PanelFactory factory = null; - private Hashtable panelMap = new Hashtable(); - - public MultiPanel() { - super(); - } - - public void setPanelFactory(PanelFactory factory) { - this.factory = factory; - } - - public void addPanel(String name) { - addPanel(name, this); - } - - public void addPanel(String name, Panel panel) { - panelMap.put(name, panel); - } - - public Panel getPanel(String name) { - return (Panel)panelMap.get(name); - } - - - // IMPLEMENTING PanelFactory - public Panel createPanel(String name) { - if(factory != null) { - return factory.createPanel(name); - } else { - return null; - } - } - // End of PanelFactory - - public void switchPanel(String name) { - Panel panel = getPanel(name); - if(panel == null) { - return; // not an existing panel - } - if(panel == this) { - panel = createPanel(name); - addPanel(name, panel); - } - switchPanel(panel); - } - - public void switchPanel(Panel panel) { - this.removeAll(); - this.add(panel); - this.invalidate(); - this.repaint(); - } - -} \ No newline at end of file diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/MulticastRequestEvent.java b/genjava/gj-gui/src/java/com/generationjava/awt/MulticastRequestEvent.java deleted file mode 100644 index f7973dd7..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/MulticastRequestEvent.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.generationjava.awt; - -public class MulticastRequestEvent extends RequestEvent { - - public MulticastRequestEvent(String name, Object value) { - super(name, value); - } - -} \ No newline at end of file diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/PanelFactory.java b/genjava/gj-gui/src/java/com/generationjava/awt/PanelFactory.java deleted file mode 100644 index e0429cd1..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/PanelFactory.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.generationjava.awt; - -import java.awt.Panel; - -public interface PanelFactory { - - public Panel createPanel(String name); - -} \ No newline at end of file diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/ReportEvent.java b/genjava/gj-gui/src/java/com/generationjava/awt/ReportEvent.java deleted file mode 100644 index 57d31ac5..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/ReportEvent.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.generationjava.awt; - -public class ReportEvent { - - private String name; - private String type; - private Object value; - - public ReportEvent(String name, Object value) { - this.name = name; - this.value = value; - } - - public Object getValue() { - return this.value; - } - - public String getName() { - return this.name; - } - - public String toString() { - return ""+this.name+":"+this.value; - } - -} \ No newline at end of file diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/RequestEvent.java b/genjava/gj-gui/src/java/com/generationjava/awt/RequestEvent.java deleted file mode 100644 index c30d3a22..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/RequestEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.generationjava.awt; - -public class RequestEvent { - - private String name; - private String type; - private Object value; - - public RequestEvent(String name, Object value) { - this.name = name; - this.value = value; - } - - public Object getValue() { - return this.value; - } - - public void setValue(Object obj) { - this.value = value; - } - - public String getName() { - return this.name; - } - - public String toString() { - return ""+this.name+":"+this.value; - } - -} \ No newline at end of file diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/SaveableApplication.java b/genjava/gj-gui/src/java/com/generationjava/awt/SaveableApplication.java deleted file mode 100644 index a57046e4..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/SaveableApplication.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.generationjava.awt; - -import java.awt.FileDialog; -import java.awt.event.ActionEvent; - -abstract public class SaveableApplication extends BasicApplication { - - public final int SAVE = FileDialog.SAVE; - - public SaveableApplication(String name) { - super(name); - - registerMenuItem("File","Save",0,"S"); - registerMenuItem("File","Save As",0,"Shift-S"); - registerMenuItem("File","Revert",0,"R"); - } - - abstract protected void fileSaved(String filename, Object obj); - abstract protected String getCurrentFilename(); - - public void actionPerformed(ActionEvent ae) { - String cmd = ae.getActionCommand(); - if("Save".equals(cmd)) { - String filename = getCurrentFilename(); - if(filename == null) { - filename = getFileName(SAVE); - fileSaved(filename, getCurrent()); - } - } else - if("Save As".equals(cmd)) { - String filename = getFileName(SAVE); - if(filename != null) { - fileSaved(filename, getCurrent()); - } - } else - if("Revert".equals(cmd)) { - String filename = getCurrentFilename(); - if(filename != null) { - removeFromOpenList(getCurrent()); - fileClosed(getCurrent()); - Object obj = fileOpened(filename); - setCurrent(obj); - selection(); - addToOpenList(obj); - } - } - super.actionPerformed(ae); - } - - -} diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/SplashScreen.java b/genjava/gj-gui/src/java/com/generationjava/awt/SplashScreen.java deleted file mode 100644 index ad3673b0..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/SplashScreen.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.generationjava.awt; - -import java.awt.Image; -import java.awt.Frame; -import java.awt.Window; -import java.awt.Dimension; - -/** - * An AWT SplashScreen class. - * - * // TODO: Add a closing cross so people can stop the loading. - * // Add a progess bad. - */ -public class SplashScreen extends Window { - - // Where the image is drawn - private ImageCanvas canvas = null; - - /** - * Create a splash screen based on the given image. - * An anonymous frame will be bound to the splash screen. - * - * @param img Image to be shown on the splash screen. - */ - public SplashScreen(Image img) { - this(new Frame("Dummy Frame For SplashScreen"),img); - } - - /** - * Create a splash screen based on the given image. - * - * @param img Image to be shown on the splash screen. - * @param f Frame to bind this splash screen to. - */ - public SplashScreen(Frame f, Image img) { - super(f); - canvas = new ImageCanvas(img); - this.add(canvas, "Center"); - setSize( canvas.getPreferredSize() ); - WindowUtilities.centreWindowOnScreen(this); - } - - /** - * Overriden to return the preferred size of the image. - * - * @return Dimension measuring the preferred size. - */ - public Dimension getPreferredSize() { - return canvas.getPreferredSize(); - } - - /** - * Make sure this splash screen is at the front when it's shown. - */ - public void show() { - super.show(); - this.toFront(); - } - -} diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/VerticalFlowLayout.java b/genjava/gj-gui/src/java/com/generationjava/awt/VerticalFlowLayout.java deleted file mode 100644 index 9024bcf5..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/VerticalFlowLayout.java +++ /dev/null @@ -1,89 +0,0 @@ -// VerticalFlowLayout.java -package com.generationjava.awt; - -import java.awt.LayoutManager; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Container; -import java.awt.Insets; - -/** - * A vertical flow layout. Useful if Box isn't available. - * Based on an original in the Java Pitfalls book - 0471361747. - */ -public class VerticalFlowLayout implements LayoutManager { - - private int vertGap; - - public VerticalFlowLayout() { - this(2); - } - - public VerticalFlowLayout(int gap) { - vertGap = gap; - } - - public int getVerticalGap() { - return vertGap; - } - - // implement LayoutManager - public void addLayoutComponent(String name, Component comp) { - } - public void removeLayoutComponent(Component comp) { - } - - public Dimension preferredLayoutSize(Container parent) { - return getLayoutSize(parent,false); - } - public Dimension minimumLayoutSize(Container parent) { - return getLayoutSize(parent,true); - } - - private Dimension getLayoutSize(Container parent, boolean min) { - int count = parent.getComponentCount(); - Dimension size = new Dimension(0,0); - for(int i=0;i 0) { - h += (h * xsHeight / required.height); - } - - c.setBounds(x,y,w,h); - y += (h + getVerticalGap()); - } - } - } -} diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/WindowUtilities.java b/genjava/gj-gui/src/java/com/generationjava/awt/WindowUtilities.java deleted file mode 100644 index 61ed9670..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/WindowUtilities.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.generationjava.awt; - -import java.awt.Window; -import java.awt.Dimension; -import java.awt.Toolkit; - -/** - * A set of useful routines for manipulating Window objects. - */ -public class WindowUtilities { - - static public final int TOP = 0; - static public final int CENTRE = 1; - static public final int BOTTOM = 2; - static public final int LEFT = 3; - static public final int RIGHT = 4; - - /** - * Centre the given window on the screen, - * - * @param w Window to centre. - */ - static public void centreWindowOnScreen(Window w) { - positionWindowOnScreen(w,CENTRE,CENTRE); - } - - /** - * Position the given window on the screen at the given location, - * - * @param w Window to centre. - * @param x int x co-ordinate. - * @param y int y co-ordinate. - */ - static public void positionWindowOnScreen(Window w, int x, int y) { - Toolkit tk = w.getToolkit(); - Dimension scrn = tk.getScreenSize(); - Dimension win = w.getSize(); - int nx = 0,ny = 0; - switch(x) { - case LEFT: nx = 0; break; - case CENTRE: nx = (int)((scrn.width-win.width)/2); break; - case RIGHT: nx = (int)(scrn.width-win.width); break; - } - switch(y) { - case TOP: ny = 0; break; - case CENTRE: ny = (int)((scrn.height-win.height)/2); break; - case BOTTOM: ny = (int)(scrn.height-win.height); break; - } - w.setLocation(nx,ny); - } - - /** - * Resizes the given window to the given ratio of the screen size, - * - * @param w Window to centre. - * @param ratio double value to change the window size to. - */ - static public void sizeWindowOnScreen(Window w, double ratio) { - Toolkit tk = w.getToolkit(); - Dimension scrn = tk.getScreenSize(); - w.setSize( new Dimension( (int)(scrn.width*ratio), (int)(scrn.height*ratio) ) ); - } - - static public void maxWindowOnScreen(Window w) { - sizeWindowOnScreen(w, 1); - } - -} diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/Zoomer.java b/genjava/gj-gui/src/java/com/generationjava/awt/Zoomer.java deleted file mode 100644 index e3cf0ce8..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/Zoomer.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.generationjava.awt; - -import java.awt.Image; -import java.awt.Point; -import java.awt.Rectangle; -import com.generationjava.awt.ImageLoaderFacade; -import java.awt.image.ImageProducer; -import java.awt.image.PixelGrabber; -import java.awt.image.MemoryImageSource; - -public class Zoomer implements ImageSource, InformationListener { - - private ImageSource source; - private double magnification; - private Image croppedImage; - - private Rectangle viewport; - - public Zoomer(ImageSource source) { - this.source = source; - this.magnification = 1; - } - - public Image getImage() { - if (croppedImage == null) { - croppedImage = this.source.getImage(); - viewport = new Rectangle(croppedImage.getWidth(null), - croppedImage.getHeight(null)); - } - return croppedImage; - } - - public void report(ReportEvent re) { - if ("zoom-in".equals(re.getName())) { - magnify(magnification / 2); - } else if ("zoom-out".equals(re.getName())) { - magnify(magnification * 2); - } - } - - public Object request(RequestEvent re) { - return null; - } - - public void magnify() { - magnify(magnification); - } - - public void magnify(double x) { - Point pt = new Point(); - pt.x = getImage().getWidth(null) / 2; - pt.y = getImage().getHeight(null) / 2; - magnify(x, pt); - } - - public void magnify(double x, Point p) { - Image img = null; - if (x > 1.0) { - img = source.getImage(); - viewport.x = (int)(viewport.x); - viewport.y = (int)(viewport.y); - viewport.width = (int)(getImage().getWidth(null)); - viewport.height = (int)(getImage().getHeight(null)); - } else { - img = source.getImage(); - img.getHeight(null); - viewport.width = (int)(img.getWidth(null) * x); - viewport.height = (int)(img.getHeight(null) * x); - viewport.x = (int)(p.x - viewport.width / x); - viewport.y = (int)(p.y - viewport.height / x); - } - magnification = x; - - // crop image - int[] pixels = new int[viewport.width * viewport.height]; - PixelGrabber pg = new PixelGrabber(img, viewport.x, viewport.y, - viewport.width, viewport.height, pixels, 0, viewport.width); - try { - pg.grabPixels(); - } catch (InterruptedException ie) { - ie.printStackTrace(); - } - - ImageProducer ip = - new MemoryImageSource(viewport.width, viewport.height, - pixels, 0, viewport.width); - croppedImage = ImageLoaderFacade.getInstance().getImage(ip); - } - -} diff --git a/genjava/gj-gui/src/java/com/generationjava/awt/package.html b/genjava/gj-gui/src/java/com/generationjava/awt/package.html deleted file mode 100644 index 64aa3795..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/awt/package.html +++ /dev/null @@ -1,8 +0,0 @@ - - -

- Generic components that aide when coding with AWT. Some parts will also - be of use when using Swing due to Swing's descendency from AWT. -

- - diff --git a/genjava/gj-gui/src/java/com/generationjava/swing/AutoOptionDialog.java b/genjava/gj-gui/src/java/com/generationjava/swing/AutoOptionDialog.java deleted file mode 100644 index a4c96999..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/swing/AutoOptionDialog.java +++ /dev/null @@ -1,365 +0,0 @@ -package com.generationjava.swing; - -import javax.swing.JDialog; -import javax.swing.JFrame; -import java.util.Map; -import java.util.HashMap; -import java.util.ArrayList; -import java.util.Set; -import java.util.Iterator; -import java.util.Collection; -import java.awt.LayoutManager; -import javax.swing.JLabel; -import javax.swing.JButton; -import javax.swing.Icon; - -import javax.swing.JPanel; -import java.awt.BorderLayout; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -// DialogEntry -import java.awt.Component; -// StringDialogEntry -import javax.swing.JTextField; -// BooleanDialogEntry -import javax.swing.JCheckBox; -// Object[]DialogEntry -import javax.swing.JComboBox; -// CollectionDialogEntry -//import java.lang.reflect.Constructor; -import java.util.Collection; -import javax.swing.JList; - -/** - * A class for easily creating configuration/option dialogs. - * - * @version 0.9 A finished alpha version. The plus points are that data is - * supplied as normal data types and returned more or less the same. - * The Event/Listener model used seems fine. The negative side is that - * it doesn't feel to be the right separation. It also feels clunky. - * - * TODO: Properly Javadoc, - * Split into class files. - * Work out how to get data out again. - * Make it serializable. Ensure JavaBeanable. - */ - -public class AutoOptionDialog extends JDialog { - - static public void main(String[] args) { - Map map = new HashMap(); - map.put("Test","Whee"); - map.put("And",new Boolean(true)); - Object[] bob = new Object[3]; - bob[0] = "Hey"; - bob[1] = "You"; - bob[2] = "Fred!"; - map.put("Message",bob); - java.util.ArrayList li = new java.util.ArrayList(); - for(int i=0;i<10;i++) - li.add(""+i); - map.put("Maybe",li); - JFrame jf = new JFrame(); - AutoDialogListener adl = new AutoDialogListener() { - public void dialogApplied(AutoDialogEvent ade) { - System.out.println(""+ade.getDataMap()); - } - }; - //JDialog jd = new AutoOptionDialog(jf,"TEST",true,map,new java.awt.FlowLayout()); - JDialog jd = new AutoOptionDialog(jf,adl,"TEST",true,map); - jd.show(); - } - - private Map myData = null; - private AutoDialogListener myListener = null; - - public AutoOptionDialog(JFrame owner, AutoDialogListener adl, String title, boolean modal, Map data, LayoutManager layout) { - super(owner,title,modal); - myData = preParse(data); // bother storing this? - myListener = adl; - initDialog(myData, layout); - pack(); - } - - public AutoOptionDialog(JFrame owner, AutoDialogListener adl, String title, boolean modal, Map data) { - this(owner,adl,title,modal,data,new java.awt.GridLayout(data.keySet().size(),1)); - } - public AutoOptionDialog(JFrame owner, String title, boolean modal, Map data) { - this(owner,null,title,modal,data,new java.awt.GridLayout(data.keySet().size(),1)); - - // can`t have this before the this() - AutoDialogListener adl = null; - if(owner instanceof AutoDialogListener) { - myListener = (AutoDialogListener)owner; - } - } - - public Map preParse(Map data) { - Map returnData = new HashMap(); - Iterator dataKeysI = data.keySet().iterator(); - while(dataKeysI.hasNext()) { - Object key = dataKeysI.next(); - Object returnKey = null; - Object value = data.get(key); - Object returnValue = null; - if(key instanceof String) { - returnKey = new JLabel((String)key); - } else - if(key instanceof Icon) { - returnKey = new JLabel((Icon)key); - } else - if(key instanceof JLabel) { - returnKey = key; - // desired state - } else { - // COMPLAIN!! - } - - if(value instanceof String) { - returnData.put(returnKey,new StringDialogEntry( value)); - } else - if(value instanceof Boolean) { - returnData.put(returnKey,new BooleanDialogEntry( value)); - } else - if(value instanceof Collection) { - returnData.put(returnKey,new CollectionDialogEntry( value)); - } else - if(value instanceof Object[]) { - returnData.put(returnKey,new ObjectArrayDialogEntry( value)); - } else - if(value instanceof DialogEntry) { - returnData.put(returnKey,value); - //leave alone - } else { - // COMPLAIN! - } - } - return returnData; - } - - protected void initDialog(Map data, LayoutManager layout) { - this.getContentPane().setLayout( new BorderLayout()); - JPanel panel = new JPanel(); - JPanel buttonPanel = new JPanel(); - panel.setLayout(layout); - Set keys = data.keySet(); - - Iterator keysI = keys.iterator(); - while(keysI.hasNext()) { - JLabel key = (JLabel)keysI.next(); - DialogEntry de = (DialogEntry)data.get(key); - panel.add(key); - Component com = de.createComponent(); - panel.add(com); - } - final AutoOptionDialog self = this; // FIX - JButton okB = new JButton("OK"); - okB.addActionListener( new ActionListener() { - public void actionPerformed(ActionEvent ae) { - self.hide(); // FIX - } - }); - buttonPanel.add( okB ); - JButton cancelB = new JButton("Cancel"); - buttonPanel.add( cancelB ); - if(myListener != null) { - JButton applyB = new JButton("Apply"); - applyB.addActionListener( new ActionListener() { - public void actionPerformed(ActionEvent ae) { - myListener.dialogApplied(new AutoDialogEvent(getDataMap())); - } - }); - buttonPanel.add( applyB ); - } - this.getContentPane().add( panel, BorderLayout.CENTER ); - this.getContentPane().add( buttonPanel, BorderLayout.SOUTH ); - } - - public Object getData(Object key) { - return getDataMap().get(key); - } - - public Map getDataMap() { - // can i translate these??? - HashMap map = new HashMap(); - Set keys = myData.keySet(); - - Iterator keysI = keys.iterator(); - while(keysI.hasNext()) { - JLabel key = (JLabel)keysI.next(); - DialogEntry de = (DialogEntry)myData.get(key); - map.put(key.getText(), de.getValue()); - } - - return map; - } -} - -// question as whether to have data in these or not..... -interface DialogEntry { - public Component createComponent(); - public Component getComponent(); - public Object getValue(); -} - -class StringDialogEntry implements DialogEntry { - - private Object obj; - private Component c; - - public StringDialogEntry(Object obj) { - this.obj = obj; - } - - public Component createComponent() { - if(!(obj instanceof String)) { - return null; // throw wobbly? - } else { - c = new JTextField( (String)obj ); - return c; - } - } - public Component getComponent() { - return c; - } - public Object getValue() { - if(!(c instanceof JTextField)) { - return null; // throw wobbly? - } else { - return ((JTextField)c).getText(); - } - } -} - -class BooleanDialogEntry implements DialogEntry { - - private Object obj; - private Component c; - - public BooleanDialogEntry(Object obj) { - this.obj = obj; - } - - public Component createComponent() { - if(!(obj instanceof Boolean)) { - return null; // throw wobbly? - } else { - c = new JCheckBox( "",((Boolean)obj).booleanValue() ); - return c; - } - } - public Component getComponent() { - return c; - } - public Object getValue() { - if(!(c instanceof JCheckBox)) { - return null; // throw wobbly? - } else { - return new Boolean(((JCheckBox)c).isSelected()); - } - } -} - -class CollectionDialogEntry implements DialogEntry { - private Collection col; - private Component c; - - public CollectionDialogEntry(Object col) { - this.col = (Collection)col; - } - - - public Component createComponent() { - if(col == null) { - return null; - } - - c = new JList( col.toArray() ); - return c; - } - public Component getComponent() { - return c; - } - public Object getValue() { - if(!(c instanceof JList)) { - return null; // throw wobbly? - } else { - /* - // far too far too ambitious - try { - Class[] params = new Class[1]; - params[0] = (new Object[0]).getClass(); - Constructor con = specificClass.getConstructor( params ); - Object[] args = new Object[1]; - args[0] = ((JComboBox)c).getSelectedObjects(); - return con.newInstance(args); - } catch(Exception e) { - System.out.println("Exception: "+e.getMessage()); - //e.printStackTrace(); - return null; - } - */ - ArrayList list = new ArrayList(); - Object[] objarray = ((JList)c).getSelectedValues(); - for(int i=0;i oldwidth) { - System.err.print("Width was: "+column.getPreferredWidth()); - column.setPreferredWidth(width); - System.err.println(" - Setting width to : "+width); - } - } - */ - - // add single click column sorting - getTableHeader().addMouseListener(new MouseListener() { - public void mouseClicked(MouseEvent me) { - if(me.isPopupTrigger()) { - return; - } - int col = columnAtPoint(me.getPoint()); - ((GJTableModel)getModel()).sortBy(col); - } - public void mouseReleased(MouseEvent me) { - } - public void mouseEntered(MouseEvent me) { - } - public void mouseExited(MouseEvent me) { - } - public void mousePressed(MouseEvent me) { - if( (me.isPopupTrigger()) || - ( (me.getModifiers() & InputEvent.BUTTON3_MASK) != 0) - ) - { - popup.show(me.getComponent(), me.getX(), me.getY()); - } - } - }); - addMouseListener(this); - popup = new JPopupMenu("Modify Table"); - getColumnModel().addColumnModelListener( - new TableColumnModelListener() { - public void columnAdded(TableColumnModelEvent tcme) { - } - public void columnMarginChanged(ChangeEvent ce) { - } - public void columnRemoved(TableColumnModelEvent tcme) { - } - public void columnSelectionChanged(ListSelectionEvent lse) { - } - public void columnMoved(TableColumnModelEvent tcme) { - int idx = tcme.getFromIndex(); - Component comp = GJTable.this.popup.getComponent(idx); - GJTable.this.popup.remove(idx); - GJTable.this.popup.insert(comp, tcme.getToIndex()); - } - - } - ); - - Iterator iterator = headers.iterator(); - while(iterator.hasNext()) { - String header = (String)iterator.next(); - boolean checked = !header.startsWith(HIDDEN_TAG); - JCheckBoxMenuItem item = new JCheckBoxMenuItem(header,checked); - popup.add(item); - item.addActionListener(this); - } - popup.setInvoker(this); - - hidePopup = new JPopupMenu("Hide Column"); - { - JMenuItem item = new JMenuItem("New"); - item.addActionListener(this); - hidePopup.add( item ); - - item = new JMenuItem("Clone"); - item.addActionListener(this); - hidePopup.add( item ); - - item = new JMenuItem("Remove"); - item.addActionListener(this); - hidePopup.add( item ); - - hidePopup.setInvoker(this); - } - } - - public boolean getScrollableTracksViewportWidth() { - return false; - } - - // need to update the popup - public void updateModel(List headers, MultiHashMap contents) { - ((GJTableModel)getModel()).updateModel(headers, contents); - popup.removeAll(); - Iterator iterator = headers.iterator(); - while(iterator.hasNext()) { - String header = (String)iterator.next(); - boolean checked = !header.startsWith(HIDDEN_TAG); - JCheckBoxMenuItem item = new JCheckBoxMenuItem(header,checked); - popup.add(item); - item.addActionListener(this); - } - hideColumns(headers); - } - public void setEditable(boolean bool) { - ((GJTableModel)getModel()).setEditable(bool); - } - - private void hideColumns(List columns) { - if(columns == null) { - return; - } - - Iterator iterator = columns.iterator(); - while(iterator.hasNext()) { - String name = (String)iterator.next(); - if(!name.startsWith(HIDDEN_TAG)) { - continue; - } - TableColumn column = getColumn(name); - if(column != null) { - hideColumn(name, column); - } - } - } - - private void hideColumn(String name, TableColumn column) { - int[] wid = new int[3]; - wid[0] = column.getMinWidth(); - wid[1] = column.getMaxWidth(); - wid[2] = column.getPreferredWidth(); - columnWidths.put(name,wid); - column.setMinWidth(0); - column.setMaxWidth(0); - column.setPreferredWidth(0); - } - - // ActionListener interface - public void actionPerformed(ActionEvent ae) { - JMenuItem item = (JMenuItem)ae.getSource(); - String name = item.getLabel(); - if(item instanceof JCheckBoxMenuItem) { - TableColumn column = getColumn(name); - if(column.getWidth() == 0) { - int[] wid = (int[])columnWidths.get(name); - column.setMinWidth(wid[0]); - column.setMaxWidth(wid[1]); - column.setPreferredWidth(wid[2]); - columnWidths.remove(name); - } else { - hideColumn(name, column); - } - } else { - GJTableModel model = (GJTableModel)getModel(); - int idx = model.getRowCount(); - if("New".equals(name)) { - model.newRow(); - editCellAt(idx,0); - changeSelection(idx,0,false,false); - } else - if("Clone".equals(name)) { - model.cloneRow(lastRow); - editCellAt(idx,0); - changeSelection(idx,0,false,false); - } else - if("Remove".equals(name)) { - int count = getSelectedRowCount(); - if(count > 0) { - // remove other selected rows - int[] rows = getSelectedRows(); - // go from top so we don't change the indexes - for(int i=count-1; i>=0; i--) { - model.removeRow(rows[i]); - } - } -// model.removeRow(lastRow); - lastRow -= count; - if(lastRow < 0) { - lastRow = 0; - } - editCellAt(lastRow,0); - changeSelection(idx,0,false,false); - } - - } - } - // End of ActionListener interface - - // MouseListener interface - public void mousePressed(MouseEvent me) { - if( (me.isPopupTrigger()) || - ( (me.getModifiers() & InputEvent.BUTTON3_MASK) != 0) - ) - { - lastRow = rowAtPoint(me.getPoint()); - hidePopup.show(me.getComponent(), me.getX(), me.getY()); - } - } - public void mouseReleased(MouseEvent me) { - } - public void mouseEntered(MouseEvent me) { - } - public void mouseExited(MouseEvent me) { - } - public void mouseClicked(MouseEvent me) { - } - // End of MouseListener interface - -} diff --git a/genjava/gj-gui/src/java/com/generationjava/swing/GJTableEvent.java b/genjava/gj-gui/src/java/com/generationjava/swing/GJTableEvent.java deleted file mode 100644 index f7c97116..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/swing/GJTableEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.generationjava.swing; - -import java.util.List; -import com.generationjava.lang.Constant; - -public class GJTableEvent { - - static public Constant SORT = new Constant(); - static public Constant REMOVE = new Constant(); - - private List list; - private Constant type; - private int row; - - public void setNewOrder(List list) { - this.type = GJTableEvent.SORT; - this.list = list; - } - - public List getNewOrder() { - return this.list; - } - - public void setRemoved(int row) { - this.type = GJTableEvent.REMOVE; - this.row = row; - } - - public int getRemoved() { - return this.row; - } - - public Constant getType() { - return this.type; - } - -} diff --git a/genjava/gj-gui/src/java/com/generationjava/swing/GJTableHideException.java b/genjava/gj-gui/src/java/com/generationjava/swing/GJTableHideException.java deleted file mode 100644 index 4443ea19..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/swing/GJTableHideException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.generationjava.swing; - -public class GJTableHideException extends Exception { - - public GJTableHideException() { - super(); - } - - public GJTableHideException(String msg) { - super(msg); - } - -} diff --git a/genjava/gj-gui/src/java/com/generationjava/swing/GJTableListener.java b/genjava/gj-gui/src/java/com/generationjava/swing/GJTableListener.java deleted file mode 100644 index 173b3923..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/swing/GJTableListener.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.generationjava.swing; - -public interface GJTableListener { - - public void rowRemoved(GJTableEvent event); - -} diff --git a/genjava/gj-gui/src/java/com/generationjava/swing/GJTableModel.java b/genjava/gj-gui/src/java/com/generationjava/swing/GJTableModel.java deleted file mode 100755 index 372b45d7..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/swing/GJTableModel.java +++ /dev/null @@ -1,272 +0,0 @@ -package com.generationjava.swing; - -import javax.swing.table.AbstractTableModel; - -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.HashSet; -import java.util.Comparator; -import com.generationjava.compare.BeanComparator; -import com.generationjava.compare.NumericStringComparator; -import org.apache.commons.collections.comparators.ReverseComparator; - -import org.apache.commons.collections.MultiHashMap; - -public class GJTableModel extends AbstractTableModel { - - // contains the name of the headers. doesn't change order - private List headers; - - // contains the list of rows. changes order on sorting - private List rows; - - // visual order of columns - private int[] headerToColumn; - - // Remember the last column to be sorted, so next sort can - // reverse. - private int lastColumn = -1; - - // is this an editable model - private boolean editable; - - // an empty row. this is cloned when a new row is made - private ArrayList emptyRow; - - // Used for submitting - private HashSet deletedRows = new HashSet(); - private HashSet newRows = new HashSet(); - private HashSet modifiedRows = new HashSet(); - - // list of sort-listeners - private List sortListeners; - - // a listener to just the table - private List tableListeners; - - // index used in sorting when there's a listener - private ArrayList sortIndex = new ArrayList(); - - public GJTableModel(List headers, MultiHashMap map) { - super(); - updateModel(headers,map); - } - - public Iterator[] getChanges() { -// no longer necessary.... -// modifiedRows.removeAll(newRows); -// modifiedRows.removeAll(deletedRows); - return new Iterator[] { newRows.iterator(), - deletedRows.iterator(), - modifiedRows.iterator() - }; - } - - public void clearChanges() { - this.newRows.clear(); - this.modifiedRows.clear(); - this.deletedRows.clear(); - } - - public Iterator iterateHeaders() { - return this.headers.iterator(); - } - - public void addSortListener(GJTableSortListener listener) { - this.sortListeners.add(listener); - } - - public void addTableListener(GJTableListener listener) { - this.tableListeners.add(listener); - } - - public void updateModel(List headers, MultiHashMap map) { - this.headers = headers; - this.rows = new ArrayList(); - this.emptyRow = new ArrayList(); - - int width = headers.size(); - - // setup the header to column 'mapping'. - // also the visible columns - this.headerToColumn = new int[width]; - for(int i=0;i size) { - for(int i=this.sortIndex.size(); i>=size; i--) { - this.sortIndex.remove(i); - } - } - - // sortIndex is now the same size as this.rows, copy data in. - for(int i=0; i 0) { - menu.setMnemonic((int)mnemonic.charAt(0)); - } - parent.insert(menu, idx); - return menu; - } - private JMenu createMenu(String menuName) { - JMenu menu = new JMenu( menuName); - if(menuName != null && menuName.length() > 0) { - menu.setMnemonic( (int)menuName.charAt(0) ); - } - return menu; - } - protected Object registerMenuItem(String menuName, String itemName) { - return registerMenuItem(menuName, itemName, MENU_END, null); - } - protected Object registerMenuItem(String menuName, String itemName, String ch) { - return registerMenuItem(menuName, itemName, MENU_END, ch); - } - protected Object registerMenuItem(String menuName, String itemName, int block) { - return registerMenuItem(menuName, itemName, MENU_END, null); - } - protected Object registerMenuItem(String menuName, String itemName, int block, String ch) { - String label = getLabel(itemName); - JMenuItem mi = new JMenuItem( label ); - // set up accelerator? - if(ch != null) { - int mask = 0; - if(ch.indexOf("Shift") != -1) { - mask |= ActionEvent.SHIFT_MASK; - } - if(true) { - mask |= ActionEvent.CTRL_MASK; - } - int key = (int)ch.charAt(ch.length()-1); - mi.setAccelerator( KeyStroke.getKeyStroke(key, mask) ); - } - mi.addActionListener(this); - return registerMenuItem(menuName, mi, block); - } - protected Object registerMenuItem(String menuName, JMenuItem item, int block) { - JMenu m = (JMenu) getMenu(menuName); - int idx = getBlockIndex(m, block); - m.insert(item,idx); - return m; - } - - private int getBlockIndex(JMenu menu, int block) { - if(block == MENU_START) { - return 0; - } - Component[] comps = menu.getMenuComponents(); - if(block == MENU_END) { - return comps.length; - } - int i; - int sz = comps.length; - for(i=0; i0;i--) { - Object element = sourceListModel.getElementAt(selec[i-1]); - if(!opType.equals(COPY)) { - sourceListModel.removeElementAt(selec[i-1]); - } - if(!opType.equals(DELETE)) { - targetListModel.addElement(element); - } - } - sourceList.revalidate(); - targetList.revalidate(); - } - - public JList getSourceList() { - return sourceList; - } - - public void setSourceList(JList list) { - sourceList = list; - } - - public JList getTargetList() { - return targetList; - } - - public void setTargetList(JList list) { - targetList = list; - } -} diff --git a/genjava/gj-gui/src/java/com/generationjava/swing/JSaveableApplication.java b/genjava/gj-gui/src/java/com/generationjava/swing/JSaveableApplication.java deleted file mode 100644 index c51b525a..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/swing/JSaveableApplication.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.generationjava.swing; - -import java.awt.FileDialog; -import java.awt.event.ActionEvent; - -abstract public class JSaveableApplication extends JBasicApplication { - - public final int SAVE = FileDialog.SAVE; - - public JSaveableApplication(String name) { - super(name); - - registerMenuItem("File","Save",0,"S"); - registerMenuItem("File","Save As",0,"Shift-S"); - registerMenuItem("File","Revert",0,"R"); - } - - abstract protected void fileSaved(String filename, Object obj); - abstract protected String getCurrentFilename(); - - public void actionPerformed(ActionEvent ae) { - String cmd = ae.getActionCommand(); - if("Save".equals(cmd)) { - String filename = getCurrentFilename(); - if(filename == null) { - filename = getFileName(SAVE); - fileSaved(filename, getCurrent()); - } - } else - if("Save As".equals(cmd)) { - String filename = getFileName(SAVE); - if(filename != null) { - fileSaved(filename, getCurrent()); - } - } else - if("Revert".equals(cmd)) { - String filename = getCurrentFilename(); - if(filename != null) { - removeFromOpenList(getCurrent()); - fileClosed(getCurrent()); - Object obj = fileOpened(filename); - setCurrent(obj); - selection(); - addToOpenList(obj); - } - } - super.actionPerformed(ae); - } - - -} diff --git a/genjava/gj-gui/src/java/com/generationjava/swing/ListDataAdapter.java b/genjava/gj-gui/src/java/com/generationjava/swing/ListDataAdapter.java deleted file mode 100644 index f930747d..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/swing/ListDataAdapter.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.generationjava.swing; - -import javax.swing.event.*; - -public class ListDataAdapter implements ListDataListener { - public void contentsChanged(ListDataEvent ae) { - } - public void intervalAdded(ListDataEvent ae) { - } - public void intervalRemoved(ListDataEvent ae) { - } -} diff --git a/genjava/gj-gui/src/java/com/generationjava/swing/MagnifyImagePanel.java b/genjava/gj-gui/src/java/com/generationjava/swing/MagnifyImagePanel.java deleted file mode 100644 index e5957d27..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/swing/MagnifyImagePanel.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.generationjava.swing; - -import java.awt.Image; -import java.awt.Graphics; -import javax.swing.JPanel; -import com.generationjava.awt.ImageLoaderFacade; -import java.awt.image.ImageProducer; -import java.awt.image.PixelGrabber; -import java.awt.image.MemoryImageSource; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Rectangle; - -public class MagnifyImagePanel extends JPanel { - - private Image myImage = null; - private int imageWidth = 0; - private int imageHeight = 0; - private double magnification = 1.0; - private Image croppedImage = null; - private Rectangle viewport = null; - - public MagnifyImagePanel() { - } - - public void paint(Graphics g) { - super.paint(g); - if(getImage() == null) { - return; - } else - if(magnification < 1.0) { - int w = (int)(this.getWidth()*magnification); - int h = (int)(this.getHeight()*magnification); - int x = (int)((this.getWidth() - w)/2); - int y = (int)((this.getHeight() - h)/2); - g.drawImage(getImage(), x, y, w,h ,this); - } else { - g.drawImage(getImage(), 0, 0, this.getWidth(), this.getHeight(),this); - } - } - - public Dimension getPreferredSize() { - return new Dimension( myImage.getWidth(this), myImage.getHeight(this) ); - } - - public void setImage(Image img) { - myImage = img; - croppedImage = null; - imageWidth = img.getWidth(this); - imageHeight = img.getHeight(this); - Dimension size = new Dimension( imageWidth, imageHeight ); - this.setSize( size ); - viewport = new Rectangle( size ); - invalidate(); - repaint(); - } - - public Image getImage() { - if( (croppedImage != null) && (magnification > 1.0) ) { - return croppedImage; - } else { - return myImage; - } - } - - public void magnify(double x, Point p) { - if(myImage == null) { return; } - if(x < 1.0) { // exempt for special-centering handling. - magnification = x; - viewport = new Rectangle( imageWidth, imageHeight ); - } else - { - Image img = null; - if(x < magnification) { - img = myImage; // need to work on original to go backwards. - viewport.x = (int)( viewport.x - (imageWidth/x - imageWidth/magnification)/2); - viewport.y = (int)( viewport.y - (imageHeight/x - imageHeight/magnification)/2); - viewport.width = (int)(imageWidth/x); - viewport.height = (int)(imageHeight/x); - } else { - img = myImage; - Point clicked = new Point(); - clicked.x = (int)(viewport.x + p.x*viewport.width/this.getWidth()); - clicked.y = (int)(viewport.y + p.y*viewport.height/this.getHeight()); - viewport.width = (int)(imageWidth/x); - viewport.height = (int)(imageHeight/x); - viewport.x = (int)(clicked.x - viewport.width/2); - viewport.y = (int)(clicked.y - viewport.height/2); - } - magnification = x; - - // Validate viewport. Use Math.max ? - if(viewport.x < 0) viewport.x = 0; - if(viewport.y < 0) viewport.y = 0; - if(viewport.x > this.getWidth() - viewport.width) { - viewport.x = this.getWidth() - viewport.width; - } - if(viewport.y > this.getHeight() - viewport.height) { - viewport.y = this.getHeight() - viewport.height; - } - - // crop image - int[] pixels = new int[viewport.width*viewport.height]; - PixelGrabber pg = new PixelGrabber(img, viewport.x, viewport.y, - viewport.width, viewport.height, - pixels, 0, viewport.width); - try { // decide where to propagate this exception to - pg.grabPixels(); - } catch(InterruptedException ie) { - ie.printStackTrace(); - } - - ImageProducer ip = new MemoryImageSource(viewport.width,viewport.height, - pixels,0,viewport.width); - croppedImage = ImageLoaderFacade.getInstance().getImage(ip); - - // clear up resources - ip = null; - pixels = null; - } - invalidate(); - repaint(); - } - -} - diff --git a/genjava/gj-gui/src/java/com/generationjava/swing/MultiImagePanel.java b/genjava/gj-gui/src/java/com/generationjava/swing/MultiImagePanel.java deleted file mode 100644 index 3677283b..00000000 --- a/genjava/gj-gui/src/java/com/generationjava/swing/MultiImagePanel.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.generationjava.swing; - -import java.awt.Image; -import java.awt.Graphics; -import javax.swing.JPanel; -import java.util.ArrayList; -import java.util.List; - - -public class MultiImagePanel extends JPanel { - - // should we use BorderLayout consts here? - static public final String EAST = "EAST"; - static public final String NORTH = "NORTH"; - static public final String WEST = "WEST"; - static public final String SOUTH = "SOUTH"; - - private ArrayList myImages = new ArrayList(); - private ArrayList myPositions = new ArrayList(); - - public MultiImagePanel() { - } - - public void paint(Graphics g) { - super.paint(g); - List imgs = getImages(); - if(imgs == null) return; - int n = numberOfImages(); - for(int i=0;i>>"); - item.addMouseListener( new MouseAdapter() { - public void mouseEntered(MouseEvent ae) { - if(PopupTreeMenu.this.done) { - return; - } - PopupTreeMenu.this.done = true; - PopupTreeMenu.this.removeAll(); - PopupTreeMenuItem loading = new PopupTreeMenuItem("Loading..."); - PopupTreeMenu.this.add(loading); - PopupTreeMenu.this.getPopupMenu().pack(); - PopupTreeMenu.this.getPopupMenu().invalidate(); - PopupTreeMenu.this.getPopupMenu().repaint(); - - // get values - - // create components - PopupTreeMenu.this.removeAll(); - String urltmp = url + "?option="+label+"&name="+name; - try { - String data = UrlW.getContent(urltmp).toString(); - String[] values = StringUtils.split(data, "|"); - int sz = values.length; - for(int i=0; i - -

- Lots of lovely Swing widgets. -

- - diff --git a/genjava/gj-gui/xdocs/changes.xml b/genjava/gj-gui/xdocs/changes.xml deleted file mode 100644 index c09cb59f..00000000 --- a/genjava/gj-gui/xdocs/changes.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Henri Yandell - Release Notes - - - - - - - diff --git a/genjava/gj-gui/xdocs/images/1x1.gif b/genjava/gj-gui/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/genjava/gj-gui/xdocs/images/1x1.gif and /dev/null differ diff --git a/genjava/gj-gui/xdocs/images/osjava.gif b/genjava/gj-gui/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/genjava/gj-gui/xdocs/images/osjava.gif and /dev/null differ diff --git a/genjava/gj-gui/xdocs/navigation.xml b/genjava/gj-gui/xdocs/navigation.xml deleted file mode 100644 index ae46a44a..00000000 --- a/genjava/gj-gui/xdocs/navigation.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - genjava - - - - - - - - - - - - - - - diff --git a/genjava/gj-mail/LICENSE.txt b/genjava/gj-mail/LICENSE.txt deleted file mode 100644 index 38aecf65..00000000 --- a/genjava/gj-mail/LICENSE.txt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/genjava/gj-mail/maven.xml b/genjava/gj-mail/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/genjava/gj-mail/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/genjava/gj-mail/pom.xml b/genjava/gj-mail/pom.xml deleted file mode 100755 index 78799e77..00000000 --- a/genjava/gj-mail/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - genjava - genjava - UNUSED - - 4.0.0 - gj-mail - GenJava-Mail - 1.0 - 2002 - - - Mail component of GenJava-Core. Adds some helper functionality around JavaMail. - - - - - - - geronimo-spec - geronimo-spec-javamail - 1.3.1-rc3 - - - gj-core - genjava - 3.0 - - - - commons-lang - commons-lang - 2.0 - - - - - - diff --git a/genjava/gj-mail/project.properties b/genjava/gj-mail/project.properties deleted file mode 100644 index d0f1d722..00000000 --- a/genjava/gj-mail/project.properties +++ /dev/null @@ -1,18 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.checkstyle.properties=../../hen_checkstyle.xml - -maven.javadoc.stylesheet=../../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/genjava/gj-mail/project.xml b/genjava/gj-mail/project.xml deleted file mode 100755 index d7968170..00000000 --- a/genjava/gj-mail/project.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - ../project.xml - gj-mail - GenJava-Mail - 1.0 - 2002 - - - Mail component of GenJava-Core. Adds some helper functionality around JavaMail. - - - Mail helpers - - - - geronimo-spec - geronimo-spec-javamail - 1.3.1-rc3 - - - gj-core - genjava - 3.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - commons-lang - 2.0 - http://jakarta.apache.org/commons/lang.html - - - - - diff --git a/genjava/gj-mail/src/java/com/generationjava/mail/MBoxMimeMessage.java b/genjava/gj-mail/src/java/com/generationjava/mail/MBoxMimeMessage.java deleted file mode 100644 index f56c119c..00000000 --- a/genjava/gj-mail/src/java/com/generationjava/mail/MBoxMimeMessage.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.mail; - -import java.io.InputStream; - -import javax.mail.*; -import javax.mail.internet.*; - -import com.generationjava.collections.CollectionsW; -import com.generationjava.io.StreamW; -import org.apache.commons.lang.StringUtils; - -// one other idea is to allow a body only to be passed in, -// with the headers already set within that. - -// TODO: -// Attachment: 1. , -// 2. ..... -public class MBoxMimeMessage extends MimeMessage { - - private static java.text.DateFormat format = new java.text.SimpleDateFormat(); - - public MBoxMimeMessage(Session session) { - super(session); - } - - public void setText(String body) throws MessagingException { - parseMBox(this, body); - } - - public void parseMBox(Part mimePart, String body) throws MessagingException { -// Date: 26 Feb 2001 00:11:05 +0000 -// From: -// To: -// Subject: -// Content-Type: TEXT/PLAIN; charset=US-ASCII -// then a blank line. How to handle multi?? - -// multi is handled by: -// Content-Type: multipart/alternative; boundary="FLAG" -// --FLAG -// Content-Type: text/plain; charset="iso-8859-1" -// ....texxt... -// Content-Type: text/html; charset="iso-8859-1" -// Content-Transfer-Encoding: quoted-printable - - // split lines - String[] lines = StringUtils.split(body, "\n"); - - // pre process lines so that any headers that are split - // over a newline are joined - - int sz = lines.length; - String multipart = null; - String mimeType = null; - String subtype = null; - int i=0; // kept for later - for(; i [content-type] "comment", - String[] attachments = StringUtils.split(value, ","); - Multipart multi = new MimeMultipart(); - mimePart.setContent(multi); - for(int k=0; k - - - - Henri Yandell - Release Notes - - - - - - - diff --git a/genjava/gj-mail/xdocs/images/1x1.gif b/genjava/gj-mail/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/genjava/gj-mail/xdocs/images/1x1.gif and /dev/null differ diff --git a/genjava/gj-mail/xdocs/images/osjava.gif b/genjava/gj-mail/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/genjava/gj-mail/xdocs/images/osjava.gif and /dev/null differ diff --git a/genjava/gj-mail/xdocs/navigation.xml b/genjava/gj-mail/xdocs/navigation.xml deleted file mode 100644 index ae46a44a..00000000 --- a/genjava/gj-mail/xdocs/navigation.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - genjava - - - - - - - - - - - - - - - diff --git a/genjava/gj-scrape/LICENSE.txt b/genjava/gj-scrape/LICENSE.txt deleted file mode 100644 index 38aecf65..00000000 --- a/genjava/gj-scrape/LICENSE.txt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/genjava/gj-scrape/benchmark/Large.java b/genjava/gj-scrape/benchmark/Large.java deleted file mode 100644 index 928c0d94..00000000 --- a/genjava/gj-scrape/benchmark/Large.java +++ /dev/null @@ -1,48 +0,0 @@ -import com.generationjava.scrape.*; - -import org.apache.commons.lang.time.StopWatch; - -public class Large { - - public static void main(String[] args) { - test(1, 1); - test(10, 2); - test(100, 5); - test(100, 10); - test(250, 5); - } - - public static void test(int tr, int td) { - String html = makeLargePage(tr, td); - HtmlScraper scraper = new HtmlScraper(); - scraper.scrape(html); - int c = 0; - StopWatch sw = new StopWatch(); - sw.start(); - while(scraper.move("tr")) { - for(int i=0; i < td; i++) { - String str = scraper.get("td"); - scraper.move("td"); - } - c++; - } - System.out.println("["+tr+","+td+"] "+sw.toString()); - } - - private static String makeLargePage(int tr, int td) { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - for(int i=0; i < tr; i++) { - buffer.append(""); - for(int j=0; j < td; j++) { - buffer.append(""); - } - buffer.append(""); - } - buffer.append("
Content"); - buffer.append(j); - buffer.append("
"); - return buffer.toString(); - } - -} diff --git a/genjava/gj-scrape/benchmark/compile.sh b/genjava/gj-scrape/benchmark/compile.sh deleted file mode 100755 index 04152971..00000000 --- a/genjava/gj-scrape/benchmark/compile.sh +++ /dev/null @@ -1 +0,0 @@ -javac -classpath ../target/gj-scrape-2.0.jar:/Users/hen/.maven/repository/commons-lang/jars/commons-lang-2.0.jar Large.java diff --git a/genjava/gj-scrape/benchmark/run1.0.sh b/genjava/gj-scrape/benchmark/run1.0.sh deleted file mode 100755 index 7fa26c3a..00000000 --- a/genjava/gj-scrape/benchmark/run1.0.sh +++ /dev/null @@ -1 +0,0 @@ -java -classpath .:../target/gj-scrape-1.0.jar:/Users/hen/.maven/repository/commons-lang/jars/commons-lang-2.0.jar Large diff --git a/genjava/gj-scrape/benchmark/run2.0.sh b/genjava/gj-scrape/benchmark/run2.0.sh deleted file mode 100755 index 8363a871..00000000 --- a/genjava/gj-scrape/benchmark/run2.0.sh +++ /dev/null @@ -1 +0,0 @@ -java -classpath .:../target/gj-scrape-2.0.jar:/Users/hen/.maven/repository/commons-lang/jars/commons-lang-2.0.jar Large diff --git a/genjava/gj-scrape/maven.xml b/genjava/gj-scrape/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/genjava/gj-scrape/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/genjava/gj-scrape/pom.xml b/genjava/gj-scrape/pom.xml deleted file mode 100644 index c7bbf07b..00000000 --- a/genjava/gj-scrape/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - genjava - genjava - UNUSED - - 4.0.0 - gj-scrape - GenJava-Scrape - 2.0.1 - 2002 - - - Simple scraping component of GenJava-Core. - - - - - - - commons-lang - commons-lang - 2.0 - - - - - - diff --git a/genjava/gj-scrape/project.properties b/genjava/gj-scrape/project.properties deleted file mode 100644 index d0f1d722..00000000 --- a/genjava/gj-scrape/project.properties +++ /dev/null @@ -1,18 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.checkstyle.properties=../../hen_checkstyle.xml - -maven.javadoc.stylesheet=../../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/genjava/gj-scrape/project.xml b/genjava/gj-scrape/project.xml deleted file mode 100644 index c477ad6d..00000000 --- a/genjava/gj-scrape/project.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - ../project.xml - gj-scrape - GenJava-Scrape - 2.0.1 - 2002 - - - Simple scraping component of GenJava-Core. - - - Scraper APIs - - - - commons-lang - 2.0 - http://jakarta.apache.org/commons/lang.html - - - - - diff --git a/genjava/gj-scrape/src/java/com/generationjava/scrape/HtmlScraper.java b/genjava/gj-scrape/src/java/com/generationjava/scrape/HtmlScraper.java deleted file mode 100644 index 95927b12..00000000 --- a/genjava/gj-scrape/src/java/com/generationjava/scrape/HtmlScraper.java +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.scrape; - -import java.io.InputStream; -import java.io.IOException; -import java.util.LinkedList; - -import java.text.Format; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.math.NumberUtils; -import com.generationjava.web.HtmlW; -import com.generationjava.web.XmlW; - -/// simple system in. need to now consider the move methods. -/// then need to make sure the get method obeys internal -/// rules. ie) if given td.a and u find td.td, should then look -/// at that td? I guess so. Just as long as a tag doesn't span -/// another that it's not allowed to. - -// need to be able to say: move to b.class=blah and b=foo - -/// Add a moveback(String tag) method -/// Add a getContent(int i) method to get untagged blocks of text - /** - HtmlScraper scraper = new HtmlScraper(); - scraper.scrape(UrlW.openUrlStream("http://www.yandell.org")); - System.err.println(scraper.get("TITLE").trim()); - System.err.println(scraper.get("HEAD.TITLE").trim()); - System.err.println(scraper.get("HTML.HEAD.TITLE").trim()); - System.err.println(scraper.get("HTML.HEAD.META[name]")); - while(scraper.move("LI")) { - System.err.println(scraper.get("A[HREF]")); - } - System.err.println(scraper.get("LI.I")); - */ -public class HtmlScraper { - - // The entire page - private String page; - // Lowercase version of the entire page - private String lcPage; - // Position at which the string-scraper has reached - private int currentIndex; - - // Whether it has made the first move. - // A hack to handle the semantics of wanting to - // move to the tag that starts the text. - private boolean firstMove; - - public HtmlScraper() { - } - - public int getIndex() { - return this.currentIndex; - } - - public void scrape(String text) { - if(text.startsWith("http://")) { - throw new RuntimeException("Text starts with http://. This could be bad. "); - } - - this.page = text; - this.lcPage = text.toLowerCase(); - reset(); - } - - public HtmlScraper scrapeTag(String tag) { - HtmlScraper scraper = new HtmlScraper(); - scraper.scrape(get(tag)); - return scraper; - } - - /** - * Move back to the start of the page. - */ - public void reset() { - this.currentIndex = 0; - } - - /** - * Move to the specified tag. - */ - // This needs to be case-insensitive - public boolean move(String tag) { - - int lastIdx = this.currentIndex + 1; - - // HACK: We expect move(String) to work the first time, even if it starts with that tag - if(firstMove == false && this.currentIndex == 0 && page.startsWith("<") ) { - firstMove = true; - lastIdx--; - } - - int idx = XmlW.getIndexOpeningTag(lcPage, tag.toLowerCase(), lastIdx); - if(idx == -1) { - return false; - } else { - this.currentIndex = idx; - return true; - } - } - - /** - * Helper method. - * Move a number of tags. - */ - public boolean move(String tag, int sz) { - for(int i=0; i< sz; i++) { - if(!move(tag)) { - return false; - } - } - return true; - } - - // finds any tag with name=value attribute. Need to be able - // to specify the tag really, and also the same for a value. - // really we need a generic search method? :) - // get this value, is it this. if not, find next. - - // Tricky. name needs to be case-insensitive, value needs - // to not be. - public boolean moveToTagWith(String name, String value) { - int idx = this.page.indexOf(name+"=\""+value+"\"", this.currentIndex); - if(idx == -1) { - idx = this.page.indexOf(name+"="+value, this.currentIndex); - } - if(idx == -1) { - idx = this.page.indexOf(name+"='"+value+"'", this.currentIndex); - } - if(idx == -1) { - return false; - } else { - idx = this.page.lastIndexOf("<", idx); - if(idx == this.currentIndex) { - // then we just found the previous one, so we need to bump things - // along a little bit - int nextTag = this.page.indexOf("<", this.currentIndex + 1); - if(nextTag == -1) { - return false; - } else { - this.currentIndex = nextTag; - boolean found = moveToTagWith(name, value); - if(!found) { - // reset the currentIndex - this.currentIndex = idx; - } - return found; - } - } - this.currentIndex = idx; - return true; - } - } - - // moveTo a[href], www.yandell.org - // TODO: Kill the moveToTagWith method and have: *[href], www.foo.com - public boolean moveTo(String get, String value) { - HtmlScraper scraper = new HtmlScraper(); - scraper.scrape(this.page.substring(this.currentIndex)); - int count = 1; - while(true) { - boolean found = scraper.move(get); - if(!found) { - return false; - } - String chunk = scraper.get(get); - if( (chunk == null) || (chunk.equals("")) ) { - return false; - } - if(chunk.equals(value)) { - move(get, count); - break; - } else { - count++; - } - } - return true; - } - - /** - * Move to a specified piece of text. - */ - public boolean moveToText(String text) { - int idx = this.page.indexOf(text, this.currentIndex); - if(idx == -1) { - return false; - } else { - this.currentIndex = idx; - return true; - } - } - - /** - * Move to a specified comment. The parameter should - * not contain the HTML comment syntax. - */ - public boolean moveToComment(String comment) { - int idx = this.page.indexOf(comment, this.currentIndex); - if(idx == -1) { - return false; - } else { - idx = page.lastIndexOf(" - -

- A HtmlScraping library. Well really an Xml one. -

- - diff --git a/genjava/gj-scrape/src/java/com/generationjava/web/HtmlW.java b/genjava/gj-scrape/src/java/com/generationjava/web/HtmlW.java deleted file mode 100644 index 31835749..00000000 --- a/genjava/gj-scrape/src/java/com/generationjava/web/HtmlW.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.web; - -import org.apache.commons.lang.StringUtils; - -/** - * HTML helping static methods. - * Due to case insensitivity, these methods can't match the XML ones. - */ -public class HtmlW { - - /** - * Place <br>'s before each newline. - */ - static public String nl2br(String str) { - return StringUtils.replace(str, "\n", "
\n"); - } - - - /// TODO: escape all html char entitie - static public String escapeHtml(String str) { - // handles & < > " ' - str = XmlW.escapeXml(str); - - str = StringUtils.replace(str, "\u00a0", " "); - str = StringUtils.replace(str, "\u00a1", "¡"); - str = StringUtils.replace(str, "\u00a2", "¢"); - str = StringUtils.replace(str, "\u00a3", "£"); - str = StringUtils.replace(str, "\u00a4", "¤"); - str = StringUtils.replace(str, "\u00a5", "¥"); - str = StringUtils.replace(str, "\u00a6", "¦"); - str = StringUtils.replace(str, "\u00a7", "§"); - str = StringUtils.replace(str, "\u00a8", "¨"); - str = StringUtils.replace(str, "\u00a9", "©"); - str = StringUtils.replace(str, "\u00aa", "ª"); - str = StringUtils.replace(str, "\u00ab", "«"); - str = StringUtils.replace(str, "\u00ac", "¬"); - str = StringUtils.replace(str, "\u00ad", "­"); - str = StringUtils.replace(str, "\u00ae", "®"); - str = StringUtils.replace(str, "\u00af", "¯"); -/* -° -&#176 -± -&#177 -² -&#178 -³ -&#179 -´ -&#180 -µ -&#181 -¶ -&#182 -· -&#183 -¸ -&#184 -¹ -&#185 -º -&#186 -» -&#187 -¼ -&#188 -½ -&#189 -¾ -&#190 -¿ -&#191 -À -&#192 -Á -&#193 -Â -&#194 -Ã -&#195 -Ä -&#196 -Å -&#197 -Æ -&#198 -Ç -&#199 -È -&#200 -É -&#201 -Ê -&#202 -Ë -&#203 -Ì -&#204 -Í -&#205 -Î -&#206 -Ï -&#207 -*/ - - return str; - } - - // add unescape for the html entities - - //------------------------------------------------------------- - // Variants of the XmlW methods that work on case-insensitivity - //------------------------------------------------------------- - static public int getIndexOpeningTag(String text, String tag) { - return XmlW.getIndexOpeningTag(text.toLowerCase(), tag.toLowerCase() ); - } - static public int getIndexClosingTag(String text, String tag) { - return XmlW.getIndexClosingTag(text.toLowerCase(), tag.toLowerCase() ); - } - - // Copy of XmlW at the moment - static public String getContent(String text, String tag) { - return getContent(text, tag, text.toLowerCase()); - } - static public String getContent(String text, String tag, String lcText) { - int idx = XmlW.getIndexOpeningTag(lcText, tag.toLowerCase()); - if(idx == -1) { - return ""; - } - int end = XmlW.getIndexClosingTag(lcText, tag.toLowerCase(), idx); - idx = text.indexOf('>', idx); - if(idx == -1) { - return ""; - } - return text.substring(idx+1, end); - } - - // Copies of XmlW. Need to merge these. - static public String getAttribute(String text, String attribute) { - return getAttribute(text, attribute, 0); - } - static public String getAttribute(String text, String attribute, int idx) { - return getAttribute(text, attribute, idx, text.toLowerCase()); - } - static public String getAttribute(String text, String attribute, int idx, String lcText) { - int close = text.indexOf(">", idx); - int doubleAttrIdx = lcText.indexOf(attribute.toLowerCase()+"=\"", idx); - int singleAttrIdx = lcText.indexOf(attribute.toLowerCase()+"='", idx); - - int attrIdx = doubleAttrIdx; - String endQuote = "\""; - if(doubleAttrIdx == -1 || (singleAttrIdx != -1 && singleAttrIdx < doubleAttrIdx) ) { - attrIdx = singleAttrIdx; - endQuote = "'"; - } - - if(attrIdx == -1) { - return null; - } - if(attrIdx > close) { - return null; - } - int attrStartIdx = attrIdx + attribute.length() + 2; - int attrCloseIdx = text.indexOf(endQuote, attrStartIdx); - if(attrCloseIdx > close) { - return null; - } - return XmlW.unescapeXml(text.substring(attrStartIdx, attrCloseIdx)); - } - -} diff --git a/genjava/gj-scrape/src/java/com/generationjava/web/XmlW.java b/genjava/gj-scrape/src/java/com/generationjava/web/XmlW.java deleted file mode 100644 index bdbd0947..00000000 --- a/genjava/gj-scrape/src/java/com/generationjava/web/XmlW.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.web; - -import org.apache.commons.lang.StringUtils; - -/** - * XML helping static methods. - */ -final public class XmlW { - - static public String escapeXml(String str) { - str = StringUtils.replace(str,"&","&"); - str = StringUtils.replace(str,"<","<"); - str = StringUtils.replace(str,">",">"); - str = StringUtils.replace(str,"\"","""); - str = StringUtils.replace(str,"'","'"); - return str; - } - - static public String unescapeXml(String str) { - str = StringUtils.replace(str,"&","&"); - str = StringUtils.replace(str,"<","<"); - str = StringUtils.replace(str,">",">"); - str = StringUtils.replace(str,""","\""); - str = StringUtils.replace(str,"'","'"); - return str; - } - - /** - * Remove any xml tags from a String. - */ - static public String removeXml(String str) { - int sz = str.length(); - StringBuffer buffer = new StringBuffer(sz); - boolean inString = false; - boolean inTag = false; - for(int i=0; i') { - inTag = false; - continue; - } - if(!inTag) { - buffer.append(ch); - } - } - return buffer.toString(); - } - - static public String getContent(String text, String tag) { - int idx = XmlW.getIndexOpeningTag(text, tag); - if(idx == -1) { - return ""; - } - text = text.substring(idx); - int end = XmlW.getIndexClosingTag(text, tag); - idx = text.indexOf('>'); - if(idx == -1) { - return ""; - } - return text.substring(idx+1, end); - } - - static public int getIndexOpeningTag(String text, String tag) { - return getIndexOpeningTag(text, tag, 0); - } - static public int getIndexOpeningTag(String text, String tag, int start) { - // consider whitespace? - int idx = text.indexOf("<"+tag, start); - if(idx == -1) { - return -1; - } - char next = text.charAt(idx+1+tag.length()); - if( (next == '>') || Character.isWhitespace(next) ) { - return idx; - } else { - return getIndexOpeningTag(tag, text, idx+1); - } - } - - // Pass in "para" and a string that starts with - // and it will return the index of the matching - // It assumes well-formed xml. Or well enough. - static public int getIndexClosingTag(String text, String tag) { - return getIndexClosingTag(text, tag, 0); - } - static public int getIndexClosingTag(String text, String tag, int start) { - String open = "<"+tag; - String close = ""; - int closeSz = close.length(); - int nextCloseIdx = text.indexOf(close, start); - if(nextCloseIdx == -1) { - return -1; - } - int count = StringUtils.countMatches(text.substring(start, nextCloseIdx), open); - if(count == 0) { - return -1; // tag is never opened - } - int expected = 1; - while(count != expected) { - nextCloseIdx = text.indexOf(close, nextCloseIdx+closeSz); - if(nextCloseIdx == -1) { - return -1; - } - count = StringUtils.countMatches(text.substring(start, nextCloseIdx), open); - expected++; - } - return nextCloseIdx; - } - - static public String getAttribute(String text, String attribute) { - return getAttribute(text, attribute, 0); - } - static public String getAttribute(String text, String attribute, int idx) { - int close = text.indexOf(">", idx); - int doubleAttrIdx = text.indexOf(attribute+"=\"", idx); - int singleAttrIdx = text.indexOf(attribute+"='", idx); - - int attrIdx = doubleAttrIdx; - String endQuote = "\""; - if(doubleAttrIdx == -1 || (singleAttrIdx != -1 && singleAttrIdx < doubleAttrIdx) ) { - attrIdx = singleAttrIdx; - endQuote = "'"; - } - - if(attrIdx == -1) { - return null; - } - if(attrIdx > close) { - return null; - } - int attrStartIdx = attrIdx + attribute.length() + 2; - int attrCloseIdx = text.indexOf(endQuote, attrStartIdx); - if(attrCloseIdx > close) { - return null; - } - return unescapeXml(text.substring(attrStartIdx, attrCloseIdx)); - } - -} diff --git a/genjava/gj-scrape/src/test/com/generationjava/scrape/HtmlScraperTest.java b/genjava/gj-scrape/src/test/com/generationjava/scrape/HtmlScraperTest.java deleted file mode 100644 index b28bac15..00000000 --- a/genjava/gj-scrape/src/test/com/generationjava/scrape/HtmlScraperTest.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.generationjava.scrape; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -public class HtmlScraperTest extends TestCase { - - public static final String TEST_PAGE = "
FOO
"; - - private HtmlScraper scraper; - - public HtmlScraperTest(String name) { - super(name); - } - - public void setUp() { - scraper = new HtmlScraper(); - scraper.scrape(TEST_PAGE); - } - - public void tearDown() { - scraper = null; - } - - //----------------------------------------------------------------------- - // To test: - // HtmlScraper()->scrape(..)->get/move etc - - public void testScrape() { - assertEquals( "FOO", scraper.get("td") ); - } - - public void testScrapeAttribute() { - assertEquals( "ffffff", scraper.get("table[bgcolor]") ); - } - - public void testCaseInsensitive() { - assertEquals( "FOO", scraper.get("TD") ); - assertEquals( "FOO", scraper.get("Td") ); - assertEquals( "FOO", scraper.get("tD") ); - assertEquals( "FOO", scraper.get("td") ); - } - - public void testCaseInsensitiveAttribute() { - assertEquals( "ffffff", scraper.get("TABLE[bgcolor]") ); - assertEquals( "ffffff", scraper.get("TABLE[BGCOLOR]") ); - assertEquals( "ffffff", scraper.get("table[BGCOLOR]") ); - assertEquals( "ffffff", scraper.get("table[bgcolor]") ); - } - - public void testSingleQuoteAttributes() { - assertEquals( "center", scraper.get("td[align]") ); - } - - public void testScrapeTag() { - HtmlScraper scraper2 = scraper.scrapeTag("table"); - assertEquals( "FOO", scraper2.toString() ); - } - - public void testScrapeTableCell() { - scraper.move("tr"); - String t = scraper.get("tr"); - HtmlScraper scraper2 = new HtmlScraper(); - scraper2.scrape(t); -// HtmlScraper scraper2 = scraper.scrapeTag("tr"); - assertEquals( "FOO", scraper2.toString() ); - assertTrue(scraper2.move("td")); - assertEquals("FOO", scraper2.get("td")); - } - - public void testTmp() { - HtmlScraper s = new HtmlScraper(); - s.scrape("FOO"); - assertTrue(s.move("td")); - assertEquals("FOO", s.get("td")); - } - - public void testMoveToTagWithTwice() { - assertTrue( scraper.moveToTagWith("bgcolor", "ffffff") ); - assertFalse( scraper.moveToTagWith("bgcolor", "ffffff") ); - - scraper.scrape(TEST_PAGE+TEST_PAGE); - assertTrue( scraper.moveToTagWith("bgcolor", "ffffff") ); - assertTrue( scraper.moveToTagWith("bgcolor", "ffffff") ); - assertFalse( scraper.moveToTagWith("bgcolor", "ffffff") ); - } - - public void testMove() { - assertTrue( scraper.move("td") ); - assertEquals( "FOO", scraper.get("td") ); - assertFalse( scraper.move("td") ); - - scraper.scrape(TEST_PAGE+TEST_PAGE); - assertTrue( scraper.move("td") ); - assertEquals( "FOO", scraper.get("td") ); - assertTrue( scraper.move("td") ); - assertEquals( "FOO", scraper.get("td") ); - assertFalse( scraper.move("td") ); - } - - public void testScrapeTable() { - Object[] data = scraper.scrapeTable(); - assertEquals( "FOO", ((Object[])data[0])[0] ); - } - - public void testScrapeTable2() { - Object[] data = scraper.scrapeTable( new Object[] { String.class } ); - assertEquals( "FOO", ((Object[])data[0])[0] ); - } - -} - diff --git a/genjava/gj-scrape/src/test/com/generationjava/web/HtmlWTest.java b/genjava/gj-scrape/src/test/com/generationjava/web/HtmlWTest.java deleted file mode 100644 index c09fe77e..00000000 --- a/genjava/gj-scrape/src/test/com/generationjava/web/HtmlWTest.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.generationjava.web; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -public class HtmlWTest extends TestCase { - - private String testHtml = "test"; - - public HtmlWTest(String name) { - super(name); - } - - public void testEscape() { - String toEscape = "4 is < 7 & 7 is > 4 but \"7\" and '4' make error. "; - String expected = "4 is < 7 & 7 is > 4 but "7" and '4' make error. "; - assertEquals( expected, HtmlW.escapeHtml( toEscape ) ); - } - - /* - public void testUnescape() { - String toUnescape = "4 is < 7 & 7 is > 4 but "7" and '4' make error. "; - String expected = "4 is < 7 & 7 is > 4 but \"7\" and '4' make error. "; - assertEquals( expected, HtmlW.unescapeHtml( toUnescape ) ); - } - - public void testSymmetry() { - String expected = "4 is < 7 & 7 is > 4 but \"7\" and '4' make error. "; - assertEquals( expected, HtmlW.unescapeHtml( HtmlW.escapeHtml( expected ) ) ); - } - */ - - public void testGetAttribute() { - assertEquals( "foo", HtmlW.getAttribute( this.testHtml, "thing" ) ); - assertEquals( "foo", HtmlW.getAttribute( this.testHtml, "Thing" ) ); - } - - public void testGetIndexOpeningTag() { - assertEquals( 0, HtmlW.getIndexOpeningTag(this.testHtml, "bar") ); - assertEquals( 0, HtmlW.getIndexOpeningTag(this.testHtml, "BAR") ); - } - - public void testGetIndexClosingTag() { - assertEquals( 36, HtmlW.getIndexClosingTag(this.testHtml, "bar") ); - assertEquals( 36, HtmlW.getIndexClosingTag(this.testHtml, "bAR") ); - } - - public void testGetContent() { - assertEquals( "test", HtmlW.getContent(this.testHtml, "bar") ); - assertEquals( "test", HtmlW.getContent(this.testHtml, "bAr") ); - } - - public void testSingleQuoteAttribute() { - assertEquals( "single", HtmlW.getAttribute(this.testHtml, "other" ) ); - assertEquals( "single", HtmlW.getAttribute(this.testHtml, "oTHer" ) ); - } - -} diff --git a/genjava/gj-scrape/src/test/com/generationjava/web/XmlWTest.java b/genjava/gj-scrape/src/test/com/generationjava/web/XmlWTest.java deleted file mode 100644 index e9028c63..00000000 --- a/genjava/gj-scrape/src/test/com/generationjava/web/XmlWTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.generationjava.web; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -public class XmlWTest extends TestCase { - - private String testXml = "test"; - - public XmlWTest(String name) { - super(name); - } - - //----------------------------------------------------------------------- - // To test: - // XmlW.escapeXml - // XmlW.unescapeXml - // XmlW.getContent - - public void testEscape() { - String toEscape = "4 is < 7 & 7 is > 4 but \"7\" and '4' make error. "; - String expected = "4 is < 7 & 7 is > 4 but "7" and '4' make error. "; - assertEquals( expected, XmlW.escapeXml( toEscape ) ); - } - - public void testUnescape() { - String toUnescape = "4 is < 7 & 7 is > 4 but "7" and '4' make error. "; - String expected = "4 is < 7 & 7 is > 4 but \"7\" and '4' make error. "; - assertEquals( expected, XmlW.unescapeXml( toUnescape ) ); - } - - public void testSymmetry() { - String expected = "4 is < 7 & 7 is > 4 but \"7\" and '4' make error. "; - assertEquals( expected, XmlW.unescapeXml( XmlW.escapeXml( expected ) ) ); - } - - public void testRemove() { - assertEquals( "FOO", XmlW.removeXml("FOO") ); - assertEquals( "FOO", XmlW.removeXml("FOO") ); - assertEquals( "FOO", XmlW.removeXml("FOO") ); - assertEquals( "FOO", XmlW.removeXml("FOO") ); - assertEquals( "some comment", XmlW.removeXml("

some comment

") ); - assertEquals( "", XmlW.removeXml("") ); - } - - public void testGetAttribute() { - assertEquals( "foo", XmlW.getAttribute( this.testXml, "thing" ) ); - } - - public void testGetIndexOpeningTag() { - assertEquals( 0, XmlW.getIndexOpeningTag(this.testXml, "bar") ); - } - - public void testGetIndexClosingTag() { - assertEquals( 36, XmlW.getIndexClosingTag(this.testXml, "bar") ); - } - - public void testGetContent() { - assertEquals( "test", XmlW.getContent(this.testXml, "bar") ); - } - - public void testSingleQuoteAttribute() { - assertEquals( "single", XmlW.getAttribute(this.testXml, "other" ) ); - } - -} diff --git a/genjava/gj-scrape/xdocs/ScrapePath.example b/genjava/gj-scrape/xdocs/ScrapePath.example deleted file mode 100644 index cdb2b844..00000000 --- a/genjava/gj-scrape/xdocs/ScrapePath.example +++ /dev/null @@ -1,41 +0,0 @@ - -!special text;;3;4"; -for(var i=0; -i'; -if( ((i+1)>=total) ||(((i+1) % width) == 0)){ -cp_contents += ""; -} -} -if(document.getElementById){ -//var width1 = Math.floor(width/2); -//var width2 = width = width1; -//cp_contents += ""; -cp_contents += ""; -} -cp_contents += "
;= - -move-to-comment 'special text'; move-to-tag 'table'; 3 move-to-tag 'tr'; 4 move-to-tag 'td'; get-tag 'td'; - -move-to-comment 'special text'; \ -move-to-tag 'table'; \ -3 move-to-tag 'tr'; \ -4 move-to-tag 'td'; \ -get-tag 'td'; - - -Object scrapeScript(String script, String text) - - -HtmlScraper scrapeTag(String tag) -boolean move(String tag) -boolean moveToTagWith(String name, String value) -boolean moveTo(String get, String value) -boolean moveToText(String text) -boolean moveToComment(String comment) -String getContentToText(String text) -String[] getChildren(String parent, String child) -String get(String tag) -Object[] scrapeTable(Object[] pattern) - -scrape-tag (replaces the current scraper) -move-to-tag -move-to-any-tag-with -move-to-tag-with -move-to-text -move-to-comment -get-tag -(get-children not supported) -(scrape-table not supported (pattern argument is tricky)) - -; separated -newlines ignored (whitespace) -trim whitespace on each side -repeat-number can start a line (a la vi) - diff --git a/genjava/gj-scrape/xdocs/ScrapePath.xml b/genjava/gj-scrape/xdocs/ScrapePath.xml deleted file mode 100644 index 9a12ac0f..00000000 --- a/genjava/gj-scrape/xdocs/ScrapePath.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - Henri Yandell - Scrape Path - - - -
-

ScrapePath is a simple scripting language that maps to the gj-scrape library. Having it as a language allows scraping to be configured entirely in a configuration file and not need tiny bits of code.

-

ScrapePath is pragmatically created because it's needed, and not based on language-creation experience. To that end, much criticism will be valid.

-
-
-

The language consists of semi-colon separated operations. Each operation consists of an optional times to repeat number, a operator character and following argument text. Newlines are treated as spaces and any whitespace at the start or end of an operation is ignored.

-

The format of the argument text is defined by the operator in question.

-
-
-
-
<
-
The move operator. The argument text is the tag to move to which may end with an optional closing >. For example <table> will move to the next table tag.
-
!
-
The move-to-comment operator. The argument text is treated as a single comment to move to. For example, !special text will move to the html comment <!-- special text -->.
-
=
-
The return operator. The argument text is the tag[attr] value to return. The scrape path script will end as soon as it sees this.
-
#
-
A Scrape Path comment. Everything up until the ; will be ignored. Alternatively, move to tag with id/name equal to?
-
.
-
Move to tag with class equal?
-
-
- -
diff --git a/genjava/gj-scrape/xdocs/changes.xml b/genjava/gj-scrape/xdocs/changes.xml deleted file mode 100644 index 244ae2ae..00000000 --- a/genjava/gj-scrape/xdocs/changes.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Henri Yandell - Changes - - - - - If a page starts with a tag, moving to that tag will now move to the first instance of the tag and not the second one. - Helper method to suck a html table into a double array. - - - Bug introduced in 2.0 that means a move() ends up a character too far into the text and a subsequent get does not work. - - - HtmlScraper does not handle apostrophe's [rather than double-quotes]. - moveToTagWith called twice will find the first one again - Performance Bottleneck: extensive use of toLowerCase in com.generationjava.web.HtmlW.getIndexOpeningTag - Add a scrape(String tag) method - Target is always the first argument in HtmlW/XmlW. - - - HtmlScraper needs to be case insensitive. - - - diff --git a/genjava/gj-scrape/xdocs/images/1x1.gif b/genjava/gj-scrape/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/genjava/gj-scrape/xdocs/images/1x1.gif and /dev/null differ diff --git a/genjava/gj-scrape/xdocs/images/osjava.gif b/genjava/gj-scrape/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/genjava/gj-scrape/xdocs/images/osjava.gif and /dev/null differ diff --git a/genjava/gj-scrape/xdocs/navigation.xml b/genjava/gj-scrape/xdocs/navigation.xml deleted file mode 100644 index ae46a44a..00000000 --- a/genjava/gj-scrape/xdocs/navigation.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - genjava - - - - - - - - - - - - - - - diff --git a/genjava/gj-servlet/LICENSE.txt b/genjava/gj-servlet/LICENSE.txt deleted file mode 100644 index 38aecf65..00000000 --- a/genjava/gj-servlet/LICENSE.txt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/genjava/gj-servlet/maven.xml b/genjava/gj-servlet/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/genjava/gj-servlet/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/genjava/gj-servlet/pom.xml b/genjava/gj-servlet/pom.xml deleted file mode 100644 index 5c9403e4..00000000 --- a/genjava/gj-servlet/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - genjava - genjava - UNUSED - - 4.0.0 - gj-servlet - GenJava-Servlet - 1.0 - 2002 - - - Servlet Components - - - - - - - servletapi - servletapi - 2.3 - - - commons-collections - commons-collections - 2.1 - - - - gj-core - genjava - 3.0 - - - - - - diff --git a/genjava/gj-servlet/project.properties b/genjava/gj-servlet/project.properties deleted file mode 100644 index d0f1d722..00000000 --- a/genjava/gj-servlet/project.properties +++ /dev/null @@ -1,18 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.checkstyle.properties=../../hen_checkstyle.xml - -maven.javadoc.stylesheet=../../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/genjava/gj-servlet/project.xml b/genjava/gj-servlet/project.xml deleted file mode 100644 index c9faf9a8..00000000 --- a/genjava/gj-servlet/project.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - ../project.xml - gj-servlet - GenJava-Servlet - 1.0 - 2002 - - - Servlet Components - - - Servlet Components - - - - servletapi - 2.3 - - - commons-collections - 2.1 - http://jakarta.apache.org/commons/collections.html - - - gj-core - genjava - 3.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - - - diff --git a/genjava/gj-servlet/src/java/com/generationjava/namespace/ServletNamespace.java b/genjava/gj-servlet/src/java/com/generationjava/namespace/ServletNamespace.java deleted file mode 100644 index 6e13212e..00000000 --- a/genjava/gj-servlet/src/java/com/generationjava/namespace/ServletNamespace.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.namespace; - -import java.util.Iterator; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; - -/** - * A servlet implementation of a Namespace. - * The request overrides the session. - */ -public class ServletNamespace extends AbstractNamespace { - - private HttpServletRequest request; - private HttpSession session; - - public ServletNamespace(HttpServletRequest request) { - this(request,null); - } - - public ServletNamespace(HttpServletRequest request, HttpSession session) { - this.request = request; - this.session = session; - } - - public Object getValue(String name) { - Object val = this.request.getAttribute(name); - if(val != null) { - return val; - } - - val = this.request.getParameter(name); - if(val != null) { - return val; - } - - if(this.session != null) { - val = this.session.getAttribute(name); - } - - return val; - } - - public void putValue(String name, Object info) { - this.request.setAttribute(name, info); - } - - public Iterator iterateNames() { - return null; - // iterate the null thingies - } - -} diff --git a/genjava/gj-servlet/src/java/com/generationjava/servlet/FileSystemServlet.java b/genjava/gj-servlet/src/java/com/generationjava/servlet/FileSystemServlet.java deleted file mode 100644 index f5bfe14e..00000000 --- a/genjava/gj-servlet/src/java/com/generationjava/servlet/FileSystemServlet.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.generationjava.servlet; - -import java.io.IOException; -import java.io.File; -import java.io.Writer; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; - -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpServletRequest; - -import com.generationjava.io.find.FileFinder; -import com.generationjava.io.find.Finder; - -public class FileSystemServlet extends HttpServlet { - - public void doGet(HttpServletRequest request, - HttpServletResponse response) - throws ServletException, IOException - { - ServletConfig config = getServletConfig(); - - // the root of the file-system - String root = config.getInitParameter("root"); - - // pattern of files to consider - String filePattern = config.getInitParameter("file-pattern"); - // pattern of dirs to consider - String dirsPattern = config.getInitParameter("dirs-pattern"); - // also ones to exclude?? - - // a properties file mapping a mime type to a java class - // to display it. Must extend display(file). - String mimeUrl = config.getInitParameter("mime"); - - // use getResource to load mime mapping. FileW. - - Writer out = response.getWriter(); - out.write("root="+root); - out.write("
"); - out.write("file-pattern="+filePattern); - out.write("
"); - out.write("dirs-pattern="+dirsPattern); - out.write("
"); - out.write("mime="+mimeUrl); - out.write("
"); - - // if no request passed in, then run on root. - String target = request.getParameter("target"); - /* - if(target == null) { - target = root; - } else { - // SECURITY. ISH. - target = root + target; - } - */ - target = root; - - // open request-target as a directory. - Finder finder = new FileFinder(); - File file = new File(target); - - String[] found = finder.find(file); - for(int i=0; i"); - } - - // if request-target == directory - // get all files in the directory that match pattern? - // Ask each displayer to do an iconDisplay for each one. - // show on a html page as clickable icons. - // if request-target = a file. - // ask its displayer to show it in long form. - - // handle the concept of a file-writing. - // maybe make an applet front end rather than browser someday. - // offer multiple views etc. - - } - -} diff --git a/genjava/gj-servlet/src/java/com/generationjava/servlet/RequestMap.java b/genjava/gj-servlet/src/java/com/generationjava/servlet/RequestMap.java deleted file mode 100644 index ccfb80d6..00000000 --- a/genjava/gj-servlet/src/java/com/generationjava/servlet/RequestMap.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.servlet; - -import java.util.Enumeration; -import java.util.Map; -import java.util.HashMap; - -import javax.servlet.ServletRequest; - -import org.apache.commons.collections.ProxyMap; - -/** - * @deprecated as not that special. Gone in 3.0. - */ -public class RequestMap extends ProxyMap { - - public RequestMap(ServletRequest request) { - super(new HashMap()); - Map map = request.getParameterMap(); - putAll(map); - - /* - Enumeration enum = request.getAttributeNames(); - while(enum.hasMoreElements()) { - String name = (String)enum.nextElement(); - - String[] strings = request.getParameterValues(name); - int sz = strings.length; - for(int i=0; i - -

- Helpers for javax.servlet. -

- - diff --git a/genjava/gj-servlet/src/java/com/generationjava/taglib/AbstractBodyTag.java b/genjava/gj-servlet/src/java/com/generationjava/taglib/AbstractBodyTag.java deleted file mode 100644 index 487e5d62..00000000 --- a/genjava/gj-servlet/src/java/com/generationjava/taglib/AbstractBodyTag.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.generationjava.taglib; - -import java.io.IOException; -import java.io.StringWriter; - -import java.util.Properties; - -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.JspWriter; -import javax.servlet.jsp.PageContext; -import javax.servlet.jsp.tagext.BodyTagSupport; - -/** - * Abstract class for the Taglibs. - * It has a param ability which binds to a generic ParamTag. - * - * @author bayard@generationjava.com - * @version 0.1, 20011028 - */ -abstract public class AbstractBodyTag extends BodyTagSupport { - - private Properties params; - - /** - * Empty constructor. Initialises the attributes. - */ - public AbstractBodyTag() { - initAttributes(); - } - - // code to handle adding params.. - /** - * Set a param. - */ - public void putParam(String name, String value) { - if(params == null) { - params = new Properties(); - } - params.put(name, value); - } - - /** - * Get a param out. - */ - public String getParam(String name) { - if(params == null) { - return null; - } - return params.getProperty(name); - } - - /** - * Initialise any properties to default values. - * This method is called upon construction. - * This is a default empty implementation. - */ - public void initAttributes() { - params.clear(); - } - -} diff --git a/genjava/gj-servlet/src/java/com/generationjava/taglib/AbstractStringBodyTag.java b/genjava/gj-servlet/src/java/com/generationjava/taglib/AbstractStringBodyTag.java deleted file mode 100644 index 2a12f35f..00000000 --- a/genjava/gj-servlet/src/java/com/generationjava/taglib/AbstractStringBodyTag.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.generationjava.taglib; - -import java.io.IOException; -import java.io.StringWriter; - -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.JspWriter; -import javax.servlet.jsp.PageContext; - -/** - * Abstract class for the Taglibs. - * It handles the JSP taglib side of things and calls abstract - * protected methods to delegate the actual body functionality. - * - * @author bayard@generationjava.com - * @version 0.1, 20011028 - */ -abstract public class AbstractStringBodyTag extends AbstractBodyTag { - - /** - * Empty constructor. - */ - public AbstractStringBodyTag() { - super(); - } - - /** - * Handles the manipulation of the String tag, - * evaluating the body of the tag. The evaluation - * is delegated to the actOnBody(String) method - * and then the initAttributes() method is called. - */ - public int doEndTag() throws JspException { - - if( (bodyContent == null) ) { - return SKIP_BODY; - } - String text = ""; - if(bodyContent != null) { - StringWriter body = new StringWriter(); - try { - bodyContent.writeOut(body); - text = body.toString(); - } catch(IOException ioe) { - ioe.printStackTrace(); - } - } - JspWriter writer = pageContext.getOut(); - try { - actOnBody(text); - initAttributes(); - } catch (IOException e) { - throw new JspException(e.toString()); - } - - return (SKIP_BODY); - } - - /** - * Perform an operation on the passed in String. - * - * @param str String to be manipulated - */ - abstract public void actOnBody(String str) throws IOException; - -} diff --git a/genjava/gj-servlet/src/java/com/generationjava/taglib/ParamTag.java b/genjava/gj-servlet/src/java/com/generationjava/taglib/ParamTag.java deleted file mode 100644 index 922340ab..00000000 --- a/genjava/gj-servlet/src/java/com/generationjava/taglib/ParamTag.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.generationjava.taglib; - -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.JspWriter; -import javax.servlet.jsp.PageContext; -import javax.servlet.jsp.tagext.TagSupport; - -/** - * - * - * @author bayard@generationjava.com - * @version 0.1, 20011030 - */ -public class ParamTag extends TagSupport { - - private String name; - private String value; - - /** - * Empty constructor. - */ - public ParamTag() { - super(); - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.value = value; - } - - /** - * Initialise any properties to default values. - */ - public void initAttributes() { - } - - /// TODO: Implement its doing method. This would look at its - /// parent, and if it is of type AbstractBodyTag, then it - /// puts itself into the tag. Maybe use an Interface instead. - -} diff --git a/genjava/gj-servlet/xdocs/changes.xml b/genjava/gj-servlet/xdocs/changes.xml deleted file mode 100644 index adc3c280..00000000 --- a/genjava/gj-servlet/xdocs/changes.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Henri Yandell - Release Notes - - - - - - - diff --git a/genjava/gj-servlet/xdocs/images/1x1.gif b/genjava/gj-servlet/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/genjava/gj-servlet/xdocs/images/1x1.gif and /dev/null differ diff --git a/genjava/gj-servlet/xdocs/images/osjava.gif b/genjava/gj-servlet/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/genjava/gj-servlet/xdocs/images/osjava.gif and /dev/null differ diff --git a/genjava/gj-servlet/xdocs/navigation.xml b/genjava/gj-servlet/xdocs/navigation.xml deleted file mode 100644 index ae46a44a..00000000 --- a/genjava/gj-servlet/xdocs/navigation.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - genjava - - - - - - - - - - - - - - - diff --git a/genjava/gj-tools/LICENSE.txt b/genjava/gj-tools/LICENSE.txt deleted file mode 100644 index 38aecf65..00000000 --- a/genjava/gj-tools/LICENSE.txt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/genjava/gj-tools/maven.xml b/genjava/gj-tools/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/genjava/gj-tools/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/genjava/gj-tools/pom.xml b/genjava/gj-tools/pom.xml deleted file mode 100644 index ef8e81ce..00000000 --- a/genjava/gj-tools/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - genjava - genjava - UNUSED - - 4.0.0 - gj-tools - GenJava-Tools - 1.0 - 2002 - - - A Tools API to make it simpler to write command line tools. - - - - - - - commons-lang - commons-lang - 2.0 - - - - commons-cli - commons-cli - 1.0 - - - - commons-collections - commons-collections - 2.1 - - - - gj-core - genjava - 3.0 - - - - - - diff --git a/genjava/gj-tools/project.properties b/genjava/gj-tools/project.properties deleted file mode 100644 index d0f1d722..00000000 --- a/genjava/gj-tools/project.properties +++ /dev/null @@ -1,18 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.checkstyle.properties=../../hen_checkstyle.xml - -maven.javadoc.stylesheet=../../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/genjava/gj-tools/project.xml b/genjava/gj-tools/project.xml deleted file mode 100644 index 59b47ab4..00000000 --- a/genjava/gj-tools/project.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - ../project.xml - gj-tools - GenJava-Tools - 1.0 - 2002 - - - A Tools API to make it simpler to write command line tools. - - - Tools API - - - - commons-lang - 2.0 - http://jakarta.apache.org/commons/lang.html - - - commons-cli - 1.0 - http://jakarta.apache.org/commons/cli/ - - - commons-collections - 2.1 - http://jakarta.apache.org/commons/collections.html - - - gj-core - genjava - 3.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - - - diff --git a/genjava/gj-tools/src/java/com/generationjava/net/WGet.java b/genjava/gj-tools/src/java/com/generationjava/net/WGet.java deleted file mode 100644 index c31ecbc9..00000000 --- a/genjava/gj-tools/src/java/com/generationjava/net/WGet.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.net; - -import java.net.URL; -import java.net.MalformedURLException; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.IOException; - -/** - * Simple class allowing URLs to be obtained. - */ -public class WGet { - - // full url: http://www.generationjava.com/ - /** - * Provide a string url and it downloads the contents at - * that url. - */ - public String downloadPage(String urlStr) { - if(urlStr.indexOf("http://") == -1) { - urlStr = "http://"+urlStr; - } - StringBuffer sb = new StringBuffer(); - URL url = null; - try { - url = new URL(urlStr); - } catch(MalformedURLException mue) { - System.err.println("Had nasty url: "+urlStr); - mue.printStackTrace(); - return ""; - } - try { - InputStream is = url.openStream(); - BufferedReader bis = new BufferedReader(new InputStreamReader(is)); - String line = null; - while( (line = bis.readLine()) != null) { - sb.append(line); - } - } catch(IOException ioe) { - System.err.println("Had problems with: "+urlStr); - ioe.printStackTrace(); - } - return sb.toString(); - } -} diff --git a/genjava/gj-tools/src/java/com/generationjava/tools/AbstractTool.java b/genjava/gj-tools/src/java/com/generationjava/tools/AbstractTool.java deleted file mode 100644 index 4d2b5bc6..00000000 --- a/genjava/gj-tools/src/java/com/generationjava/tools/AbstractTool.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.tools; - -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.PosixParser; -import org.apache.commons.cli.PatternOptionBuilder; -import org.apache.commons.cli.ParseException; - -abstract public class AbstractTool implements Tool { - - public CommandLine getCArgs(String flags, String[] args) { - try { - return new PosixParser().parse(PatternOptionBuilder.parsePattern(flags), args); - } catch(ParseException pe) { - throw new RuntimeException(pe); - } - } - - abstract public void runTool(String[] args) throws ToolException; - -} diff --git a/genjava/gj-tools/src/java/com/generationjava/tools/CommandLineToolRunner.java b/genjava/gj-tools/src/java/com/generationjava/tools/CommandLineToolRunner.java deleted file mode 100644 index 6f7d9e05..00000000 --- a/genjava/gj-tools/src/java/com/generationjava/tools/CommandLineToolRunner.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.tools; - -import com.generationjava.lang.ClassW; - -public class CommandLineToolRunner { - - public CommandLineToolRunner() { - } - - public boolean runTool(Class clss, String[] args) { - Object obj = ClassW.createObject(clss); - if(obj instanceof Tool) { - return runTool((Tool)obj, args); - } else { - System.err.println("Class "+clss.getName()+" is not an instance of com.generationjava.tools.Tool"); - return false; - } - } - public boolean runTool(Tool tool, String[] args) { - try { - tool.runTool(args); - return true; - } catch(ToolException te) { - System.err.println(te.getMessage()); - return false; - } - } - -} diff --git a/genjava/gj-tools/src/java/com/generationjava/tools/Run.java b/genjava/gj-tools/src/java/com/generationjava/tools/Run.java deleted file mode 100644 index 77c04f69..00000000 --- a/genjava/gj-tools/src/java/com/generationjava/tools/Run.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.tools; - -import com.generationjava.collections.CollectionsW; -import com.generationjava.lang.ClassW; -import org.apache.commons.lang.StringUtils; -import com.generationjava.util.PropertiesLoader; -import java.util.Properties; - -/** - * A class which runs tools. - */ -public class Run { - - static public void main(String[] strs) { - /* - PropertiesLoader pl = new PropertiesLoader(); - Properties props = pl.findProperties("com/generationjava/test/test.properties"); - if(props != null) { - String location = props.getProperty("scaffold.package"); - if (strs[0].indexOf(".") == -1) { - strs[0] = location+"."+strs[0]; - } - if (strs[0].indexOf("Scaffold") == -1) { - strs[0] += "Scaffold"; - } - } else { - System.err.println("Can't find com.generationjava.test.test.properties."); - } - */ - strs[0] = "com.generationjava.tools."+StringUtils.capitalise(strs[0])+"Tool"; - - CommandLineToolRunner cltr = new CommandLineToolRunner(); - cltr.runTool(ClassW.getClass(strs[0]), CollectionsW.getSubArray(strs,1)); - } - -} diff --git a/genjava/gj-tools/src/java/com/generationjava/tools/Tool.java b/genjava/gj-tools/src/java/com/generationjava/tools/Tool.java deleted file mode 100644 index c3d2eeb1..00000000 --- a/genjava/gj-tools/src/java/com/generationjava/tools/Tool.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.tools; - -import org.apache.commons.cli.CommandLine; - -public interface Tool { - - public CommandLine getCArgs(String flags, String[] args); - - public void runTool(String[] args) throws ToolException; - -} diff --git a/genjava/gj-tools/src/java/com/generationjava/tools/ToolException.java b/genjava/gj-tools/src/java/com/generationjava/tools/ToolException.java deleted file mode 100644 index f9bb3fac..00000000 --- a/genjava/gj-tools/src/java/com/generationjava/tools/ToolException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.tools; - -public class ToolException extends Exception { - - public ToolException() { - super(); - } - - public ToolException(String msg) { - super(msg); - } - - public ToolException(Throwable t) { - super(t); - } - - public ToolException(String msg, Throwable t) { - super(msg,t); - } - -} diff --git a/genjava/gj-tools/src/java/com/generationjava/util/ClassFinder.java b/genjava/gj-tools/src/java/com/generationjava/util/ClassFinder.java deleted file mode 100644 index 019cc258..00000000 --- a/genjava/gj-tools/src/java/com/generationjava/util/ClassFinder.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.util; - -import java.io.File; -import java.io.IOException; -import java.util.zip.ZipFile; -import java.util.zip.ZipEntry; -import java.util.Iterator; - -import org.apache.commons.collections.IteratorUtils; -import org.apache.commons.lang.StringUtils; -import com.generationjava.tools.AbstractTool; -import com.generationjava.tools.CommandLineToolRunner; - -import org.apache.commons.cli.CommandLine; - -/** - * Find a Class by name. That is, find the directory or jar it is in. - */ -public class ClassFinder extends AbstractTool { - - // add an argument to return all duplicate fqnames in jars - static public void main(String[] strs) { - CommandLineToolRunner cltr = new CommandLineToolRunner(); - cltr.runTool(ClassFinder.class, strs); - } - - public void runTool(String[] strs) { - CommandLine cargs = getCArgs("fc:", strs); - ClassFinder cf = new ClassFinder(); - - if(cargs.hasOption("c")) { - cf.setClasspath((String)cargs.getOptionValue("c")); - } - - boolean fail = cargs.hasOption("f"); - - for(int i=0;i - - - - Henri Yandell - Release Notes - - - - - - - diff --git a/genjava/gj-tools/xdocs/images/1x1.gif b/genjava/gj-tools/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/genjava/gj-tools/xdocs/images/1x1.gif and /dev/null differ diff --git a/genjava/gj-tools/xdocs/images/osjava.gif b/genjava/gj-tools/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/genjava/gj-tools/xdocs/images/osjava.gif and /dev/null differ diff --git a/genjava/gj-tools/xdocs/navigation.xml b/genjava/gj-tools/xdocs/navigation.xml deleted file mode 100644 index ae46a44a..00000000 --- a/genjava/gj-tools/xdocs/navigation.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - genjava - - - - - - - - - - - - - - - diff --git a/genjava/gj-xml/LICENSE.txt b/genjava/gj-xml/LICENSE.txt deleted file mode 100644 index 38aecf65..00000000 --- a/genjava/gj-xml/LICENSE.txt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/genjava/gj-xml/maven.xml b/genjava/gj-xml/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/genjava/gj-xml/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/genjava/gj-xml/pom.xml b/genjava/gj-xml/pom.xml deleted file mode 100644 index 5c999483..00000000 --- a/genjava/gj-xml/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - genjava - genjava - UNUSED - - 4.0.0 - gj-xml - GenJava-XML - 1.2 - 2002 - - - XML parser component of GenJava-Core. - - - - - - - - - src/test/data - - - - - - - diff --git a/genjava/gj-xml/project.properties b/genjava/gj-xml/project.properties deleted file mode 100644 index d0f1d722..00000000 --- a/genjava/gj-xml/project.properties +++ /dev/null @@ -1,18 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.checkstyle.properties=../../hen_checkstyle.xml - -maven.javadoc.stylesheet=../../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/genjava/gj-xml/project.xml b/genjava/gj-xml/project.xml deleted file mode 100644 index 34302839..00000000 --- a/genjava/gj-xml/project.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - ../project.xml - gj-xml - GenJava-XML - 2.0 - 2002 - - - XML parser component of GenJava-Core. - - - XML Parser - - - - - - src/test/data - - - - **/*Test.java - - - - - - diff --git a/genjava/gj-xml/src/java/com/generationjava/io/xml/XMLNode.java b/genjava/gj-xml/src/java/com/generationjava/io/xml/XMLNode.java deleted file mode 100644 index 9f6400b3..00000000 --- a/genjava/gj-xml/src/java/com/generationjava/io/xml/XMLNode.java +++ /dev/null @@ -1,478 +0,0 @@ -/* - * Copyright (c) 2006, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.io.xml; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.ArrayList; - -/** - * An xml tag. It can be a processing instructon, an empty tag or - * a normal tag. Currently, if the tag is inside a namespace then - * that is a part of the name. That is, all names of tags are - * fully qualified by the namespace. - */ -public class XMLNode { - - private static final Iterator EMPTY = new NullIterator(); - - private HashMap myAttrs; - private HashMap myNodes; // allows quick lookup - private ArrayList myNodeList; // maintains order of myNodes - private String name; - private String value; - private boolean pi; - private boolean comment; - private boolean doctype; - - /** - * Empty Constructor. - */ - public XMLNode() { - this(""); - } - - /** - * Create a new node with this name. - */ - public XMLNode(String name) { - this.name = name; - } - - /** - * Add a child node to this node. - */ - public void addNode(XMLNode node) { - if(this.myNodes == null) { - this.myNodes = new HashMap(); - this.myNodeList = new ArrayList(); - } - this.myNodeList.add(node); - Object obj = this.myNodes.get( node.getName() ); - if(obj == null) { - this.myNodes.put( node.getName(), node ); - } else - if(obj instanceof XMLNode) { - ArrayList list = new ArrayList(); - list.add(obj); - list.add(node); - this.myNodes.put( node.getName(), list ); - } else - if(obj instanceof ArrayList) { - ArrayList list = (ArrayList)obj; - list.add(node); - } - } - - // Iterates a child node. Possibly needs renaming. - // That is, it iterates a child nodes value. - /** - * - */ - public Iterator iterateNode(String name) { - if(this.myNodes == null) { - return EMPTY; - } - Object obj = this.myNodes.get( name ); - if(obj == null) { - return EMPTY; - } else - if(obj instanceof ArrayList) { - return ((ArrayList)obj).iterator(); - } else { - return new SingleIterator(obj); - } - } - - /** - * Add an attribute with specified name and value. - */ - public void addAttr(String name, String value) { - if(this.myAttrs == null) { - this.myAttrs = new HashMap(); - } - value = unescapeXml(value); - this.myAttrs.put( name, value ); - } - - /** - * Get the attribute with the specified name. - */ - public String getAttr(String name) { - if(myAttrs == null) { - return null; - } - return (String)this.myAttrs.get(name); - } - - /** - * Iterate over all the attributes of this node. - * In the order they were added. - */ - public Iterator iterateAttr() { - if(this.myAttrs == null) { - return EMPTY; - } else { - return this.myAttrs.keySet().iterator(); - } - } - - /** - * Get the node with the specified name. - */ - public XMLNode getNode(String name) { - if(this.myNodes == null) { - return null; - } - Object obj = this.myNodes.get(name); - if(obj instanceof XMLNode) { - return (XMLNode)obj; - } - return null; - } - - /** - * Iterate over all of this node's children nodes. - */ - public Iterator iterateNode() { - if(this.myNodes == null) { - return EMPTY; - } else { -// return this.myNodes.iterator(); - return this.myNodeList.iterator(); - } - } - - /** - * Get the name of this node. Includes the namespace. - */ - public String getName() { - return this.name; - } - - /** - * Get the namespace of this node. - */ - public String getNamespace() { - if(this.name.indexOf(":") != -1) { - return this.name.substring(0,this.name.indexOf(":")); - } else { - return ""; - } - } - - /** - * Get the tag name of this node. Doesn't include namespace. - */ - public String getTagName() { - if(this.name.indexOf(":") != -1) { - return this.name.substring(this.name.indexOf(":")+1); - } else { - return this.name; - } - } - - /** - * Get the appended toString's of the children of this node. - * For a text node, it will print out the plaintext. - */ - public String getValue() { - if(isComment()) { - return ""; - } - if(isDocType()) { - return ""; - } - if(this.value != null) { - return this.value; - } - if(isInvisible()) { - return ""; - } - // QUERY: shouldn't call toString. Needs to improve - if(this.myNodeList != null) { - StringBuffer buffer = new StringBuffer(); - Iterator iter = iterateNode(); - while(iter.hasNext()) { - buffer.append(iter.next().toString()); - } - return buffer.toString(); - } - return null; - } - - /** - * Set the plaintext contained in this node. - */ - public void setPlaintext(String str) { - this.value = unescapeXml(str); - } - - /** - * Is this a normal tag? - * That is, not plaintext, not comment and not a pi. - */ - public boolean isTag() { - return !(this.pi || (this.name == null) || (this.value != null)); - } - - /** - * Is it invisible - */ - public boolean isInvisible() { - return this.name == null; - } - - /** - * Set whether this node is invisible or not. - */ - public void setInvisible(boolean b) { - if(b) { - this.name = null; - } - } - - /** - * Is it a doctype - */ - public boolean isDocType() { - return this.doctype; - } - - /** - * Set whether this node is a doctype or not. - */ - public void setDocType(boolean b) { - this.doctype = b; - } - - /** - * Is it a comment - */ - public boolean isComment() { - return this.comment; - } - - /** - * Set whether this node is a comment or not. - */ - public void setComment(boolean b) { - this.comment = b; - } - - /** - * Is it a processing instruction - */ - public boolean isPI() { - return this.pi; - } - - /** - * Set whether this node is a processing instruction or not. - */ - public void setPI(boolean b) { - this.pi = b; - } - - // IMPL: Assumes that you're unable to remove nodes from - // a parent node. removeNode and removeAttr is likely to - // become a needed functionality. - /** - * Is this node empty. - */ - public boolean isEmpty() { - return (this.myNodes == null); - } - - /** - * Is this a text node. - */ - public boolean isTextNode() { - return ((this.value != null) && !comment && !doctype && !pi); - } - - // not entirely necessary, but allows XMLNode's to be output - // int XML by calling .toString() on the root node. - // Probably wants some indentation handling? - /** - * Turn this node into a String. Outputs the node as - * XML. So a large amount of output. - */ - public String toString() { - if(isComment()) { - return ""; - } - if(isDocType()) { - return ""; - } - if(value != null) { - return value; - } - - StringBuffer tmp = new StringBuffer(); - - if(!isInvisible()) { - tmp.append("<"); - if(isPI()) { - tmp.append("?"); - } - tmp.append(name); - } - - Iterator iter = iterateAttr(); - while(iter.hasNext()) { - tmp.append(" "); - String obj = (String)iter.next(); - tmp.append(obj); - tmp.append("=\""); - tmp.append(getAttr(obj)); - tmp.append("\""); - } - if(isEmpty()) { - if(isPI()) { - tmp.append("?>"); - } else { - if(!isInvisible()) { - tmp.append("/>"); - } - } - } else { - if(!isInvisible()) { - tmp.append(">"); - } - - tmp.append(bodyToString()); - - if(!isInvisible()) { - tmp.append("\n"); - } - } - return tmp.toString(); - } - - /** - * Get the String version of the body of this tag. - */ - public String bodyToString() { - StringBuffer tmp = new StringBuffer(); - Iterator iter = iterateNode(); - while(iter.hasNext()) { - Object obj = iter.next(); - if(obj instanceof XMLNode) { - XMLNode node = (XMLNode)obj; - tmp.append(node); - } else - if(obj instanceof ArrayList) { - ArrayList nodelist = (ArrayList)obj; - Iterator nodeItr = nodelist.iterator(); - while(nodeItr.hasNext()) { - XMLNode node = (XMLNode)nodeItr.next(); - tmp.append(node); - } - } - } - return tmp.toString(); - } - - private static String unescapeXml(String str) { - str = replace(str,"&","&"); - str = replace(str,"<","<"); - str = replace(str,">",">"); - str = replace(str,""","\""); - str = replace(str,"'","'"); - return str; - } - - // from Commons.Lang.StringUtils - private static String replace(String text, String repl, String with) { - int max = -1; - if (text == null || repl == null || with == null || repl.length() == 0 || max == 0) { - return text; - } - - StringBuffer buf = new StringBuffer(text.length()); - int start = 0, end = 0; - while ((end = text.indexOf(repl, start)) != -1) { - buf.append(text.substring(start, end)).append(with); - start = end + repl.length(); - - if (--max == 0) { - break; - } - } - buf.append(text.substring(start)); - return buf.toString(); - } - -} - -/** - * An empty iterator. Nicer to return than just plain null. - */ -class NullIterator implements Iterator { - public Object next() { - return null; - } - - public boolean hasNext() { - return false; - } - - public void remove() { - throw new UnsupportedOperationException("There is nothing to remove"); - } -} -/** - * A single iterator. Saves time on making an ArrayList. - */ -class SingleIterator implements Iterator { - - private Object obj; - - public SingleIterator(Object obj) { - this.obj = obj; - } - - public Object next() { - Object tmp = this.obj; - this.obj = null; - return tmp; - } - - public boolean hasNext() { - return (obj != null); - } - - public void remove() { - throw new UnsupportedOperationException("This is an immutable iterator"); - } -} diff --git a/genjava/gj-xml/src/java/com/generationjava/io/xml/XMLParser.java b/genjava/gj-xml/src/java/com/generationjava/io/xml/XMLParser.java deleted file mode 100644 index 50e9c00f..00000000 --- a/genjava/gj-xml/src/java/com/generationjava/io/xml/XMLParser.java +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of Genjava-Core nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.generationjava.io.xml; - -import java.io.Reader; -import java.io.IOException; -import java.util.Stack; - -/** - * A tiny parser of xml text. It is intended to deal with simple - * config files. - */ -public class XMLParser { - - // various states in which the parser may be. - private static final int VACUUM = 1; - private static final int IN_TAG = 2; - private static final int IN_TAG_NAME = 3; - private static final int CLOSING_TAG = 9; - private static final int SLASH = 4; - private static final int ATTR_NAME = 5; - private static final int END_ATTR_NAME = 6; - private static final int ATTR_VALUE = 7; - private static final int END_ATTR_VALUE = 8; - private static final int START_COMMENT = 10; - private static final int IN_COMMENT = 11; - // special state to handle the DOCTYPE 'tag' - private static final int IN_DOCTYPE = 12; - private static final int IN_DTD = 13; - - public XMLParser() { - } - - /** - * Parse an XML text read in from a Reader. - * Returns the root node of the xml text. - */ - public XMLNode parseXML(Reader reader) throws IOException { - int state = VACUUM; - int x = 1; // current character number - int y = 1; // current line number - int rch = 0; - char ch; - boolean pi = false; - - StringBuffer tag_name = new StringBuffer(); - StringBuffer attr_name = new StringBuffer(); - StringBuffer attr_value = new StringBuffer(); - StringBuffer value = new StringBuffer(); - - XMLNode root = null; - XMLNode node = null; - - - // the current parent. - XMLNode parent = null; - - // Stack is used to remember the hierarchy of parents. - Stack stack = new Stack(); - - while( (rch = reader.read()) != -1) { - ch = (char)rch; - // QUERY: Should newlines only be allowed in a VACUUM ? - // error messaging - x++; - if(ch == '\n') { - y++; - x = 1; - continue; - } - - switch(state) { - case VACUUM: { - if(ch == '<') { - pi = false; - state = IN_TAG_NAME; - if( value.length() != 0 ) { - node = new XMLNode(tag_name.toString()); - node.setPlaintext(value.toString().trim()); - parent.addNode(node); - value.setLength(0); - } - } else - if( (ch == ' ') || (ch == '\t') ) { - if(value.length() != 0) { - value.append(ch); - } - continue; - } else - if(ch == '\r') { // part of a newline. - if(value.length() != 0) { - value.append(ch); - } - continue; - } else { - value.append(ch); - } - } - break; - - case START_COMMENT: { - if(ch == '-') { - // feels bad to do this here. - ch = (char)reader.read(); - if(ch == '-') { - state = IN_COMMENT; - } else { - value.append("!-"); - value.append(ch); - } - } else { - tag_name.append('!'); - tag_name.append(ch); - state = IN_TAG_NAME; - } - } - break; - - case IN_COMMENT: { - if(ch == '-') { - // feels bad to do this here. - ch = (char)reader.read(); - if(ch == '-') { - ch = (char)reader.read(); - if(ch == '>') { - node = new XMLNode(); - node.setPlaintext(value.toString().trim()); - node.setComment(true); - if(parent == null) { - parent = new XMLNode(); - parent.setInvisible(true); - root = parent; - } - parent.addNode(node); - value.setLength(0); - state = VACUUM; - } else { - value.append("--"); - value.append(ch); - } - } else { - value.append("-"); - value.append(ch); - } - } else { - value.append(ch); - } - } - break; - - case IN_DOCTYPE: { - if(ch == '[') { - value.append(ch); - state = IN_DTD; - } else - if(ch == '>') { - node = new XMLNode("!DOCTYPE"); - node.setPlaintext(value.toString()); - node.setDocType(true); - if(parent == null) { - parent = new XMLNode(); - parent.setInvisible(true); - root = parent; - } - parent.addNode(node); - value.setLength(0); - state = VACUUM; - } else { - value.append(ch); - } - } - break; - - case IN_DTD: { - if(ch == ']') { - value.append(ch); - state = IN_DOCTYPE; - } else { - value.append(ch); - } - } - - case IN_TAG_NAME: { - if( (ch == '!') && (tag_name.length() == 0) ) { - state = START_COMMENT; - } else - if( !pi && (ch == '?') && (tag_name.length() == 0) ) { - pi = true; - } else - if( (ch == '/') && (tag_name.length() == 0) ) { - // closing tag - parent = (XMLNode)stack.pop(); - state = CLOSING_TAG; - } else - if( ((ch == ' ') || (ch == '\t') || (ch == '>') || (ch == '/')) || (ch == '?') ) { - if("!DOCTYPE".equals(tag_name.toString())) { - state = IN_DOCTYPE; - tag_name.setLength(0); - continue; - } - if(pi) { - if(parent == null) { - parent = new XMLNode(); - parent.setInvisible(true); - root = parent; - } - } - node = new XMLNode(tag_name.toString()); - node.setPI(pi); - pi = false; - if(root == null) { - root = node; - } - if(parent != null) { - parent.addNode(node); - } - tag_name.setLength(0); - if( (ch == '/') || (ch == '?') ) { - state = SLASH; - } else - if(ch == '>') { - state = VACUUM; - stack.push(parent); - parent = node; - } else { - state = IN_TAG; - } - } else { - tag_name.append(ch); - } - } - break; - - case IN_TAG: { - if((ch == ' ') || (ch == '\t') ) { - continue; - } else - if(ch == '>') { - state = VACUUM; - stack.push(parent); - parent = node; - } else - if( (ch == '/') || (ch == '?') ) { - // empty tag - state = SLASH; - } else { - state = ATTR_NAME; - attr_name.setLength(1); - attr_name.setCharAt(0,ch); - } - } - break; - - case SLASH: { - if(ch == '>') { - state = VACUUM; - } else { - state = IN_TAG; - } - } - break; - - case CLOSING_TAG: { - if(ch == '>') { - state = VACUUM; - } else { - continue; - } - } - break; - - case ATTR_NAME: { - if((ch == ' ') || (ch == '\t') ) { - node.addAttr(attr_name.toString(), attr_name.toString()); - state = IN_TAG; - } else - if(ch == '=') { - state = END_ATTR_NAME; - } else { - attr_name.append(ch); - } - } - break; - - case END_ATTR_NAME: { - if(ch == '"') { - state = ATTR_VALUE; - attr_value.setLength(0); - } else { - state = ATTR_NAME; - } - } - break; - - case ATTR_VALUE: { - if(ch == '"') { - node.addAttr(attr_name.toString(), attr_value.toString()); - state = IN_TAG; - } else { - attr_value.append(ch); - } - } - break; - } - } - return root; - } - -} diff --git a/genjava/gj-xml/src/test/com/generationjava/io/xml/XMLParserTest.java b/genjava/gj-xml/src/test/com/generationjava/io/xml/XMLParserTest.java deleted file mode 100644 index 26842e38..00000000 --- a/genjava/gj-xml/src/test/com/generationjava/io/xml/XMLParserTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.generationjava.io.xml; - -import junit.framework.TestCase; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.Iterator; - -public class XMLParserTest extends TestCase { - - private XMLNode node; - - public XMLParserTest(String name) { - super(name); - } - - public void setUp() { - } - - private void use(String filename) throws IOException { - InputStream in = this.getClass().getClassLoader().getResourceAsStream(filename); - Reader reader = new InputStreamReader(in); - XMLParser parser = new XMLParser(); - node = parser.parseXML(reader); - reader.close(); - } - - public void tearDown() throws IOException { - } - - public void testSimple() throws IOException { - use("test.xml"); - assertEquals("one", node.getName()); - Iterator iter = node.iterateNode(); - XMLNode child = (XMLNode) iter.next(); - assertEquals("two", child.getName()); - XMLNode child2 = node.getNode("two"); - assertEquals(child, child2); - } - - public void testSingleIterator() throws IOException { - use("test.xml"); - Iterator nodeIter = node.iterateNode("two"); - int count = 0; - while(nodeIter.hasNext()) { - XMLNode subnode = (XMLNode) nodeIter.next(); - assertEquals("two", subnode.getName()); - count++; - } - assertEquals(1, count); - } - - public void testUnescapeXml() throws IOException { - use("unescape.xml"); - XMLNode child = node.getNode("two"); - assertEquals("Foo < Bar", child.getValue()); - assertEquals("1>2", child.getAttr("test")); - } - -} diff --git a/genjava/gj-xml/src/test/data/test.xml b/genjava/gj-xml/src/test/data/test.xml deleted file mode 100644 index 6a6e3333..00000000 --- a/genjava/gj-xml/src/test/data/test.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/genjava/gj-xml/src/test/data/unescape.xml b/genjava/gj-xml/src/test/data/unescape.xml deleted file mode 100644 index 5d8b8fe5..00000000 --- a/genjava/gj-xml/src/test/data/unescape.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Foo < Bar - diff --git a/genjava/gj-xml/xdocs/changes.xml b/genjava/gj-xml/xdocs/changes.xml deleted file mode 100644 index 5dcb16b7..00000000 --- a/genjava/gj-xml/xdocs/changes.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Henri Yandell - Changes - - - - - Character entities now escaped. - Node was returning EMPTY when it had a single value. - - - XMLProperties does not add root's attributes as properties. - - - diff --git a/genjava/gj-xml/xdocs/images/1x1.gif b/genjava/gj-xml/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/genjava/gj-xml/xdocs/images/1x1.gif and /dev/null differ diff --git a/genjava/gj-xml/xdocs/images/osjava.gif b/genjava/gj-xml/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/genjava/gj-xml/xdocs/images/osjava.gif and /dev/null differ diff --git a/genjava/gj-xml/xdocs/navigation.xml b/genjava/gj-xml/xdocs/navigation.xml deleted file mode 100644 index ae46a44a..00000000 --- a/genjava/gj-xml/xdocs/navigation.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - genjava - - - - - - - - - - - - - - - diff --git a/genjava/pom.xml b/genjava/pom.xml deleted file mode 100644 index aac00f6a..00000000 --- a/genjava/pom.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - 4.0.0 - genjava - genjava - GenJava Components - UNUSED - pom - - - gj-beans - gj-config - gj-core - gj-csv - gj-find - gj-gui - gj-mail - gj-scrape - gj-servlet - gj-tools - gj-xml - - - - OSJava - - - - 2000 - - - - - - - - - - scm:svn:http://svn.osjava.org/svn/osjava/trunk/genjava - http://svn.osjava.org/svn/osjava/trunk/genjava - - - - - osjava-users - http://lists.osjava.org/mailman/listinfo/osjava-users - http://lists.osjava.org/mailman/listinfo/osjava-users - http://lists.osjava.org/mailman/private/osjava-users/ - - - - - - Henri Yandell - hen - bayard@generationjava.com - GenerationJava - - Java Developer - - - - - - - - Steve Heath - steve@smallcogs.com - - - - - - junit - junit - 3.8.1 - test - - - - - - src/java - src/test - - - - - - - maven-jxr-plugin - maven-javadoc-plugin - maven-license-plugin - maven-changes-plugin - - - diff --git a/genjava/project.properties b/genjava/project.properties deleted file mode 100644 index 2055edeb..00000000 --- a/genjava/project.properties +++ /dev/null @@ -1,18 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -# maven.xdoc.version = v${pom.currentVersion} - -maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory - -maven.javadoc.stylesheet = ../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/genjava/project.xml b/genjava/project.xml deleted file mode 100644 index 4ee67178..00000000 --- a/genjava/project.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - 3 - genjava - genjava - GenJava - 1.0 - - - OSJava - http://www.osjava.org/ - /images/osjava.gif - - 2000 - com.generationjava - /images/1x1.gif - - http://www.osjava.org/genjava/ - http://issues.osjava.org/jira/browse/GJC - www.osjava.org/genjava - /sites/org/osjava/www/releases/official/genjava/${pom.artifactId}/ - /sites/org/osjava/www/releases/official/genjava/${pom.artifactId}/ - - - - osjava-users - http://lists.osjava.org/mailman/listinfo/osjava-users - http://lists.osjava.org/mailman/listinfo/osjava-users - http://lists.osjava.org/mailman/private/osjava-users/ - - - - - - Henri Yandell - hen - bayard@generationjava.com - GenerationJava - - Java Developer - - - - - - - - Steve Heath - steve@smallcogs.com - - - - - bayard@www.generationjava.com - src/java - src/test - - - - - maven-jxr-plugin - maven-javadoc-plugin - maven-license-plugin - maven-changes-plugin - - - diff --git a/genjava/xdocs/Genjava.xml b/genjava/xdocs/Genjava.xml deleted file mode 100644 index 4dd5ff9e..00000000 --- a/genjava/xdocs/Genjava.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Henri Yandell - Genjava - - - -
-

Genjava is a collection of small Java libraries that I've created while working on various other projects. It was formally known as 'genjava-core', but I'm now attempting to leave the monolithic single project and move to a more Commons-like style akin to Jakarta Commons.

-
-
-

A couple of questions in 1 letter here. First, my name is Henri Yandell and secondly, yes this is mainly a non-community project for various personal uses. By open-sourcing my own generic code, I believe this lets me use it at work more easily. It also provides me with a way to educate myself about library management and the creation of a product site. If you think something here is worth it, feel free to nudge me into offering it to the Commons community.

-
-
-

Some don't like the style of Jakarta Commons, but I've yet to see them provide any better solution. I expect to use lessons learnt at Jakarta Commons in the management of this code and vice versa.

-
-
-

I enjoy working on Jakarta Commons projects and so you can expect to see my code depend on those projects whenever I feel the need. I also will happily depend on any of the Genjava code and of course, I'll depend on other jars if that is the role of the utility. So expect to see gj-mail depend on Sun's mail.jar etc...

-
-
-

OSJava.org is a small community of Java coders, mostly working on their own individual projects. Various of my projects form a part of this community.

-
- -
diff --git a/genjava/xdocs/dormant.xml b/genjava/xdocs/dormant.xml deleted file mode 100644 index 66a0e2b2..00000000 --- a/genjava/xdocs/dormant.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - Henri Yandell - Genjava - - - -
-

Additionally, the following components have been released but are not considered active:

- - - - - - -
ComponentVersionDescriptionjavadocviewable sourcedependenciesrelease notesdownload
gj-beans1.0A bean introspection library. Unlikely to be worth choosing over Jakarta BeanUtils. apisrc/testjarsrelease notesdownload
gj-gui0.1An assortment of widgets and other GUI components. Needs polishing. apisrc/testjarsrelease notesdownload
gj-servlet1.0A little bit of Servlet helping code, sadly little bit is the right phrase. apisrc/testjarsrelease notesdownload
gj-tools1.0Command line tools framework, with a couple of tools. Designed to make it simpler to push out a command line program but probably not too exciting. apisrc/testjarsrelease notesdownload
-
- -
diff --git a/genjava/xdocs/images/1x1.gif b/genjava/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/genjava/xdocs/images/1x1.gif and /dev/null differ diff --git a/genjava/xdocs/images/core-logo.jpg b/genjava/xdocs/images/core-logo.jpg deleted file mode 100644 index 32bd0334..00000000 Binary files a/genjava/xdocs/images/core-logo.jpg and /dev/null differ diff --git a/genjava/xdocs/images/initials.jpg b/genjava/xdocs/images/initials.jpg deleted file mode 100644 index 32bd0334..00000000 Binary files a/genjava/xdocs/images/initials.jpg and /dev/null differ diff --git a/genjava/xdocs/images/osjava.gif b/genjava/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/genjava/xdocs/images/osjava.gif and /dev/null differ diff --git a/genjava/xdocs/index.xml b/genjava/xdocs/index.xml deleted file mode 100644 index bca11363..00000000 --- a/genjava/xdocs/index.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Henri Yandell - Genjava - - - -
-

Genjava is a repository of reusable components. The released components are:

- - - - - - - - - - -
ComponentVersionDescriptionjavadocviewable sourcedependenciesrelease notesdownload
gj-config1.0A simple configuration system, primarily for use with a JNDI implementation, such as simple-jndi. apisrc/testdepsrelease notesdownload
gj-core3.0The largest of the components, Core contains many things dependent on the JDK. apisrc/testdepsrelease notesdownload
gj-scrape1.0Set of helpers for dealing with HTML and XML without having to parse it. apisrc/testdepsrelease notesdownload
Deprecated
gj-csv1.0CSV reader/writer - see Commons CSV for a list of alternatives. apisrc/testdepsrelease notesdownload
gj-find0.1UNIX find command in Java - see Commons IO, much of the code ended up there. apisrc/testdepsrelease notesdownload
gj-mail1.0JavaMail helper - use Commons Email instead. apisrc/testdepsrelease notesdownload
gj-xml1.0A tiny XML parser - consider nanoxml instead. apisrc/testdepsrelease notesdownload
- -
- -
diff --git a/genjava/xdocs/legacy.xml b/genjava/xdocs/legacy.xml deleted file mode 100644 index 340603d4..00000000 --- a/genjava/xdocs/legacy.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - Henri Yandell - Genjava - - - -
-

For those looking for 'genjava-core' v2.2, the release is available at http://dist.osjava.org/releases/official/genjava-core/.

-
- -
diff --git a/genjava/xdocs/navigation.xml b/genjava/xdocs/navigation.xml deleted file mode 100644 index 64befea4..00000000 --- a/genjava/xdocs/navigation.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - genjava - - - - - - - - - - - - - - - - - - - - diff --git a/genjava/xdocs/sandbox.xml b/genjava/xdocs/sandbox.xml deleted file mode 100644 index 38716fe5..00000000 --- a/genjava/xdocs/sandbox.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - Henri Yandell - Genjava - - - -
-

Currently there are no unreleased components.

-
- -
diff --git a/hen_checkstyle.xml b/hen_checkstyle.xml deleted file mode 100644 index 6abd4571..00000000 --- a/hen_checkstyle.xml +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jardiff/LICENSE.txt b/jardiff/LICENSE.txt deleted file mode 100644 index 59b1ceab..00000000 --- a/jardiff/LICENSE.txt +++ /dev/null @@ -1,30 +0,0 @@ -JarDiff - -Copyright (c) 2005, Antony Riley -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -+ Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - -+ Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -+ Neither the name JarDiff nor the names of its contributors may - be used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/jardiff/pom.xml b/jardiff/pom.xml deleted file mode 100644 index b17faedd..00000000 --- a/jardiff/pom.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - 4.0.0 - org.osjava.jardiff - jardiff - jar - 1.0.0 - JarDiff - - OSJAVA - - http://www.osjava.org/jardiff - 2005 - A tool to help visualise API differences between two different versions of - a project. Jardiff takes two jar files and outputs all the public API changes - as xml, html or plain text. Currently this is command line driven, though - we are working on an ant plugin. It requires java 1.4 to run. - - Jira - http://issues.osjava.org/jira/browse/JDF - - - - users - http://groups.google.com/group/osjava - http://groups.google.com/group/osjava - http://groups.google.com/group/osjava - - - - - asm - asm - 3.1 - - - asm - asm-commons - 3.1 - - - commons-cli - commons-cli - 1.1 - - - org.apache.ant - ant - 1.7.0 - provided - - - - src/java - - - src/resources - - - src/xsl - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - org.osjava.jardiff.Main - true - lib - - - - - - maven-assembly-plugin - - - src/assembly/dist.xml - - - - - package - - attached - - - - - - - diff --git a/jardiff/project.properties b/jardiff/project.properties deleted file mode 100644 index 226a8433..00000000 --- a/jardiff/project.properties +++ /dev/null @@ -1,21 +0,0 @@ -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory - -#maven.checkstyle.properties=../hen_checkstyle.xml - -maven.javadoc.stylesheet = ../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ - -maven.jar.mainclass=org.osjava.jardiff.Main -maven.uberjar.main=org.osjava.jardiff.Main diff --git a/jardiff/project.xml b/jardiff/project.xml deleted file mode 100644 index 736ba0dc..00000000 --- a/jardiff/project.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - 3 - jardiff - jardiff - 0.3.0 - - OSJava - http://www.osjava.org/ - http://www.osjava.org/images/osjava.gif - - 2005 - org.osjava.jardiff - http://www.osjava.org/images/osjava.gif - - Background - At OSjava, we were using a shell script to work out API differences between - our release versions. This unfortunately doesn't scale very well to larger - projects, the main reason for jardiff was to do the same in a much shorter - time (From memory it was taking minutes to get the API diff from two fairly - small jars). In it's current state, jardiff can generate the api differences - between rt.jar for java 1.4 and java 1.5 in under 20 seconds, so it should - scale to even the largest of projects. - ]]> - - A jar diff generator - - - http://www.osjava.org/jardiff/ - http://issues.osjava.org/jira/browse/JDF - dist.osjava.org/maven/jardiff/ - /sites/org/osjava/www/maven/jardiff/ - /sites/org/osjava/www/maven/builds/jardiff/ - - - scm:svn:http://osjava.googlecode.com/svn/trunk/jardiff - http://osjava.googlecode.com/svn/trunk/jardiff - - - - - users - http://groups.google.com/group/osjava - http://groups.google.com/group/osjava - http://groups.google.com/group/osjava - - - - - - Antony Riley - antony - cyberiantiger@gmail.com - osjava - - Java Developer - - - - - - - - - - asm - asm - 2.1 - http://asm.objectweb.org/ - - - asm - asm-commons - 2.1 - http://asm.objectweb.org/ - - - commons-cli - 1.0 - http://jakarta.apache.org/commons/cli/ - - - ant - ant - 1.6.5 - http://ant.apache.org/ - - false - - - - ant - ant-trax - 1.6.5 - http://ant.apache.org/ - - false - - - - - - cyberiantiger@gmail.com - src/java - - - - style - src/xsl - - jardiff-html.xsl - jardiff-text.xsl - jardiff-xhtml.xsl - jardiff-html-base.xsl - - - - ant - src/resources - - jardiff.properties - - - - - - - - maven-jxr-plugin - maven-javadoc-plugin - maven-license-plugin - maven-changes-plugin - - - diff --git a/jardiff/src/assembly/dist.xml b/jardiff/src/assembly/dist.xml deleted file mode 100644 index 28e1e2b7..00000000 --- a/jardiff/src/assembly/dist.xml +++ /dev/null @@ -1,34 +0,0 @@ - - dist - - tar.gz - - false - - - target - - - *.jar - - - - - - - *.txt - - - - - - /lib - false - runtime - - - jardiff-*.jar - - - - diff --git a/jardiff/src/examples/README.txt b/jardiff/src/examples/README.txt deleted file mode 100644 index e4c61f00..00000000 --- a/jardiff/src/examples/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -This directory contains the following examples. -(They both require that you run maven uberjar first, -or change the library paths appropriately). - -jardiff.sh - shell script to perform a jardiff between - jardiff 0.1 and jardiff 0.2 -build.xml - ant build script to perform a jardiff between - jardiff 0.1 and jardiff 0.2 diff --git a/jardiff/src/examples/build.xml b/jardiff/src/examples/build.xml deleted file mode 100644 index 6c147c81..00000000 --- a/jardiff/src/examples/build.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jardiff/src/examples/diff.css b/jardiff/src/examples/diff.css deleted file mode 100644 index e69de29b..00000000 diff --git a/jardiff/src/examples/jardiff.sh b/jardiff/src/examples/jardiff.sh deleted file mode 100755 index adee761f..00000000 --- a/jardiff/src/examples/jardiff.sh +++ /dev/null @@ -1,18 +0,0 @@ -#! /bin/sh - - -if [ ! -f jardiff-0.1.jar ]; then - wget 'http://www.ibiblio.org/maven/jardiff/jars/jardiff-0.1.jar' || - exit 1 -fi - -if [ ! -f jardiff-0.2.jar ]; then - wget 'http://www.ibiblio.org/maven/jardiff/jars/jardiff-0.2.jar' || - exit 1 -fi - -java -jar ../../target/jardiff-0.2-uber.jar -f jardiff-0.1.jar \ --t jardiff-0.2.jar -o html -O jardiff-0.1-0.2.html \ --fa "http://dist.osjava.org/releases/multidoc-jnr/jardiff/0.1" \ --ta "http://dist.osjava.org/releases/multidoc-jnr/jardiff/0.2" \ --s "diff.css" diff --git a/jardiff/src/java/org/osjava/jardiff/AbstractDiffHandler.java b/jardiff/src/java/org/osjava/jardiff/AbstractDiffHandler.java deleted file mode 100644 index 2c06906e..00000000 --- a/jardiff/src/java/org/osjava/jardiff/AbstractDiffHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * org.osjava.jardiff.AbstractDiffHandler - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; - -/** - * An abstract implementation of DiffHandler which provides utility methods. - * - * @author Antony Riley - */ -public abstract class AbstractDiffHandler implements DiffHandler -{ - /** - * Get the java classname given the internal class name internalName. - * - * @return the classname for internalName - */ - protected final String getClassName(String internalName) { - StringBuffer ret = new StringBuffer(internalName.length()); - for (int i = 0; i < internalName.length(); i++) { - char ch = internalName.charAt(i); - switch (ch) { - case '$': - case '/': - ret.append('.'); - break; - default: - ret.append(ch); - } - } - return ret.toString(); - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/AbstractInfo.java b/jardiff/src/java/org/osjava/jardiff/AbstractInfo.java deleted file mode 100644 index 7acebd5b..00000000 --- a/jardiff/src/java/org/osjava/jardiff/AbstractInfo.java +++ /dev/null @@ -1,316 +0,0 @@ -/* - * org.osjava.jardiff.AbstractInfo - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; - -import org.objectweb.asm.Opcodes; - -/** - * An abstract class representing information about a class, method or field. - * - * @author Antony Riley - */ -public abstract class AbstractInfo -{ - /** - * The string used to represent a class, method or field with public - * access. - */ - public final static String ACCESS_PUBLIC = "public"; - - /** - * The string used to represent a class, method or field with protected - * access. - */ - public final static String ACCESS_PROTECTED = "protected"; - - /** - * The string used to represent a class, method or field with package - * private access. - * Package private access is the default access level used by java when - * you do not specify one of public, protected or private. - */ - public final static String ACCESS_PACKAGE = "package"; - - /** - * The string used to represent a class, method or field with private - * access. - */ - public final static String ACCESS_PRIVATE = "private"; - - /** - * The access flags for this class, method or field. - */ - private final int access; - - /** - * The internal name of this class, method or field. - */ - private final String name; - - /** - * Construct a new AbstractInfo with the specified access and name. - * - * @param access The access flags for this class, method or field. - * @param name The internal name of this class, method or field. - */ - public AbstractInfo(int access, String name) { - this.access = access; - this.name = name; - } - - /** - * Get the access flags for this class, method or field. - * - * @return the access flags. - */ - public final int getAccess() { - return access; - } - - /** - * Get the internal name of this class, method or field. - * - * @return the name - */ - public final String getName() { - return name; - } - - /** - * Test if this class, method or field is public. - * - * @return true if it is public. - */ - public final boolean isPublic() { - return (access & Opcodes.ACC_PUBLIC) != 0; - } - - /** - * Test if this class, method or field is protected. - * - * @return true if it is protected. - */ - public final boolean isProtected() { - return (access & Opcodes.ACC_PROTECTED) != 0; - } - - /** - * Test if this class, method or field is package private. - * - * @return true if it is package private. - */ - public final boolean isPackagePrivate() { - return (access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | - Opcodes.ACC_PRIVATE)) == 0; - } - - /** - * Test if this class, method or field is private. - * - * @return true if it is private. - */ - public final boolean isPrivate() { - return (access & Opcodes.ACC_PRIVATE) != 0; - } - - /** - * Test if this class, method or field is abstract. - * - * @return true if it is abstract. - */ - public final boolean isAbstract() { - return (access & Opcodes.ACC_ABSTRACT) != 0; - } - - /** - * Test if this class, method or field is annotation - * - * @return true if it is annotation. - */ - public final boolean isAnnotation() { - return (access & Opcodes.ACC_ANNOTATION) != 0; - } - - /** - * Test if this class, method or field is a bridge - * - * @return true if it is a bridge. - */ - public final boolean isBridge() { - return (access & Opcodes.ACC_BRIDGE) != 0; - } - - /** - * Test if this class, method or field is deprecated. - * - * @return true if it is deprecated. - */ - public final boolean isDeprecated() { - return (access & Opcodes.ACC_DEPRECATED) != 0; - } - - /** - * Test if this class, method or field is an enum. - * - * @return true if it is an enum. - */ - public final boolean isEnum() { - return (access & Opcodes.ACC_ENUM) != 0; - } - - /** - * Test if this class, method or field is final. - * - * @return true if it is final. - */ - public final boolean isFinal() { - return (access & Opcodes.ACC_FINAL) != 0; - } - - /** - * Test if this class, method or field is an interface. - * - * @return true if it is an interface. - */ - public final boolean isInterface() { - return (access & Opcodes.ACC_INTERFACE) != 0; - } - - /** - * Test if this class, method or field is native. - * - * @return true if it is native. - */ - public final boolean isNative() { - return (access & Opcodes.ACC_NATIVE) != 0; - } - - /** - * Test if this class, method or field is static. - * - * @return true if it is static. - */ - public final boolean isStatic() { - return (access & Opcodes.ACC_STATIC) != 0; - } - - /** - * Test if this class, method or field is string. - * - * @return true if it is strict. - */ - public final boolean isStrict() { - return (access & Opcodes.ACC_STRICT) != 0; - } - - /** - * Test if this class, method or field is super. - * - * @return true if it is super. - */ - public final boolean isSuper() { - return (access & Opcodes.ACC_SUPER) != 0; - } - - /** - * Test if this class, method or field is synchronized. - * - * @return true if it is synchronized - */ - public final boolean isSynchronized() { - return (access & Opcodes.ACC_SYNCHRONIZED) != 0; - } - - /** - * Test if this class, method or field is synthetic. - * - * @return true if it is synchronized. - */ - public final boolean isSynthetic() { - return (access & Opcodes.ACC_SYNTHETIC) != 0; - } - - /** - * Test if this class or field is transient. - * If this flag is set on a method it means something different. - * - * @return true if it is transient. - */ - public final boolean isTransient() { - return !(this instanceof MethodInfo) && - ((access & Opcodes.ACC_TRANSIENT) != 0); - } - - /** - * Test if this method is varargs. - * If this flag is set on a class or field it means something different. - * Well, it probably shouldn't be set on a class as it would make - * no sense, it only really makes sense on fields and methods. - * - * @return true if it is vargargs. - */ - public final boolean isVarargs() { - return (this instanceof MethodInfo) && - ((access & Opcodes.ACC_VARARGS) != 0); - } - - /** - * Test if this class, method or field is volatile. - * - * @return true if it is volatile. - */ - public final boolean isVolatile() { - return (access & Opcodes.ACC_VOLATILE) != 0; - } - - /** - * Retrivie the access level for this class, method or field. - * - * @return the access level - */ - public final String getAccessType() { - if (isPublic()) - return ACCESS_PUBLIC; - if (isProtected()) - return ACCESS_PROTECTED; - if (isPrivate()) - return ACCESS_PRIVATE; - return ACCESS_PACKAGE; - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/ClassInfo.java b/jardiff/src/java/org/osjava/jardiff/ClassInfo.java deleted file mode 100644 index 498c11d3..00000000 --- a/jardiff/src/java/org/osjava/jardiff/ClassInfo.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * org.osjava.jardiff.ClassInfo - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; -import java.util.Map; - -/** - * Information about a class file. - * - * @author Antony Riley - */ -public final class ClassInfo extends AbstractInfo -{ - /** - * The classfile version number. - */ - private int version; - - /** - * The class signature. - */ - private String signature; - - /** - * The internal classname of the superclass. - */ - private String supername; - - /** - * An array of names of internal classnames of interfaces implmented - * by the class. - */ - private String[] interfaces; - - /** - * A map of method signature to MethodInfo, for the methods provided - * by this class. - */ - private Map methodMap; - - /** - * A map of field signature to FieldInfo, for the fields provided by - * this class. - */ - private Map fieldMap; - - /** - * Create a new classinfo. - * - * @param version the class file version number. - * @param access the access flags for the class. - * @param name the internal name of the class. - * @param signature the signature of the class. - * @param interfaces an array of internal names of interfaces implemented - * by the class. - * @param methodMap a map of methods provided by this class. - * @param fieldMap a map of fields provided by this class. - */ - public ClassInfo(int version, int access, String name, String signature, - String supername, String[] interfaces, Map methodMap, - Map fieldMap) { - super(access, name); - this.version = version; - this.signature = signature; - this.supername = supername; - this.interfaces = interfaces; - this.methodMap = methodMap; - this.fieldMap = fieldMap; - } - - /** - * Get the class file version. - * - * @return The class file version as specified in the java language spec. - */ - public final int getVersion() { - return version; - } - - /** - * Get the class signature. - * - * @return the class signature - */ - public final String getSignature() { - return signature; - } - - /** - * Get the internal name of the superclass. - * - * @return the internal name of the superclass - */ - public final String getSupername() { - return supername; - } - - /** - * Get the internal names of the interfaces implemented by this class - * - * @return an array of internal names of classes implemented by the class. - */ - public final String[] getInterfaces() { - return interfaces; - } - - /** - * Get the map of method signatures to methods. - * - * @return a map with method signatures as keys, and MethodInfos as values. - */ - public final Map getMethodMap() { - return methodMap; - } - - /** - * Get the map of field signatures to fields. - * - * @return a map with field signatures as keys, and FieldInfos as values. - */ - public final Map getFieldMap() { - return fieldMap; - } - - /** - * Get the signature size of this class. - * The size is defined as the number of signatures in a class, - * namely methods + fields + 1. - * - * @return an integer representing an abstract concept of size - */ - public final int getSignatureSize() { - int n = 1; - if( fieldMap != null ) { - n += fieldMap.size(); - } - if( methodMap != null ) { - n += methodMap.size(); - } - return n; - } - -} diff --git a/jardiff/src/java/org/osjava/jardiff/ClassInfoVisitor.java b/jardiff/src/java/org/osjava/jardiff/ClassInfoVisitor.java deleted file mode 100644 index a97885d0..00000000 --- a/jardiff/src/java/org/osjava/jardiff/ClassInfoVisitor.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * org.osjava.jardiff.ClassInfoVisitor - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; -import java.util.HashMap; -import java.util.Map; - -import org.objectweb.asm.FieldVisitor; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.commons.EmptyVisitor; - -/** - * A reusable class which uses the ASM to build up ClassInfo about a - * java class file. - * - * @author Antony Riley - */ -public class ClassInfoVisitor extends EmptyVisitor -{ - /** - * The class file version. - */ - private int version; - - /** - * The access flags for the class. - */ - - private int access; - - /** - * The internal name of the class. - */ - private String name; - - /** - * The signature of the class - */ - private String signature; - - /** - * The internal name of the superclass. - */ - private String supername; - - /** - * An array of internal names of interfaces implemented by this class. - */ - private String[] interfaces; - - /** - * A map of method signature to a MethodInfo describing the method. - */ - private Map methodMap; - - /** - * A map of field signature to a FieldInfo describing the field. - */ - private Map fieldMap; - - /** - * Reset this ClassInfoVisitor so that it can be used to visit another - * class. - */ - public void reset() { - methodMap = new HashMap(); - fieldMap = new HashMap(); - } - - /** - * The the classInfo this ClassInfoVisitor has built up about a class - */ - public ClassInfo getClassInfo() { - return new ClassInfo(version, access, name, signature, supername, - interfaces, methodMap, fieldMap); - } - - /** - * Receive notification of information about a class from ASM. - * - * @param version the class file version number. - * @param access the access flags for the class. - * @param name the internal name of the class. - * @param signature the signature of the class. - * @param supername the internal name of the super class. - * @param interfaces the internal names of interfaces implemented. - */ - public void visit(int version, int access, String name, String signature, - String supername, String[] interfaces) { - this.version = version; - this.access = access; - this.name = name; - this.signature = signature; - this.supername = supername; - this.interfaces = interfaces; - } - - public MethodVisitor visitMethod(int access, String name, String desc, - String signature, String[] exceptions) { - methodMap.put(name + desc, new MethodInfo(access, name, desc, - signature, exceptions)); - return null; - } - - public FieldVisitor visitField(int access, String name, String desc, - String signature, Object value) { - fieldMap.put(name, - new FieldInfo(access, name, desc, signature, value)); - return this; - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/DOMDiffHandler.java b/jardiff/src/java/org/osjava/jardiff/DOMDiffHandler.java deleted file mode 100644 index af159c51..00000000 --- a/jardiff/src/java/org/osjava/jardiff/DOMDiffHandler.java +++ /dev/null @@ -1,725 +0,0 @@ -/* - * org.osjava.jardiff.DOMDiffHandler - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/jardiff/src/ava/org/osjava/jardiff/DOMDiffHandler.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; - -/* Not in 1.4.2 -import javax.xml.XMLConstants; -*/ -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.Result; -import org.w3c.dom.*; - -import org.objectweb.asm.Type; - -/** - * A specific type of DiffHandler which uses DOM to create an XML document - * describing the changes in the diff. - * - * @author Antony Riley - */ -public class DOMDiffHandler implements DiffHandler -{ - /** - * The XML namespace used. - */ - public static final String XML_URI = "http://www.osjava.org/jardiff/0.1"; - - /** - * The javax.xml.transform.sax.Transformer used to convert - * the DOM to text. - */ - private final Transformer transformer; - - /** - * Where we write the result to. - */ - private final Result result; - - /** - * The document object we're building - */ - private final Document doc; - - /** - * The current Node. - */ - private Node currentNode; - - /** - * Create a new DOMDiffHandler which writes to System.out - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public DOMDiffHandler() throws DiffException { - try { - TransformerFactory tf = TransformerFactory.newInstance(); - this.transformer = tf.newTransformer(); - this.result = new StreamResult(System.out); - this.currentNode = null; - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setNamespaceAware(true); - DocumentBuilder db = dbf.newDocumentBuilder(); - this.doc = db.newDocument(); - } catch (TransformerConfigurationException tce) { - throw new DiffException(tce); - } catch (ParserConfigurationException pce) { - throw new DiffException(pce); - } - } - - /** - * Create a new DOMDiffHandler with the specified Transformer and Result. - * This method allows the user to choose what they are going to do with - * the output in a flexible manner, allowing a stylesheet to be specified - * and some result object. - * - * @param transformer The transformer to transform the output with. - * @param result Where to put the result. - */ - public DOMDiffHandler(Transformer transformer, Result result) - throws DiffException - { - try { - this.transformer = transformer; - this.result = result; - this.currentNode = null; - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setNamespaceAware(true); - DocumentBuilder db = dbf.newDocumentBuilder(); - this.doc = db.newDocument(); - } catch (ParserConfigurationException pce) { - throw new DiffException(pce); - } - } - - /** - * Start the diff. - * This writes out the start of a <diff> node. - * - * @param oldJar ignored - * @param newJar ignored - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startDiff(String oldJar, String newJar) throws DiffException { - Element tmp = doc.createElementNS(XML_URI, "diff"); - tmp.setAttribute( "old", oldJar); - tmp.setAttribute( "new", newJar); - doc.appendChild(tmp); - currentNode = tmp; - } - - /** - * Start the list of old contents. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startOldContents() throws DiffException { - Element tmp = doc.createElementNS(XML_URI, "oldcontents"); - currentNode.appendChild(tmp); - currentNode = tmp; - } - - /** - * Start the list of old contents. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startNewContents() throws DiffException { - Element tmp = doc.createElementNS(XML_URI, "newcontents"); - currentNode.appendChild(tmp); - currentNode = tmp; - } - - /** - * Add a contained class. - * - * @param info information about a class - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void contains(ClassInfo info) throws DiffException { - Element tmp = doc.createElementNS(XML_URI, "class"); - tmp.setAttribute("name", info.getName()); - currentNode.appendChild(tmp); - } - - /** - * End the list of old contents. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endOldContents() throws DiffException { - currentNode = currentNode.getParentNode(); - } - - /** - * End the list of new contents. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endNewContents() throws DiffException { - currentNode = currentNode.getParentNode(); - } - - /** - * Start the removed node. - * This writes out a <removed> node. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startRemoved() throws DiffException { - Element tmp = doc.createElementNS(XML_URI, "removed"); - currentNode.appendChild(tmp); - currentNode = tmp; - } - - /** - * Write out class info for a removed class. - * This writes out the nodes describing a class - * - * @param info The info to write out. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void classRemoved(ClassInfo info) throws DiffException { - writeClassInfo(info); - } - - /** - * End the removed section. - * This closes the <removed> tag. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endRemoved() throws DiffException { - currentNode = currentNode.getParentNode(); - } - - /** - * Start the added section. - * This opens the <added> tag. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startAdded() throws DiffException { - Element tmp = doc.createElementNS(XML_URI, "added"); - currentNode.appendChild(tmp); - currentNode = tmp; - } - - /** - * Write out the class info for an added class. - * This writes out the nodes describing an added class. - * - * @param info The class info describing the added class. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void classAdded(ClassInfo info) throws DiffException { - writeClassInfo(info); - } - - /** - * End the added section. - * This closes the <added> tag. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endAdded() throws DiffException { - currentNode = currentNode.getParentNode(); - } - - /** - * Start the changed section. - * This writes out the <changed> node. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startChanged() throws DiffException { - Element tmp = doc.createElementNS(XML_URI, "changed"); - currentNode.appendChild(tmp); - currentNode = tmp; - } - - /** - * Start a changed section for an individual class. - * This writes out an <classchanged> node with the real class - * name as the name attribute. - * - * @param internalName the internal name of the class that has changed. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startClassChanged(String internalName) throws DiffException - { - Element tmp = doc.createElementNS(XML_URI, "classchanged"); - tmp.setAttribute( "name", internalName); - currentNode.appendChild(tmp); - currentNode = tmp; - } - - /** - * Write out info about a removed field. - * This just writes out the field info, it will be inside a start/end - * removed section. - * - * @param info Info about the field that's been removed. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void fieldRemoved(FieldInfo info) throws DiffException { - writeFieldInfo(info); - } - - /** - * Write out info about a removed method. - * This just writes out the method info, it will be inside a start/end - * removed section. - * - * @param info Info about the method that's been removed. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void methodRemoved(MethodInfo info) throws DiffException { - writeMethodInfo(info); - } - - /** - * Write out info about an added field. - * This just writes out the field info, it will be inside a start/end - * added section. - * - * @param info Info about the added field. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void fieldAdded(FieldInfo info) throws DiffException { - writeFieldInfo(info); - } - - /** - * Write out info about a added method. - * This just writes out the method info, it will be inside a start/end - * added section. - * - * @param info Info about the added method. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void methodAdded(MethodInfo info) throws DiffException { - writeMethodInfo(info); - } - - /** - * Write out info aboout a changed class. - * This writes out a <classchange> node, followed by a - * <from> node, with the old information about the class - * followed by a <to> node with the new information about the - * class. - * - * @param oldInfo Info about the old class. - * @param newInfo Info about the new class. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void classChanged(ClassInfo oldInfo, ClassInfo newInfo) - throws DiffException - { - Node currentNode = this.currentNode; - Element tmp = doc.createElementNS(XML_URI, "classchange"); - Element from = doc.createElementNS(XML_URI, "from"); - Element to = doc.createElementNS(XML_URI, "to"); - tmp.appendChild(from); - tmp.appendChild(to); - currentNode.appendChild(tmp); - this.currentNode = from; - writeClassInfo(oldInfo); - this.currentNode = to; - writeClassInfo(newInfo); - this.currentNode = currentNode; - } - - /** - * Write out info aboout a changed field. - * This writes out a <fieldchange> node, followed by a - * <from> node, with the old information about the field - * followed by a <to> node with the new information about the - * field. - * - * @param oldInfo Info about the old field. - * @param newInfo Info about the new field. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void fieldChanged(FieldInfo oldInfo, FieldInfo newInfo) - throws DiffException - { - Node currentNode = this.currentNode; - Element tmp = doc.createElementNS(XML_URI, "fieldchange"); - Element from = doc.createElementNS(XML_URI, "from"); - Element to = doc.createElementNS(XML_URI, "to"); - tmp.appendChild(from); - tmp.appendChild(to); - currentNode.appendChild(tmp); - this.currentNode = from; - writeFieldInfo(oldInfo); - this.currentNode = to; - writeFieldInfo(newInfo); - this.currentNode = currentNode; - } - - /** - * Write out info aboout a changed method. - * This writes out a <methodchange> node, followed by a - * <from> node, with the old information about the method - * followed by a <to> node with the new information about the - * method. - * - * @param oldInfo Info about the old method. - * @param newInfo Info about the new method. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void methodChanged(MethodInfo oldInfo, MethodInfo newInfo) - throws DiffException - { - Node currentNode = this.currentNode; - Element tmp = doc.createElementNS(XML_URI, "methodchange"); - Element from = doc.createElementNS(XML_URI, "from"); - Element to = doc.createElementNS(XML_URI, "to"); - tmp.appendChild(from); - tmp.appendChild(to); - currentNode.appendChild(tmp); - this.currentNode = from; - writeMethodInfo(oldInfo); - this.currentNode = to; - writeMethodInfo(newInfo); - this.currentNode = currentNode; - } - - /** - * End the changed section for an individual class. - * This closes the <classchanged> node. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endClassChanged() throws DiffException { - currentNode = currentNode.getParentNode(); - } - - /** - * End the changed section. - * This closes the <changed> node. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endChanged() throws DiffException { - currentNode = currentNode.getParentNode(); - } - - /** - * End the diff. - * This closes the <diff> node. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endDiff() throws DiffException { - DOMSource source = new DOMSource(doc); - try { - transformer.transform(source, result); - } catch (TransformerException te) { - throw new DiffException(te); - } - } - - /** - * Write out information about a class. - * This writes out a <class> node, which contains information about - * what interfaces are implemented each in a <implements> node. - * - * @param info Info about the class to write out. - */ - protected void writeClassInfo(ClassInfo info) { - Node currentNode = this.currentNode; - Element tmp = doc.createElementNS(XML_URI, "class"); - currentNode.appendChild(tmp); - this.currentNode = tmp; - addAccessFlags(info); - if (info.getName() != null) - tmp.setAttribute( "name", - info.getName()); - if (info.getSignature() != null) - tmp.setAttribute( "signature", - info.getSignature()); - if (info.getSupername() != null) - tmp.setAttribute( "superclass", - info.getSupername()); - tmp.setAttribute( "signatureSize", Integer.toString(info.getSignatureSize()) ); - String[] interfaces = info.getInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - Element iface = doc.createElementNS(XML_URI, "implements"); - tmp.appendChild(iface); - iface.setAttribute( "name", - interfaces[i]); - } - this.currentNode = currentNode; - } - - /** - * Write out information about a method. - * This writes out a <method> node which contains information about - * the arguments, the return type, and the exceptions thrown by the - * method. - * - * @param info Info about the method. - */ - protected void writeMethodInfo(MethodInfo info) { - Node currentNode = this.currentNode; - Element tmp = doc.createElementNS(XML_URI, "method"); - currentNode.appendChild(tmp); - this.currentNode = tmp; - addAccessFlags(info); - - if (info.getName() != null) - tmp.setAttribute( "name", info.getName()); - if (info.getSignature() != null) - tmp.setAttribute( "signature", info.getSignature()); - tmp.setAttribute( "signatureSize", "1" ); - if (info.getDesc() != null) - addMethodNodes(info.getDesc()); - String[] exceptions = info.getExceptions(); - if (exceptions != null) { - for (int i = 0; i < exceptions.length; i++) { - Element excep = doc.createElementNS(XML_URI, "exception"); - excep.setAttribute( "name", exceptions[i]); - tmp.appendChild(excep); - } - } - this.currentNode = currentNode; - } - - /** - * Write out information about a field. - * This writes out a <field> node with attributes describing the - * field. - * - * @param info Info about the field. - */ - protected void writeFieldInfo(FieldInfo info) { - Node currentNode = this.currentNode; - Element tmp = doc.createElementNS(XML_URI, "field"); - currentNode.appendChild(tmp); - this.currentNode = tmp; - addAccessFlags(info); - - if (info.getName() != null) - tmp.setAttribute( "name", - info.getName()); - if (info.getSignature() != null) - tmp.setAttribute( "signature", - info.getSignature()); - if (info.getValue() != null) - tmp.setAttribute( "value", - info.getValue().toString()); - tmp.setAttribute( "signatureSize", "1" ); - if (info.getDesc() != null) - addTypeNode(info.getDesc()); - this.currentNode = currentNode; - } - - /** - * Add attributes describing some access flags. - * This adds the attributes to the attr field. - * - * @see #attr - * @param info Info describing the access flags. - */ - protected void addAccessFlags(AbstractInfo info) { - Element currentNode = (Element) this.currentNode; - currentNode.setAttribute( "access", info.getAccessType()); - if (info.isAbstract()) - currentNode.setAttribute( "abstract", "yes"); - if (info.isAnnotation()) - currentNode.setAttribute( "annotation", "yes"); - if (info.isBridge()) - currentNode.setAttribute( "bridge", "yes"); - if (info.isDeprecated()) - currentNode.setAttribute( "deprecated", "yes"); - if (info.isEnum()) - currentNode.setAttribute( "enum", "yes"); - if (info.isFinal()) - currentNode.setAttribute( "final", "yes"); - if (info.isInterface()) - currentNode.setAttribute( "interface", "yes"); - if (info.isNative()) - currentNode.setAttribute( "native", "yes"); - if (info.isStatic()) - currentNode.setAttribute( "static", "yes"); - if (info.isStrict()) - currentNode.setAttribute( "strict", "yes"); - if (info.isSuper()) - currentNode.setAttribute( "super", "yes"); - if (info.isSynchronized()) - currentNode.setAttribute( "synchronized", "yes"); - if (info.isSynthetic()) - currentNode.setAttribute( "synthetic", "yes"); - if (info.isTransient()) - currentNode.setAttribute( "transient", "yes"); - if (info.isVarargs()) - currentNode.setAttribute( "varargs", "yes"); - if (info.isVolatile()) - currentNode.setAttribute( "volatile", "yes"); - } - - /** - * Add the method nodes for the method descriptor. - * This writes out an <arguments> node containing the - * argument types for the method, followed by a <return> node - * containing the return type. - * - * @param desc The descriptor for the method to write out. - */ - protected void addMethodNodes(String desc) { - Type[] args = Type.getArgumentTypes(desc); - Type ret = Type.getReturnType(desc); - Node currentNode = this.currentNode; - Element tmp = doc.createElementNS(XML_URI,"arguments"); - currentNode.appendChild(tmp); - this.currentNode = tmp; - for (int i = 0; i < args.length; i++) - addTypeNode(args[i]); - tmp = doc.createElementNS(XML_URI,"return"); - currentNode.appendChild(tmp); - this.currentNode = tmp; - addTypeNode(ret); - this.currentNode = currentNode; - } - - /** - * Add a type node for the specified descriptor. - * - * @param desc A type descriptor. - */ - protected void addTypeNode(String desc) { - addTypeNode(Type.getType(desc)); - } - - /** - * Add a type node for the specified type. - * This writes out a <type> node with attributes describing - * the type. - * - * @param type The type to describe. - */ - protected void addTypeNode(Type type) { - Element tmp = doc.createElementNS(XML_URI, "type"); - currentNode.appendChild(tmp); - int i = type.getSort(); - if (i == Type.ARRAY) { - tmp.setAttribute( "array", "yes"); - tmp.setAttribute( "dimensions", - "" + type.getDimensions()); - type = type.getElementType(); - i = type.getSort(); - } - switch (i) { - case Type.BOOLEAN: - tmp.setAttribute( "primitive", "yes"); - tmp.setAttribute( "name", "boolean"); - break; - case Type.BYTE: - tmp.setAttribute( "primitive", "yes"); - tmp.setAttribute( "name", "byte"); - break; - case Type.CHAR: - tmp.setAttribute( "primitive", "yes"); - tmp.setAttribute( "name", "char"); - break; - case Type.DOUBLE: - tmp.setAttribute( "primitive", "yes"); - tmp.setAttribute( "name", "double"); - break; - case Type.FLOAT: - tmp.setAttribute( "primitive", "yes"); - tmp.setAttribute( "name", "float"); - break; - case Type.INT: - tmp.setAttribute( "primitive", "yes"); - tmp.setAttribute( "name", "int"); - break; - case Type.LONG: - tmp.setAttribute( "primitive", "yes"); - tmp.setAttribute( "name", "long"); - break; - case Type.OBJECT: - tmp.setAttribute( "name", type.getInternalName()); - break; - case Type.SHORT: - tmp.setAttribute( "primitive", "yes"); - tmp.setAttribute( "name", "short"); - break; - case Type.VOID: - tmp.setAttribute( "primitive", "yes"); - tmp.setAttribute( "name", "void"); - break; - } - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/DiffCriteria.java b/jardiff/src/java/org/osjava/jardiff/DiffCriteria.java deleted file mode 100644 index b235405a..00000000 --- a/jardiff/src/java/org/osjava/jardiff/DiffCriteria.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * org.osjava.jardiff.DiffCriteria - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; - -/** - * An interface for choosing which API differences are interesting. - * - * @author Antony Riley - */ -public interface DiffCriteria -{ - /** - * Check if the class described by classinfo is interesting. - * - * @return true if classinfo is interesting, false otherwise. - */ - public boolean validClass(ClassInfo classinfo); - - /** - * Check if the method described by methodinfo is interesting. - * - * @return true if methodinfo is interesting, false otherwise. - */ - public boolean validMethod(MethodInfo methodinfo); - - /** - * Check if the method described by fieldinfo is interesting. - * - * @return true if fieldinfo is interesting, false otherwise. - */ - public boolean validField(FieldInfo fieldinfo); - - /** - * Check if the differences between the class described by infoA and - * the class described by infoB are interesting. - * - * @return true if the changes are interesting, false otherwise. - */ - public boolean differs(ClassInfo infoA, ClassInfo infoB); - - /** - * Check if the differences between the method described by infoA and - * the method described by infoB are interesting. - * - * @return true if the changes are interesting, false otherwise. - */ - public boolean differs(MethodInfo methodinfo, MethodInfo methodinfo_1_); - - /** - * Check if the differences between the field described by infoA and the - * field described by infoB are interesting. - * - * @return true if the changes are interesting, false otherwise. - */ - public boolean differs(FieldInfo fieldinfo, FieldInfo fieldinfo_2_); -} diff --git a/jardiff/src/java/org/osjava/jardiff/DiffException.java b/jardiff/src/java/org/osjava/jardiff/DiffException.java deleted file mode 100644 index 8ddf5292..00000000 --- a/jardiff/src/java/org/osjava/jardiff/DiffException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * org.osjava.jardiff.DiffException - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; - -/** - * A wrapper exception classes for various exceptions that can happen - * whilst performing a diff. - * - * @author Antony Riley - */ -public class DiffException extends Exception -{ - /** - * Create a new DiffException wrapping another exception. - * - * @param toWrap the wrapped exception - */ - public DiffException(Exception toWrap) { - super((Throwable) toWrap); - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/DiffHandler.java b/jardiff/src/java/org/osjava/jardiff/DiffHandler.java deleted file mode 100644 index 92eadcd9..00000000 --- a/jardiff/src/java/org/osjava/jardiff/DiffHandler.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * org.osjava.jardiff.DiffHandler - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; - -/** - * An interface for classes which wish to receive information about - * differences in class files between two different jar file version to - * implement. - * - * @author Antony Riley - */ -public interface DiffHandler -{ - /** - * Start a diff between two versions, where string a is the old version - * and string b is the new version. - * - * @param a the name of the old version - * @param b the name of the new version - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startDiff(String a, String b) - throws DiffException; - - /** - * Start the list of old contents. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startOldContents() throws DiffException; - - /** - * Start the list of new contents. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startNewContents() throws DiffException; - - /** - * Add a contained class. - * - * @param info information about a class - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void contains(ClassInfo info) throws DiffException; - - /** - * End the list of old contents. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endOldContents() throws DiffException; - - /** - * End the list of new contents. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endNewContents() throws DiffException; - - /** - * Start the list of removed classes. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startRemoved() throws DiffException; - - /** - * Notification that a class was removed. - * - * @param classinfo information about the class that has been removed. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void classRemoved(ClassInfo classinfo) throws DiffException; - - /** - * End of list of removed classes. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endRemoved() throws DiffException; - - /** - * Start of list of added classes. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startAdded() throws DiffException; - - /** - * Notification that a class was added. - * - * @param classinfo information about the class that has been removed. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void classAdded(ClassInfo classinfo) throws DiffException; - - /** - * End of list of removed classes. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endAdded() throws DiffException; - - /** - * Start list of changed classes. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startChanged() throws DiffException; - - /** - * Start information about class changes for the classname passed. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startClassChanged(String string) throws DiffException; - - /** - * The field was removed for the current class that has changed. - * - * @param fieldinfo Information about the field removed. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void fieldRemoved(FieldInfo fieldinfo) throws DiffException; - - /** - * The method was removed for the current class that has changed. - * - * @param methodinfo Information about the method removed. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void methodRemoved(MethodInfo methodinfo) throws DiffException; - - /** - * The field was added for the current class that has changed. - * - * @param fieldinfo Information about the field added. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void fieldAdded(FieldInfo fieldinfo) throws DiffException; - - /** - * The method was added for the current class that has changed. - * - * @param methodinfo Information about the method added. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void methodAdded(MethodInfo methodinfo) throws DiffException; - - /** - * The current class has changed. - * This is called when a class's interfaces or superclass or access - * flags have changed. - * - * @param oldClassinfo Information about the old class. - * @param newClassinfo Information about the new class. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void classChanged(ClassInfo oldClassinfo, ClassInfo newClassinfo) - throws DiffException; - - /** - * A field on the current class has changed. - * - * @param oldFieldinfo Information about the old field. - * @param newFieldinfo Information about the new field. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void fieldChanged(FieldInfo oldFieldinfo, FieldInfo newFieldinfo) - throws DiffException; - - /** - * A method on the current class has changed. - * - * @param oldMethodInfo Information about the old method. - * @param newMethodInfo Information about the new method. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void methodChanged - (MethodInfo oldMethodInfo, MethodInfo newMethodInfo) throws DiffException; - - /** - * End of changes for the current class. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endClassChanged() throws DiffException; - - /** - * End of class changes. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endChanged() throws DiffException; - - /** - * End of the diff. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endDiff() throws DiffException; -} diff --git a/jardiff/src/java/org/osjava/jardiff/FieldInfo.java b/jardiff/src/java/org/osjava/jardiff/FieldInfo.java deleted file mode 100644 index d319aea5..00000000 --- a/jardiff/src/java/org/osjava/jardiff/FieldInfo.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * org.osjava.jardiff.FieldInfo - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; - -/** - * Information about a field of a class. - * - * @author Antony Riley - */ -public final class FieldInfo extends AbstractInfo -{ - /** - * The field descriptor for this field. - */ - private String desc; - - /** - * The signature for this field. - */ - private String signature; - - /** - * The initial value of this field. - */ - private Object value; - - /** - * Create a new FieldInfo - * - * @param access The access flags. - * @param name The name of the field. - * @param desc The field discriptor. - * @param signature The signature of this field. - * @param value The initial value of the field. - */ - public FieldInfo(int access, String name, String desc, String signature, - Object value) { - super(access, name); - this.desc = desc; - this.signature = signature; - this.value = value; - } - - /** - * Get the descriptor for this FieldInfo. - * - * @return The field descriptor. - */ - public final String getDesc() { - return desc; - } - - /** - * Get the signature for this fieldinfo. - * - * @return The signature. - */ - public final String getSignature() { - return signature; - } - - /** - * Get the initial value for this fieldinfo - * - * @return The initial value. - */ - public final Object getValue() { - return value; - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/JarDiff.java b/jardiff/src/java/org/osjava/jardiff/JarDiff.java deleted file mode 100644 index 09dc034a..00000000 --- a/jardiff/src/java/org/osjava/jardiff/JarDiff.java +++ /dev/null @@ -1,489 +0,0 @@ -/* - * org.osjava.jardiff.JarDiff - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.TreeMap; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -/* -import javax.xml.transform.ErrorListener; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.sax.TransformerHandler; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; -*/ - -import org.objectweb.asm.ClassReader; - -/** - * A class to perform a diff between two jar files. - * - * @author Antony Riley - */ -public class JarDiff -{ - /** - * A map containing information about classes which are dependencies. - * Keys are internal class names. - * Values are instances of ClassInfo. - */ - protected Map depClassInfo = new HashMap(); - - /** - * A map containing information about classes in the old jar file. - * Keys are internal class names. - * Values are instances of ClassInfo. - */ - protected Map oldClassInfo = new TreeMap(); - - /** - * A map containing information about classes in the new jar file. - * Keys are internal class names. - * Values are instances of ClassInfo. - */ - protected Map newClassInfo = new TreeMap(); - - /** - * An array of dependencies which are jar files, or urls. - */ - private URL[] deps; - - /** - * A class loader used for loading dependency classes. - */ - private URLClassLoader depLoader; - - /** - * The name of the old version. - */ - private String oldVersion; - - /** - * The name of the new version. - */ - private String newVersion; - - /** - * Class info visitor, used to load information about classes. - */ - private ClassInfoVisitor infoVisitor = new ClassInfoVisitor(); - - /** - * Create a new JarDiff object. - */ - public JarDiff() { - } - - /** - * Set the name of the old version. - * - * @param oldVersion the name - */ - public void setOldVersion(String oldVersion) { - this.oldVersion = oldVersion; - } - - /** - * Get the name of the old version. - * - * @return the name - */ - public String getOldVersion() { - return oldVersion; - } - - /** - * Set the name of the new version. - * - * @param newVersion - */ - public void setNewVersion(String newVersion) { - this.newVersion = newVersion; - } - - /** - * Get the name of the new version. - * - * @return the name - */ - public String getNewVersion() { - return newVersion; - } - - /** - * Set the dependencies. - * - * @param deps an array of urls pointing to jar files or directories - * containing classes which are required dependencies. - */ - public void setDependencies(URL[] deps) { - this.deps = deps; - } - - /** - * Get the dependencies. - * - * @return the dependencies as an array of URLs - */ - public URL[] getDependencies() { - return deps; - } - - /** - * Load classinfo given a ClassReader. - * - * @param reader the ClassReader - * @return the ClassInfo - */ - private synchronized ClassInfo loadClassInfo(ClassReader reader) - throws IOException - { - infoVisitor.reset(); - reader.accept(infoVisitor, ClassReader.SKIP_CODE); - return infoVisitor.getClassInfo(); - } - - /** - * Load all the classes from the specified URL and store information - * about them in the specified map. - * This currently only works for jar files, not directories - * which contain classes in subdirectories or in the current directory. - * - * @param infoMap the map to store the ClassInfo in. - * @throws DiffException if there is an exception reading info about a - * class. - */ - private void loadClasses(Map infoMap, URL path) throws DiffException { - try { - File jarFile = null; - if(!"file".equals(path.getProtocol()) || path.getHost() != null) { - // If it's not a local file, store it as a temporary jar file. - // java.util.jar.JarFile requires a local file handle. - jarFile = File.createTempFile("jardiff","jar"); - // Mark it to be deleted on exit. - jarFile.deleteOnExit(); - InputStream in = path.openStream(); - OutputStream out = new FileOutputStream(jarFile); - byte[] buffer = new byte[4096]; - int i; - while( (i = in.read(buffer,0,buffer.length)) != -1) { - out.write(buffer, 0, i); - } - in.close(); - out.close(); - } else { - // Else it's a local file, nothing special to do. - jarFile = new File(path.getPath()); - } - loadClasses(infoMap, jarFile); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Load all the classes from the specified URL and store information - * about them in the specified map. - * This currently only works for jar files, not directories - * which contain classes in subdirectories or in the current directory. - * - * @param infoMap the map to store the ClassInfo in. - * @param file the jarfile to load classes from. - * @throws IOException if there is an IOException reading info about a - * class. - */ - private void loadClasses(Map infoMap, File file) throws DiffException { - try { - JarFile jar = new JarFile(file); - Enumeration e = jar.entries(); - while (e.hasMoreElements()) { - JarEntry entry = (JarEntry) e.nextElement(); - String name = entry.getName(); - if (!entry.isDirectory() && name.endsWith(".class")) { - ClassReader reader - = new ClassReader(jar.getInputStream(entry)); - ClassInfo ci = loadClassInfo(reader); - infoMap.put(ci.getName(), ci); - } - } - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Load old classes from the specified URL. - * - * @param loc The location of a jar file to load classes from. - * @throws DiffException if there is an IOException. - */ - public void loadOldClasses(URL loc) throws DiffException { - loadClasses(oldClassInfo, loc); - } - - /** - * Load new classes from the specified URL. - * - * @param loc The location of a jar file to load classes from. - * @throws DiffException if there is an IOException. - */ - public void loadNewClasses(URL loc) throws DiffException { - loadClasses(newClassInfo, loc); - } - - /** - * Load old classes from the specified File. - * - * @param file The location of a jar file to load classes from. - * @throws DiffException if there is an IOException - */ - public void loadOldClasses(File file) throws DiffException { - loadClasses(oldClassInfo, file); - } - - /** - * Load new classes from the specified File. - * - * @param file The location of a jar file to load classes from. - * @throws DiffExeption if there is an IOException - */ - public void loadNewClasses(File file) throws DiffException { - loadClasses(newClassInfo, file); - } - - /** - * Perform a diff sending the output to the specified handler, using - * the specified criteria to select diffs. - * - * @param handler The handler to receive and handle differences. - * @param criteria The criteria we use to select differences. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void diff(DiffHandler handler, DiffCriteria criteria) - throws DiffException - { - // TODO: Build the name from the MANIFEST rather than the filename - handler.startDiff(oldVersion, newVersion); - Iterator i; - - handler.startOldContents(); - i = oldClassInfo.entrySet().iterator(); - while(i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - ClassInfo ci = (ClassInfo) entry.getValue(); - if(criteria.validClass(ci)) { - handler.contains(ci); - } - } - handler.endOldContents(); - - handler.startNewContents(); - i = newClassInfo.entrySet().iterator(); - while(i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - ClassInfo ci = (ClassInfo) entry.getValue(); - if(criteria.validClass(ci)) { - handler.contains(ci); - } - } - handler.endNewContents(); - - java.util.Set onlyOld = new TreeSet(oldClassInfo.keySet()); - java.util.Set onlyNew = new TreeSet(newClassInfo.keySet()); - java.util.Set both = new TreeSet(oldClassInfo.keySet()); - onlyOld.removeAll(newClassInfo.keySet()); - onlyNew.removeAll(oldClassInfo.keySet()); - both.retainAll(newClassInfo.keySet()); - handler.startRemoved(); - i = onlyOld.iterator(); - while (i.hasNext()) { - String s = (String) i.next(); - ClassInfo ci = (ClassInfo) oldClassInfo.get(s); - if (criteria.validClass(ci)) - handler.classRemoved(ci); - } - handler.endRemoved(); - handler.startAdded(); - i = onlyNew.iterator(); - while (i.hasNext()) { - String s = (String) i.next(); - ClassInfo ci = (ClassInfo) newClassInfo.get(s); - if (criteria.validClass(ci)) - handler.classAdded(ci); - } - handler.endAdded(); - java.util.Set removedMethods = new TreeSet(); - java.util.Set removedFields = new TreeSet(); - java.util.Set addedMethods = new TreeSet(); - java.util.Set addedFields = new TreeSet(); - java.util.Set changedMethods = new TreeSet(); - java.util.Set changedFields = new TreeSet(); - handler.startChanged(); - i = both.iterator(); - while (i.hasNext()) { - String s = (String) i.next(); - ClassInfo oci = (ClassInfo) oldClassInfo.get(s); - ClassInfo nci = (ClassInfo) newClassInfo.get(s); - if (criteria.validClass(oci) || criteria.validClass(nci)) { - Map oldMethods = oci.getMethodMap(); - Map oldFields = oci.getFieldMap(); - Map newMethods = nci.getMethodMap(); - Map newFields = nci.getFieldMap(); - Iterator j = oldMethods.entrySet().iterator(); - while (j.hasNext()) { - Map.Entry entry = (Map.Entry) j.next(); - if (criteria.validMethod((MethodInfo) entry.getValue())) - removedMethods.add(entry.getKey()); - } - j = oldFields.entrySet().iterator(); - while (j.hasNext()) { - Map.Entry entry = (Map.Entry) j.next(); - if (criteria.validField((FieldInfo) entry.getValue())) - removedFields.add(entry.getKey()); - } - j = newMethods.entrySet().iterator(); - while (j.hasNext()) { - Map.Entry entry = (Map.Entry) j.next(); - if (criteria.validMethod((MethodInfo) entry.getValue())) - addedMethods.add(entry.getKey()); - } - j = newFields.entrySet().iterator(); - while (j.hasNext()) { - Map.Entry entry = (Map.Entry) j.next(); - if (criteria.validField((FieldInfo) entry.getValue())) - addedFields.add(entry.getKey()); - } - changedMethods.addAll(removedMethods); - changedMethods.retainAll(addedMethods); - removedMethods.removeAll(changedMethods); - addedMethods.removeAll(changedMethods); - changedFields.addAll(removedFields); - changedFields.retainAll(addedFields); - removedFields.removeAll(changedFields); - addedFields.removeAll(changedFields); - j = changedMethods.iterator(); - while (j.hasNext()) { - String desc = (String) j.next(); - MethodInfo oldInfo = (MethodInfo) oldMethods.get(desc); - MethodInfo newInfo = (MethodInfo) newMethods.get(desc); - if (!criteria.differs(oldInfo, newInfo)) - j.remove(); - } - j = changedFields.iterator(); - while (j.hasNext()) { - String desc = (String) j.next(); - FieldInfo oldInfo = (FieldInfo) oldFields.get(desc); - FieldInfo newInfo = (FieldInfo) newFields.get(desc); - if (!criteria.differs(oldInfo, newInfo)) - j.remove(); - } - boolean classchanged = criteria.differs(oci, nci); - if (classchanged || !removedMethods.isEmpty() - || !removedFields.isEmpty() || !addedMethods.isEmpty() - || !addedFields.isEmpty() || !changedMethods.isEmpty() - || !changedFields.isEmpty()) { - handler.startClassChanged(s); - handler.startRemoved(); - j = removedFields.iterator(); - while (j.hasNext()) - handler - .fieldRemoved((FieldInfo) oldFields.get(j.next())); - j = removedMethods.iterator(); - while (j.hasNext()) - handler.methodRemoved((MethodInfo) - oldMethods.get(j.next())); - handler.endRemoved(); - handler.startAdded(); - j = addedFields.iterator(); - while (j.hasNext()) - handler - .fieldAdded((FieldInfo) newFields.get(j.next())); - j = addedMethods.iterator(); - while (j.hasNext()) - handler.methodAdded((MethodInfo) - newMethods.get(j.next())); - handler.endAdded(); - handler.startChanged(); - if (classchanged) - handler.classChanged(oci, nci); - j = changedFields.iterator(); - while (j.hasNext()) { - Object tmp = j.next(); - handler.fieldChanged((FieldInfo) oldFields.get(tmp), - (FieldInfo) newFields.get(tmp)); - } - j = changedMethods.iterator(); - while (j.hasNext()) { - Object tmp = j.next(); - handler.methodChanged((MethodInfo) oldMethods.get(tmp), - ((MethodInfo) - newMethods.get(tmp))); - } - handler.endChanged(); - handler.endClassChanged(); - removedMethods.clear(); - removedFields.clear(); - addedMethods.clear(); - addedFields.clear(); - changedMethods.clear(); - changedFields.clear(); - } - } - } - handler.endChanged(); - handler.endDiff(); - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/Main.java b/jardiff/src/java/org/osjava/jardiff/Main.java deleted file mode 100644 index 3f89bd10..00000000 --- a/jardiff/src/java/org/osjava/jardiff/Main.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * org.osjava.jardiff.Main - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.util.HashSet; -import java.util.Set; - -import javax.xml.transform.ErrorListener; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.sax.TransformerHandler; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.GnuParser; -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.Parser; -import org.apache.commons.cli.ParseException; -import org.apache.commons.cli.Options; - -/** - * A static entry point for use from the command line. - */ -public class Main { - - /** - * Private constructor to prevent this class being instantiated. - */ - private Main() { - } - - /** - * Define set of valid formats. - * This is here to make maintenance more easy. - */ - private final static Set FORMATS = new HashSet(); - - /** - * Can you javadoc static code, I think not, but lets try anyway. - */ - static { - FORMATS.add("html"); - FORMATS.add("xhtml"); - FORMATS.add("text"); - } - - /** - * Utility function for showing help using commons-cli. - * @param options Command line options. - * @param msg Optional message to show. - */ - private static void showHelp(Options options, String msg) { - if(msg != null) { - System.out.println(msg); - } - HelpFormatter hf = new HelpFormatter(); - hf.printHelp("JarDiff -f -t [-F ] [-T ] [[-o ]|[-x ]] [-O ] [-s ] [-fa ] [-ta ]", options); - } - - /** - * Main method to allow this to be run from the command line. - * This needs work, currently only takes two arguments, which are - * the old jar file and the new jar file. - * - * @param args A string array of length two containing the filenames of - * two jar files, the first of which being the older of the - * two. - * @throws Exception when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public static void main(String[] args) throws Exception { - try { - Options options = new Options(); - Option tmp; - tmp = new Option("f","from",true,"from jar file"); - options.addOption(tmp); - tmp = new Option("t","to",true,"to jar file"); - options.addOption(tmp); - tmp = new Option("F","from-name",true,"from name"); - options.addOption(tmp); - tmp = new Option("T","to-name",true,"to name"); - options.addOption(tmp); - //tmp = new Option("d","dep",true,"dependency path"); - //options.addOption(tmp); - tmp = new Option("o","output-format",true,"output format, xml or html"); - options.addOption(tmp); - tmp = new Option("O","out",true,"output file"); - options.addOption(tmp); - tmp = new Option("h","help",false,"print help on command line arguments"); - options.addOption(tmp); - tmp = new Option("x","xsl",true,"custom xsl sheet to format output with"); - options.addOption(tmp); - tmp = new Option("s","stylesheet",true,"stylesheet to link to when generating html"); - options.addOption(tmp); - tmp = new Option("fa","from-api",true,"relative location of from api"); - options.addOption(tmp); - tmp = new Option("ta","to-api",true,"relative location of to api"); - options.addOption(tmp); - Parser parser = new GnuParser(); - CommandLine cli = null; - try { - cli = parser.parse(options, args); - } catch (ParseException pe) { - showHelp(options, pe.getMessage()); - return; - } - args = cli.getArgs(); - if(cli.hasOption('h')) - { - showHelp(options, null); - return; - } - if(args.length > 0) { - showHelp(options, "Additional arguments specified"); - return; - } - if(!cli.hasOption('f')) { - showHelp(options, "Missing required argument: -f"); - return; - } - if(!cli.hasOption('t')) { - showHelp(options, "Missing required argument: -t"); - return; - } - - TransformerFactory tf = TransformerFactory.newInstance(); - tf.setErrorListener( - new ErrorListener() { - public void warning(TransformerException te) { - System.err.println("xslt warning: "+te.getMessageAndLocation()); - } - public void error(TransformerException te) { - System.err.println("xslt error: "+te.getMessageAndLocation()); - } - public void fatalError(TransformerException te) { - System.err.println("xslt fatal error: "+te.getMessageAndLocation()); - } - }); - Transformer ot; - if(cli.hasOption('o')) { - if(cli.hasOption('x')) { - showHelp(options, "Cannot use both -x and -o"); - return; - } - String val = cli.getOptionValue('o'); - if("xml".equals(val)) { - ot = tf.newTransformer(); - } else if(FORMATS.contains(val)) { - URL url = JarDiff.class.getClassLoader() - .getResource("style/jardiff-"+val+".xsl"); - ot = tf.newTransformer( - new StreamSource( url.toString() ) - ); - } else { - showHelp(options, "Invalid output format: "+val); - return; - } - } else if(cli.hasOption('x')) { - File xsl = new File(cli.getOptionValue('x')); - ot = tf.newTransformer(new StreamSource(xsl)); - } else { - ot = tf.newTransformer(); - } - if(cli.hasOption("s")) { - ot.setParameter("stylesheet", cli.getOptionValue("s")); - } - if(cli.hasOption("fa")) { - ot.setParameter("from-api", cli.getOptionValue("fa")); - } - if(cli.hasOption("ta")) { - ot.setParameter("to-api", cli.getOptionValue("ta")); - } - OutputStream out; - if(cli.hasOption('O')) { - out = new FileOutputStream(cli.getOptionValue('O')); - } else { - out = System.out; - } - JarDiff jd = new JarDiff(); - File oldFile = new File(cli.getOptionValue('f')); - File newFile = new File(cli.getOptionValue('t')); - if(cli.hasOption('F')) { - jd.setOldVersion(cli.getOptionValue('F')); - } else { - jd.setOldVersion(oldFile.getName()); - } - if(cli.hasOption('T')) { - jd.setNewVersion(cli.getOptionValue('T')); - } else { - jd.setNewVersion(newFile.getName()); - } - jd.loadOldClasses(oldFile); - jd.loadNewClasses(newFile); - jd.diff( - new DOMDiffHandler(ot, new StreamResult(out)), - new SimpleDiffCriteria() - ); - out.close(); - } catch (Exception e) { - e.printStackTrace(System.err); - } - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/MethodInfo.java b/jardiff/src/java/org/osjava/jardiff/MethodInfo.java deleted file mode 100644 index b83edaa3..00000000 --- a/jardiff/src/java/org/osjava/jardiff/MethodInfo.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * org.osjava.jardiff.MethodInfo - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; - -/** - * A class to hold information about a method. - * - * @author Antony Riley - */ -public final class MethodInfo extends AbstractInfo -{ - /** - * The method descriptor. - */ - private String desc; - - /** - * The signature of the method. - */ - private String signature; - - /** - * An array of the exceptions thrown by this method. - */ - private String[] exceptions; - - /** - * Create a new MethodInfo with the specified parameters. - * - * @param access The access flags for the method. - * @param name The name of the method. - * @param signature The signature of the method. - * @param exceptions The exceptions thrown by the method. - */ - public MethodInfo(int access, String name, String desc, String signature, - String[] exceptions) { - super(access, name); - this.desc = desc; - this.signature = signature; - this.exceptions = exceptions; - } - - /** - * Get the descriptor for the method. - * - * @return the descriptor - */ - public final String getDesc() { - return desc; - } - - /** - * Get the signature for the method. - * - * @return the signature - */ - public final String getSignature() { - return signature; - } - - /** - * Get the array of exceptions which can be thrown by the method. - * - * @return the exceptions as a String[] of internal names. - */ - public final String[] getExceptions() { - return exceptions; - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/SimpleDiffCriteria.java b/jardiff/src/java/org/osjava/jardiff/SimpleDiffCriteria.java deleted file mode 100644 index 244b59ca..00000000 --- a/jardiff/src/java/org/osjava/jardiff/SimpleDiffCriteria.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * org.osjava.jardiff.SimpleDiffCriteria - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; -import java.util.Arrays; -import java.util.HashSet; - -/** - * A specific type of DiffCriteria which is only true for classes, methods - * and fields which are not synthetic, and are public or protected. - * - * @author Antony Riley - */ -public class SimpleDiffCriteria implements DiffCriteria -{ - /** - * Check if a class is valid. - * If the class is not synthetic and is public or protected, return true. - * - * @param info Info describing the class. - * @return True if the class meets the criteria, false otherwise. - */ - public boolean validClass(ClassInfo info) { - return !info.isSynthetic() && (info.isPublic() || info.isProtected()); - } - - /** - * Check if a method is valid. - * If the method is not synthetic and is public or protected, return true. - * - * @param info Info describing the method. - * @return True if the method meets the criteria, false otherwise. - */ - public boolean validMethod(MethodInfo info) { - return !info.isSynthetic() && (info.isPublic() || info.isProtected()); - } - - /** - * Check if a field is valid. - * If the method is not synthetic and is public or protected, return true. - * - * @param info Info describing the field. - * @return True if the field meets the criteria, false otherwise. - */ - public boolean validField(FieldInfo info) { - return !info.isSynthetic() && (info.isPublic() || info.isProtected()); - } - - /** - * Check if there is a change between two versions of a class. - * Returns true if the access flags differ, or if the superclass differs - * or if the implemented interfaces differ. - * - * @param oldInfo Info about the old version of the class. - * @param newInfo Info about the new version of the class. - * @return True if the classes differ, false otherwise. - */ - public boolean differs(ClassInfo oldInfo, ClassInfo newInfo) { - if (oldInfo.getAccess() != newInfo.getAccess()) - return true; - // Yes classes can have a null supername, e.g. java.lang.Object ! - if(oldInfo.getSupername() == null) { - if(newInfo.getSupername() != null) { - return true; - } - } else if (!oldInfo.getSupername().equals(newInfo.getSupername())) { - return true; - } - java.util.Set oldInterfaces - = new HashSet(Arrays.asList(oldInfo.getInterfaces())); - java.util.Set newInterfaces - = new HashSet(Arrays.asList(newInfo.getInterfaces())); - if (!oldInterfaces.equals(newInterfaces)) - return true; - return false; - } - - /** - * Check if there is a change between two versions of a method. - * Returns true if the access flags differ, or if the thrown - * exceptions differ. - * - * @param oldInfo Info about the old version of the method. - * @param newInfo Info about the new version of the method. - * @return True if the methods differ, false otherwise. - */ - public boolean differs(MethodInfo oldInfo, MethodInfo newInfo) { - if (oldInfo.getAccess() != newInfo.getAccess()) - return true; - if (oldInfo.getExceptions() == null - || newInfo.getExceptions() == null) { - if (oldInfo.getExceptions() != newInfo.getExceptions()) - return true; - } else { - java.util.Set oldExceptions - = new HashSet(Arrays.asList(oldInfo.getExceptions())); - java.util.Set newExceptions - = new HashSet(Arrays.asList(newInfo.getExceptions())); - if (!oldExceptions.equals(newExceptions)) - return true; - } - return false; - } - - /** - * Check if there is a change between two versions of a field. - * Returns true if the access flags differ, or if the inital value - * of the field differs. - * - * @param oldInfo Info about the old version of the field. - * @param newInfo Info about the new version of the field. - * @return True if the fields differ, false otherwise. - */ - public boolean differs(FieldInfo oldInfo, FieldInfo newInfo) { - if (oldInfo.getAccess() != newInfo.getAccess()) - return true; - if (oldInfo.getValue() == null || newInfo.getValue() == null) { - if (oldInfo.getValue() != newInfo.getValue()) - return true; - } else if (!oldInfo.getValue().equals(newInfo.getValue())) - return true; - return false; - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/StreamDiffHandler.java b/jardiff/src/java/org/osjava/jardiff/StreamDiffHandler.java deleted file mode 100644 index 35847c89..00000000 --- a/jardiff/src/java/org/osjava/jardiff/StreamDiffHandler.java +++ /dev/null @@ -1,784 +0,0 @@ -/* - * org.osjava.jardiff.StreamDiffHandler - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/jardiff/src/ava/org/osjava/jardiff/DOMDiffHandler.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; - -import java.io.BufferedOutputStream; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import org.objectweb.asm.Type; - -/** - * A specific type of DiffHandler which uses an OutputStream to create an - * XML document describing the changes in the diff. - * This is needed for java 1.2 compatibility for the ant task. - * - * @author Antony Riley - */ -public class StreamDiffHandler implements DiffHandler -{ - /** - * The XML namespace used. - */ - public static final String XML_URI = "http://www.osjava.org/jardiff/0.1"; - - /** - * The javax.xml.transform.sax.Transformer used to convert - * the DOM to text. - */ - private final BufferedWriter out; - - /** - * Create a new StreamDiffHandler which writes to System.out - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public StreamDiffHandler() throws DiffException { - try { - out = new BufferedWriter( - new OutputStreamWriter(System.out, "UTF-8") - ); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Create a new StreamDiffHandler with the specified OutputStream. - * - * @param out Where to write output. - */ - public StreamDiffHandler(OutputStream out) - throws DiffException - { - try { - this.out = new BufferedWriter( - new OutputStreamWriter(out, "UTF-8") - ); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Start the diff. - * This writes out the start of a <diff> node. - * - * @param oldJar name of old jar file. - * @param newJar name of new jar file. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startDiff(String oldJar, String newJar) throws DiffException { - try { - out.write(""); - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Start the list of old contents. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startOldContents() throws DiffException { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Start the list of old contents. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startNewContents() throws DiffException { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Add a contained class. - * - * @param info information about a class - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void contains(ClassInfo info) throws DiffException { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * End the list of old contents. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endOldContents() throws DiffException { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * End the list of new contents. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endNewContents() throws DiffException { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Start the removed node. - * This writes out a <removed> node. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startRemoved() throws DiffException { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Write out class info for a removed class. - * This writes out the nodes describing a class - * - * @param info The info to write out. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void classRemoved(ClassInfo info) throws DiffException { - try { - writeClassInfo(info); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * End the removed section. - * This closes the <removed> tag. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endRemoved() throws DiffException { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Start the added section. - * This opens the <added> tag. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startAdded() throws DiffException { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Write out the class info for an added class. - * This writes out the nodes describing an added class. - * - * @param info The class info describing the added class. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void classAdded(ClassInfo info) throws DiffException { - try { - writeClassInfo(info); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * End the added section. - * This closes the <added> tag. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endAdded() throws DiffException { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Start the changed section. - * This writes out the <changed> node. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startChanged() throws DiffException { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Start a changed section for an individual class. - * This writes out an <classchanged> node with the real class - * name as the name attribute. - * - * @param internalName the internal name of the class that has changed. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void startClassChanged(String internalName) throws DiffException - { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Write out info about a removed field. - * This just writes out the field info, it will be inside a start/end - * removed section. - * - * @param info Info about the field that's been removed. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void fieldRemoved(FieldInfo info) throws DiffException { - try { - writeFieldInfo(info); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Write out info about a removed method. - * This just writes out the method info, it will be inside a start/end - * removed section. - * - * @param info Info about the method that's been removed. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void methodRemoved(MethodInfo info) throws DiffException { - try { - writeMethodInfo(info); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Write out info about an added field. - * This just writes out the field info, it will be inside a start/end - * added section. - * - * @param info Info about the added field. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void fieldAdded(FieldInfo info) throws DiffException { - try { - writeFieldInfo(info); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Write out info about a added method. - * This just writes out the method info, it will be inside a start/end - * added section. - * - * @param info Info about the added method. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void methodAdded(MethodInfo info) throws DiffException { - try { - writeMethodInfo(info); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Write out info aboout a changed class. - * This writes out a <classchange> node, followed by a - * <from> node, with the old information about the class - * followed by a <to> node with the new information about the - * class. - * - * @param oldInfo Info about the old class. - * @param newInfo Info about the new class. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void classChanged(ClassInfo oldInfo, ClassInfo newInfo) - throws DiffException - { - try { - out.write(""); - writeClassInfo(oldInfo); - out.write(""); - writeClassInfo(newInfo); - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Write out info aboout a changed field. - * This writes out a <fieldchange> node, followed by a - * <from> node, with the old information about the field - * followed by a <to> node with the new information about the - * field. - * - * @param oldInfo Info about the old field. - * @param newInfo Info about the new field. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void fieldChanged(FieldInfo oldInfo, FieldInfo newInfo) - throws DiffException - { - try { - out.write(""); - writeFieldInfo(oldInfo); - out.write(""); - writeFieldInfo(newInfo); - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Write out info aboout a changed method. - * This writes out a <methodchange> node, followed by a - * <from> node, with the old information about the method - * followed by a <to> node with the new information about the - * method. - * - * @param oldInfo Info about the old method. - * @param newInfo Info about the new method. - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void methodChanged(MethodInfo oldInfo, MethodInfo newInfo) - throws DiffException - { - try { - out.write(""); - writeMethodInfo(oldInfo); - out.write(""); - writeMethodInfo(newInfo); - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * End the changed section for an individual class. - * This closes the <classchanged> node. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endClassChanged() throws DiffException { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * End the changed section. - * This closes the <changed> node. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endChanged() throws DiffException { - try { - out.write(""); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * End the diff. - * This closes the <diff> node. - * - * @throws DiffException when there is an underlying exception, e.g. - * writing to a file caused an IOException - */ - public void endDiff() throws DiffException { - try { - out.write(""); - out.newLine(); - out.close(); - } catch (IOException ioe) { - throw new DiffException(ioe); - } - } - - /** - * Write out information about a class. - * This writes out a <class> node, which contains information about - * what interfaces are implemented each in a <implements> node. - * - * @param info Info about the class to write out. - * @throws IOException when there is an underlying IOException. - */ - protected void writeClassInfo(ClassInfo info) throws IOException { - out.write(""); - } - String[] interfaces = info.getInterfaces(); - for (int i = 0; i < interfaces.length; i++) { - out.write(""); - } - out.write(""); - } - - /** - * Write out information about a method. - * This writes out a <method> node which contains information about - * the arguments, the return type, and the exceptions thrown by the - * method. - * - * @param info Info about the method. - * @throws IOException when there is an underlying IOException. - */ - protected void writeMethodInfo(MethodInfo info) throws IOException { - out.write(""); - if (info.getDesc() != null) { - addMethodNodes(info.getDesc()); - } - String[] exceptions = info.getExceptions(); - if (exceptions != null) { - for (int i = 0; i < exceptions.length; i++) { - out.write(""); - } - } - out.write(""); - } - - /** - * Write out information about a field. - * This writes out a <field> node with attributes describing the - * field. - * - * @param info Info about the field. - * @throws IOException when there is an underlying IOException. - */ - protected void writeFieldInfo(FieldInfo info) throws IOException { - out.write(""); - if (info.getDesc() != null) { - addTypeNode(info.getDesc()); - } - out.write(""); - } - - /** - * Add attributes describing some access flags. - * This adds the attributes to the attr field. - * - * @param info Info describing the access flags. - * @throws IOException when there is an underlying IOException. - */ - protected void addAccessFlags(AbstractInfo info) throws IOException { - out.write(" access=\""); - // Doesn't need escaping. - out.write(info.getAccessType()); - out.write("\""); - if (info.isAbstract()) - out.write(" abstract=\"yes\""); - if (info.isAnnotation()) - out.write(" annotation=\"yes\""); - if (info.isBridge()) - out.write(" bridge=\"yes\""); - if (info.isDeprecated()) - out.write(" deprecated=\"yes\""); - if (info.isEnum()) - out.write(" enum=\"yes\""); - if (info.isFinal()) - out.write(" final=\"yes\""); - if (info.isInterface()) - out.write(" interface=\"yes\""); - if (info.isNative()) - out.write(" native=\"yes\""); - if (info.isStatic()) - out.write(" static=\"yes\""); - if (info.isStrict()) - out.write(" strict=\"yes\""); - if (info.isSuper()) - out.write(" super=\"yes\""); - if (info.isSynchronized()) - out.write(" synchronized=\"yes\""); - if (info.isSynthetic()) - out.write(" synthetic=\"yes\""); - if (info.isTransient()) - out.write(" transient=\"yes\""); - if (info.isVarargs()) - out.write(" varargs=\"yes\""); - if (info.isVolatile()) - out.write(" volatile=\"yes\""); - } - - /** - * Add the method nodes for the method descriptor. - * This writes out an <arguments> node containing the - * argument types for the method, followed by a <return> node - * containing the return type. - * - * @param desc The descriptor for the method to write out. - * @throws IOException when there is an underlying IOException. - */ - protected void addMethodNodes(String desc) throws IOException { - Type[] args = Type.getArgumentTypes(desc); - Type ret = Type.getReturnType(desc); - out.write(""); - for (int i = 0; i < args.length; i++) - addTypeNode(args[i]); - out.write(""); - out.write(""); - addTypeNode(ret); - out.write(""); - } - - /** - * Add a type node for the specified descriptor. - * - * @param desc A type descriptor. - * @throws IOException when there is an underlying IOException. - */ - protected void addTypeNode(String desc) throws IOException { - addTypeNode(Type.getType(desc)); - } - - /** - * Add a type node for the specified type. - * This writes out a <type> node with attributes describing - * the type. - * - * @param type The type to describe. - * @throws IOException when there is an underlying IOException. - */ - protected void addTypeNode(Type type) throws IOException { - out.write(""); - break; - case Type.BYTE: - out.write(" primitive=\"yes\" name=\"byte\"/>"); - break; - case Type.CHAR: - out.write(" primitive=\"yes\" name=\"char\"/>"); - break; - case Type.DOUBLE: - out.write(" primitive=\"yes\" name=\"double\"/>"); - break; - case Type.FLOAT: - out.write(" primitive=\"yes\" name=\"float\"/>"); - break; - case Type.INT: - out.write(" primitive=\"yes\" name=\"int\"/>"); - break; - case Type.LONG: - out.write(" primitive=\"yes\" name=\"long\"/>"); - break; - case Type.OBJECT: - out.write(" name=\""); - out.write(xmlEscape(type.getInternalName())); - out.write("\"/>"); - break; - case Type.SHORT: - out.write(" primitive=\"yes\" name=\"short\"/>"); - break; - case Type.VOID: - out.write(" primitive=\"yes\" name=\"void\"/>"); - break; - } - } - - /** - * Escape some text into a format suitable for output as xml. - * - * @param str the text to format - * @return the formatted text - */ - private final String xmlEscape(final String str) { - StringBuffer ret = new StringBuffer(str.length()); - for(int i=0;i': - ret.append(">"); - break; - default: - ret.append(ch); - } - } - return ret.toString(); - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/Tools.java b/jardiff/src/java/org/osjava/jardiff/Tools.java deleted file mode 100644 index 23b64455..00000000 --- a/jardiff/src/java/org/osjava/jardiff/Tools.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * org.osjava.jardiff.Tools - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff; - -/** - * A set of Tools which do not belong anywhere else in the API at this time. - * This is nasty, but for now, useful. - * - * @author Antony Riley - */ -public final class Tools -{ - /** - * Private constructor so this class can't be instantiated. - */ - private Tools() { - /* empty */ - } - - /** - * Get the java class name given an internal class name. - * This method currently replaces all instances of $ and / with . this - * may not be according to the java language spec, and will almost - * certainly fail for some inner classes. - * - * @param internalName The internal name of the class. - * @return The java class name. - */ - public static final String getClassName(String internalName) { - StringBuffer ret = new StringBuffer(internalName.length()); - for (int i = 0; i < internalName.length(); i++) { - char ch = internalName.charAt(i); - switch (ch) { - case '$': - case '/': - ret.append('.'); - break; - default: - ret.append(ch); - } - } - return ret.toString(); - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/ant/JDTraXLiaison.java b/jardiff/src/java/org/osjava/jardiff/ant/JDTraXLiaison.java deleted file mode 100644 index 487dfe88..00000000 --- a/jardiff/src/java/org/osjava/jardiff/ant/JDTraXLiaison.java +++ /dev/null @@ -1,535 +0,0 @@ -/* - * org.osjava.jardiff.ant.JDTraXLiaison - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff.ant; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.util.Vector; -import java.util.Enumeration; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.transform.ErrorListener; -import javax.xml.transform.Source; -import javax.xml.transform.SourceLocator; -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.URIResolver; -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; -import javax.xml.transform.TransformerConfigurationException; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.taskdefs.XSLTLiaison2; -import org.apache.tools.ant.taskdefs.XSLTProcess; -import org.apache.tools.ant.taskdefs.XSLTLogger; -import org.apache.tools.ant.taskdefs.XSLTLoggerAware; -import org.apache.tools.ant.types.XMLCatalog; -import org.apache.tools.ant.util.JAXPUtils; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -/* JarDiff modifications of Ant class anotated with // JARDIFF */ - -/** - * Custom TraX liaison class. - * - * This allows loading a stylesheet from a systemid (URL). - */ -public class JDTraXLiaison implements JDXSLTLiaison3, ErrorListener, - XSLTLoggerAware -{ - - /** - * The systemid of the stylesheet (a URL). - */ - private String systemid; // JARDIFF: Added. - - /** - * Create a new JDTraXLiaison. - */ - // JARDIFF: Modified constructor name. - public JDTraXLiaison() throws Exception { - } - - /** - * the name of the factory implementation class to use - * or null for default JAXP lookup. - */ - private String factoryName = null; - - /** The trax TransformerFactory */ - private TransformerFactory tfactory = null; - - /** stylesheet to use for transformation */ - private File stylesheet; - - private XSLTLogger logger; - - /** possible resolver for publicIds */ - private EntityResolver entityResolver; - - /** transformer to use for processing files */ - private Transformer transformer; - - /** The In memory version of the stylesheet */ - private Templates templates; - - /** - * The modification time of the stylesheet from which the templates - * are read - */ - private long templatesModTime; - - /** possible resolver for URIs */ - private URIResolver uriResolver; - - /** transformer output properties */ - private Vector outputProperties = new Vector(); - - /** stylesheet parameters */ - private Vector params = new Vector(); - - /** factory attributes */ - private Vector attributes = new Vector(); - - // JARDIFF: Added Method. - public void setStylesheet(String systemid) { - if(this.systemid != null) { - transformer = null; - // Can't check mod time on URLs - if(this.systemid.equals(systemid)) { - templates = null; - } - } - this.systemid = systemid; - this.stylesheet = null; - } - - public void setStylesheet(File stylesheet) throws Exception { - if (this.stylesheet != null) { - // resetting the stylesheet - reset transformer - transformer = null; - - // do we need to reset templates as well - if (!this.stylesheet.equals(stylesheet) - || (stylesheet.lastModified() != templatesModTime)) { - templates = null; - } - } - this.stylesheet = stylesheet; - // JARDIFF: Added next line. - this.systemid = stylesheet.toURL().toString(); - } - - public void transform(File infile, File outfile) throws Exception { - if (transformer == null) { - createTransformer(); - } - - InputStream fis = null; - OutputStream fos = null; - try { - fis = new BufferedInputStream(new FileInputStream(infile)); - fos = new BufferedOutputStream(new FileOutputStream(outfile)); - StreamResult res = new StreamResult(fos); - // not sure what could be the need of this... - res.setSystemId(JAXPUtils.getSystemId(outfile)); - Source src = getSource(fis, infile); - transformer.transform(src, res); - } finally { - // make sure to close all handles, otherwise the garbage - // collector will close them...whenever possible and - // Windows may complain about not being able to delete files. - try { - if (fis != null) { - fis.close(); - } - } catch (IOException ignored) { - // ignore - } - try { - if (fos != null) { - fos.close(); - } - } catch (IOException ignored) { - // ignore - } - } - } - - /** - * Get the source instance from the stream and id of the file. - * @param is the stream containing the stylesheet data. - * @param infile the file that will be used for the systemid. - * @return the configured source instance matching the stylesheet. - * @throws Exception if there is a problem creating the source. - */ - // JARDIFF: Added for compatability. - private Source getSource(InputStream is, File infile) - throws ParserConfigurationException, SAXException { - return getSource(is, JAXPUtils.getSystemId(infile)); - } - - // JARDIFF: Modified method parameters - private Source getSource(InputStream is, String systemid) - throws ParserConfigurationException, SAXException { - // todo: is this comment still relevant ?? - // FIXME: need to use a SAXSource as the source for the transform - // so we can plug in our own entity resolver - Source src = null; - if (entityResolver != null) { - if (getFactory().getFeature(SAXSource.FEATURE)) { - SAXParserFactory spFactory = SAXParserFactory.newInstance(); - spFactory.setNamespaceAware(true); - XMLReader reader = spFactory.newSAXParser().getXMLReader(); - reader.setEntityResolver(entityResolver); - src = new SAXSource(reader, new InputSource(is)); - } else { - throw new IllegalStateException("xcatalog specified, but " - + "parser doesn't support SAX"); - } - } else { - // WARN: Don't use the StreamSource(File) ctor. It won't work with - // xalan prior to 2.2 because of systemid bugs. - src = new StreamSource(is); - } - // JARDIFF: Modified (moved to overloaded method variant). - src.setSystemId(systemid); - return src; - } - - /** - * Read in templates from the stylesheet - */ - private void readTemplates() - throws IOException, TransformerConfigurationException, - ParserConfigurationException, SAXException { - - // Use a stream so that you can close it yourself quickly - // and avoid keeping the handle until the object is garbaged. - // (always keep control), otherwise you won't be able to delete - // the file quickly on windows. - InputStream xslStream = null; - try { - // JARDIFF: Largely modified. - if(stylesheet != null) { - xslStream - = new BufferedInputStream(new FileInputStream(stylesheet)); - templatesModTime = stylesheet.lastModified(); - } else { - xslStream = - new URL(systemid).openStream(); - templatesModTime = 0L; - } - Source src = getSource(xslStream, systemid); - templates = getFactory().newTemplates(src); - } finally { - if(xslStream != null) { - xslStream.close(); - } - } - } - - /** - * Create a new transformer based on the liaison settings - * @return the newly created and configured transformer. - * @throws Exception thrown if there is an error during creation. - * @see #setStylesheet(java.io.File) - * @see #addParam(java.lang.String, java.lang.String) - * @see #setOutputProperty(java.lang.String, java.lang.String) - */ - private void createTransformer() throws Exception { - if (templates == null) { - readTemplates(); - } - - transformer = templates.newTransformer(); - - // configure the transformer... - transformer.setErrorListener(this); - if (uriResolver != null) { - transformer.setURIResolver(uriResolver); - } - for (int i = 0; i < params.size(); i++) { - final String[] pair = (String[]) params.elementAt(i); - transformer.setParameter(pair[0], pair[1]); - } - for (int i = 0; i < outputProperties.size(); i++) { - final String[] pair = (String[]) outputProperties.elementAt(i); - transformer.setOutputProperty(pair[0], pair[1]); - } - } - - /** - * return the Transformer factory associated to this liaison. - * @return the Transformer factory associated to this liaison. - * @throws BuildException thrown if there is a problem creating - * the factory. - * @see #setFactory(String) - * @since Ant 1.5.2 - */ - private TransformerFactory getFactory() throws BuildException { - if (tfactory != null) { - return tfactory; - } - // not initialized yet, so create the factory - if (factoryName == null) { - tfactory = TransformerFactory.newInstance(); - } else { - try { - Class clazz = Class.forName(factoryName); - tfactory = (TransformerFactory) clazz.newInstance(); - } catch (Exception e) { - throw new BuildException(e); - } - } - tfactory.setErrorListener(this); - - // specific attributes for the transformer - for (int i = 0; i < attributes.size(); i++) { - final Object[] pair = (Object[]) attributes.elementAt(i); - tfactory.setAttribute((String) pair[0], pair[1]); - } - - if (uriResolver != null) { - tfactory.setURIResolver(uriResolver); - } - return tfactory; - } - - - /** - * Set the factory name to use instead of JAXP default lookup. - * @param name the fully qualified class name of the factory to use - * or null for the default JAXP look up mechanism. - * @since Ant 1.6 - */ - public void setFactory(String name) { - factoryName = name; - } - - /** - * Set a custom attribute for the JAXP factory implementation. - * @param name the attribute name. - * @param value the value of the attribute, usually a boolean - * string or object. - * @since Ant 1.6 - */ - public void setAttribute(String name, Object value) { - final Object[] pair = new Object[]{name, value}; - attributes.addElement(pair); - } - - /** - * Set the output property for the current transformer. - * Note that the stylesheet must be set prior to calling - * this method. - * @param name the output property name. - * @param value the output property value. - * @since Ant 1.5 - * @since Ant 1.5 - */ - public void setOutputProperty(String name, String value) { - final String[] pair = new String[]{name, value}; - outputProperties.addElement(pair); - } - - /** Set the class to resolve entities during the transformation - */ - public void setEntityResolver(EntityResolver aResolver) { - entityResolver = aResolver; - } - - /** Set the class to resolve URIs during the transformation - */ - public void setURIResolver(URIResolver aResolver) { - uriResolver = aResolver; - } - - public void addParam(String name, String value) { - final String[] pair = new String[]{name, value}; - params.addElement(pair); - } - - public void setLogger(XSLTLogger l) { - logger = l; - } - - public void error(TransformerException e) { - logError(e, "Error"); - } - - public void fatalError(TransformerException e) { - logError(e, "Fatal Error"); - throw new BuildException("Fatal error during transformation", e); - } - - public void warning(TransformerException e) { - logError(e, "Warning"); - } - - private void logError(TransformerException e, String type) { - if (logger == null) { - return; - } - - StringBuffer msg = new StringBuffer(); - SourceLocator locator = e.getLocator(); - if (locator != null) { - String systemid = locator.getSystemId(); - if (systemid != null) { - String url = systemid; - if (url.startsWith("file:///")) { - url = url.substring(8); - } - msg.append(url); - } else { - msg.append("Unknown file"); - } - int line = locator.getLineNumber(); - if (line != -1) { - msg.append(":" + line); - int column = locator.getColumnNumber(); - if (column != -1) { - msg.append(":" + column); - } - } - } - msg.append(": " + type + "! "); - msg.append(e.getMessage()); - if (e.getCause() != null) { - msg.append(" Cause: " + e.getCause()); - } - - logger.log(msg.toString()); - } - - // kept for backwards compatibility - /** - * @deprecated use org.apache.tools.ant.util.JAXPUtils#getSystemId instead - */ - protected String getSystemId(File file) { - return JAXPUtils.getSystemId(file); - } - - - /** - * Specific configuration for the TRaX liaison. - * @param xsltTask the XSLTProcess task instance from which this liasion - * is to be configured. - */ - public void configure(XSLTProcess xsltTask) { - XSLTProcess.Factory factory = xsltTask.getFactory(); - if (factory != null) { - setFactory(factory.getName()); - - // configure factory attributes - for (Enumeration attrs = factory.getAttributes(); - attrs.hasMoreElements();) { - XSLTProcess.Factory.Attribute attr = - (XSLTProcess.Factory.Attribute) attrs.nextElement(); - setAttribute(attr.getName(), attr.getValue()); - } - } - - XMLCatalog xmlCatalog = xsltTask.getXMLCatalog(); - // use XMLCatalog as the entity resolver and URI resolver - if (xmlCatalog != null) { - setEntityResolver(xmlCatalog); - setURIResolver(xmlCatalog); - } - - - // configure output properties - for (Enumeration props = xsltTask.getOutputProperties(); - props.hasMoreElements();) { - XSLTProcess.OutputProperty prop - = (XSLTProcess.OutputProperty) props.nextElement(); - setOutputProperty(prop.getName(), prop.getValue()); - } - } - - /** - * Specific configuration for the TRaX liaison. - * @param xsltTask the XSLTProcess task instance from which this liasion - * is to be configured. - */ - // JARDIFF: Added - public void configure(JDXSLTProcess xsltTask) { - JDXSLTProcess.Factory factory = xsltTask.getFactory(); - if (factory != null) { - setFactory(factory.getName()); - - // configure factory attributes - for (Enumeration attrs = factory.getAttributes(); - attrs.hasMoreElements();) { - JDXSLTProcess.Factory.Attribute attr = - (JDXSLTProcess.Factory.Attribute) attrs.nextElement(); - setAttribute(attr.getName(), attr.getValue()); - } - } - - XMLCatalog xmlCatalog = xsltTask.getXMLCatalog(); - // use XMLCatalog as the entity resolver and URI resolver - if (xmlCatalog != null) { - setEntityResolver(xmlCatalog); - setURIResolver(xmlCatalog); - } - - - // configure output properties - for (Enumeration props = xsltTask.getOutputProperties(); - props.hasMoreElements();) { - JDXSLTProcess.OutputProperty prop - = (JDXSLTProcess.OutputProperty) props.nextElement(); - setOutputProperty(prop.getName(), prop.getValue()); - } - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/ant/JDXSLTLiaison3.java b/jardiff/src/java/org/osjava/jardiff/ant/JDXSLTLiaison3.java deleted file mode 100644 index 3ed24ede..00000000 --- a/jardiff/src/java/org/osjava/jardiff/ant/JDXSLTLiaison3.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * org.osjava.jardiff.JDXSLTLiaison3 - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff.ant; - -import org.apache.tools.ant.taskdefs.XSLTLiaison2; - -/** - * Extended proxy interface for XSLT processors. - * - * @see JDXSLTProcess - * @since JarDiff 0.2 - */ -public interface JDXSLTLiaison3 extends XSLTLiaison2 { - - /** - * Set the stylesheet to use for the transformation. - * @param systemid the systemid of the stylesheet (a URL). - * @throws Exception thrown if any problems happen - * @since JarDiff 0.2 - */ - void setStylesheet(String systemid) throws Exception; - - /** - * Configure the liaison from the XSLTProcess task. - */ - void configure(JDXSLTProcess process); - -} diff --git a/jardiff/src/java/org/osjava/jardiff/ant/JDXSLTProcess.java b/jardiff/src/java/org/osjava/jardiff/ant/JDXSLTProcess.java deleted file mode 100644 index 03fce6ac..00000000 --- a/jardiff/src/java/org/osjava/jardiff/ant/JDXSLTProcess.java +++ /dev/null @@ -1,1058 +0,0 @@ -/* - * org.osjava.jardiff.JDXSLTProcess - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff.ant; - -import java.io.File; -import java.util.Enumeration; -import java.util.Vector; -import org.apache.tools.ant.AntClassLoader; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.DynamicConfigurator; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Mapper; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Reference; -import org.apache.tools.ant.types.XMLCatalog; -import org.apache.tools.ant.util.FileNameMapper; -import org.apache.tools.ant.util.FileUtils; - -import org.apache.tools.ant.taskdefs.MatchingTask; -import org.apache.tools.ant.taskdefs.XSLTLiaison2; -import org.apache.tools.ant.taskdefs.XSLTLiaison; -import org.apache.tools.ant.taskdefs.XSLTLogger; -import org.apache.tools.ant.taskdefs.XSLTLoggerAware; - -public class JDXSLTProcess extends MatchingTask implements XSLTLogger { - - /** destination directory */ - private File destDir = null; - - /** where to find the source XML file, default is the project's basedir */ - private File baseDir = null; - - /** XSL stylesheet */ - private String xslFile = null; - - /** extension of the files produced by XSL processing */ - private String targetExtension = ".html"; - - /** additional parameters to be passed to the stylesheets */ - private Vector params = new Vector(); - - /** Input XML document to be used */ - private File inFile = null; - - /** Output file */ - private File outFile = null; - - /** The name of the XSL processor to use */ - private String processor; - - /** Classpath to use when trying to load the XSL processor */ - private Path classpath = null; - - /** - * Systemid of stylesheet (url). - */ - // JARDIFF: Added - private String styleurl = null; - - /** The Liason implementation to use to communicate with the XSL - * processor */ - private XSLTLiaison liaison; - - /** Flag which indicates if the stylesheet has been loaded into - * the processor */ - private boolean stylesheetLoaded = false; - - /** force output of target files even if they already exist */ - private boolean force = false; - - /** Utilities used for file operations */ - private FileUtils fileUtils; - - /** XSL output properties to be used */ - private Vector outputProperties = new Vector(); - - /** for resolving entities such as dtds */ - private XMLCatalog xmlCatalog = new XMLCatalog(); - - // JARDIFF: Modified. - /** Name of the TRAX Liaison class */ - private static final String TRAX_LIAISON_CLASS = - "org.osjava.jardiff.ant.JDTraXLiaison"; - - /** Name of the now-deprecated XSLP Liaison class */ - private static final String XSLP_LIAISON_CLASS = - "org.apache.tools.ant.taskdefs.optional.XslpLiaison"; - - /** Name of the now-deprecated Xalan liaison class */ - private static final String XALAN_LIAISON_CLASS = - "org.apache.tools.ant.taskdefs.optional.XalanLiaison"; - - /** - * Whether to style all files in the included directories as well. - * - * @since Ant 1.5 - */ - private boolean performDirectoryScan = true; - - /** - * factory element for TraX processors only - * @since Ant 1.6 - */ - private Factory factory = null; - - /** - * whether to reuse Transformer if transforming multiple files. - * @since 1.5.2 - */ - private boolean reuseLoadedStylesheet = true; - - /** - * AntClassLoader for the nested <classpath> - if set. - * - *

We keep this here in order to reset the context classloader - * in execute. We can't use liaison.getClass().getClassLoader() - * since the actual liaison class may have been loaded by a loader - * higher up (system classloader, for example).

- * - * @since Ant 1.6.2 - */ - private AntClassLoader loader = null; - - /** - * Mapper to use when a set of files gets processed. - * - * @since Ant 1.6.2 - */ - private Mapper mapperElement = null; - - - /** - * Creates a new JDXSLTProcess Task. - * @since JarDiff 0.2 - */ - // JARDIFF:Modified - public JDXSLTProcess() { - fileUtils = FileUtils.newFileUtils(); - } //-- JDXSLTProcess - - /** - * Whether to style all files in the included directories as well; - * optional, default is true. - * - * @param b true if files in included directories are processed. - * @since Ant 1.5 - */ - public void setScanIncludedDirectories(boolean b) { - performDirectoryScan = b; - } - - /** - * Controls whether the stylesheet is reloaded for every transform. - * - *

Setting this to true may get around a bug in certain - * Xalan-J versions, default is false.

- * - * @since Ant 1.5.2 - */ - public void setReloadStylesheet(boolean b) { - reuseLoadedStylesheet = !b; - } - - /** - * Defines the mapper to map source to destination files. - * @exception BuildException if more than one mapper is defined - * @since Ant 1.6.2 - */ - public void addMapper(Mapper mapper) { - if (mapperElement != null) { - throw new BuildException("Cannot define more than one mapper", - getLocation()); - } - mapperElement = mapper; - } - - /** - * Executes the task. - * - * @exception BuildException if there is an execution problem. - * @todo validate that if either in or our is defined, then both are - */ - public void execute() throws BuildException { - File savedBaseDir = baseDir; - - DirectoryScanner scanner; - String[] list; - String[] dirs; - - // JARDIFF: Added check - if(xslFile != null && styleurl != null) { - throw new BuildException( - "cannot specify both styleurl and xslfile", getLocation() - ); - } - // JARDIFF: modified - if (xslFile == null && styleurl == null) { - throw new BuildException("no stylesheet specified", getLocation()); - } - - if (inFile != null && !inFile.exists()) { - throw new BuildException("input file " + inFile.toString() + " does not exist", getLocation()); - } - - try { - if (baseDir == null) { - baseDir = getProject().resolveFile("."); - } - - liaison = getLiaison(); - - // JARDIFF: Added - if(! (liaison instanceof JDXSLTLiaison3) && styleurl != null ) { - throw new BuildException( - "processor does not support style urls", getLocation() - ); - } - - - // check if liaison wants to log errors using us as logger - if (liaison instanceof XSLTLoggerAware) { - ((XSLTLoggerAware) liaison).setLogger(this); - } - - log("Using " + liaison.getClass().toString(), Project.MSG_VERBOSE); - - // JARDIFF: Modified. - Object styleob; - if(styleurl != null) { - styleob = styleurl; - } else { - File stylesheet = getProject().resolveFile(xslFile); - if (!stylesheet.exists()) { - stylesheet = fileUtils.resolveFile(baseDir, xslFile); - /* - * shouldn't throw out deprecation warnings before we know, - * the wrong version has been used. - */ - if (stylesheet.exists()) { - log("DEPRECATED - the style attribute should be relative " - + "to the project\'s"); - log(" basedir, not the tasks\'s basedir."); - } - } - styleob = stylesheet; - } - - // if we have an in file and out then process them - if (inFile != null && outFile != null) { - process(inFile, outFile, styleob); - return; - } - - /* - * if we get here, in and out have not been specified, we are - * in batch processing mode. - */ - - //-- make sure Source directory exists... - if (destDir == null) { - String msg = "destdir attributes must be set!"; - throw new BuildException(msg); - } - scanner = getDirectoryScanner(baseDir); - log("Transforming into " + destDir, Project.MSG_INFO); - - // Process all the files marked for styling - list = scanner.getIncludedFiles(); - for (int i = 0; i < list.length; ++i) { - process(baseDir, list[i], destDir, styleob); - } - if (performDirectoryScan) { - // Process all the directories marked for styling - dirs = scanner.getIncludedDirectories(); - for (int j = 0; j < dirs.length; ++j) { - list = new File(baseDir, dirs[j]).list(); - for (int i = 0; i < list.length; ++i) { - process(baseDir, dirs[j] + File.separator + list[i], - destDir, styleob); - } - } - } - } finally { - if (loader != null) { - loader.resetThreadContextLoader(); - loader = null; - } - liaison = null; - stylesheetLoaded = false; - baseDir = savedBaseDir; - } - } - - /** - * Set whether to check dependencies, or always generate; - * optional, default is false. - * - * @param force true if always generate. - */ - public void setForce(boolean force) { - this.force = force; - } - - /** - * Set the base directory; - * optional, default is the project's basedir. - * - * @param dir the base directory - **/ - public void setBasedir(File dir) { - baseDir = dir; - } - - /** - * Set the destination directory into which the XSL result - * files should be copied to; - * required, unless in and out are - * specified. - * @param dir the name of the destination directory - **/ - public void setDestdir(File dir) { - destDir = dir; - } - - /** - * Set the desired file extension to be used for the target; - * optional, default is html. - * @param name the extension to use - **/ - public void setExtension(String name) { - targetExtension = name; - } - - /** - * Name of the stylesheet to use - given either relative - * to the project's basedir or as an absolute path; required. - * - * @param xslFile the stylesheet to use - */ - public void setStyle(String xslFile) { - this.xslFile = xslFile; - } - - /** - * Set the optional classpath to the XSL processor - * - * @param classpath the classpath to use when loading the XSL processor - */ - public void setClasspath(Path classpath) { - createClasspath().append(classpath); - } - - /** - * Set the optional classpath to the XSL processor - * - * @return a path instance to be configured by the Ant core. - */ - public Path createClasspath() { - if (classpath == null) { - classpath = new Path(getProject()); - } - return classpath.createPath(); - } - - /** - * Set the reference to an optional classpath to the XSL processor - * - * @param r the id of the Ant path instance to act as the classpath - * for loading the XSL processor - */ - public void setClasspathRef(Reference r) { - createClasspath().setRefid(r); - } - - /** - * Set the name of the XSL processor to use; optional, default trax. - * Other values are "xalan" for Xalan1 and "xslp" for XSL:P, though the - * later is strongly deprecated. - * - * @param processor the name of the XSL processor - */ - public void setProcessor(String processor) { - this.processor = processor; - } - - /** - * Set the stylesheet url. - * - * @since JarDiff 0.2 - */ - public void setStyleurl(String styleurl) { - this.styleurl = styleurl; - } - - /** - * Add the catalog to our internal catalog - * - * @param xmlCatalog the XMLCatalog instance to use to look up DTDs - */ - public void addConfiguredXMLCatalog(XMLCatalog xmlCatalog) { - this.xmlCatalog.addConfiguredXMLCatalog(xmlCatalog); - } - - /** - * Load processor here instead of in setProcessor - this will be - * called from within execute, so we have access to the latest - * classpath. - * - * @param proc the name of the processor to load. - * @exception Exception if the processor cannot be loaded. - */ - private void resolveProcessor(String proc) throws Exception { - if (proc.equals("trax")) { - final Class clazz = loadClass(TRAX_LIAISON_CLASS); - liaison = (XSLTLiaison) clazz.newInstance(); - } else if (proc.equals("xslp")) { - log("DEPRECATED - xslp processor is deprecated. Use trax " - + "instead."); - final Class clazz = loadClass(XSLP_LIAISON_CLASS); - liaison = (XSLTLiaison) clazz.newInstance(); - } else if (proc.equals("xalan")) { - log("DEPRECATED - xalan processor is deprecated. Use trax " - + "instead."); - final Class clazz = loadClass(XALAN_LIAISON_CLASS); - liaison = (XSLTLiaison) clazz.newInstance(); - } else { - liaison = (XSLTLiaison) loadClass(proc).newInstance(); - } - } - - /** - * Load named class either via the system classloader or a given - * custom classloader. - * - * @param classname the name of the class to load. - * @return the requested class. - * @exception Exception if the class could not be loaded. - */ - private Class loadClass(String classname) throws Exception { - if (classpath == null) { - return Class.forName(classname); - } else { - loader = getProject().createClassLoader(classpath); - loader.setThreadContextLoader(); - Class c = Class.forName(classname, true, loader); - return c; - } - } - - /** - * Specifies the output name for the styled result from the - * in attribute; required if in is set - * - * @param outFile the output File instance. - */ - public void setOut(File outFile) { - this.outFile = outFile; - } - - /** - * specifies a single XML document to be styled. Should be used - * with the out attribute; ; required if out is set - * - * @param inFile the input file - */ - public void setIn(File inFile) { - this.inFile = inFile; - } - - /** - * Processes the given input XML file and stores the result - * in the given resultFile. - * - * @param baseDir the base directory for resolving files. - * @param xmlFile the input file - * @param destDir the destination directory - * @param stylesheet the stylesheet to use. - * @exception BuildException if the processing fails. - */ - private void process(File baseDir, String xmlFile, File destDir, - Object stylesheet) - throws BuildException { - - File outFile = null; - File inFile = null; - - try { - long styleSheetLastModified = 0L; - // JARDIFF: Added - if(stylesheet instanceof File) { - styleSheetLastModified = ( (File)stylesheet ).lastModified(); - } - inFile = new File(baseDir, xmlFile); - - if (inFile.isDirectory()) { - log("Skipping " + inFile + " it is a directory.", - Project.MSG_VERBOSE); - return; - } - - FileNameMapper mapper = null; - if (mapperElement != null) { - mapper = mapperElement.getImplementation(); - } else { - mapper = new StyleMapper(); - } - - String[] outFileName = mapper.mapFileName(xmlFile); - if (outFileName == null || outFileName.length == 0) { - log("Skipping " + inFile + " it cannot get mapped to output.", - Project.MSG_VERBOSE); - return; - } else if (outFileName == null || outFileName.length > 1) { - log("Skipping " + inFile + " its mapping is ambiguos.", - Project.MSG_VERBOSE); - return; - } - - outFile = new File(destDir, outFileName[0]); - - if (force - || inFile.lastModified() > outFile.lastModified() - || styleSheetLastModified > outFile.lastModified()) { - ensureDirectoryFor(outFile); - log("Processing " + inFile + " to " + outFile); - - configureLiaison(stylesheet); - liaison.transform(inFile, outFile); - } - } catch (Exception ex) { - // If failed to process document, must delete target document, - // or it will not attempt to process it the second time - log("Failed to process " + inFile, Project.MSG_INFO); - if (outFile != null) { - outFile.delete(); - } - - throw new BuildException(ex); - } - - } //-- processXML - - /** - * Process the input file to the output file with the given stylesheet. - * - * @param inFile the input file to process. - * @param outFile the destination file. - * @param stylesheet the stylesheet to use. - * @exception BuildException if the processing fails. - */ - private void process(File inFile, File outFile, Object stylesheet) - throws BuildException { - try { - long styleSheetLastModified = 0L; - // JARDIFF: Added - if(stylesheet instanceof File) { - styleSheetLastModified = ( (File)stylesheet ).lastModified(); - } - log("In file " + inFile + " time: " + inFile.lastModified(), - Project.MSG_DEBUG); - log("Out file " + outFile + " time: " + outFile.lastModified(), - Project.MSG_DEBUG); - log("Style file " + xslFile + " time: " + styleSheetLastModified, - Project.MSG_DEBUG); - if (force || inFile.lastModified() >= outFile.lastModified() - || styleSheetLastModified >= outFile.lastModified()) { - ensureDirectoryFor(outFile); - log("Processing " + inFile + " to " + outFile, - Project.MSG_INFO); - configureLiaison(stylesheet); - liaison.transform(inFile, outFile); - } else { - log("Skipping input file " + inFile - + " because it is older than output file " + outFile - + " and so is the stylesheet " + stylesheet, Project.MSG_DEBUG); - } - } catch (Exception ex) { - log("Failed to process " + inFile, Project.MSG_INFO); - if (outFile != null) { - outFile.delete(); - } - throw new BuildException(ex); - } - } - - /** - * Ensure the directory exists for a given file - * - * @param targetFile the file for which the directories are required. - * @exception BuildException if the directories cannot be created. - */ - private void ensureDirectoryFor(File targetFile) - throws BuildException { - File directory = fileUtils.getParentFile(targetFile); - if (!directory.exists()) { - if (!directory.mkdirs()) { - throw new BuildException("Unable to create directory: " - + directory.getAbsolutePath()); - } - } - } - - /** - * Get the factory instance configured for this processor - * - * @return the factory instance in use - */ - public Factory getFactory() { - return factory; - } - - /** - * Get the XML catalog containing entity definitions - * - * @return the XML catalog for the task. - */ - public XMLCatalog getXMLCatalog() { - return xmlCatalog; - } - - public Enumeration getOutputProperties() { - return outputProperties.elements(); - } - - - /** - * Get the Liason implementation to use in processing. - * - * @return an instance of the XSLTLiason interface. - */ - protected XSLTLiaison getLiaison() { - // if processor wasn't specified, see if TraX is available. If not, - // default it to xslp or xalan, depending on which is in the classpath - if (liaison == null) { - if (processor != null) { - try { - resolveProcessor(processor); - } catch (Exception e) { - throw new BuildException(e); - } - } else { - try { - resolveProcessor("trax"); - } catch (Throwable e1) { - try { - resolveProcessor("xalan"); - } catch (Throwable e2) { - try { - resolveProcessor("xslp"); - } catch (Throwable e3) { - e3.printStackTrace(); - e2.printStackTrace(); - throw new BuildException(e1); - } - } - } - } - } - return liaison; - } - - /** - * Create an instance of an XSL parameter for configuration by Ant. - * - * @return an instance of the Param class to be configured. - */ - public Param createParam() { - Param p = new Param(); - params.addElement(p); - return p; - } - - /** - * The Param inner class used to store XSL parameters - */ - public static class Param { - /** The parameter name */ - private String name = null; - - /** The parameter's value */ - private String expression = null; - - private String ifProperty; - private String unlessProperty; - private Project project; - - /** - * Set the current project - * - * @param project the current project - */ - public void setProject(Project project) { - this.project = project; - } - - /** - * Set the parameter name. - * - * @param name the name of the parameter. - */ - public void setName(String name) { - this.name = name; - } - - /** - * The parameter value - * NOTE : was intended to be an XSL expression. - * @param expression the parameter's value. - */ - public void setExpression(String expression) { - this.expression = expression; - } - - /** - * Get the parameter name - * - * @return the parameter name - * @exception BuildException if the name is not set. - */ - public String getName() throws BuildException { - if (name == null) { - throw new BuildException("Name attribute is missing."); - } - return name; - } - - /** - * Get the parameter's value - * - * @return the parameter value - * @exception BuildException if the value is not set. - */ - public String getExpression() throws BuildException { - if (expression == null) { - throw new BuildException("Expression attribute is missing."); - } - return expression; - } - - /** - * Set whether this param should be used. It will be - * used if the property has been set, otherwise it won't. - * @param ifProperty name of property - */ - public void setIf(String ifProperty) { - this.ifProperty = ifProperty; - } - - /** - * Set whether this param should NOT be used. It - * will not be used if the property has been set, otherwise it - * will be used. - * @param unlessProperty name of property - */ - public void setUnless(String unlessProperty) { - this.unlessProperty = unlessProperty; - } - /** - * Ensures that the param passes the conditions placed - * on it with if and unless properties. - */ - public boolean shouldUse() { - if (ifProperty != null && project.getProperty(ifProperty) == null) { - return false; - } else if (unlessProperty != null - && project.getProperty(unlessProperty) != null) { - return false; - } - - return true; - } - } // Param - - - /** - * Create an instance of an output property to be configured. - * @return the newly created output property. - * @since Ant 1.5 - */ - public OutputProperty createOutputProperty() { - OutputProperty p = new OutputProperty(); - outputProperties.addElement(p); - return p; - } - - - /** - * Specify how the result tree should be output as specified - * in the - * specification. - * @since Ant 1.5 - */ - public static class OutputProperty { - /** output property name */ - private String name; - - /** output property value */ - private String value; - - /** - * @return the output property name. - */ - public String getName() { - return name; - } - - /** - * set the name for this property - * @param name A non-null String that specifies an - * output property name, which may be namespace qualified. - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the output property value. - */ - public String getValue() { - return value; - } - - /** - * set the value for this property - * @param value The non-null string value of the output property. - */ - public void setValue(String value) { - this.value = value; - } - } - - /** - * Initialize internal instance of XMLCatalog - */ - public void init() throws BuildException { - super.init(); - xmlCatalog.setProject(getProject()); - } - - /** - * Loads the stylesheet and set xsl:param parameters. - * - * @param stylesheet the file form which to load the stylesheet. - * @exception BuildException if the stylesheet cannot be loaded. - */ - protected void configureLiaison(Object stylesheet) throws BuildException { - if (stylesheetLoaded && reuseLoadedStylesheet) { - return; - } - stylesheetLoaded = true; - - try { - log("Loading stylesheet " + stylesheet, Project.MSG_INFO); - // JARDIFF: ADDED - if(stylesheet instanceof File) { - liaison.setStylesheet((File) stylesheet); - } else { - if(liaison instanceof JDXSLTLiaison3) { - ((JDXSLTLiaison3)liaison). - setStylesheet((String) stylesheet); - } else { - String msg = "liaison does not support stylesheet urls"; - throw new BuildException(msg, getLocation()); - } - } - for (Enumeration e = params.elements(); e.hasMoreElements();) { - Param p = (Param) e.nextElement(); - if (p.shouldUse()) { - liaison.addParam(p.getName(), p.getExpression()); - } - } - // JARDIFF: Modified (nasty workaround) - if (liaison instanceof JDXSLTLiaison3) { - ((JDXSLTLiaison3) liaison).configure(this); - } - } catch (Exception ex) { - log("Failed to transform using stylesheet " + stylesheet, - Project.MSG_INFO); - throw new BuildException(ex); - } - } - - /** - * Create the factory element to configure a trax liaison. - * @return the newly created factory element. - * @throws BuildException if the element is created more than one time. - */ - public Factory createFactory() throws BuildException { - if (factory != null) { - throw new BuildException("'factory' element must be unique"); - } - factory = new Factory(); - return factory; - } - - /** - * The factory element to configure a transformer factory - * @since Ant 1.6 - */ - public static class Factory { - - /** the factory class name to use for TraXLiaison */ - private String name; - - /** - * the list of factory attributes to use for TraXLiaison - */ - private Vector attributes = new Vector(); - - /** - * @return the name of the factory. - */ - public String getName() { - return name; - } - - /** - * Set the name of the factory - * @param name the name of the factory. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Create an instance of a factory attribute. - * the newly created factory attribute - */ - public void addAttribute(Attribute attr) { - attributes.addElement(attr); - } - - /** - * return the attribute elements. - * @return the enumeration of attributes - */ - public Enumeration getAttributes() { - return attributes.elements(); - } - - /** - * A JAXP factory attribute. This is mostly processor specific, for - * example for Xalan 2.3+, the following attributes could be set: - *
    - *
  • http://xml.apache.org/xalan/features/optimize (true|false)
  • - *
  • http://xml.apache.org/xalan/features/incremental (true|false)
  • - *
- */ - public static class Attribute implements DynamicConfigurator { - - /** attribute name, mostly processor specific */ - private String name; - - /** attribute value, often a boolean string */ - private Object value; - - /** - * @return the attribute name. - */ - public String getName() { - return name; - } - - /** - * @return the output property value. - */ - public Object getValue() { - return value; - } - - public Object createDynamicElement(String name) throws BuildException { - return null; - } - - public void setDynamicAttribute(String name, String value) - throws BuildException { - // only 'name' and 'value' exist. - if ("name".equalsIgnoreCase(name)) { - this.name = value; - } else if ("value".equalsIgnoreCase(name)) { - // a value must be of a given type - // say boolean|integer|string that are mostly used. - if ("true".equalsIgnoreCase(value) - || "false".equalsIgnoreCase(value)) { - this.value = new Boolean(value); - } else { - try { - this.value = new Integer(value); - } catch (NumberFormatException e) { - this.value = value; - } - } - } else { - throw new BuildException("Unsupported attribute: " + name); - } - } - } // -- class Attribute - - } // -- class Factory - - /** - * Mapper implementation of the "traditional" way <xslt> - * mapped filenames. - * - *

If the file has an extension, chop it off. Append whatever - * the user has specified as extension or ".html".

- * - * @since Ant 1.6.2 - */ - private class StyleMapper implements FileNameMapper { - public void setFrom(String from) {} - public void setTo(String to) {} - public String[] mapFileName(String xmlFile) { - int dotPos = xmlFile.lastIndexOf('.'); - if (dotPos > 0) { - xmlFile = xmlFile.substring(0, dotPos); - } - return new String[] {xmlFile + targetExtension}; - } - } -} diff --git a/jardiff/src/java/org/osjava/jardiff/ant/JarDiffTask.java b/jardiff/src/java/org/osjava/jardiff/ant/JarDiffTask.java deleted file mode 100644 index b9dd45fd..00000000 --- a/jardiff/src/java/org/osjava/jardiff/ant/JarDiffTask.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * org.osjava.jardiff.ant.JarDiffTask - * - * $Id: IOThread.java 1952 2005-08-28 18:03:41Z cybertiger $ - * $URL: https://svn.osjava.org/svn/osjava/trunk/osjava-nio/src/java/org/osjava/nio/IOThread.java $ - * $Rev: 1952 $ - * $Date: 2005-08-28 18:03:41 +0000 (Sun, 28 Aug 2005) $ - * $Author: cybertiger $ - * - * Copyright (c) 2005, Antony Riley - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name JarDiff nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.jardiff.ant; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.URL; -import java.util.Set; -import java.util.HashSet; -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.SAXTransformerFactory; -import javax.xml.transform.sax.TransformerHandler; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.osjava.jardiff.JarDiff; -import org.osjava.jardiff.DiffException; -import org.osjava.jardiff.StreamDiffHandler; -import org.osjava.jardiff.SimpleDiffCriteria; - -/** - * Process two jarfiles generating a public API difference report. - * This is useful for keeping track of API changes between versions of a - * project. - * - * @author Antony Riley - */ -public class JarDiffTask extends Task { - - /** - * The jarfile this diff is from. - */ - private File fromJar = null; - - /** - * The jarfile this diff is to. - */ - private File toJar = null; - - /** - * The file to write the report to. - */ - private File out = null; - - /** - * The name to use for the from version. - */ - private String fromName = null; - - /** - * The name to use for the to verison. - */ - private String toName = null; - - /** - * Force output, even if the existing output is newer than - * the jar files. - */ - private boolean force = false; - - /** - * Run the task, generating the jardiff report. - * - * @throws BuildException When there is an error creating the diff, - * When there is a problem with the xml parser, - * When there is a problem with the xslt transformer - * When the attributes specified are invalid. - */ - public void execute() throws BuildException { - try { - if(fromJar == null) { - throw new BuildException("no fromjar file specified", - getLocation()); - } - if(toJar == null) { - throw new BuildException("no tojar file specified", - getLocation()); - } - if(out == null) { - throw new BuildException("no out file specified", - getLocation()); - } - if(fromName == null) { - fromName = fromJar.getName(); - } - if(toName == null) { - toName = toJar.getName(); - } - if(!fromJar.exists() || !fromJar.isFile() || !fromJar.canRead()) { - String msg = "fromjar is not a file, or cannot be read"; - throw new BuildException(msg, getLocation()); - } - if(!toJar.exists() || !toJar.isFile() || !toJar.canRead()) { - String msg = "tojar is not a file, or cannot be read"; - throw new BuildException(msg, getLocation()); - } - long outModified = out.lastModified(); - long oldModified = fromJar.lastModified(); - long newModified = toJar.lastModified(); - if(force || oldModified > outModified || newModified > outModified) - { - log("Writing xml api diff to "+out); - JarDiff jd = new JarDiff(); - jd.setOldVersion(fromName); - jd.setNewVersion(toName); - jd.loadOldClasses(fromJar); - jd.loadNewClasses(toJar); - jd.diff( - new StreamDiffHandler(new FileOutputStream(out)), - new SimpleDiffCriteria() - ); - } - } catch (DiffException de) { - throw new BuildException(de); - } catch (IOException ioe) { - throw new BuildException(ioe); - } - } - - /** - * Set the from jar file. - * Required attribute. - * - * @param fromJar a jar file. - */ - public void setFromjar(File fromJar) { - this.fromJar = fromJar; - } - - /** - * Set the to jar file. - * Required attribute. - * @param toJar a jar file. - */ - public void setTojar(File toJar) { - this.toJar = toJar; - } - - /** - * Set the out file. - * Required attribute. - * - * @param out an output file. - */ - public void setOut(File out) { - this.out = out; - } - - /** - * Set the from jar visible name. - * Optional attribute. - * Defaults to the filename of fromjar. - * - * @param fromName a visible name. - */ - public void setFromname(String fromName) { - this.fromName = fromName; - } - - /** - * Set the to jar visible name. - * Optional attribute. - * Defaults to the filename of tojar. - * - * @param toName a visible name. - */ - public void setToname(String toName) { - this.toName = toName; - } - - /** - * Force output even if there is an existing diff file which is - * newer than the source jar files. - * Optional attribute. - * Defaults to false. - * - * @param force true to force output, false otherwise - */ - public void setForce(boolean force) { - this.force = force; - } -} diff --git a/jardiff/src/resources/jardiff.properties b/jardiff/src/resources/jardiff.properties deleted file mode 100644 index 2231c015..00000000 --- a/jardiff/src/resources/jardiff.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Ant properties defining tasks. -jdxslt=org.osjava.jardiff.ant.JDXSLTProcess -jardiff=org.osjava.jardiff.ant.JarDiffTask diff --git a/jardiff/src/scripts/jardiff b/jardiff/src/scripts/jardiff deleted file mode 100755 index 62522e62..00000000 --- a/jardiff/src/scripts/jardiff +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -java -jar ~/bin/lib/jardiff-0.2-uber.jar $@ diff --git a/jardiff/src/xsl/jardiff-html-base.xsl b/jardiff/src/xsl/jardiff-html-base.xsl deleted file mode 100644 index f07b4afb..00000000 --- a/jardiff/src/xsl/jardiff-html-base.xsl +++ /dev/null @@ -1,457 +0,0 @@ - - - - - - - - - - - - - - - - Comparing <xsl:value-of select="@old"/> to <xsl:value-of select="@new"/> - - - - - - - - - - -

Comparing to

- -

API diff generated by JarDiff

- - -
- - - - - - - - - - -

Removed classes

-
    - -
  • - - - - - - - - -
  • -
    -
-
-
- - - - -

Added classes

-
    - -
  • - - - - - - - - -
  • -
    -
-
-
- - - - -

Changed classes

-
    - -
  • - - - -

    - - - -
    Removed:
    -
      - -
    • - - - - - - - -
    • -
      - -
    • - - - - - - - - - - - - - -
    • -
      -
    -
    - -
    Added:
    -
      - -
    • - - - - - - - -
    • -
      - -
    • - - - - - - - - - - - - - -
    • -
      -
    -
    - -
    Changed:
    -
      - -
    • - - From: - - - - - - - - -
      - - To: - - - - - - - - -
    • -
      - -
    • - - From: - - - - - - - - - -
      - - To: - - - - - - - - - -
    • -
      - -
    • - - From: - - - - - - - - - - - - - - - -
      - - To: - - - - - - - - - - - - - - - -
    • -
      -
    -
    -
  • -
    -
-
-
- - - - - - - - - - - - - - - - - - - - - - - (, ) - - - - - - deprecated: - - final - static - synchronized - abstract - - - - - - - - - - - - - (, ) throws , - - - - - - - deprecated: - - final - static - transient - volatile - - - - - = ; - - - - - - - deprecated: - - abstract - static - final - - - - extends - - implements - - , - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [] - - - - - - - - - - - - - -
diff --git a/jardiff/src/xsl/jardiff-html.xsl b/jardiff/src/xsl/jardiff-html.xsl deleted file mode 100644 index e09bee8c..00000000 --- a/jardiff/src/xsl/jardiff-html.xsl +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/jardiff/src/xsl/jardiff-text.xsl b/jardiff/src/xsl/jardiff-text.xsl deleted file mode 100644 index 435f20ad..00000000 --- a/jardiff/src/xsl/jardiff-text.xsl +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - Comparing to - -API diff generated by JarDiff http://www.osjava.org/jardiff/ - - - - - - - - -Class removed: - - - - - - -Class added: - - - - - - -Class changed: - - Methods removed: - - - - - - - - Methods added: - - - - - - - - Fields removed: - - - - - - Fields added: - - - - - - Class descriptor changed: - old: - - - - new: - - - - - - - - Method changed: - old: - - - - - - new: - - - - - - - - - - Field changed: - old: - - - - new: - - - - - - - - - - deprecated: - - abstract - static - final - - - - extends - - implements - - - - , - - - - - -deprecated: - - final - static - synchronized - abstract - varargs - - - - - - - - - - - - - (, ) throws , ; - - - -deprecated: - - final - static - synchronized - abstract - transient - volatile - - - - - = ; - - - - - - - - - - - - - - - - - - - - - [] - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jardiff/src/xsl/jardiff-xhtml.xsl b/jardiff/src/xsl/jardiff-xhtml.xsl deleted file mode 100644 index eee5b43f..00000000 --- a/jardiff/src/xsl/jardiff-xhtml.xsl +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/jardiff/xdocs/CLI.xml b/jardiff/xdocs/CLI.xml deleted file mode 100644 index 49443465..00000000 --- a/jardiff/xdocs/CLI.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - Antony Riley - Examples - - -
-

- Using jardiff is relatively simple, I suggest just grabbing the - jardiff-0.1-uber.jar, as this is executable from the command line, - and includes all the dependencies. -

-

If you ever need to list the options that jardiff understands

- java -jar jardiff-0.1-uber.jar --help -

This lists all the options as follows:

-
-usage: JarDiff -f <from jar> -t <to jar> [-F <from name>] [-T <to name>]
-               [[-o <xml|html|xhtml|text>]|[-x <xsl file>]] [-O <file>]
-               [-s <href>] [-fa <href>] [-ta <href>]
-
- -o,--output-format    output format, xml or html
- -F,--from-name        from name
- -T,--to-name          to name
- -O,--out              output file
- -f,--from             from jar file
- -h,--help             print help on command line arguments
- -t,--to               to jar file
- -x,--xsl              custom xsl sheet to format output with
- -fa,--from-api        relative location of from api
- -ta,--to-api          relative location of to api
- -s,--stylesheet       stylesheet to link to when generating html
-      
-

- For instance, the following would be a typical invocation: -

- java -jar jardiff-0.1-uber.jar -f jardiff-0.1.jar -t jardiff-0.2.jar -o text -

- This will print out in text the public API changes between jardiff-0.1.jar and jardiff-0.2.jar
- Another typical invocation would be to write a html report on the differences between two versions of a project, for example: -

- java -jar jardiff-0.1-uber.jar -f myproject-0.1.jar -t myproject-0.2.jar -o html -O diff-0.1-0.2.html -

- This will write a file called "diff-0.1-0.2.html" in the current directory.
- If you want to read the raw xml report. (Jardiff uses xml for it's own - internal format, and uses built in stylesheets to convert output to - text, html and xhtml) you would use -o xml.

-

- If you're brave enough to build your own style sheet for jardiff. (It's - probably a good idea to use one of the built in stylesheets and build - upon it if you want to do this, the built in xml format is not that - easy to deal with), you would specify -x mystylesheet.xsl. -

-

- The stylesheet argument specifies a relative href to a stylesheet to - be used, this is used instead of the generated style information. -

-

- The from-api and to-api arguments specify hrefs to the api docs for the - from api, and api docs for the to api. -

-

- An example of command line execute is included in the distribution - in the src/examples directory. -

-
- -
diff --git a/jardiff/xdocs/HowTo.xml b/jardiff/xdocs/HowTo.xml deleted file mode 100644 index 6f638f8f..00000000 --- a/jardiff/xdocs/HowTo.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - Antony Riley - How To - - -
-

- Using jardiff is relatively simple, I suggest just grabbing the - jardiff-0.1-uber.jar, as this is executable from the command line, - and includes all the dependencies. -

-

If you ever need to list the options that jardiff understands

- java -jar jardiff-0.1-uber.jar --help -

This lists all the options as follows:

-
-usage: JarDiff -f <from jar> -t <to jar> [-F <from name>] [-T <to name>]
-               [[-o <xml|html|xhtml|text>]|[-x <xsl file>]] [-O <file>]
- -o,--output-format    output format, xml or html
- -F,--from-name        from name
- -T,--to-name          to name
- -O,--out              output file
- -f,--from             from jar file
- -h,--help             print help on command line arguments
- -t,--to               to jar file
- -x,--xsl              custom xsl sheet to format output with
-      
-

- For instance, the following would be a typical invocation: -

- java -jar jardiff-0.1-uber.jar -f jardiff-0.1.jar -t jardiff-0.2.jar -o text -

- This will print out in text the public API changes between jardiff-0.1.jar and jardiff-0.2.jar
- Another typical invocation would be to write a html report on the differences between two versions of a project, for example: -

- java -jar jardiff-0.1-uber.jar -f myproject-0.1.jar -t myproject-0.2.jar -o html -O diff-0.1-0.2.html -

- This will write a file called "diff-0.1-0.2.html" in the current directory.
- If you want to read the raw xml report. (Jardiff uses xml for it's own - internal format, and uses built in stylesheets to convert output to - text, html and xhtml) you would use -o xml.

-

- If you're brave enough to build your own style sheet for jardiff. (It's - probably a good idea to use one of the built in stylesheets and build - upon it if you want to do this, the built in xml format is not that - easy to deal with), you would specify -x mystylesheet.xsl. -

-
- -
diff --git a/jardiff/xdocs/RoadMap.xml b/jardiff/xdocs/RoadMap.xml deleted file mode 100644 index e664d4df..00000000 --- a/jardiff/xdocs/RoadMap.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - Antony Riley - Examples - - -
-

- What follows is a rough plan of what will be implemented in what order - when it comes to JarDiff, unfortunately I cannot give concrete release - dates for any of these, as often my spare time is at a premium. -

-
-
-

- Version 0.1 included the following features. -

-
    -
  • BSD style license
  • -
  • XML output format
  • -
  • Text output format
  • -
  • (x)html output format
  • -
  • Lightweight and fast
  • -
  • Good command line interface
  • -
  • Simple extensible API
  • -
  • Supports JDK 1.4 or higher
  • -
-
-
-

- Version 0.2 includes the following additional features. -

-
    -
  • Ant task interface (supports JDK 1.2 or higher)
  • -
  • Better formatted html output
  • -
  • Ability to specify a custom stylesheet for html output
  • -
  • Abillty to link html output to javadocs
  • -
-
-
-

- Version 0.3 will include the following additional features. -

-
    -
  • Maven interface
  • -
  • Ability to specify permissions to produce diff for.
    - (private, package, protected, or public, and/or synthetic)
  • -
  • Major change to API to mirror java class loading. - (needed for dependency loading, which is needed to generate compatability information).
  • -
-
-
-

- Version 0.4 will include the following additional features. -

-
    -
  • Change compatability information (unknown, none, source, binary, all)
  • -
  • Ability to fail maven and ant tasks if jars are not compatible.
  • -
-
-
-

- Version 0.5 will include the following additional features. -

-
    -
  • Eclipse plugin
  • -
  • JDK 1.5 features (Enums, generics, varargs)
  • -
-
-
-

- Version 1.0 will include the following additional features. -

-
    -
  • Stabilised API
  • -
  • Bug fixes
  • -
  • XML Schema for diff output
  • -
-
- -
diff --git a/jardiff/xdocs/ant.xml b/jardiff/xdocs/ant.xml deleted file mode 100644 index 77aeb1c6..00000000 --- a/jardiff/xdocs/ant.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - Antony Riley - Examples - - -
-

- To use JarDiff from an ant build script, is relatively trivial, - here is an example: -

-

-
-  
-  
-  
-  
-  
-  
-  
-  
-  
-  
-
-
-  
-    
-    
-      
-      
-      
-    
-  
-
-
-]]>
-

- There is a fully functional ant build script in src/examples in the - distribution. -

-
-
-

- The jardiff task generates an xml document describing the changes - between two jar files. -

-

- The jardiff task takes the following options: -

- - - - - - - - -
AttributeTypeMeaningRequireddefault
fromjarfileFrom jar fileYesnone
tojarfileTo jar fileYesnone
outfileOutput xml fileYesnone
fromnamestringName of from versionNofromjar filename
tonamestringName of to versionNotojar filename
forcebooleanOverwrite output file if it already exists, and is newer than both source jar files.NoNo
-
-
-

- The jdxslt task is an extension of the built in and xslt task, which - allows a stylesheet to be specified as a URL (in the example, we use - an xslt contained in the jardiff jar file, which can be resolved - to a url, and then passed into an xslt task as the style). -

-

- It is fine to use the built in ant xslt task, as the only modification - I made was to allow specifying the stylesheet as a url, as I see - no reason to have to extract a stylesheet from a jarfile before using - it. -

-

- The jdxslt task takes exactly the same arguments as the xslt core task - with the following modifications. -

- - - - -
AttributeTypeMeaningRequireddefault
stylefileStylesheet to useYes, or styleurlnone
styleurlstringURL of stylesheet to useYes, or stylenone
-
- -
diff --git a/jardiff/xdocs/navigation.xml b/jardiff/xdocs/navigation.xml deleted file mode 100644 index 8fbfba9c..00000000 --- a/jardiff/xdocs/navigation.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - JarDiff - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jpe/JPEz.txt b/jpe/JPEz.txt deleted file mode 100644 index d68b776d..00000000 --- a/jpe/JPEz.txt +++ /dev/null @@ -1,31 +0,0 @@ -From the JIRA project for JPEz (JPE for the Zaurus): - -* Machines do not include Zaurus. Add two Z form factors? - -* Compilation fails as tools.jar does not work on Z. - Need to switch to a command line compilation method, rather than using the tools.jar Javac. This needs to be pluggable. - Plug in compiler system written. Needs testing on the zaurus at some point. - -* Unable to run Java programs on the Z - Nothing happens when you run the class. God knows why. - -* IPKG package lacks icon - -* Fonts don't do change - They do on the Mac though, so a Z thing - -* JPEz icon opens up in PDA mode - You can only open in clam shell mode if you type jpe on the command line. Why?? - If you hold down on icon, and turn off magnify, then it opens fine. - So how to put this in the install package? - -* Pluggable tab completion - Need to co-opt the tab key for completing text. This would be looked up against a properties file of some kind. - -* IPKG plugin - Take the Deploy app + new genjava-ipkg package and integrate them into JPEz. - -* jpe.properties is too much of a pain - The jpe.properties needs to be in the CLASSPATH. It wasn't before due to psion bugs. - This now loads using the correct ResourceBundle system. - This is not working correctly, so re-opening it until it is satisfactorily fixed. diff --git a/jpe/LICENSE.txt b/jpe/LICENSE.txt deleted file mode 100644 index 3912109b..00000000 --- a/jpe/LICENSE.txt +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) 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 -this service 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 make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. 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. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -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 -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the 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 a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE 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. - - 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 -convey 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 2 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, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision 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, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This 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 Library General -Public License instead of this License. diff --git a/jpe/docs/config.xml b/jpe/docs/config.xml deleted file mode 100644 index 8f1718f7..00000000 --- a/jpe/docs/config.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - -15 -c:\jpe\jpe-src0.9\jpe.properties -C:\generationjava\com\generationjava\generate\generators\ -C:\generationjava\com\generationjava\io\xml\XMLParser.java -Arial -5 -netbook - - - - - -C:\generationjava\com\generationjava\cards\Card.java - - - - - -C:\generationjava\com\generationjava\generate\util\ObjectModelHelper.java - - - - - -C:\generationjava\com\generationjava\cards\Pack.java - - - - - -C:\generationjava\com\generationjava\generate\generators\XMLPickler.java - - - - - -false -C:\generationjava\com\generationjava\io\xml\XMLParser.java -0 - - - - - -false -C:\generationjava\com\generationjava\generate\generators\XMLPickler.java -0 - - - - - -false -C:\generationjava\com\generationjava\foodilizer\Foodilizer.java -2307 - - - - - -false -c:\jpe\jpe-src0.9\\readme.txt -0 - - diff --git a/jpe/docs/readme.txt b/jpe/docs/readme.txt deleted file mode 100644 index 71dff1ef..00000000 --- a/jpe/docs/readme.txt +++ /dev/null @@ -1,245 +0,0 @@ -JPE 0.9.** - bayard@generationjava.com -(http://www.generationjava.com/java/JPE.shtml) - -Licenced under GPL. - -A series of patches and functionality enhancements to version -0.9b. - -New functionalities: - - JStyle added in. Let's you reformat your java code. - Autoindentation. Makes your life easier. - Regexp search and replace. - Regexp search, hidden behind Find. Start your find with / and - it is automatically a regexp find. - Import text. - Create from templates. - Revert to saved file. - Improved shortcut keys. IMO :) - Recently opened files list. - Run Garbage Collector. - Separate JPE application error log. - Imports fixing. Searches your source and works out the import - statements for you. - Plus many bug-fixes. - -Recent new things - -To upgrade JPE v0.9.** on Epoc: - Copy jpe.jar over the top of your existing: - C:\System\Apps\JPE\jpe.jar - Copy jstyle.jar and gnu-regexp-1.0.8.jar into the same directory. - Amend the jpe.txt file to include the above two jar's in the classpath. - Run JPE! :) - -********** ORIGINAL readme.txt *********** - - JPE 0.9b - Java Psion Editor / Readme - ----------------------------------------------------------- - - Released under the OpenSource GNU-Licence - (c) Submarine - Daniel Ockeloen, Thanks to psion netherlands - - The Epoc parts (loader, logo, installer) where made by Oliver - Toelker for which many thanks. - - This is a beta release of a programming tool that allows me - to use my netbook as a on the road programming tool. Im normally - not into writing frontend code (like a editor) so since this is a - opensource project please fix my mistakes. My first goals are very - simple i want a editor that allows me to work on multiple files switch - between them, compile them using javac and run them. I started out - with a good look at MiniEdit from M.Tjioe based on a example made - in 1997 bij John Jensen not much code is left of that but i like to - thank them for a running example that i could base this work on. - - How to install - ------------------ - - You probably allready used the installed and started JPE - using the application bar. Ifso then only make sure you have - installed the missing.jar file correctly (so you can compile). - - To run and use JPE you need to have a epoc32 release 5 with - the java runtime installed. Last but not least you also need a - new classes.zip that holds the missing classes not installed by - the symbian jdk. - - You can download the new classes.zip (thanks to John Davies) - from http://www.davies.lu/Java. - - Install the zip file as d:\Classes\lib\missing.jar , if you don't - jpe will give a error ones you try to compile something. You - can edit the classpath in jpe.txt. - - you can also start JPE from inside eshell/JShell with the following - command line : - - java -cp d:\Classes\lib\missing.jar;c:\MJC;c:\JPE JPE - - optional commands - - -Djpe.home=e:\prg\jpe (override auto find jpe.home) - - Using JPE - ------------- - - The idea of JPE is to keep the number of actions needed to load/edit - compile and run your programs with as low as possible. One of the - ways to do this is to try to be stateless between uses JPE. This - means that JPE remembers what files you had you had open and what - lines you where working on. It saves the state of JPE and the files in - XML format in a file called config.xml. - - The menu's are explained below but i use it in the following way : - I open files that will be places in my 'Opened' menu i can - switch to them at any time. JPE remembers the state of each file once - i switch. With crlt-m i can compile the file i now have - selected when done the title bar tells me if i have errors ifso - i can switch (toggle infact) with crtl-h to the error page and back. - Compile also autosaves before the compile. I can close files ones - i don't need them in your current set. Well thats about it the rest - should make sense.The font/fontsize and other setups are also - remembered by JPE. - - - TitleBar - ---------- - - The titlebar inside JPE is used (to save space) as feedback and - input system. Most command will give feedback using this bar so - keep your eye on it. Also command like find, run, goto etc etc use - it to obtain input from you. - - feedback - general feedback on actions inside the bar, default - it shows you the filename of the selected file. - - input - it can ask you to input a string for example when doing - a search. it can also ask you for one key dialog like - on exit or save etc etc. - - status - at the end of the titlebar it shows you the current line - number and 3 possible indicators : - - s for saved/unchanged - c for the file is compiled without errors - l file is locked (readonly mode). - - Ctrl-keys - ------------ - - JPE provides alot of key bindings for most used command. for - example using the crtl-m, crtl-h, crtl-g , crtl-d and crtl-r combo you - can edit, compile, debug run and see output all without using any - menu's. A few handy ones are : - - ctrl-e - Exit JPE - ctrl-x - Cut - ctrl-c - Copy - ctrl-v - Paste - ctrl-f - Find - ctrl-shift-f Find again - ctrl-g - Goto first compile error - ctrl-shift-g Goto line number - ctrl-d - Goto/Toggle debug window - ctrl-h - Goto/Toggle error window - ctrl-m - Compile file - ctrl-r - Run as application - ctrl-shift-r Run as application with params - ctrl-p - Font size up - ctrl-o -Font size down - - File menu - ------------- - - new - Creates a new file under the name untitled*.txt - - Open - Opens a file using a file requester - - Close - Close a file (unload it from JPE and the Opened menu) - - Lock/unlock - A toggle that makes the file read only or not - inside JPE. This is usefull for heaving files open - to look at them but makes sure you can't change - them (happens alot on a small keyboard). - - Save - saves a file under its old name - - Save as - ask user for new name and save it as such - - Exit - check if all files are saved and exit JPE - - - Edit Menu - ------------- - - Cut - Copy the selected text area to the clipboard and remove - it from the selected text file. - - Copy - Copy the selected test area to the clipboard - - Paste - Insert the text on the clipboard in this text area at - the current pos. - - Find - Find a given text in the current text - - Find Again - Find the text again from the current cursor position - - Goto Line - Ask for a line number and jump to it - - Goto Error - Jump to the first compile error if possible, file - must be 'compiled' to make this work - - Select All - Select the whole text Area - - - Log Menu - ------------- - - StdOut - Show the standard output of JPE, the compiler and - the running applications started by JPE. - - StdErr - Shows the standard error output of JPE, the compiler - and running applications started by JPE. - - - Extra Menu - --------------- - - Compile - Save and compile the selected file using the java - compiler, output if any in stdErr (ctrl-h) - - Run as App - Run the current file as a java application - - Run as with param - Run like application with parameter line - - Font up - Make the current font bigger - - Font down - Make the current fonr smaller - - Arial - Switch to the Arial font - - Courier - Switch to the Courier font - - Times - Switch to the New Times Roman font - - Machine - Switch to prefered machine setup - - - Opened - ----------- - - Well it holds the opened files and you can switch to them - using this pulldown. - - - - have Fun and remember this is a beta-release, - - Daniel Ockeloen - daniel@submarine.nl - - - - \ No newline at end of file diff --git a/jpe/maven.xml b/jpe/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/jpe/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/jpe/project.properties b/jpe/project.properties deleted file mode 100644 index 893c0f22..00000000 --- a/jpe/project.properties +++ /dev/null @@ -1,22 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven2/,http://repo1.maven.org/maven/ -maven.changelog.factory=org.apache.maven.cvslib.CvsChangeLogFactory - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=../1x1.gif - -maven.jar.mainclass=com.generationjava.apps.jpe.JPE - -maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory - -maven.checkstyle.properties=../hen_checkstyle.xml - -maven.javadoc.stylesheet = ../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/jpe/project.xml b/jpe/project.xml deleted file mode 100644 index 6ab8a286..00000000 --- a/jpe/project.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - 3 - jpe - jpe - 0.9.11.1 - - OSJava - http://www.osjava.org/ - /images/osjava.gif - - 1999 - com.generationjava.apps.jpe - /images/1x1.gif - - - jpe - - - The Java PDA Editor. An IDE for PDA's, originally written for the Psion platform and now under development for the Sharp Zaurus c760. - - - Java PDA Editor - - http://www.osjava.org/jpe/ - http://issues.osjava.org:8080/jira/browse/BrowseProject.jspa?id=xxxxx - dist.osjava.org/maven/jpe - /sites/org/osjava/www/releases/official/jpe/ - /sites/org/osjava/www/releases/official/jpe/ - - - scm:svn:http://svn.osjava.org/svn/osjava/trunk/jpe - http://svn.osjava.org/svn/osjava/trunk/jpe - - - - - - Henri Yandell - hen - bayard@generationjava.com - GenerationJava - - Java Developer - - - - - - - - jstyle - unknown - - - - gnu-regexp - 1.1.4 - - - - - - bayard@www.generationjava.com - - src/java - - src/test - - - - **/*Test.java - - - - - - - - include = *.properties - - - - - - - diff --git a/jpe/src/java/com/generationjava/apps/jpe/AbstractHandler.java b/jpe/src/java/com/generationjava/apps/jpe/AbstractHandler.java deleted file mode 100644 index faab38f9..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/AbstractHandler.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.generationjava.apps.jpe; - -import java.awt.Menu; -import java.awt.MenuBar; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -/** -* base class for all the handlers JPE uses to allow for loadable parts -* still needs alot of work -*/ -public class AbstractHandler implements ActionListener, Handler, AskInterface { - private JPE jpe; - private String name; - - /** - * construct the handler - */ - public AbstractHandler(JPE jpe) { - this("Unknown",jpe); - } - - public AbstractHandler(String name, JPE jpe) { - setJPE(jpe); - setName(name); - } - - public JPE getJPE() { - return jpe; - } - - public void setJPE(JPE jpe) { - this.jpe = jpe; - } - - public String getText(String key) { - return TextController.getInstance().getText(key); - } - - public String getText(String key, Object value) { - return TextController.getInstance().getText(key,value); - } - - public String getText(String key, Object value1, Object value2) { - return TextController.getInstance().getText(key,value1,value2); - } - - public String getText(String key, Object[] vals) { - return TextController.getInstance().getText(key,vals); - } - /** - * create menu, should be overridden by its subclasses - */ - public void createMenu(MenuBar bar) { - Menu m = new Menu(getName()); - m.add(getName()); - m.addActionListener(this); - bar.add(m); - } - - /** - * return the name of the handler - */ - public String getName() { - return name; - } - - public void setName(String s) { - name = s; - } - - /** - * awt callback handler should be overriden by its subclasses - */ - public void actionPerformed(ActionEvent evt) { - String cmd = evt.getActionCommand(); - System.out.println(getName()+"="+cmd); - } - - /** - * - */ - public void askCallback(String command,String result) { - System.out.println("AskCall back used with cmd='"+command+"' and result='"+result+"' should be overridden by subclass"); - } -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/AskInterface.java b/jpe/src/java/com/generationjava/apps/jpe/AskInterface.java deleted file mode 100644 index 71352a2b..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/AskInterface.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.generationjava.apps.jpe; - -/** -* ask interface is used as a callback system for input dialog handler -* its using a callback so i don't have to use a extra thread -*/ -interface AskInterface { - public void askCallback(String command,String result); -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/Compiler.java b/jpe/src/java/com/generationjava/apps/jpe/Compiler.java deleted file mode 100644 index 6dfdf8e9..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/Compiler.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Created on Aug 23, 2003 - */ -package com.generationjava.apps.jpe; - -import java.io.PrintStream; - -/** - * Plug-in compiler so that different platforms may have - * different compiling. - * - * @author hen - */ -public interface Compiler { - - public void compile(String filename) throws CompilerException; - public void setErrorStream(PrintStream errorStream); - -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/CompilerException.java b/jpe/src/java/com/generationjava/apps/jpe/CompilerException.java deleted file mode 100644 index 8826f35e..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/CompilerException.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Created on Aug 23, 2003 - */ -package com.generationjava.apps.jpe; - -/** - * @author hen - */ -public class CompilerException extends Exception { - - public CompilerException(Throwable thble) { - super(thble.getMessage()); - } - -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/ConfigHandler.java b/jpe/src/java/com/generationjava/apps/jpe/ConfigHandler.java deleted file mode 100644 index f96c14e0..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/ConfigHandler.java +++ /dev/null @@ -1,219 +0,0 @@ -package com.generationjava.apps.jpe; - -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.StringTokenizer; -import java.util.Vector; - -/** - * Config handler reads, keeps and stores all the states within - * JPE. The current load/storage model is based on a XML file - * format. - */ -public class ConfigHandler extends AbstractHandler { - - // Current Config file (config.xml) - OpenFile file; - - // Hashtable with Vectors of Hashtables per xml type - Hashtable props=new Hashtable(); - - // Construct new Config handler - public ConfigHandler(JPE jpe) { - super("Config",jpe); - - // Open the config file within the defined path in getMyPath() - file=new OpenFile(getJPE().getMyPath()+"/config.xml"); - if (file!=null) { - - // read the XML based config file. - props=readXMLConfig(file); - } - } - - - /** - * get property within named node with given key - * will only return the first one !! - */ - public String getProperty(String nodename, String key) { - - // get the correct Vector - Object obj=props.get(nodename); - if (obj!=null) { - - // check if found object is a Vector (should be) - if (obj instanceof Vector) { - - // So its a Vector lets cast it one. - Vector vec=(Vector)obj; - - // obtain the _first_ Hashtable with keys/values from Vector - Hashtable onenode=(Hashtable)vec.elementAt(0); - - // return the value defined by the wanted key - return((String)onenode.get(key)); - } - } - return(null); - } - - - /** - * store a new value for variable defined by key in the connect - * xml node (defined by nodename) - */ - public void putProperty(String nodename, String key, String value) { - // did we allready have a node under this type ? - Object obj=props.get(nodename); - if (obj!=null) { - if (obj instanceof Vector) { - // yes, then update this node - Vector vec=(Vector)obj; - Hashtable onenode=(Hashtable)vec.elementAt(0); - onenode.put(key,value); - } - } else { - // no, create a Vector and store the key/value - Vector vec=new Vector(); - Hashtable onenode=new Hashtable(); - onenode.put(key,value); - } - // sync the changed to disk - syncConfigFile(); - } - - /** - * store a new properties vector, watch out replaces all nodes - * of the given type ! - */ - public void putProperties(String nodename, Vector values) { - props.put(nodename,values); - // sync to disk ? - syncConfigFile(); - } - - /** - * get the properties vector of the wanted type - */ - public Vector getProperties(String nodename) { - // get the object rom our props - Object obj=props.get(nodename); - if (obj!=null) { - // object found is it a vector (should be) - if (obj instanceof Vector) { - // cast it to Vector and return it - Vector vec=(Vector)obj; - return(vec); - } - } - // not vector found under the wanted name return null - return(null); - } - - - /** - * convert the openfile to props (expects the file to be - * xml). Very basic xml reader will be replaced in time but - * works for now) - */ - public static Hashtable readXMLConfig(OpenFile file) { - Hashtable results=new Hashtable(); - String body=file.getText(); - int pos=body.indexOf("")); - String begintoken="<"+key+">"; - endtoken=""; - - String value=nodedata.substring(nodedata.indexOf(begintoken)+begintoken.length()); - value=value.substring(0,value.indexOf(endtoken)); - - results.put(key,value); - - nodedata=nodedata.substring(nodedata.indexOf(endtoken)+endtoken.length()); - bpos=nodedata.indexOf("<"); - } - return(results); - } - - /** - * save currect props file back to disk as xml. - */ - public void syncConfigFile() { - String body=""; - Enumeration e=props.keys(); - while (e.hasMoreElements()) { - String key=(String)e.nextElement(); - Vector vec=(Vector)props.get(key); - Enumeration f=vec.elements(); - while (f.hasMoreElements()) { - Hashtable onenode=(Hashtable)f.nextElement(); - String nodename=(String)onenode.get("nodename"); - body+="\n"; - body+="\n"; - body+="<"+nodename+">\n"; - Enumeration g=onenode.keys(); - while (g.hasMoreElements()) { - String fkey=(String)g.nextElement(); - String fvalue=(String)onenode.get(fkey); - if (!fkey.equals("nodename")) { - body+="<"+fkey+">"+fvalue+"\n"; - } - } - body+="\n\n"; - } - } - file.setText(body); - file.saveFile(); - } - -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/EditHandler.java b/jpe/src/java/com/generationjava/apps/jpe/EditHandler.java deleted file mode 100644 index acb44309..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/EditHandler.java +++ /dev/null @@ -1,341 +0,0 @@ -package com.generationjava.apps.jpe; - -import java.awt.Menu; -import java.awt.MenuBar; -import java.awt.MenuShortcut; -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.ClipboardOwner; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.StringSelection; -import java.awt.datatransfer.Transferable; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.awt.event.ActionEvent; -import java.io.IOException; - -/** -* File handler handles all the request from the file menu -* extends Handler object so it can be loaded in JPE object -*/ -public class EditHandler extends AbstractHandler implements ClipboardOwner { - - - // Strings for the pulldown - String CutString=getText("JPE.menu.Edit.cut"); - String CopyString=getText("JPE.menu.Edit.copy"); - String PasteString=getText("JPE.menu.Edit.paste"); - String SelectAllString=getText("JPE.menu.Edit.selectAll"); - String FindString=getText("JPE.menu.Edit.find.find"); - String SubstituteString=getText("JPE.menu.Edit.find.substitute"); - String FindAgainString=getText("JPE.menu.Edit.find.findAgain"); - String GotoString=getText("JPE.menu.Edit.goto.gotoLine"); - String GotoErrorString=getText("JPE.menu.Edit.goto.gotoError"); - - // copy buffer for now is kept in a simple string - // having to handle this way as System clipboard is buggy. - String copyBuffer; - String searchkey=""; - - // handles the multi-question substitution functionality - private String sub_pattern; - private String sub_replace; - - /** - * create the edit handler - */ - public EditHandler(JPE jpe) { - super(jpe); - setName(getText("JPE.menu.Edit")); - } - - - /** - * called by superclass to create its menu - */ - public void createMenu(MenuBar bar) { - Menu m = new Menu(getName()); - m.add(new JPEMenuItem(CutString,new MenuShortcut('X'))); - m.add(new JPEMenuItem(CopyString,new MenuShortcut('C'))); - m.add(new JPEMenuItem(PasteString,new MenuShortcut('V'))); - - Menu m3=new Menu(getText("JPE.menu.Edit.find")); - m3.add(new JPEMenuItem(FindString,new MenuShortcut('F'))); - m3.add(new JPEMenuItem(SubstituteString,new MenuShortcut('/'))); - m3.add(new JPEMenuItem(FindAgainString,new MenuShortcut('F',true))); - m3.addActionListener(this); - m.add(m3); - - Menu m2=new Menu(getText("JPE.menu.Edit.goto")); - m2.add(new JPEMenuItem(GotoString,new MenuShortcut('G',true))); - m2.add(new JPEMenuItem(GotoErrorString,new MenuShortcut('G'))); - m2.addActionListener(this); - m.add(m2); - - m.addSeparator(); - m.add(new JPEMenuItem(SelectAllString, new MenuShortcut('A'))); - m.addActionListener(this); - bar.add(m); - } - - - /** - * AWT callback (implemented in Handler) for menu events - */ - public void actionPerformed(ActionEvent evt) { - String cmd = evt.getActionCommand(); - if (cmd.equals(CopyString)) { - doCopy(); - } else if (cmd.equals(CutString)) { - doCut(); - } else if (cmd.equals(PasteString)) { - doPaste(); - } else if (cmd.equals(SelectAllString)) { - doSelectAll(); - } else if (cmd.equals(FindString)) { - doFind(); - } else if (cmd.equals(SubstituteString)) { - doSubstitute(); - } else if (cmd.equals(FindAgainString)) { - doFindAgain(); - } else if (cmd.equals(GotoString)) { - doGoto(); - } else if (cmd.equals(GotoErrorString)) { - doGotoError(); - } - } - - - /** - * do find uses the askInterface - */ - public void doFind() { - getJPE().setAskMode(this,"find","Find = "); - } - - - /** - * do substitute uses the askInterface - * then asks another question - */ - public void doSubstitute() { - getJPE().setAskMode(this,"replaceQuestion","Pattern = "); - getJPE().setAskMode(this,"flagQuestion","Replace = "); - getJPE().setAskMode(this,"substitute","Flag(g:global) = "); - } - - - /** - * handles replace question by using the askInterface - * then asks another question - */ - public void handleReplaceQuestion(String pattern) { - if("".equals(pattern)) { - sub_pattern = searchkey; - } else { - sub_pattern = pattern; - } - } - - - /** - * handles flag question by using the askInterface - * then asks another question - */ - public void handleFlagQuestion(String replace) { - sub_replace = replace; - } - - /** - * handle substitute - */ - public void handleSubstitute(String flag) { - getJPE().say("Substituting '"+sub_pattern+"' with '"+sub_replace+"'"); - Editor editor=getJPE().getEditor(); - if (editor != null) { - if (editor.substitute(sub_pattern,sub_replace,flag)) { - getJPE().say("Regexp Subst = '"+sub_pattern+"' with '"+sub_replace+"'"); - } else { - getJPE().say("'"+sub_pattern+"' not Regexp Subst"); - } - } - } - - /** - * handle find - */ - public void handleFind(String key) { - if(!"".equals(key)) { - this.searchkey=key; - } else { - key = this.searchkey; - } - getJPE().say("Searching for = '"+key+"'"); - Editor editor=getJPE().getEditor(); - if (editor != null) { - if (key.startsWith("/")) { - key = key.substring(1); - if (editor.gotoLineWithRegexp(key)) { - getJPE().say("Regexp Found = '"+key+"'"); - } else { - getJPE().say("'"+key+"' not Regexp Found"); - } - } else { - if (editor.gotoLineWith(key)) { - getJPE().say("Found = '"+key+"'"); - } else { - getJPE().say("'"+key+"' not Found"); - } - } - } - } - - /** - * do find again - */ - public void doFindAgain() { - getJPE().say("Searching for = '"+searchkey+"'"); - Editor editor=getJPE().getEditor(); - if (editor!=null) { - if (editor.gotoLineWith(searchkey,editor.getCursorPos()+1)) { - getJPE().say("Found = '"+searchkey+"'"); - } else { - getJPE().say("no more '"+searchkey+"' not Found"); - } - } - } - - /** - * goto the first error - */ - public void doGotoError() { - getJPE().say("Jumping to first Error"); - Editor editor=getJPE().getEditor(); - if (editor!=null) { - OpenFile file=editor.getEditFile(); - int linenumber=file.getErrorPos(); - if (linenumber!=-1) { - editor.gotoLine(linenumber); - getJPE().say("Jumped first error at line "+linenumber+" (ctrl-h to toggle log)"); - return; - } - } - getJPE().say("No compile errors detected"); - } - - - /** - * do goto line uses the askInterface - */ - public void doGoto() { - getJPE().setAskMode(this,"goto","Goto line number = "); - } - - /** - * handle find - */ - public void handleGoto(String key) { - getJPE().say("Jumping to line "+key); - try { - Editor editor=getJPE().getEditor(); - int linenumber=Integer.parseInt(key); - if (editor!=null) editor.gotoLine(linenumber); - getJPE().say("Jumped to line "+key); - } catch(NumberFormatException nfe) { - Log.log(nfe); - getJPE().say("Error in jumping to line "+key); - } - } - - /** - * Handler the ask callback and finish the command started that - * started with the setAskMode. - */ - public void askCallback(String command,String result) { - if (command.equals("find")) { - handleFind(result); - } else if (command.equals("goto")) { - handleGoto(result); - } else if (command.equals("substitute")) { - handleSubstitute(result); - } else if (command.equals("replaceQuestion")) { - handleReplaceQuestion(result); - } else if (command.equals("flagQuestion")) { - handleFlagQuestion(result); - } - } - - public void lostOwnership(Clipboard cb, Transferable t) { - } - - /** - * copy the selected text to the buffer - */ - public void doCopy() { - Editor editor=getJPE().getEditor(); - copyBuffer=editor.getSelectedText(); - Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); - cb.setContents( new StringSelection(copyBuffer), this); - getJPE().say("Text Copy"); - } - - /** - * select the whole text - */ - public void doSelectAll() { - Editor editor=getJPE().getEditor(); - getJPE().say("Select All"); - editor.selectAll(); - } - - /** - * Cut the selected text and place it in the copy buffer - */ - public void doCut() { - Editor editor=getJPE().getEditor(); - copyBuffer=editor.cutSelectedText(); - Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); - cb.setContents( new StringSelection(copyBuffer), this); - getJPE().say("Text Cut"); - } - - /** - * insert the current buffer into the textareas at the cursor pos - */ - public void doPaste() { - Editor editor=getJPE().getEditor(); - Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); - Transferable tr = cb.getContents(this); - String cbBuffer = ""; - try { - cbBuffer = (String)tr.getTransferData(DataFlavor.stringFlavor); - } catch(IOException ioe) { - Log.log(ioe); - } catch(UnsupportedFlavorException ufe) { - Log.log(ufe); - } - - if(cbBuffer != null) { - // psion bug that adds on a newline. - cbBuffer = cbBuffer.substring(0,cbBuffer.length()-1); - String tmp = copyBuffer; - // make 255 a property - if(tmp.length() >= 255) { - // psion clipboard size limit bug - tmp = tmp.substring(0,255); - } - // use the clipboard version if it's not the same as the first - // 254 letters of the internal buffer. - if(!tmp.equals(cbBuffer)) { - copyBuffer = cbBuffer; - } - } - - if(copyBuffer!=null) { - editor.insertText(copyBuffer); - getJPE().say("Text Paste"); - } else { - getJPE().say("Text Paste Failed"); - } - } - -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/Editor.java b/jpe/src/java/com/generationjava/apps/jpe/Editor.java deleted file mode 100644 index b32ed7ed..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/Editor.java +++ /dev/null @@ -1,727 +0,0 @@ -package com.generationjava.apps.jpe; - -import gnu.regexp.RE; -import gnu.regexp.REException; -import gnu.regexp.REMatch; - -import java.awt.Font; -import java.awt.Frame; -import java.awt.MenuBar; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.TextEvent; -import java.awt.event.TextListener; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; - -/** -* Editor, handles the window of the selected file -* at the moment uses a TextArea to handle all the text -* commands. -*/ -public class Editor extends Frame - implements WindowListener, - KeyListener, - TextListener -{ - private JPETextArea textArea; - public OpenFile file; - JPE jpe; - - // used for autoindentation - private long aiTimeStamp = -1; - - // used to tell the file dirtyness to ignore text changes - // caused by loading a new file, or flipping to a log. - private boolean openingFile = false; - - /** - * create the Editor, it doesn't open the window at - * this stage. - */ - public Editor(MenuBar bar,JPE jpe) { - textArea = new JPETextArea(jpe); - textArea.addTextListener(this); - setMenuBar(bar); - this.jpe=jpe; - setTitle(); - textArea.addKeyListener(this); - add("Center", textArea); - addWindowListener(this); - } - - /** - * init the Text/Edit window, looks in the xml setup - * for its screensize and fontsize - */ - public void init() { - - // get the defined machine ( from config.xml ) - String setup=jpe.getProperty("setup","machine"); - - // if no defined machine was found default to netbook - if (setup==null) { - this.setSize(640, 480); - } else - - // figure out the used machine - if (setup.equals("netbook") ) { - // setup to netbook requested - this.setSize(640, 480); - } else if (setup.equals("psion7") ) { - // setup to psion7 requested - this.setSize(640, 480); - } else if (setup.equals("5mx")) { - // setup to 5mx requested - this.setSize(640, 240); - } else if (setup.equals("revo")) { - // setup to revo requested - this.setSize(480, 160); - } else { - // if unknown machine defined also default to netbook - this.setSize(640, 480); - } - - // open and make this window visible - this.setVisible(true); - - // get the defined fontsize ( from config.xml ) - String fontsize=jpe.getProperty("setup","fontsize"); - - // if no fontsize is defined default to 15 - if (setup==null) setFontSize(15); - - // try to parse the defined fontsize - try { - // set the defined fontsize - setFontSize(Integer.parseInt(fontsize)); - } catch(NumberFormatException e) { - // if something goes wrong default to 15 - setFontSize(15); - } - - // get the defined machine ( from config.xml ) - String fontname=jpe.getProperty("setup","fontname"); - if (fontname!=null) { - if (fontname.equals("Arial")) { - setNewFont("Arial"); - } else if (fontname.equals("Times")) { - setNewFont("Times New Roman"); - } else if (fontname.equals("Courier")) { - setNewFont("Courier"); - } - } - } - - - /** - * set the window to a new size and make it visible at this size - */ - public void setWindowSize(int sizex, int sizey) { - this.setSize(sizex,sizey); - this.setVisible(true); - } - - /** - * set default text to the title bar - */ - private void setTitle() - { - if (file==null) { - setTitle("No file Selected "); - } else { - setTitle("File : "+file.getName()); - } - } - - - /** - * increase the fontsize (zoom) with 1 - */ - public int doFontUp() { - // get current selected font - Font curf=textArea.getFont(); - - // get the name of this font - String name=curf.getName(); - - // get the size of this font - int size=curf.getSize(); - - // create a new font based on the old one but bigger - Font newf=new Font(name,Font.PLAIN,size+1); - - // set this new font into the textArea - textArea.setFont(newf); - - // return the new size - return(size+1); - } - - /** - * set the fontsize of the textArea to new size - */ - public void setFontSize(int size) { - // get the current selected font - Font curf=textArea.getFont(); - - // get the name of this font - String name=curf.getName(); - - // create a new font based on the old one with new size - Font newf=new Font(name,Font.PLAIN,size); - - // set this new font into the textArea - textArea.setFont(newf); - } - - - /** - * decrease the fontsize (zoom) with 1 - */ - public int doFontDown() { - // get the current selected font - Font curf=textArea.getFont(); - - // get the name of this font - String name=curf.getName(); - - // get the size of the font - int size=curf.getSize(); - - // create a new font based on the old one but smaller - Font newf=new Font(name,Font.PLAIN,size-1); - - // set this new font into the textArea - textArea.setFont(newf); - - // return the new size of the current font - return(size-1); - } - - /** - * decrease the fontsize (zoom) with 1 - */ - public void setNewFont(String name) { - // get the current selected font - Font curf=textArea.getFont(); - - // get the size of the font - int size=curf.getSize(); - - // create a new font based on the old one but smaller - Font newf=new Font(name,Font.PLAIN,size); - - // set this new font into the textArea - textArea.setFont(newf); - } - - - - public void keyPressed(KeyEvent e) { - jpe.say(); - } - - public void gotoLine(int linenumber) { - // need a smart way to do this - String body=textArea.getText(); - int lastpos=1; - int line=1; - int pos=body.indexOf("\n",lastpos); - while (pos!=-1 && line!=(linenumber-1)) { - line=line+1; - lastpos=pos+1; - pos=body.indexOf("\n",lastpos); - } - textArea.setCaretPosition(pos+1); - } - - public boolean gotoLineWith(String key) { - return this.gotoLineWith(key,0); - } - - public boolean gotoLineWith(String key,int startpos) { - // need a smart way to do this - String body=textArea.getText(); - int pos=body.indexOf(key,startpos); - if (pos!=-1) { - textArea.setCaretPosition(pos); - return(true); - } else { - return(false); - } - } - - public boolean gotoLineWithRegexp(String key) { - return this.gotoLineWithRegexp(key,0); - } - - public boolean gotoLineWithRegexp(String key,int startpos) { - String body = textArea.getText(); - int pos = -1; - try { - RE re = new RE(key); - REMatch match = re.getMatch(body,startpos); - if(match != null) { - pos = match.getStartIndex(); - } - } catch(REException ree) { - Log.log(ree); - } - if (pos != -1) { - textArea.setCaretPosition(pos); - return true; - } else { - return false; - } - } - - public boolean substitute(String key, String replace, String flag) { - return this.substitute(key,replace,0,flag); - } - - public boolean substitute(String key, String replace, int startpos, String flag) { - String body = getSelectedText(); - boolean selected = true; - String subst = null; - int pos = -1; - if( (body == null) || (body.equals("")) ) { - body = textArea.getText(); - selected = false; - } - try { - RE re = new RE(key); - REMatch match = re.getMatch(body,startpos); - if(match != null) { - pos = match.getStartIndex(); - if("g".equals(flag)) { - subst = re.substituteAll(body, replace, startpos); - } else { - subst = re.substitute(body, replace, startpos); - } - if(selected) { - insertText(subst); - } else { - setText(subst); - } - } - } catch(REException ree) { - Log.log(ree); - } - if (pos != -1) { - textArea.setCaretPosition(pos); - return true; - } else { - return false; - } - } - - public void useFile(OpenFile file) { - this.useFile(file,true); - } - - public void useFile(OpenFile file,boolean save) { - openingFile = true; - - if(save) { - // save information - if (this.file != null) { - this.file.setCaretPosition(textArea.getCaretPosition()); - this.file.setText(textArea.getText()); - } - } - - // load new file - this.file=file; - jpe.setCompileState(file.isCompiled()); - jpe.setSaveState(!file.isDirty()); - jpe.setLockState(file.isLocked()); - textArea.setText(file.getText()); - textArea.setCaretPosition(file.getCaretPosition()); - textArea.setEditable(!file.isLocked()); -// file.clearDirty(); - repaint(); - jpe.putProperty("setup","selectedfile",file.getName()); - jpe.say(); - } - - public String getText() { - return textArea.getText(); - } - - public void setText(String txt) { - textArea.setText(txt); - } - - public OpenFile getEditFile() { - file.setText(textArea.getText()); - return(file); - } - - public String getEditFilename() { - return(file.getName()); - } - - - public String getSelectedText() { - return(textArea.getSelectedText()); - } - - public String cutSelectedText() { - String text=textArea.getSelectedText(); - textArea.replaceRange("",textArea.getSelectionStart(),textArea.getSelectionEnd()); - return(text); - } - - public void insertText(String body) { - insertText(body,textArea.getCaretPosition()); - } - - public void insertText(String body, int pos) { - String sel = textArea.getSelectedText(); - if(sel != null) { - textArea.replaceRange(body,textArea.getSelectionStart(),textArea.getSelectionEnd()); - } else { - textArea.insert(body,pos); - } - } - - public void selectAll() { - textArea.selectAll(); - } - - public int getCursorPos() { - return(textArea.getCaretPosition()); - } - - public boolean getAskMode() { - return(textArea.getAskMode()); - } - - public void setAskMode(AskInterface askCaller,String command,String usermsg,boolean oneshot) { - textArea.setAskMode(askCaller,command,usermsg,oneshot); - } - - public int getCursorLine() { - // need a smart way to figure out the line number - String body=textArea.getText(); - int curpos=getCursorPos(); - int lastpos=1; - int line=1; - int pos=body.indexOf("\n",lastpos); - while (pos!=-1 && pos10 & !file.isLocked()) { - file.setDirty(); - jpe.setCompileState(file.isCompiled()); - } - jpe.setSaveState(!file.isDirty()); - */ - } - - public void textValueChanged(TextEvent te) { - if( openingFile ) { - openingFile = false; - return; - } - if(aiTimeStamp != -1) { - long tmp = aiTimeStamp + 100L; - aiTimeStamp = -1; - if( tmp > System.currentTimeMillis()) { -// Log.log("Before+100: "+tmp+" - "+System.currentTimeMillis()); - autoindent(); - } - } - if( (!openingFile) && (file != null) && (jpe != null) ) { - file.setDirty(); - jpe.setCompileState(file.isCompiled()); - jpe.setSaveState(!file.isDirty()); - } - } - - public void keyReleased(KeyEvent e) { - } - - public void setEditable(boolean state) { - textArea.setEditable(state); - } - - - public void autoindentInit() { - aiTimeStamp = System.currentTimeMillis(); - } - - public void autoindent() { - // find the previous newline. - // grab the whitespace chars after it. - // insert them after the current character. - // position cursor in right place. - int idx = getCursorPos(); - if(idx < 2) { - return; - } - String text = getText(); -// if( (text.charAt(idx) == '\n') && (text.charAt(idx-1) == '\n') ) { -// return; -// } - int nl = -1; - for(int i=idx-2;i>0;i--) { - if(text.charAt(i) == '\n') { - nl = i; - break; - } else - if(i == 0) { - nl = 0; - } - } - if(nl == -1) { - return; - } - - String whitespace = ""; - for(int i=nl+1;i nl ) ) - { - if( text.charAt(idx-1) == '\\') { - if( text.charAt(idx-2) == '\\') { - if(!commentContext(text,idx)) { - count++; - } - } - } else - if( text.charAt(idx-1) == '\'') { - // means there's single quotes around a double quote. - // as in the while loop above. - } else { - if(!commentContext(text,idx)) { - count++; - } - } - } - return ( (count % 2) == 1 ); - } - - // not too hot. can't handle comment chars in comments. - public boolean commentContext(String text, int idx) { - int com1 = text.lastIndexOf("/*",idx); - int com2 = text.lastIndexOf("*/",idx); - int com3 = text.lastIndexOf("//",idx); - int nl = text.lastIndexOf("\n",idx); - - if( (com1 > com2) || (com3 > nl) ) { - return true; - } else { - return false; - } - } - - public int lastIndexOf(String text, char chr, int idx) { - int tmp; - while( (tmp = text.lastIndexOf(chr,idx)) != -1) { - if(!stringContext(text,tmp)) { - if(!commentContext(text,tmp)) { - return tmp; - } - } - idx = tmp-1; - } - return tmp; - } - - // When someone does a certain character, it has a partner - // character which the character moves the cursor to and - // selects before returning. - // Various issues exist: ie) context of the character: - // bob { "hh{" } should ignore the embedded one. - // "g\"" should ignore the escaped " - // " shouldn't span lines but other brackets should. - // might not just be single chars. ie) /* to */ - // so lots of rules involved. - public void doPairing(char key) { - int hilite = -1; - int idx = getCursorPos(); - String text = getText(); - int close = 0; - int open = 0; - int tmp = idx; - - if(key == '"') { - if(!stringContext(text, tmp)) { - return; - } else { - if( (text.charAt(idx-1) == '\\') && - (text.charAt(idx-2) != '\\') ) - { - return; - } else - if(commentContext(text, tmp)) { - return; - } else { - while(open != -1) { - open = text.lastIndexOf('"',tmp); - if(open == -1) { - return; - } - if(!stringContext(text, open) ) { - hilite = open; - break; - } else { - tmp = open; - } - } - } - } - } else - if(stringContext(text, idx)) { - return; - } - - if(key == '/') { - if(!commentContext(text, idx)) { - return; - } else { - if(text.charAt(idx-1) == '*') { - while(open != -1) { - open = text.lastIndexOf("/*",tmp); - close = text.lastIndexOf("*/",tmp); - if(open == -1) { - return; - } - if(open > close) { - hilite = open; - break; - } else { - return; - } - } - } else { - return; - } - } - } else - if(commentContext(text,idx)) { - return; - } - - if(key == ']') { - char openkey = '['; - while(hilite == -1) { - open = lastIndexOf(text, openkey,tmp); - close = lastIndexOf(text, key,tmp); - if(open == -1) { - return; - } else - if(open > close) { - hilite = open; - break; - } else { - return; - } - } - } - - char openchr = 'q'; - char closechr = 'q'; - - if(hilite == -1) { - switch(key) { - case '}' : - openchr = '{'; - closechr = '}'; - break; - case ')' : - openchr = '('; - closechr = ')'; - break; - default: - return; - } - } - - if(openchr != 'q') { - // need to move backwards, grabbing braces - // until there is one more opening brace than closing - // then that opening brace is our baby - int count = 0; - while( (count != -1) && (open != -1) ) { - open = lastIndexOf(text, openchr, tmp); - close = lastIndexOf(text, closechr, tmp); - if(open > close) { - tmp = open-1; - count--; - } else { - tmp = close-1; - count++; - } - } - hilite = open; - } - - if(hilite != -1) { - textArea.setCaretPosition(hilite); - try { - Thread.sleep(500); - } catch(InterruptedException ie) { - ie.printStackTrace(); - } - textArea.setCaretPosition(idx); - } - } - -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/ExtraHandler.java b/jpe/src/java/com/generationjava/apps/jpe/ExtraHandler.java deleted file mode 100644 index 8f3645c9..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/ExtraHandler.java +++ /dev/null @@ -1,464 +0,0 @@ -package com.generationjava.apps.jpe; - -import java.awt.Menu; -import java.awt.MenuBar; -import java.awt.MenuShortcut; -import java.awt.event.ActionEvent; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringReader; -import java.io.StringWriter; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.StringTokenizer; -import java.util.Vector; - -import jstyle.JSBeautifier; -import jstyle.JSFormatter; - -import com.generationjava.apps.jpe.compiler.CommandLineCompiler; -import com.generationjava.apps.jpe.compiler.ToolsCompiler; - -/** -* Extra handler handles all the request from the extra menu -* extends Handler object so it can be loaded in JPE object -*/ -public class ExtraHandler extends AbstractHandler { - - JPEClassloader loader; - - // Strings for the pulldown - private String CompileString=getText("JPE.menu.Extra.compile"); - private String FontUpString=getText("JPE.menu.Extra.font.increase"); - private String FontDownString=getText("JPE.menu.Extra.font.decrease"); - private String SetRevoString="Revo"; - private String Set5mxString="5mx"; - private String SetPsion7String="Psion 7"; - private String SetNetbookString="Netbook"; - private String FontArialString="Arial"; - private String FontTimesString="Times"; - private String FontCourierString="Courier"; - private String RunAppString=getText("JPE.menu.Extra.run.run"); - private String RunAppParamString=getText("JPE.menu.Extra.run.withParam"); - private String reformatString=getText("JPE.menu.Extra.style.reformat"); - private String beautifyString=getText("JPE.menu.Extra.style.beautify"); - private String GarbageString=getText("JPE.menu.Extra.garbage"); - private String FixImportsString=getText("JPE.menu.Extra.style.fixImports"); - - private String kjcString = "koji"; - private String javacString = "javac"; - private String toolsString = "tools.jar"; - private String jikesString = "jikes"; - - private String runAppParam; - private Compiler compiler; - - /** - * create the extra handler - */ - public ExtraHandler(JPE jpe) { - super(jpe); - setName(getText("JPE.menu.Extra")); - - // TODO: Use a getProperty - this.compiler = new CommandLineCompiler(); - LogHandler lh=(LogHandler)getJPE().getHandler("Log"); - this.compiler.setErrorStream(lh.lpse); - } - - - /** - * called by superclass to create its menu - */ - public void createMenu(MenuBar bar) { - Menu m = new Menu(getName()); - m.add(new JPEMenuItem(CompileString,new MenuShortcut('M'))); - m.add(new JPEMenuItem(GarbageString,new MenuShortcut('M',true))); - - Menu submenu3 = new Menu(getText("JPE.menu.Extra.run")); - submenu3.add(new JPEMenuItem(RunAppString,new MenuShortcut('R'))); - submenu3.add(new JPEMenuItem(RunAppParamString,new MenuShortcut('R',true))); - submenu3.addActionListener(this); - m.add(submenu3); - - Menu submenu = new Menu(getText("JPE.menu.Extra.font")); - submenu.add(new JPEMenuItem(FontUpString)); - submenu.add(new JPEMenuItem(FontDownString)); - submenu.add(FontArialString); - submenu.add(FontCourierString); - submenu.add(FontTimesString); - submenu.addActionListener(this); - m.add(submenu); - - // create the machine selector - Menu submenu2 = new Menu(getText("JPE.menu.Extra.machine")); - submenu2.add(SetRevoString); - submenu2.add(Set5mxString); - submenu2.add(SetPsion7String); - submenu2.add(SetNetbookString); - submenu2.addActionListener(this); - m.add(submenu2); - - Menu submenu4 = new Menu(getText("JPE.menu.Extra.style")); - submenu4.add(reformatString); - submenu4.add(beautifyString); - submenu4.add(FixImportsString); - submenu4.addActionListener(this); - m.add(submenu4); - - Menu submenu5 = new Menu(getText("JPE.menu.Extra.compiler")); - submenu5.add(kjcString); - submenu5.add(toolsString); - submenu5.add(jikesString); - submenu5.add(javacString); - submenu5.addActionListener(this); - m.add(submenu5); - - m.addActionListener(this); - - bar.add(m); - } - - /** - * AWT callback (implemented in Handler) for menu events - */ - public void actionPerformed(ActionEvent evt) { - String cmd = evt.getActionCommand(); - if (cmd.equals(CompileString)) { - doCompile(); - } else if (cmd.equals(GarbageString)) { - doGarbage(); - } else if (cmd.equals(FontUpString)) { - doFontUp(); - } else if (cmd.equals(FontDownString)) { - doFontDown(); - } else if (cmd.equals(SetNetbookString)) { - doNetbookSetup(); - } else if (cmd.equals(SetPsion7String)) { - doNetbookSetup(); - } else if (cmd.equals(Set5mxString)) { - do5mxSetup(); - } else if (cmd.equals(SetRevoString)) { - doRevoSetup(); - } else if (cmd.equals(FontTimesString)) { - setNewFont("Times New Roman"); - } else if (cmd.equals(FontArialString)) { - setNewFont("Arial"); - } else if (cmd.equals(FontCourierString)) { - setNewFont("Courier"); - } else if (cmd.equals(RunAppString)) { - doRunApp(); - } else if (cmd.equals(RunAppParamString)) { - doRunAppParam(); - } else if(cmd.equals(reformatString)) { - doStyle("format"); - } else if(cmd.equals(beautifyString)) { - doStyle("beautify"); - } else if(cmd.equals(FixImportsString)) { - fixImports(); - } else if(cmd.equals(jikesString)) { - this.compiler = new CommandLineCompiler("jikes", ""); - } else if(cmd.equals(javacString)) { - this.compiler = new CommandLineCompiler(); - } else if(cmd.equals(kjcString)) { - this.compiler = new CommandLineCompiler("kjc", ""); - } else if(cmd.equals(toolsString)) { - this.compiler = new ToolsCompiler(); - } - } - - public void doGarbage() { - System.gc(); - getJPE().say("Attempting to garbage collect."); - } - - public void doRunApp() { - handleRunApp(null); - } - - /** - * do find uses the askInterface - */ - public void doRunAppParam() { - getJPE().setAskMode(this,"runparam","Start with param line : "); - } - - - public void handleRunApp(String params) { - Editor editor=(Editor)getJPE().getEditor(); - OpenFile file=editor.getEditFile(); - String filename=file.getName(); - if (filename.indexOf(".java")==-1) { - getJPE().say("Not a java file, can only run java applications"); - return; - } - filename=filename.substring(0,filename.length()-4)+"class"; - - - // create a new classloader - JPEClassloader loader=new JPEClassloader(); - - - if ("".equals(params)) { - params = runAppParam; - } - - String argv[]; - if (params == null) { - argv = new String[0]; - } else { - // store - runAppParam = params; - - // build up a vector of the params - StringTokenizer tok=new StringTokenizer(params," \n\r"); - Vector pr=new Vector(); - while (tok.hasMoreTokens()) { - pr.addElement(tok.nextToken()); - } - argv = new String[pr.size()]; - int i=0; - for (i=0;i"); - txt = re.substitute(txt,""+new Date()); - file.setText(txt); - } catch(REException ree) { - ree.printStackTrace(); - } - } - - // add the file to the opened file list - ofh.addFile(file); - - // load this file into the text area - getJPE().getEditor().useFile(file); - } - - /** - * open a file, lets the user pick one using a FileDialog - */ - private void openFile() { - // get the openfile handler to add the new file - OpenFileHandler ofh=(OpenFileHandler)getJPE().getHandler("Opened"); - if (ofh==null) { - // no opened handler started so lets start one and add it the - // menu. - ofh=(OpenFileHandler)getJPE().addHandler(new OpenFileHandler(getJPE())); - ofh.createMenu(getJPE().getMenuBar()); - } - - // open a dialog to let the user select the file we need to load - String filename=getFileName(FileDialog.LOAD); - - // lets check if we allready have this file open - OpenFile file=ofh.getOpenFile(filename); - if (file==null) { - // file not opened at this moment lets open it - file=new OpenFile(filename); - ofh.addFile(file); - } - - // load this file into the text area - getJPE().getEditor().useFile(file); - } - - private void lockFile() { - OpenFileHandler ofh=(OpenFileHandler)getJPE().getHandler("Opened"); - Editor editor=(Editor)getJPE().getEditor(); - if (editor!=null) { - OpenFile file=editor.getEditFile(); - if (file.isLocked()) { - file.clearLocked(); - getJPE().setLockState(false); - getJPE().say("file is now unlocked ( read / write )"); - } else { - file.setLocked(); - getJPE().setLockState(true); - getJPE().say("file is now locked (read only)"); - } - ofh.updateProperties(); - } - } - /** - * close the selected file, meaning removing it from the Opened - * list and removing it from the auto reload on startup list - */ - private void closeFile() { - OpenFileHandler ofh=(OpenFileHandler)getJPE().getHandler("Opened"); - Editor editor=(Editor)getJPE().getEditor(); - if (editor!=null) { - OpenFile file=editor.getEditFile(); - if (!file.isDirty()) { - ofh.removeFile(file); - addRecent(file.getName()); - ofh.switchOpenFile(); - } else { - getJPE().setAskMode(this,"close","File not saved, save first (y/n) ? ",true); - } - } - } - - - private void handleClose(String result) { - // get the text handler - Editor editor=(Editor)getJPE().getEditor(); - if (editor!=null) { - // get the selected file from the text handler - OpenFile file=editor.getEditFile(); - if (file!=null) { - if (result.equals("y")) file.saveFile(); - file.clearDirty(); - closeFile(); - } - } - } - - - /** - * ask the user for a filename (using a file requester) and save - * the current file under that name - */ - private void saveAsFile() { - // get openfile handlers - OpenFileHandler ofh=(OpenFileHandler)getJPE().getHandler("Opened"); - if (ofh!=null) { - // ask the user for the file name - String filename=getFileName(FileDialog.SAVE); - // get the text handler - Editor editor=(Editor)getJPE().getEditor(); - // get the selected file - OpenFile file=editor.getEditFile(); - // remove the file from the opened list - ofh.removeFile(file); - if (file!=null) { - // set the new name in the file - file.setName(filename); - getJPE().say("Saving file "+file.getName()); - // save the file under this new name - file.saveFile(); - // add the file to the opened files again (now new name) - ofh.addFile(file); - getJPE().say("Saved file "+file.getName()); - } - } - } - - - /** - * save selected file to disk - */ - private void saveFile() { - // get the text handler - Editor editor=(Editor)getJPE().getEditor(); - if (editor!=null) { - // get the selected file from the text handler - OpenFile file=editor.getEditFile(); - if (file!=null) { - // signal the use we are saving and save it to disk - getJPE().say("Saving file "+file.getName()); - file.saveFile(); - getJPE().say("Saved file "+file.getName()); - } - } - } - - /** - * get the filename from the user using a file requester - */ - private String getFileName(int mode) { - String prompt; - String filename; - String pathname; - File file; - - // depending on load or save set the prompt - if (mode == FileDialog.LOAD) { - prompt = "Open File "; - } else { - prompt = "Save File As "; - } - - // create a file requester - FileDialog d = new FileDialog(getJPE().getEditor(), prompt, mode); - - // set the file filter (not working on epoc it seems) - d.setFilenameFilter(new JPEFilenameFilter()); - - // set the directory to open in (not working?) - //d.setDirectory("c:\\JPE"); - d.setDirectory(dir); - - // show requester (blocks until user is done) - d.show(); - - // optain the filename - filename = d.getFile(); - - // complete the file name by adding its path - pathname = d.getDirectory() + filename; - - if (filename != null) { - dir = d.getDirectory(); - getJPE().putProperty("setup","currentdir",dir); - // if we have a filename return it - return(pathname); - } else { - // return null to signal a problem - return(null); - } - } - /** - * Handler the ask callback and finish the command started that - * started with the setAskMode. - */ - public void askCallback(String command,String result) { - if (command.equals("exit")) { - handleExit(result); - } else if (command.equals("force-exit")) { - forceExit(result); - } else if (command.equals("revert")) { - handleRevert(result); - } else if (command.equals("close")) { - handleClose(result); - } - } - - public void importFile() { - Editor editor=getJPE().getEditor(); - - String tempfilename = getFileName(FileDialog.LOAD); - OpenFile tempfile = new OpenFile(tempfilename); - String txt = tempfile.getText(); - - if (txt != null) { - editor.insertText(txt); - getJPE().say("Text Import"); - } - } - - - public void revertFile() { - getJPE().setAskMode(this,"revert","Revert file, all changes will be lost (y/n) ? ",true); - } - - public void handleRevert(String answer) { - if("y".equals(answer)) { - Editor editor=(Editor)getJPE().getEditor(); - if (editor!=null) { - // get the selected file from the text handler - OpenFile file=editor.getEditFile(); - if (file!=null) { - // revert the file - file.loadFile(); - // tell editor to useFile, without saving - editor.useFile(file,false); - } - } - } - } - - protected void addRecent(String file) { - if(recentFiles == null) { - recentFiles = new Vector(); - } - for(int i=0;i recentMax) { - recentFiles.setSize(recentMax); - } - if(recentMenu.getItemCount() > recentMax) { - recentMenu.remove(recentMax); - } - updateProperties(); - } - - protected void removeRecent(String file) { - if(recentFiles == null) { - return; - } else { - recentFiles.removeElement(file); - for(int i=0;i SecurityManager already loaded"); - } - } - - // create the menu bar of JPE - bar = new MenuBar(); - - // create the config handler (read config.xml) - addHandler(new ConfigHandler(this)); - -// QN: Why did I want this to be configurable?? -// String i18n = getProperty("setup", "i18n"); -// if (i18n == null) { -// i18n = getMyPath() + "jpe.properties"; -// getConfigHandler().putProperty("setup", "i18n", i18n); -// } - - // init text controller - TextController tc = TextController.getInstance(); - - // startup the needed Handler (will change in future release) - Handler handler = new FileHandler(this); - handler.createMenu(bar); - addHandler(handler); - - handler = new EditHandler(this); - handler.createMenu(bar); - addHandler(handler); - - handler = new LogHandler(this); - handler.createMenu(bar); - addHandler(handler); - - handler = new ExtraHandler(this); - handler.createMenu(bar); - addHandler(handler); - - handler = new HelpHandler(this); - handler.createMenu(bar); - addHandler(handler); - -// System.err.println(i18n); - - // create the titlebar handler - addHandler(new TitleBarHandler(this)); - - // create the edit window and init it. - editor = new Editor(bar, this); - editor.init(); - - // read if we had opened files in the last run of JPE if we did - // then restart them again. - Vector vec = getProperties("openfile"); - if (vec != null) { - - // we had opened file so start the openfile handler - OpenFileHandler ofh = (OpenFileHandler) getOpenFileHandler(); - if (ofh == null) { - // add the openfile handler to the menu - ofh = (OpenFileHandler) addHandler(new OpenFileHandler(this)); - ofh.createMenu(bar); - } - - // now we have the handler open the files - ofh.openFiles(); - - // was one of the files active in the editor ? - String selfile = getProperty("setup", "selectedfile"); - if (selfile != null) { - // yes then lets make it active again. - ofh.switchOpenFile(selfile); - } - } - - } - - /** - * main method needed to start the application - */ - public static void main(String[] args) { - // create a instance of JPE to start the app - JPE p = new JPE(); - } - - /** - * return the text handler - */ - public Editor getEditor() { - return (editor); - } - - /** - * return the config handler - */ - public ConfigHandler getConfigHandler() { - return (ConfigHandler) getHandler("Config"); - } - - /** - * return the config handler - */ - public TitleBarHandler getTitleBarHandler() { - return (TitleBarHandler) getHandler("TitleBar"); - } - - public OpenFileHandler getOpenFileHandler() { - return (OpenFileHandler) getHandler("Opened"); - } - - /** - * return the requested handler - */ - public Handler getHandler(String name) { - return (Handler) handlers.get(name); - } - - /** - * add a new Handler to the application, the must follow the - * handler interface to be accepted - */ - public Handler addHandler(Handler handler) { - // add it to the list of running handlers - handlers.put(handler.getName(), handler); - // return the handler again, caller might wanne use it - return handler; - } - - /** - * return the active menu bar - */ - public MenuBar getMenuBar() { - return bar; - } - - /** - * the say commands allows the different parts to give feedback - * to the user. This call reroutes to the handler that implements - * it at the moment. no param means display what the app thinks - * is best to display at this time. - */ - public void say() { - // at the moment hardwired to titlebar handler so give it to - // that handler - getTitleBarHandler().say(); - } - - /** - * the say commands allows the different parts to give feedback - * to the user. This call reroutes to the handler that implements - * it at the moment. - */ - public void say(String msg) { - // at the moment hardwired to titlebar handler so give it to - // that handler - getTitleBarHandler().say(msg); - } - - /** - * A brief is a temporary say. It lasts n seconds and then - * should vanish, putting back the previous message. - */ - public void brief(String msg) { - getTitleBarHandler().say(msg); - } - - /** - * get a property from the config handler defined by its - * nodename and key. Allways returns the value as a string. - */ - public String getProperty(String nodename, String key) { - if (getConfigHandler() != null) { - // reroute this call to the current config hander - return (getConfigHandler().getProperty(nodename, key)); - } - return null; - } - - /** - * store a property in the defined node by its given key, replaces - * the value if it was allready defined. - */ - public void putProperty(String nodename, String key, String value) { - if (getConfigHandler() != null) { - // reroute this call to the loaded config handler - getConfigHandler().putProperty(nodename, key, value); - } - } - - /** - * get a properties vector from the config handler defined by its - * nodename. Allways returns the a vector with hashtables with - * keys/values. - */ - public Vector getProperties(String nodename) { - if (getConfigHandler() != null) { - return (getConfigHandler().getProperties(nodename)); - } - return (null); - } - - public boolean getAskMode() { - return (editor.getAskMode()); - } - - public void setAskMode( - AskInterface askCaller, - String command, - String usermsg) { - editor.setAskMode(askCaller, command, usermsg, false); - } - - public void setAskMode( - AskInterface askCaller, - String command, - String usermsg, - boolean oneshot) { - editor.setAskMode(askCaller, command, usermsg, oneshot); - } - - /** - * store a properties Vector, replaces the whole vector if it was - * allready defined by its nodename so make sure you have merged - * the nodes yourself if needed ! - */ - public void putProperties(String nodename, Vector values) { - if (getConfigHandler() != null) { - getConfigHandler().putProperties(nodename, values); - } - } - - /** - * return the file path to JPE itself, should be defined in env. variable - * home.jpe and defaults to c:\JPE - */ - public String getMyPath() { - if (jpehome != null) - return (jpehome); - - // get defined path - String cp = System.getProperty("java.class.path"); - StringTokenizer tok = new StringTokenizer(cp, ";\n\r"); - while (tok.hasMoreTokens()) { - String tmp = tok.nextToken(); - if (tmp.indexOf('?') == -1 && tmp.indexOf(".jar") == -1) { - try { - File file = - new File(tmp + "com/generationjava/apps/jpe/JPE.class"); - if (file.isFile()) { - jpehome = tmp; - return tmp; - } - } catch (Exception e) { - } - } else if ( - tmp.indexOf('?') == -1 && tmp.indexOf("JPE.jar") != -1) { - try { - tmp = tmp.substring(0, tmp.length() - 8); - File file = - new File(tmp + "com/generationjava/apps/jpe/JPE.class"); - if (file.isFile()) { - jpehome = tmp; - return tmp; - } - } catch (Exception e) { - } - } - } - // keep this in just so people can still set it if they really want - String tmp = System.getProperty("jpe.home"); - if (tmp != null && !tmp.equals("")) { - // path defined so return it - return tmp; - } - tmp = System.getProperty("user.dir"); - if (tmp != null && !tmp.equals("")) { - return tmp + "/"; - } - // path not defined so return default, should never happen - return "C:\\system\\apps\\jpe"; - } - - public void setCompileState(boolean state) { - getTitleBarHandler().setCompileState(state); - } - - public void setSaveState(boolean state) { - getTitleBarHandler().setSaveState(state); - } - - public void setLockState(boolean state) { - getTitleBarHandler().setLockState(state); - editor.setEditable(!state); - } - - public String requestConsume(KeyEvent e) { - if (!e.isControlDown()) { - return null; - } - char c = e.getKeyChar(); - if ((c == '.') || (c == ',')) { - if ((getOpenFileHandler()).endOfList(c)) { - return "No more open files in that direction."; - } - } - return null; - } - - public void requestExit() { - wantexit = true; - say("Exit called, goodbye"); - getEditor().dispose(); - System.exit(0); - } - -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/JPEClassloader.java b/jpe/src/java/com/generationjava/apps/jpe/JPEClassloader.java deleted file mode 100644 index bb067ef1..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/JPEClassloader.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.generationjava.apps.jpe; - -import java.io.File; -import java.io.FileInputStream; -import java.util.Hashtable; - -public class JPEClassloader extends ClassLoader { - private Hashtable cache = new Hashtable(); - -/* private Hashtable ourclasses = new Hashtable(); - private boolean ours = false; - private String newname; - - private int netloaded=0,netfailed=0; - private int diskloaded=0,diskfailed=0; - private int sysloaded=0,sysfailed=0; -*/ - - public JPEClassloader() { - } - - public synchronized Class loadClass(String name, boolean resolve) { -// System.out.println("Classloader="+name); - Class c = (Class) cache.get(name); - - if (c==null) { - byte data[] = loadClassfile(name); - if (data != null) { - try { - c = defineClass(data,0,data.length); -// System.out.println("CLASS="+c); - if (c != null) { - cache.put(name,c); - cache.put(c.getName(),c); - } - } catch(Exception e) { -// System.out.println("JPEClassloader: Can't load systemclass "+e); - e.printStackTrace(); - } - } else { - try { - c=findSystemClass(name); - } catch(Exception e) { - System.out.println("JPEClassloader2 : Can't load systemclass "+e); -// e.printStackTrace(); - } - } - } - return c; - } - - - private Class defineClass(String name, byte data[], boolean resolve) { -// System.out.println("Classloader="+name); - Class c = null; - if (data != null) { - try { - // For 1.1 this should be : - c=defineClass(data,0,data.length); - } catch (ArrayIndexOutOfBoundsException a) { - System.out.println("JPEClassloader: Class ["+name+"] could not be loaded"); - } - if (resolve) resolveClass(c); - } - if (c != null) { - // Always store package name as well - cache.put(c.getName(),c); - cache.put(name,c); // Overwrites previous put in case of name being the package name -// System.out.println("Added default class : "+name); - } - return c; - } - - - /** - * Load a class from disk - */ - private byte[] loadClassfile(String name) { - FileInputStream scan = null; - File scanfile=null; - int filesize=0; - byte data[]=null; - - if (name.indexOf(".class")==-1) { - System.out.println("NAME1="+name); - name=name.replace('.',File.separatorChar); - System.out.println("NAME2="+name); - name="c:\\MJC\\"+name+".class"; - System.out.println("NAME3="+name); - } - - scanfile = new File(name); - - try { - scan = new FileInputStream(scanfile); - } catch(Exception e) { - return null; - } - try { - filesize = (int)scanfile.length(); - } catch (Exception e) { - System.out.println("JPEClassLoader: Can't determine filesize : "+name); - return null; - } - data = new byte[filesize]; - try { - scan.read(data,0,filesize); - } catch(Exception e) { - System.out.println("JPEClassLoader: Can't read from : "+name); - } - return data; - } - - -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/JPEFilenameFilter.java b/jpe/src/java/com/generationjava/apps/jpe/JPEFilenameFilter.java deleted file mode 100644 index f1d5f84b..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/JPEFilenameFilter.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.generationjava.apps.jpe; - -import java.io.File; -import java.io.FilenameFilter; - -public class JPEFilenameFilter implements FilenameFilter { - - public boolean accept(File file, String filename) { - System.out.println("JPEFilenameFilter.accept="+filename); - if (filename.endsWith(".java")) { - return true; - } else if (filename.endsWith(".txt")) { - return true; - } else if (filename.endsWith(".xml")) { - return true; - } else { - return false; - } - } - -} - diff --git a/jpe/src/java/com/generationjava/apps/jpe/JPEMenuItem.java b/jpe/src/java/com/generationjava/apps/jpe/JPEMenuItem.java deleted file mode 100644 index b7c09afb..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/JPEMenuItem.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.generationjava.apps.jpe; - -import java.awt.MenuItem; -import java.awt.MenuShortcut; - -public class JPEMenuItem extends MenuItem { - - // this is to get around buggy JVMs that don't default to - // the label when a shortcut key is pressed. - public JPEMenuItem(String label, MenuShortcut sc) { - super(label,sc); - setActionCommand(label); - } - - public JPEMenuItem(String label) { - super(label); - } - -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/JPETextArea.java b/jpe/src/java/com/generationjava/apps/jpe/JPETextArea.java deleted file mode 100644 index 23b9c11d..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/JPETextArea.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.generationjava.apps.jpe; - -import java.awt.TextArea; -import java.awt.event.KeyEvent; -import java.util.Vector; - -/** -*/ -public class JPETextArea extends TextArea { - - String askline=""; - String usermsg=""; - String askCommand; - boolean oneshot=false; - boolean dirty=false; - boolean tab=false; - AskInterface askCaller; - JPE jpe; - private Vector queue = new Vector(); - - public JPETextArea(JPE jpe) { - this.jpe=jpe; - } - - private final boolean pairable(char ch) { - return ( (ch == '}') || - (ch == ')') || - (ch == ']') || - (ch == '/') || - (ch == '"') ); - } - - protected void processKeyEvent(KeyEvent e) { - AskInterface tmpCaller = null; - String tmpCommand = null; - String tmpLine = null; - if (e.getID()==KeyEvent.KEY_TYPED) { - if(e.isControlDown()) { - String req = jpe.requestConsume(e); - if(req != null) { - e.consume(); - jpe.brief(req); - return; - } - } - } - if (askCaller==null) { - if(queue.isEmpty()) { - char tmpkey=e.getKeyChar(); - if (e.getID()==KeyEvent.KEY_TYPED) { - if(e.getID()!=KeyEvent.VK_DOWN) { - if(!e.isControlDown()) { - if(tmpkey == '\n') { - // do autoindenting. - jpe.getEditor().autoindentInit(); -// Log.log("newline? '"+e.getKeyCode()+"' '"+e.getKeyChar()+"' '"+e.isActionKey()+"' '"+KeyEvent.getKeyText(e.getKeyCode())+"' '"+e.getModifiers()+"' '"+KeyEvent.getKeyModifiersText(e.getModifiers())+"'"); - } - } - } - if(pairable(tmpkey)) { - jpe.getEditor().doPairing(tmpkey); - } - } - super.processKeyEvent(e); - return; - } else { - Vector v = (Vector)queue.elementAt(0); - this.askCaller = (AskInterface)v.elementAt(0); - this.askCommand = (String)v.elementAt(1); - this.usermsg = (String)v.elementAt(2); - this.oneshot = ((Boolean)v.elementAt(3)).booleanValue(); - this.tab = ((Boolean)v.elementAt(4)).booleanValue(); - queue.removeElementAt(0); - } - } - if (e.getID()==KeyEvent.KEY_TYPED) { - char tmpkey=e.getKeyChar(); - if(tmpkey == '\n') { - // ignore newlines for this bit. - } else - if (tmpkey!=KeyEvent.VK_BACK_SPACE) { - askline+=tmpkey; - } else { - if (!askline.equals("")) askline=askline.substring(0,askline.length()-1); - } - if (oneshot) { - e.consume(); - tmpCaller = askCaller; - tmpLine = askline; - tmpCommand = askCommand; - askCaller=null; - askline=""; - askCommand=""; - tmpCaller.askCallback(tmpCommand,tmpLine); - if(!queue.isEmpty()) { - Vector v = (Vector)queue.elementAt(0); - String tmpmsg = (String)v.elementAt(2); - if (jpe!=null) jpe.say(tmpmsg+"_"); - } - } else if (jpe!=null) jpe.say(usermsg+askline+"_"); - if(tmpkey != '\n') { - e.consume(); - } else { - e.consume(); - tmpCaller = askCaller; - tmpLine = askline; - tmpCommand = askCommand; - askCaller=null; - askline=""; - askCommand=""; - tmpCaller.askCallback(tmpCommand,tmpLine); - if(!queue.isEmpty()) { - Vector v = (Vector)queue.elementAt(0); - String tmpmsg = (String)v.elementAt(2); - if (jpe!=null) jpe.say(tmpmsg+"_"); - } - } - } else { - e.consume(); - } - } - - public boolean getAskMode() { - return (askCaller != null); - } - - public void setAskMode(AskInterface askCaller,String command,String usermsg,boolean oneshot) { - setAskMode(askCaller,command,usermsg,oneshot,false); - } - - public void setAskMode(AskInterface askCaller,String command,String usermsg,boolean oneshot,boolean tab) { - if(getAskMode()) { - System.err.println("Trying to ask multiple questions."); - Vector v = new Vector(); - v.addElement(askCaller); - v.addElement(command); - v.addElement(usermsg); - v.addElement(new Boolean(oneshot)); - v.addElement(new Boolean(tab)); - queue.addElement(v); - return; - } - this.askCaller=askCaller; - this.askCommand=command; - this.usermsg=usermsg; - this.oneshot=oneshot; - this.tab=tab; - if (jpe!=null) jpe.say(usermsg+"_"); - } - -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/Log.java b/jpe/src/java/com/generationjava/apps/jpe/Log.java deleted file mode 100644 index 1aa61955..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/Log.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.generationjava.apps.jpe; - -// Log.java - -import java.io.PrintStream; -import java.util.Date; - -public class Log extends Object { - - static PrintStream err = System.err; - - public static void setErr(PrintStream ps) { - err = ps; - } - - public static void log(Throwable t) { - log(t.getMessage(),t); - } - - public static void log(String str, Throwable t) { - log(str); - t.printStackTrace(err); - } - - public static void log(String str) { - if(str == null) { - log("null"); - } else { - String date = ""+new Date(); - err.println("**"+date+"**"); - err.println(str); - } - } - - public static void log(Object obj) { - if(obj == null) { - log("null"); - } else { - log(obj.toString()); - } - } -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/Log2AreaStream.java b/jpe/src/java/com/generationjava/apps/jpe/Log2AreaStream.java deleted file mode 100644 index b23975e1..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/Log2AreaStream.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.generationjava.apps.jpe; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -public class Log2AreaStream extends FilterOutputStream -{ - OpenFile file; - - public void setFile(OpenFile file) { - this.file=file; - } - - - public Log2AreaStream(OutputStream LStream) { - super(LStream); - } - - - public void write(byte b[]) throws IOException { - String s=new String(b); - file.appendText(s); - } - - public void write(byte b[], int off, int len) throws IOException { - String s=new String(b, off, len); - file.appendText(s); - } -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/LogHandler.java b/jpe/src/java/com/generationjava/apps/jpe/LogHandler.java deleted file mode 100644 index beda3c71..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/LogHandler.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.generationjava.apps.jpe; - -import java.awt.Menu; -import java.awt.MenuBar; -import java.awt.MenuShortcut; -import java.awt.event.ActionEvent; -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -/** -* Log handler handles all the request from the log menu -* extends Handler object so it can be loaded in JPE object -*/ -public class LogHandler extends AbstractHandler { - - // new printstreams to handle the rerouted output/error - PrintStream lpso; - PrintStream lpse; - PrintStream jpse; - - - // Strings for the pulldown - String StdOutString=getText("JPE.menu.Log.out"); - String StdErrString=getText("JPE.menu.Log.err"); - String JpeErrString=getText("JPE.menu.Log.jpe"); - - // swap file keeps pointer to the file that was open when the - // user called the out/error window to support toggle function - OpenFile swapFile; - - // Openfiles to store the data we get from the rerouted streams - OpenFile stdOut; - OpenFile stdErr; - OpenFile jpeErr; - - /** - * create the log handler - */ - public LogHandler(JPE jpe) { - super(jpe); - setName(getText("JPE.menu.Log")); - - // create the Openfile that will hold our StdOut data - stdOut=new OpenFile(StdOutString); - // create a new stream for stdout - Log2AreaStream laso=new Log2AreaStream(new ByteArrayOutputStream()); - // set the file in our our new stream so it knows where to leave its data - laso.setFile(stdOut); - // create a new printStream from our stream - lpso=new PrintStream(laso); - // ask the system/jvm to reroute stdout to our new stream - System.setOut(lpso); - - // create the Openfile that will hold our StdErr data - stdErr=new OpenFile(StdErrString); - // create a new stream for stderr - Log2AreaStream lase=new Log2AreaStream(new ByteArrayOutputStream()); - // set the file in our our new stream so it knows where to leave its data - lase.setFile(stdErr); - // create a new printStream from our stream - lpse=new PrintStream(lase); - // ask the system/jvm to reroute stderr to our new stream - System.setErr(lpse); - - jpeErr=new OpenFile(JpeErrString); - Log2AreaStream jase=new Log2AreaStream(new ByteArrayOutputStream()); - jase.setFile(jpeErr); - jpse=new PrintStream(jase); - Log.setErr(jpse); - - } - - /** - * called by superclass to create its menu - */ - public void createMenu(MenuBar bar) { - Menu m = new Menu( getName() ); - m.add(new JPEMenuItem(StdOutString,new MenuShortcut('D'))); - m.add(new JPEMenuItem(StdErrString,new MenuShortcut('H'))); - m.add(new JPEMenuItem(JpeErrString, new MenuShortcut('H',true))); - m.addActionListener(this); - bar.add(m); - } - - - /** - * AWT callback (implemented in Handler) for menu events - */ - public void actionPerformed(ActionEvent evt) { - String cmd = evt.getActionCommand(); - if (cmd.equals(StdOutString)) { - doSwitchFile(stdOut); - } else if (cmd.equals(StdErrString)) { - doSwitchFile(stdErr); - } else if (cmd.equals(JpeErrString)) { - doSwitchFile(jpeErr); - } - } - - public void doSwitchFile(OpenFile file) { - // get the text handler - Editor editor = getJPE().getEditor(); - if(file == editor.getEditFile()) { - // switch to swap file since we were allready active - editor.useFile(swapFile); - } else { - // switch to file - OpenFile current = editor.getEditFile(); -// if(file != current) { - if( stdOut != current ) { - if( stdErr != current ) { - if( jpeErr != current ) { - swapFile = editor.getEditFile(); - } - } - } -// } - editor.useFile(file); - } - } - - /** - * clear both the stdout and stderror file - */ - public void clearLogs() { - stdOut.setText(""); - stdErr.setText(""); - } - - /** - * obtain the text from stderror (used by the compiler) - */ - public String getErrorText() { - if(stdErr != null) { - return stdErr.getText(); - } else { - return null; - } - } - -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/OpenFile.java b/jpe/src/java/com/generationjava/apps/jpe/OpenFile.java deleted file mode 100644 index 2b78f0b5..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/OpenFile.java +++ /dev/null @@ -1,185 +0,0 @@ -package com.generationjava.apps.jpe; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; - -/** -* OpenFile defines a opened file within JPE, it handles its buffers -* status and how it gets loaded and saved. -*/ -public class OpenFile { - - String filename; - String text=""; - int savedpos=0; - int errorpos=-1; - boolean dirty=false; - boolean compiled=false; - boolean locked=false; - - /** - * Create a Openfile if possible it will load it from storage - */ - public OpenFile(String filename) { - this.filename=filename; - loadFile(); - } - - - - /** - * get the name of the file - */ - public String getName() { - return(filename); - } - - /** - * set a new filename for this file - */ - public void setName(String filename) { - this.filename=filename; - } - - - /** - * load the file from disk into the buffer - */ - public void loadFile() { - String part; - File file=new File(filename); - if(!file.exists()) { - dirty = false; - return; - } - try { - // optimise here with a size for buffer. use file size - StringBuffer all = new StringBuffer((int)file.length()); - FileReader fr = new FileReader(file); - BufferedReader br = new BufferedReader(fr); - - while ( (part=br.readLine()) != null) - { - all.append(part); - all.append('\n'); - } - - br.close(); - fr.close(); - text=all.toString(); - - // chop ending newline - if(text.length() > 0) { - text = text.substring(0,text.length()-1); - } - } catch (IOException ioe) { - Log.log(ioe); - } - - dirty=false; - } - - /** - * return the text of this file - */ - public String getText() { - return(text); - } - - /** - * set the text of this file - */ - public void setText(String text) { - this.text=text; - } - - /** - * append text to the current file - */ - public void appendText(String text) { - this.text+=text; - } - - - /** - * save file to storage - */ - public void saveFile() { - try { - File file=new File(filename); - FileWriter fw = new FileWriter(file); - BufferedWriter bw=new BufferedWriter(fw); - bw.write(text,0,text.length()); - bw.close(); - fw.close(); - } catch (IOException e) { - e.printStackTrace(); - } - dirty=false; - } - - - /** - * set the cursor position within the file - */ - public void setCaretPosition(int pos) { - savedpos=pos; - } - - /** - * get the cursor position within the file - */ - public int getCaretPosition() { - return savedpos; - } - - public int getErrorPos() { - return errorpos; - } - - public void setErrorPos(int errorpos) { - this.errorpos=errorpos; - } - - public boolean isCompiled() { - return compiled; - } - - public boolean isLocked() { - return locked; - } - - public boolean isDirty() { - return dirty; - } - - public void setDirty() { - dirty=true; - clearCompiled(); - } - - public void clearDirty() { - dirty=false; - } - - public void clearCompiled() { - compiled=false; - } - public void setCompiled() { - compiled=true; - } - - public void clearLocked() { - locked=false; - } - - public void setLocked() { - locked=true; - } - - -} diff --git a/jpe/src/java/com/generationjava/apps/jpe/OpenFileHandler.java b/jpe/src/java/com/generationjava/apps/jpe/OpenFileHandler.java deleted file mode 100644 index 1fd3da8d..00000000 --- a/jpe/src/java/com/generationjava/apps/jpe/OpenFileHandler.java +++ /dev/null @@ -1,268 +0,0 @@ -package com.generationjava.apps.jpe; - -import java.awt.Menu; -import java.awt.MenuBar; -import java.awt.MenuShortcut; -import java.awt.event.ActionEvent; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Vector; - -/** -* OpenFileHandler handles all the request from the opened menu -* extends Handler object so it can be loaded in JPE object -*/ -public class OpenFileHandler extends AbstractHandler { - - // hashtable with the opened files - private Hashtable openfiles=new Hashtable(); - - // pointer to its menu - private Menu menu; - - // used to signify whether the ctrl-,/ctrl-. is in effect. - private boolean existsBefore; - private boolean existsAfter; - - /** - * create the opened file handler - */ - public OpenFileHandler(JPE jpe) { - super(jpe); - setName(getText("JPE.menu.Opened")); - } - - /** - * reopen all the files defined by the properties (config.xml) - */ - public void openFiles() { - Vector vec = getJPE().getProperties("openfile"); - if (vec!=null) { - boolean first = true; - String resetname = null; - Enumeration e=vec.elements(); - while (e.hasMoreElements()) { - Hashtable onenode=(Hashtable)e.nextElement(); - String filename=(String)onenode.get("filename"); - if (filename.indexOf("JPE:")==0) { - filename=getJPE().getMyPath()+"\\"+filename.substring(4); - } - OpenFile file=new OpenFile(filename); - String lockstate=(String)onenode.get("locked"); - if (lockstate.equals("true")) { - file.setLocked(); - getJPE().setLockState(true); - } - String pos = (String)onenode.get("cursorpos"); - try { - int num = Integer.parseInt(pos); - file.setCaretPosition(num); - } catch(NumberFormatException nfe) { - Log.log("Bad data in config for "+filename+"'s cursor position."); - } - addFile(file); - if(first) { - resetname = filename; - first = false; - } - } - reset(resetname); - } - } - - /** - * called by superclass to create its menu - */ - public void createMenu(MenuBar bar) { - menu = new Menu( getName() ); - menu.addActionListener(this); - bar.add(menu); - } - - - /** - * AWT callback (implemented in Handler) for menu events - */ - public void actionPerformed(ActionEvent evt) { - String cmd = evt.getActionCommand(); - switchOpenFile(cmd); - } - - /** - * switch to the first opened file (called on close) - * will open the readme if no files are left - */ - public boolean switchOpenFile() { - // get the 'first' in the hashtable - Enumeration e=openfiles.keys(); - if (e.hasMoreElements()) { - // one found switch to it - String filename=(String)e.nextElement(); - return(switchOpenFile(filename)); - } else { - // what no open files anymore ? lets open the default then - OpenFile file=new OpenFile(getJPE().getMyPath()+"\\readme.txt"); - // since the file was closed open it first - addFile(file); - // use the readme files - Editor editor=getJPE().getEditor(); - editor.useFile(file); - reset(getJPE().getMyPath()+"\\readme.txt"); - } - return(false); - } - - /** - * switch to a opened file, will return false if it was not - * opened - */ - public boolean switchOpenFile(String filename) { - if (filename.indexOf("JPE:")==0) { - filename=getJPE().getMyPath()+"\\"+filename.substring(4); - } - - // get the requested file from our list - OpenFile file=(OpenFile)openfiles.get(filename); - if (file!=null) { - // file found so make it active and return true - Editor editor=getJPE().getEditor(); - editor.useFile(file); - reset(filename); - return(true); - } else { - // file was not opened return false - return(false); - } - } - - private void reset(String filename) { - int menusz = menu.getItemCount(); - existsBefore = false; - existsAfter = false; - for(int i=0;i -
- - - - - - - - - - - - -
-
- - - - - - - - - -
-
- - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - -
- - diff --git a/lleutragen/docs/hendocument.css b/lleutragen/docs/hendocument.css deleted file mode 100755 index 20471bd9..00000000 --- a/lleutragen/docs/hendocument.css +++ /dev/null @@ -1,85 +0,0 @@ - body{font-family:verdana,tahoma;} - td{font-family:verdana,tahoma;} - dt{font-weight:bold;} - code{background:#eeeeee;} - - - -/* ----- Pure CSS tabs start here ----- */ -/* ------- Aguired from Mark Pilgrim -- */ -/* ---http://diveIntoMark.org/about --- */ -#nav ul { - display: block; - list-style: none outside; - padding: 0; - margin: 10px 0 0 10px; - font-family: Verdana, sans-serif; - font-size: x-small; -} - - - -#nav li { - padding: 0; - margin: 0 4px 0 0; - border-top: 1px solid #cecbc6; - border-right: 1px solid #cecbc6; - border-left: 1px solid #cecbc6; - background-color: #000000; - color: #ffffff; - font-weight: bold; - /* the next 4 lines are magic */ - display: block; - float: left; - position: relative; - top: -1.32em; -} - - - -#nav a:link, -#nav a:visited { - background-color: #000000; - color: #ffffff; - text-decoration: none; - padding-left: 1em; - padding-right: 1em; -} - - - -#nav a:hover { - background-color: #cecbc6; - color: #000000; -} - - - -#navclear { - display: none; -} - - - -html>body #navclear { - display: block; - clear: both; -} - - - -/* ----- now highlight active tab based on body @class attribute ----- */ -body.lleutranet #nav li#nav-lleutranet a, -body.hen #nav li#nav-hen a, -body.javadoc #nav li#nav-javadoc a, -body.docs #nav li#nav-docs a, -body.books #nav li#nav-books a, -body.mydocs #nav li#nav-mydocs a, -body.hendocs #nav li#nav-hendocs a, -{ - background-color: #fff; - color: #000000; -} - - - diff --git a/lleutragen/generate-site.pl b/lleutragen/generate-site.pl deleted file mode 100755 index 2cdc9f55..00000000 --- a/lleutragen/generate-site.pl +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/perl -w - -use Template; -use XML::Simple; -use Data::Dumper; - -my $db = XMLin('db/db.xml', forcearray=>1); - -my $tt = Template->new(); -my $input = 'templates/lleutranet.tt'; - -# order is a big hack. simple-xml's hash usage is a bit crappen. -my @sections = sort { $db->{'section'}->{$a}->{'order'} cmp $db->{'section'}->{$b}->{'order'} } (keys %{$db->{'section'}}); - -foreach $section (@sections) { - print "Generating $section. \n"; - my $vars = { - db => $db, - this_section => $section, - sections => \@sections - }; - $tt->process($input, $vars, "docs/$section.html") || die $tt->error(); -} - - -#print Dumper($db); - -#$db = $db->{'section'}; - - -#print Dumper($db); - -#foreach $section (keys %{$db}) { -# foreach $image ( @{$db->{$section}->{'image'}} ) { -# $imgUri = $image->{'uri'}; -# print "$imgUri for image\n"; -# } -# foreach $category ( keys %{$db->{$section}->{'category'}} ) { -# foreach $bookmark ( @{$db->{$section}->{'category'}->{$category}->{'bookmark'}} ) { -# $uri = $bookmark->{'uri'}; -# $label = $bookmark->{'label'}; -# print "$uri/$label\n"; -# } -# } -#} diff --git a/lleutragen/templates/lleutranet.tt b/lleutragen/templates/lleutranet.tt deleted file mode 100755 index cab91a92..00000000 --- a/lleutragen/templates/lleutranet.tt +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - -[% this_section %] page - - - - - - - - - - - - - - - -
- - - - - - - -

lleutranet - [% this_section %]

- - [% FOREACH image IN db.section.$this_section.image -%] - - [% END -%] - - [% FOREACH category IN db.section.$this_section.category.keys -%] -
- [% category %] -
    - [% FOREACH bookmark IN db.section.$this_section.category.$category.bookmark -%] -
  • [% bookmark.label %]
  • - [% END -%] -
-
- [% END -%] - - - - - - diff --git a/logview2/maven.xml b/logview2/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/logview2/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/logview2/project.properties b/logview2/project.properties deleted file mode 100644 index 41164f3a..00000000 --- a/logview2/project.properties +++ /dev/null @@ -1,14 +0,0 @@ -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.javadoc.stylesheet = ../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/logview2/project.xml b/logview2/project.xml deleted file mode 100644 index 56af1459..00000000 --- a/logview2/project.xml +++ /dev/null @@ -1,185 +0,0 @@ - - - - 3 - - - logview - - - LogView - - - 2.0 - - - OSJava - http://www.osjava.org - http://www.osjava.org/images/osjava.gif - - - 2002 - - - org.osjava - - - http://www.osjava.org/images/1x1.gif - - - ReportRunner package for reporting on log files. - - - Log reporting plugin - - - http://www.osjava.org/logview/ - - - http://www.osjava.org:8080/jira/browse/BrowseProject.jspa?id=10070 - - - scm:svn:http://svn.osjava.org/svn/osjava/trunk/logview2 - http://svn.osjava.org/svn/osjava/trunk/logview2 - - - - - osjava-users - http://lists.osjava.org/mailman/listinfo/osjava-users - http://lists.osjava.org/mailman/listinfo/osjava-users - http://lists.osjava.org/mailman/private/osjava-users/ - - - - - - - - - Henri Yandell - bayard - bayard at osjava.org - GenerationJava - - Java Developer - - - - - - - - - - - - - - - reportrunner - reportrunner - 0.5.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - genjava - gj-core - 3.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - genjava - gj-xml - 1.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - commons-io - commons-io - 1.0 - - - commons-codec - commons-codec - 1.3 - - - commons-lang - commons-lang - 2.0 - - - - - - - - src/java - - - src/test - - - - **/*Test.java - - - - - - - webapp/ - conf/renderers.xml - - - - - - - - maven-jxr-plugin - maven-javadoc-plugin - maven-license-plugin - maven-changes-plugin - maven-statcvs-plugin - maven-changelog-plugin - - - - diff --git a/logview2/src/java/org/osjava/logview/reports/ApacheLogReport.java b/logview2/src/java/org/osjava/logview/reports/ApacheLogReport.java deleted file mode 100644 index 2fe78a0a..00000000 --- a/logview2/src/java/org/osjava/logview/reports/ApacheLogReport.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.osjava.logview.reports; - -import java.io.*; -import java.util.*; - -import org.osjava.reportrunner.*; -import org.osjava.logview.text.*; - -import org.apache.commons.io.IOUtils; - -public abstract class ApacheLogReport extends AbstractReport { - - private String resourceName; - - public void setResource(String name, String resourceName) { - this.resourceName = resourceName; -System.out.println(""+this.resourceName); - } - - public Result execute() { - - // get File - ReportGroup group = super.getReportGroup(); - // TODO: Fix bug in which this.resourceName is not set to logfile - Resource resource = group.getResource("logfile"); - - FileReader rdr = null; - - // ip, login, username, time, method, url, protocol, status, bytes, referrer, user-agent - RegexpParser dlp = new RegexpParser("([^ ]*) ([^ ]*) ([^ ]*) \\[([^\\]]*)\\] \"([^ ]*) ([^ ]*) ([^\"]*)\" ([0-9]*) ([0-9-]*) \"([^\"]*)\" \"([^\"]*)\""); - - // read a line at a time, parsing into an Object[] with a parser - int count = 0; - try { - count++; - File file = (File) resource.accessResource(); - rdr = new FileReader(file); - BufferedReader bfr = new BufferedReader(rdr); - String line = null; - while( (line = bfr.readLine()) != null ) { - addToReport( dlp.parse(line) ); - } - } catch(IOException ioe) { - ioe.printStackTrace(); - } finally { - IOUtils.closeQuietly(rdr); - } - - return executeReport(); - } - - public abstract void addToReport(String[] fields); - public abstract Result executeReport(); - - public Choice[] getParamChoices(Param param) { - return null; - } - - public String[] getResourceNames() { - return new String[] { "logfile" }; - } - -} diff --git a/logview2/src/java/org/osjava/logview/reports/HitsByResponseCodeLogReport.java b/logview2/src/java/org/osjava/logview/reports/HitsByResponseCodeLogReport.java deleted file mode 100644 index 848652d5..00000000 --- a/logview2/src/java/org/osjava/logview/reports/HitsByResponseCodeLogReport.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.osjava.logview.reports; - -import org.osjava.reportrunner.*; -import java.util.*; - -public class HitsByResponseCodeLogReport extends ApacheLogReport { - - private static Map formattedMap = new HashMap(); - - static { - formattedMap.put("100", "Code 100 - Continue"); - formattedMap.put("101", "Code 101 - Switching Protocols"); - formattedMap.put("200", "Code 200 - OK"); - formattedMap.put("201", "Code 201 - Created"); - formattedMap.put("202", "Code 202 - Accepted"); - formattedMap.put("203", "Code 203 - Non-Authoritative Information"); - formattedMap.put("204", "Code 204 - No Content"); - formattedMap.put("205", "Code 205 - Reset Content"); - formattedMap.put("206", "Code 206 - Partial Content"); - formattedMap.put("300", "Code 300 - Multiple Choices"); - formattedMap.put("301", "Code 301 - Moved Permanently"); - formattedMap.put("302", "Code 302 - Moved Temporarily"); - formattedMap.put("303", "Code 303 - See Other"); - formattedMap.put("304", "Code 304 - Not Modified"); - formattedMap.put("305", "Code 305 - Use Proxy"); - formattedMap.put("400", "Code 400 - Bad Request"); - formattedMap.put("401", "Code 401 - Unauthorized"); - formattedMap.put("402", "Code 402 - Payment Required"); - formattedMap.put("403", "Code 403 - Forbidden"); - formattedMap.put("404", "Code 404 - Not Found"); - formattedMap.put("405", "Code 405 - Method Not Allowed"); - formattedMap.put("406", "Code 406 - Not Acceptable"); - formattedMap.put("407", "Code 407 - Proxy Authentication Required"); - formattedMap.put("408", "Code 408 - Request Time-Out"); - formattedMap.put("409", "Code 409 - Conflict"); - formattedMap.put("410", "Code 410 - Gone"); - formattedMap.put("411", "Code 411 - Length Required"); - formattedMap.put("412", "Code 412 - Precondition Failed"); - formattedMap.put("413", "Code 413 - Request Entity Too Large"); - formattedMap.put("414", "Code 414 - Request-URL Too Large"); - formattedMap.put("415", "Code 415 - Unsupported Media Type"); - formattedMap.put("500", "Code 500 - Server Error"); - formattedMap.put("501", "Code 501 - Not Implemented"); - formattedMap.put("502", "Code 502 - Bad Gateway"); - formattedMap.put("503", "Code 503 - Out of Resources"); - formattedMap.put("504", "Code 504 - Gateway Time-Out"); - formattedMap.put("505", "Code 505 - HTTP Version not supported"); - } - - Map map = new HashMap(); - - public void addToReport(String[] line) { - Integer count = (Integer) map.get(line[7]); - if(count == null) { - count = new Integer(1); - map.put( line[7], count ); - } else { - map.put( line[7], new Integer( count.intValue() + 1) ); - } - } - - public Result executeReport() { - List codes = new ArrayList(map.size()); - List counts = new ArrayList(map.size()); - Iterator iterator = map.keySet().iterator(); - while(iterator.hasNext()) { - String key = (String) iterator.next(); - codes.add( format(key) ); - counts.add( map.get(key) ); - } - return new ArrayResult( new Object[] { codes.toArray(), counts.toArray() } ); - } - - public String format(String key) { - String formatted = (String) formattedMap.get(key); - if(formatted == null) { - return key; - } else { - return formatted; - } - } -} diff --git a/logview2/src/java/org/osjava/logview/reports/ShowLogReport.java b/logview2/src/java/org/osjava/logview/reports/ShowLogReport.java deleted file mode 100644 index 71744fba..00000000 --- a/logview2/src/java/org/osjava/logview/reports/ShowLogReport.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.osjava.logview.reports; - -import org.osjava.reportrunner.*; -import java.util.ArrayList; -import java.util.List; - -public class ShowLogReport extends ApacheLogReport { - - private List list = new ArrayList(); - - public void addToReport(String[] line) { - list.add( line ); - } - - public Result executeReport() { - return new ArrayResult(getLines().toArray()); - } - - protected List getLines() { - return this.list; - } - -} diff --git a/logview2/src/java/org/osjava/logview/reports/TotalLogReport.java b/logview2/src/java/org/osjava/logview/reports/TotalLogReport.java deleted file mode 100644 index 64262e39..00000000 --- a/logview2/src/java/org/osjava/logview/reports/TotalLogReport.java +++ /dev/null @@ -1,237 +0,0 @@ -package org.osjava.logview.reports; - -import java.io.*; -import java.util.*; - -import org.osjava.reportrunner.*; -import org.osjava.logview.text.*; - -import org.apache.commons.lang.math.NumberUtils; -import java.text.SimpleDateFormat; -import java.text.ParseException; - -// TODO: Rename to SummaryLogReport -/** - * Categorically NOT threadsafe. - */ -public class TotalLogReport extends ApacheLogReport { - - public static long VISIT_INTERVAL = 30 * 60 * 1000; - - private static SimpleDateFormat fmt = new SimpleDateFormat("dd/MMM/yyyy:hh:mm:ss Z"); - - private static Column[] columns = Column.createColumns( new String[] { - "Hits", - "Files", - "Pages", - "Visits", - "Bytes", - "Unique Sites", - "Unique Urls", - "Unique Referrers", - "Unique User Agents", - "Average hits per hour", - "Average hits per day", - "Average files per day", - "Average pages per day", - "Average visits per day", - "Average bytes per day", - "Max hits per hour", - "Max hits per day", - "Max files per day", - "Max pages per day", - "Max visits per day", - "Max bytes per day", - } ); - - // for unique counts - private Set siteSet = new HashSet(); - private Set urlSet = new HashSet(); - private Set referrerSet = new HashSet(); - private Set userAgentSet = new HashSet(); - - // for counts/averages/maxes - private StatCounter hitsPerHour = new StatCounter(); - private StatCounter hitsPerDay = new StatCounter(); - private StatCounter filesPerDay = new StatCounter(); - private StatCounter pagesPerDay = new StatCounter(); - private StatCounter visitsPerDay = new StatCounter(); - private StatCounter bytesPerDay = new StatCounter(); - - private String lastDay = null; - private String lastHour = null; - - // used to calculate visits - private Map visitMap = new HashMap(); - - // ip, login, username, time, method, url, protocol, status, bytes, referrer, user-agent - public void addToReport(String[] line) { - - // BUG: fill in missing days/hours. Averages are off otherwise. - // Get timestamp in Date form - // look at lastDate, find hour difference or day difference - // and call endChunk that number of times - - // uses temporary string hack :- fails when daylight saving happens - - // chop minutes onwards off - String hour = line[3].substring(0, 13); - - // chop hours onwards off - String day = line[3].substring(0, 10); - - // check if it's a new hour - if(!hour.equals(lastHour)) { - lastHour = hour; - hitsPerHour.endChunk(); - } - - // check if it's a new day - if(!day.equals(lastDay)) { - lastDay = day; - hitsPerDay.endChunk(); - filesPerDay.endChunk(); - pagesPerDay.endChunk(); - visitsPerDay.endChunk(); - bytesPerDay.endChunk(); - } - - // hit occurred - hitsPerHour.add(1); - hitsPerDay.add(1); - - // file occurred - if("200".equals(line[7])) { - filesPerDay.add(1); - } - - // page occurred - // TODO: Needs to improve to strip off the query parameters - // TODO: Consider having "/$" be a page - if( line[5].endsWith(".html") || - line[5].endsWith(".htm") || - line[5].endsWith(".cgi") ) - { - pagesPerDay.add(1); - - Date lastHit = (Date) visitMap.get(line[0]); - Date thisHit = convert(line[3]); - // visit occurred - if(lastHit == null || - thisHit.getTime() - lastHit.getTime() > VISIT_INTERVAL) - { - visitsPerDay.add(1); - visitMap.put(line[0], thisHit); - } - } - - // bytes occurred - bytesPerDay.add( NumberUtils.stringToInt(line[8]) ); - - siteSet.add(line[0]); - urlSet.add(line[5]); - referrerSet.add(line[9]); - userAgentSet.add(line[10]); - } - - public Result executeReport() { - hitsPerHour.endChunk(); - hitsPerDay.endChunk(); - filesPerDay.endChunk(); - pagesPerDay.endChunk(); - visitsPerDay.endChunk(); - bytesPerDay.endChunk(); - - return new ArrayResult( columns, new Object[] { new Object[] { - new Integer(hitsPerDay.count()), - new Integer(filesPerDay.count()), - new Integer(pagesPerDay.count()), - new Integer(visitsPerDay.count()), - new Integer(bytesPerDay.count()), - new Integer(siteSet.size()), - new Integer(urlSet.size()), - new Integer(referrerSet.size()), - new Integer(userAgentSet.size()), - new Double(hitsPerHour.average()), - new Double(hitsPerDay.average()), - new Double(filesPerDay.average()), - new Double(pagesPerDay.average()), - new Double(visitsPerDay.average()), - new Double(bytesPerDay.average()), - new Integer(hitsPerHour.max()), - new Integer(hitsPerDay.max()), - new Integer(filesPerDay.max()), - new Integer(pagesPerDay.max()), - new Integer(visitsPerDay.max()), - new Integer(bytesPerDay.max()), - } } ); - } - - private static Date convert(String dateStr) { - try { - // 07/Mar/2005:23:36:01 -0500 - return fmt.parse(dateStr); - } catch(ParseException pe) { - pe.printStackTrace(); - return null; - } - } - -} - -class StatCounter { - - // the total of the current chunk - private int runningTotal; - - // the total of all chunks so far - private int chunksTotal; - - // the number of chunks so far - private int chunkCount; - - // the current max chunked value - private int max; - - public void add(int value) { - runningTotal += value; - } - - public void endChunk() { - if(runningTotal > max) { - max = runningTotal; - } - chunksTotal += runningTotal; - chunkCount++; - runningTotal = 0; - } - - public int count() { - return chunksTotal; - } - - public int max() { - return max; - } - - public double average() { - if(chunkCount == 0) { - return 0; - } - return round( ( (double) chunksTotal ) / ( (double) chunkCount ), 2); - } - - private double round(double value, int precision) { - double valueNum = Math.floor(value); - double decimal = value - valueNum; - for(int i=precision; i>0; i--) { - decimal *= 10; - } - decimal = Math.round(decimal); - for(int i=precision; i>0; i--) { - decimal /= 10; - } - return valueNum + decimal; - } - -} diff --git a/logview2/src/java/org/osjava/logview/text/DelimitedLineParser.java b/logview2/src/java/org/osjava/logview/text/DelimitedLineParser.java deleted file mode 100644 index 5d806839..00000000 --- a/logview2/src/java/org/osjava/logview/text/DelimitedLineParser.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.osjava.logview.text; - -import org.apache.commons.lang.StringUtils; - -public class DelimitedLineParser { - - private String delimiter; - - public DelimitedLineParser(String delimiter) { - this.delimiter = delimiter; - } - - public String[] parse(String line) { - String[] values = StringUtils.split(line, this.delimiter); - return values; - } - -} diff --git a/logview2/src/java/org/osjava/logview/text/RegexpParser.java b/logview2/src/java/org/osjava/logview/text/RegexpParser.java deleted file mode 100644 index c31c6acc..00000000 --- a/logview2/src/java/org/osjava/logview/text/RegexpParser.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.osjava.logview.text; - -import java.util.regex.*; - -public class RegexpParser { - - private String re; - - public RegexpParser(String re) { - this.re = re; - } - - public String[] parse(String line) { - Pattern pattern = Pattern.compile(this.re); - Matcher matcher = pattern.matcher(line); - matcher.matches(); - int sz = matcher.groupCount(); - String[] values = new String[sz]; - for(int i=1; i<=sz; i++) { - values[i-1] = matcher.group(i); - } - return values; - } - -} diff --git a/logview2/src/reports/logview.xml b/logview2/src/reports/logview.xml deleted file mode 100644 index d0d5f8fb..00000000 --- a/logview2/src/reports/logview.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - txt,csv,excel,invhtml,html - ip,login,username,timestamp,request,status,bytes,referrer,user-agent - - - - - - - - - txt,csv,excel,invhtml,html - hits,files,pages,visits,bytes,unique sites,uniqute urls,unique referrers,unique user-agents - - - - txt,csv,excel,invhtml,html - - - - - - diff --git a/mudclient/config.properties b/mudclient/config.properties deleted file mode 100644 index 1abca567..00000000 --- a/mudclient/config.properties +++ /dev/null @@ -1,84 +0,0 @@ -# Configuration for elephant mud client 0.4 - -# Name of the host to connect to. -net.host=cyberiantiger.org -# Port to connect to. -net.port=443 -# Terminal string to send. -net.terminal=ANSI -net.useProxy=yes -net.useJvmProxy=no -net.proxyHost=webcache.blueyonder.co.uk -net.proxyPort=8080 - -# List of output names. -output=Default,Lines,Spam -# The name of the default output -output.default=Default - -# Output properties -output.Default.keepInput=yes - -output.Lines.width=80 -output.Lines.height=25 -output.Lines.buffer=65536 -output.Lines.float=yes -output.Lines.visible=yes -output.Lines.visibleOnOutput=yes - -output.Spam.width=80 -output.Spam.height=5 -output.Spam.buffer=100 -output.Spam.float=yes -output.Spam.visible=yes -output.Spam.visibleOnOutput=yes - -# List of message classes to handle specially. -redirect=tell,hline,pline,newbie,hero,cleric,druid,fighter,monk,ranger,rogue,warmage,boom,shout,pose,advice - -# The window(s) to send specific message classes to. -# CURRENT and DEFAULT are special cases for the default output window, -# and the currrently selected output window. -redirect.tell=Lines -redirect.hline=Lines -redirect.pline=Lines -redirect.newbie=Lines -redirect.hero=Lines -redirect.cleric=Lines -redirect.druid=Lines -redirect.fighter=Lines -redirect.monk=Lines -redirect.ranger=Lines -redirect.rogue=Lines -redirect.warmage=Lines -redirect.boom=Spam -redirect.shout=Spam -redirect.pose=Spam -redirect.advice=Lines - -# List of actionKeys with KeyStrokes to fire them. -action=sendCommand,scrollUpLine,scrollDownLine,scrollUpPage,scrollDownPage,outputLeft,outputRight,outputDefault,outputSpam,outputLines -action.sendCommand=typed \n -action.scrollUpLine=shift UP -action.scrollDownLine=shift DOWN -action.scrollUpPage=shift PAGE_UP -action.scrollDownPage=shift PAGE_DOWN -action.outputLeft=shift LEFT -action.outputRight=shift RIGHT -# Some of these are missing due to name overlaps. -# Ideally lusers should be able to edit these eventually. -action.outputDefault=alt D -action.outputSpam=alt S -action.outputLines=alt L - -alias.Default.count=5 -alias.Default.1.regexp=^3$ -alias.Default.1.replace=trip Q 9;trip Q 8;trip Q 7;trip Q 6;trip Q 5;trip Q 4;trip Q 3;trip Q 2;trip Q -alias.Default.2.regexp=^6$ -alias.Default.2.replace=bag Q 9 with quiver;bag Q 8 with quiver;bag Q 7 with quiver;bag Q 6 with quiver;bag Q 5 with quiver;bag Q 4 with quiver;bag Q 3 with quiver;bag Q 2 with quiver;bag Q with quiver -alias.Default.3.regexp=^5$ -alias.Default.3.replace=lash Q 9;lash Q 8;lash Q 7;lash Q 6;lash Q 5;lash Q 4;lash Q 3;lash Q 2;lash Q -alias.Default.4.regexp=^4$ -alias.Default.4.replace=flay Q 9;flay Q 8;flay Q 7;flay Q 6;flay Q 5;flay Q 4;flay Q 3;flay Q 2;flay Q -alias.Default.5.regexp=^7$ -alias.Default.5.replace=bs Q 9;bs Q 8;bs Q 7;bs Q 6;bs Q 5;bs Q 4;bs Q 3;bs Q 2;bs Q diff --git a/mudclient/deploy.sh b/mudclient/deploy.sh deleted file mode 100755 index 0fd084f1..00000000 --- a/mudclient/deploy.sh +++ /dev/null @@ -1,16 +0,0 @@ -#! /bin/sh - - -# Deploy script for mudclient. - -java-config -s 1 - -export JAVA_HOME="$(java-config -O)" - -mvn clean install - -jarsigner target/mudclient-1.0.jar thawtefreemail - -cp target/mudclient-1.0.jar /www/www.cyberiantiger.org/ - -java-config -s 2 diff --git a/mudclient/maven.xml b/mudclient/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/mudclient/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/mudclient/pom.xml b/mudclient/pom.xml deleted file mode 100644 index df5f8ef3..00000000 --- a/mudclient/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - 4.0.0 - org.cyberiantiger.mudclient - mudclient - 1.0 - - src/java - - - src/resources - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - org.cyberiantiger.mudclient.ElephantMudClient - true - lib - - - - - - maven-assembly-plugin - - - src/assembly/dist.xml - - - - - package - - attached - - - - - - - diff --git a/mudclient/project.properties b/mudclient/project.properties deleted file mode 100644 index 48690b15..00000000 --- a/mudclient/project.properties +++ /dev/null @@ -1,17 +0,0 @@ -maven.repo.remote=http://www.generationjava.com/jars2/,http://www.ibiblio.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=../1x1.gif - -maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory - -maven.javadoc.stylesheet = ../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/mudclient/project.xml b/mudclient/project.xml deleted file mode 100644 index 48a087a8..00000000 --- a/mudclient/project.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - 3 - mudclient - mudclient - 0.5 - - OSJava - http://www.osjava.org/ - /images/osjava.gif - - 2003 - org.cyberiantiger - /images/1x1.gif - - - mudclient - - - Mudclient -

Description

-

A mudclient written entirely in java, using the swing UI components, - and some of it's own custom components.

-

Aims

-

Initially the mud client will only work with - Elephant Mud, however later on in the - project it is planned to make specific support and features plugins.

-

The mudclient requires java 1.4 or higher which can be downloaded from - www.java.com.

-

Current Status

-

Implemented

-
    -
  • Telnet Negotiation
  • -
  • Ansi control code support
  • -
  • Elephant Mud external client mode support
  • -
  • Multiple output windows for one mud
  • -
  • Configurable Keybindings
  • -
-

To Do

-
    -
  • Make the configuration alterable at runtime
  • -
  • Make the configuration persistent
  • -
  • Aliases, Macros & Triggers
  • -
  • Support for using 'ed' whilst in external client mode
  • -
  • A pluggin framework
  • -
  • Remove specific Elephant Mud stuff and make it into a plugin
  • -
- ]]> -
- - A mudclient - - http://www.osjava.org/mudclient/ - http://issues.osjava.org:8080/jira/browse/BrowseProject.jspa?id=10011 - dist.osjava.org/maven/mudclient - /sites/org/osjava/www/maven/genjava/mudclient/ - /sites/org/osjava/www/maven/builds/ - - - scm:svn:http://svn.osjava.org/svn/osjava/trunk/mudclient - http://svn.osjava.org/svn/osjava/trunk/mudclient - - - - - 1.0 - 1.0 - HEAD - - - - - - - - - - - - Antony Riley - antony - antony@cyberiantiger.org - Cyberiantiger.org - - Java Developer - - - - - - - - - - - - - - antony@www.osjava.org - - src/java - src/test - - - - src/resources - - - - - - - src/test/config - config - - - src/test - - jndi.properties - - - - - **/*Test.java - - - - - - - - - -
- diff --git a/mudclient/src/assembly/dist.xml b/mudclient/src/assembly/dist.xml deleted file mode 100644 index 7ab6bf0a..00000000 --- a/mudclient/src/assembly/dist.xml +++ /dev/null @@ -1,35 +0,0 @@ - - dist - - dir - - false - - - target - - - *.jar - - - - - - - *.txt - - - - - diff --git a/mudclient/src/html/applet.html b/mudclient/src/html/applet.html deleted file mode 100644 index 994ffc81..00000000 --- a/mudclient/src/html/applet.html +++ /dev/null @@ -1,10 +0,0 @@ - - -Elephant mud applet - - - -Get Java - - - diff --git a/mudclient/src/html/site/blue.jpg b/mudclient/src/html/site/blue.jpg deleted file mode 100644 index 0ec6cac4..00000000 Binary files a/mudclient/src/html/site/blue.jpg and /dev/null differ diff --git a/mudclient/src/html/site/ele480x60.gif b/mudclient/src/html/site/ele480x60.gif deleted file mode 100644 index cfd4d364..00000000 Binary files a/mudclient/src/html/site/ele480x60.gif and /dev/null differ diff --git a/mudclient/src/html/site/image1.jpg b/mudclient/src/html/site/image1.jpg deleted file mode 100644 index 4cbced59..00000000 Binary files a/mudclient/src/html/site/image1.jpg and /dev/null differ diff --git a/mudclient/src/html/site/index.html b/mudclient/src/html/site/index.html deleted file mode 100644 index d68a2373..00000000 --- a/mudclient/src/html/site/index.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - Hood's Elephant Mud Client - - - -
-
Hood's Elephant Mud Client
- -
- -
-
-
Blueby
-
22-12-2005 mike
-
- Blueby is a valid XHTML and - CSS design with a stylesheet for - screen and print. Images, the menu, and the side classes are excluded from printing - (look at print preview in your browser). This is a fluid design. Fluid seems to be the - new buzz-word these days, all it means is that the design will look the same at all - screen sizes. Modifying the site for your purposes should be simple to do. Enjoy. -
-
Obligatory Lorem
-
22-12-2005 mike
- -
- Aenean lorem quam, blandit quis, hendrerit vitae, pretium sed, ante. In sollicitudin consectetuer justo. Morbi pharetra mattis erat. Aliquam erat volutpat. Cras tincidunt nisl a lectus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In sit amet neque. Duis at urna convallis velit volutpat accumsan. Suspendisse arcu ante, posuere ac, dapibus quis, scelerisque ac, neque. Quisque nec pede. -
-
More Lorem
-
22-12-2005 mike
- -
- Aenean lorem quam, blandit quis, hendrerit vitae, pretium sed, ante. In sollicitudin consectetuer justo. Morbi pharetra mattis erat. Aliquam erat volutpat. Cras tincidunt nisl a lectus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In sit amet neque. Duis at urna convallis velit volutpat accumsan. Suspendisse arcu ante, posuere ac, dapibus quis, scelerisque ac, neque. Quisque nec pede. -
-
-
- -
-
links
- -
news
-
-Created a website for the mudclient. -
-
-Added support for moving around using the keypad. -
-
- - - - - diff --git a/mudclient/src/html/site/menu_bg.png b/mudclient/src/html/site/menu_bg.png deleted file mode 100644 index 9786159a..00000000 Binary files a/mudclient/src/html/site/menu_bg.png and /dev/null differ diff --git a/mudclient/src/html/site/print.css b/mudclient/src/html/site/print.css deleted file mode 100644 index add7f275..00000000 --- a/mudclient/src/html/site/print.css +++ /dev/null @@ -1,53 +0,0 @@ -body { - font-family:"Bitstream Vera Sans",Verdana,Arial,Helvetica,Sans,"Bitstream Vera Serif"; - font-size: 0.75em; - width: 100%; - margin: 0; - padding: 0; - color: #000000; -} -img { - display: none; -} -a { - content: " (" attr(href) ") "; - color: #000000; - text-decoration: underline; -} -a:hover { - color: #000000; - text-decoration: underline; -} -#top { - height: 75px; - padding: 5px; - font-family: script; - font-size: 4em; -} -#menu { - display: none; -} -.author { - font-size: .75em; - color: #000000; - padding-bottom: 1em; -} -.content { - text-align: justify; - margin-bottom: 2em; -} -.content:first-letter { - font-family: script; - font-size: 1.5em; - color: #000000; - padding-left: 0.5em; -} -.column2 { - display: none; -} -#footer { - clear: both; - font-size: .75em; - padding: 5px; - text-align: right; -} diff --git a/mudclient/src/html/site/side_bg.png b/mudclient/src/html/site/side_bg.png deleted file mode 100644 index a9c62ad5..00000000 Binary files a/mudclient/src/html/site/side_bg.png and /dev/null differ diff --git a/mudclient/src/html/site/style.css b/mudclient/src/html/site/style.css deleted file mode 100644 index b46572ad..00000000 --- a/mudclient/src/html/site/style.css +++ /dev/null @@ -1,156 +0,0 @@ -body { - font-family: "Bitstream Vera Sans",Verdana,Arial,Helvetica,Sans,"Bitstream Vera Serif"; - font-size: 1em; - width: 100%; - margin: 0; - padding: 0; - color: #081869; - background-color: #dae7f7; -} -a { - color: #6293d6; - text-decoration: underline; -} -a:hover { - color: #6293d6; - text-decoration: none; - border-bottom: 1px solid #6293d6; -} -#top { - width: 100%; - background-image: url(blue.jpg); -} -.top_title { - color: #7ca4d5; - font-size: 3em; - text-align: right; - font-family: "Times New Roman", Times, serif; - padding: 10px; -} -.menu { - padding: 0 0 2px 20px; - border-bottom: 2px solid #0087bd; -} -.menu a { - padding: 2px 10px 2px 10px; - border: 1px solid #696969; - border-bottom: 0; - background-color: #5e93d9; - text-decoration: none; - color: #0080b3; - background-image: url(menu_bg.png); -} -.menu a:hover { - padding: 2px 10px 7px 10px; - border: 1px solid #696969; - border-bottom: 0; - background-color: #dae7f7; - text-decoration: none; - color: #0080b3; - background-image: url(menu_bg.png); -} -.menu .current a { - padding: 2px 10px 7px 10px; - border: 1px solid #696969; - border-bottom: 0; - background-color: #dae7f7; - text-decoration: none; - color: #ffffff; - background-image: url(menu_bg.png); -} -.menu .current a:hover { - padding: 2px 10px 7px 10px; - border: 1px solid #696969; - border-bottom: 0; - background-color: #dae7f7; - text-decoration: none; - color: #ffffff; -} -.contain { - float: left; - width: 80.3%; /* for Firefox */ - _width: 78%; /* IE reads this but Firefox doesn't */ - margin: 1em; - padding: 2px; - background-color: #0087bd; - border: 0px solid #363636; -} -.column1 { - float: left; - width: 98%; - padding: 1%; - background-color: #ffffff; - border: 0px solid #363636; -} -.column1 .title { - font-size: 1.5em; - font-weight: bold; - color: #6293d6; -} -.author { - font-size: .75em; - color: #54614c; - padding-bottom: 1em; -} -.content { - text-align: justify; - margin-bottom: 2em; -} -.content:first-letter { - font-family: "Times New Roman", Times, serif; - font-size: 1.5em; - color: #6293d6; - padding-left: 0.5em; -} -.column2 { - float: left; - width: 13%; - padding: 8px; - background-color: #f7fbfe; - font-size: .75em; -} -.column2 .side_title { - font-weight: bold; - border-bottom: 2px solid #7ca4d5; - color: #7ca4d5; -} -.column2 .side_content { - border-top: 1px solid #0087bd; - border-bottom: 1px solid #0087bd; - padding: 5px; - margin-bottom: 2em; - background-image: url(side_bg.png); -} -.img_left { - float: left; - margin-right: 3px; - border: 1px solid #000000; -} -.img_right { - float: right; - margin-left: 3px; - border: 1px solid #000000; -} -#footer { - clear: both; - height: 15px; - font-size: .75em; - border-top: 2px solid #0087bd; - padding: 5px; - background-color: #f7fbfe; -} -#footer a { - text-decoration: none; -} -#footer a:hover { - border: 0; -} -.left { - float: left; -} -.right { - float: right; -} -UL.links { - -} diff --git a/mudclient/src/java/org/cyberiantiger/console/AbstractConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/AbstractConsoleAction.java deleted file mode 100644 index 72dd5d47..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/AbstractConsoleAction.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.cyberiantiger.console; - -public abstract class AbstractConsoleAction implements ConsoleAction { - - public boolean isEndOfLine() { - return false; - } - - public void appendToBuffer(StringBuffer buffer) { - } - -} diff --git a/mudclient/src/java/org/cyberiantiger/console/BackgroundConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/BackgroundConsoleAction.java deleted file mode 100644 index aff4d7fb..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/BackgroundConsoleAction.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.cyberiantiger.console; - -public class BackgroundConsoleAction extends AbstractConsoleAction { - - private int color; - - public BackgroundConsoleAction(int color) { - this.color = color; - } - - public void apply(Console con) { - con.setBackground(color); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/console/BeepConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/BeepConsoleAction.java deleted file mode 100644 index 2c1335fa..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/BeepConsoleAction.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.cyberiantiger.console; - -public class BeepConsoleAction extends AbstractConsoleAction { - - public BeepConsoleAction() { - } - - public void apply(Console con) { - con.beep(); - } - -} diff --git a/mudclient/src/java/org/cyberiantiger/console/BoldConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/BoldConsoleAction.java deleted file mode 100644 index 4c1d2e71..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/BoldConsoleAction.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.cyberiantiger.console; - -public class BoldConsoleAction extends AbstractConsoleAction { - - private boolean bold; - - public BoldConsoleAction(boolean bold) { - this.bold = bold; - } - - public void apply(Console con) { - con.setBold(bold); - } - -} diff --git a/mudclient/src/java/org/cyberiantiger/console/ClearScreenConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/ClearScreenConsoleAction.java deleted file mode 100644 index 7cfe732c..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/ClearScreenConsoleAction.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.cyberiantiger.console; - -public class ClearScreenConsoleAction extends AbstractConsoleAction { - - public void apply(Console con) { - con.clearScreen(); - } - - public boolean isEndOfLine() { - return true; - } -} diff --git a/mudclient/src/java/org/cyberiantiger/console/Console.java b/mudclient/src/java/org/cyberiantiger/console/Console.java deleted file mode 100644 index 92452cd0..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/Console.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.cyberiantiger.console; - -public interface Console { - - public static final int BLACK = 0; - public static final int RED = 1; - public static final int YELLOW = 2; - public static final int GREEN = 3; - public static final int CYAN = 4; - public static final int BLUE = 5; - public static final int MAGENTA = 6; - public static final int WHITE = 7; - - public static final int BOLD = 1 << 16; - public static final int FLASH = 1 << 17; - public static final int REVERSE = 1 << 18; - - public static final int DEFAULT = (BLACK<<8) | WHITE; - - public int getBufferSize(); - - public int getWidth(); - - public int getHeight(); - - public void resize(int width, int height); - - public void moveCursorX(int x); - - public void moveCursorY(int x); - - public int getCursorX(); - - public int getCursorY(); - - public void setCursorX(int x); - - public void setCursorY(int y); - - public void drawString(String str); - - public void drawString(char[] chars); - - public void drawString(char[] chars, int offset, int len); - - public void setForeground(int color); - - public void setBackground(int color); - - public void setBold(boolean bold); - - public void setFlash(boolean flash); - - public void setReverse(boolean reverse); - - public void clearScreen(); - - public void addAction(ConsoleAction action); - - public void beep(); - -} diff --git a/mudclient/src/java/org/cyberiantiger/console/ConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/ConsoleAction.java deleted file mode 100644 index c42e3f79..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/ConsoleAction.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.cyberiantiger.console; - -public interface ConsoleAction { - - public void apply(Console console); - - public boolean isEndOfLine(); - - public void appendToBuffer(StringBuffer buffer); - -} diff --git a/mudclient/src/java/org/cyberiantiger/console/ConsoleWriter.java b/mudclient/src/java/org/cyberiantiger/console/ConsoleWriter.java deleted file mode 100644 index 7f816a8f..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/ConsoleWriter.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.cyberiantiger.console; - -public interface ConsoleWriter { - - public void consoleAction(ConsoleAction con); - -} diff --git a/mudclient/src/java/org/cyberiantiger/console/ElephantMUDConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/ElephantMUDConsoleAction.java deleted file mode 100644 index 43fafc6d..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/ElephantMUDConsoleAction.java +++ /dev/null @@ -1,220 +0,0 @@ -package org.cyberiantiger.console; - -import java.util.Map; -import java.util.HashMap; -import java.util.regex.*; -import java.io.*; - -public class ElephantMUDConsoleAction extends AbstractConsoleAction { - - private static Pattern mudMode = Pattern.compile("\\A\\(/(0|\".*\"),(0|\".*\"),(0|\".*\"),(-?\\d+),(-?\\d+),(-?\\d+),/\\)(.*)\\z$",Pattern.DOTALL); - - private static Map pinkFish = new HashMap(); - - public final static int NO_WRAP = 1; - public final static int NO_BLOCK = 2; - public final static int NO_BUFFER = 4; - public final static int IS_INVIS = 8; - public final static int IS_DEAD = 16; - public final static int IS_CHANNEL = 32; - public final static int NO_NEWLINE = 64; - - static { - ConsoleAction tmp; - pinkFish.put("RESET",new ResetConsoleAction()); - pinkFish.put("BOLD",new BoldConsoleAction(true)); - pinkFish.put("FLASH",new FlashConsoleAction(true)); - pinkFish.put("RED",new ForegroundConsoleAction(Console.RED)); - pinkFish.put("YELLOW",tmp=new ForegroundConsoleAction(Console.YELLOW)); - pinkFish.put("ORANGE",tmp); - pinkFish.put("GREEN",new ForegroundConsoleAction(Console.GREEN)); - pinkFish.put("CYAN",new ForegroundConsoleAction(Console.CYAN)); - pinkFish.put("BLUE",new ForegroundConsoleAction(Console.BLUE)); - pinkFish.put("MAGENTA",new ForegroundConsoleAction(Console.MAGENTA)); - pinkFish.put("BLACK",new ForegroundConsoleAction(Console.BLACK)); - pinkFish.put("WHITE",new ForegroundConsoleAction(Console.WHITE)); - pinkFish.put("B_RED",new BackgroundConsoleAction(Console.RED)); - pinkFish.put("B_YELLOW",tmp=new BackgroundConsoleAction(Console.YELLOW)); - pinkFish.put("B_ORANGE",tmp); - pinkFish.put("B_GREEN",new BackgroundConsoleAction(Console.GREEN)); - pinkFish.put("B_CYAN",new BackgroundConsoleAction(Console.CYAN)); - pinkFish.put("B_BLUE",new BackgroundConsoleAction(Console.BLUE)); - pinkFish.put("B_MAGENTA",new BackgroundConsoleAction(Console.MAGENTA)); - pinkFish.put("B_BLACK",new BackgroundConsoleAction(Console.BLACK)); - pinkFish.put("B_WHITE",new BackgroundConsoleAction(Console.WHITE)); - tmp = new NullConsoleAction(); - pinkFish.put("ENDTERM",tmp); - pinkFish.put("TERMSIZE",tmp); - pinkFish.put("TOINPUT",tmp); - pinkFish.put("TOMAIN",tmp); - pinkFish.put("TOSTATUS",tmp); - pinkFish.put("SC",tmp); - pinkFish.put("RC",tmp); - pinkFish.put("CLS",new ClearScreenConsoleAction()); - pinkFish.put("CLEOL",tmp); - pinkFish.put("BELL",new BeepConsoleAction()); - - // The following action(s) are not used by Elephant, but included for - // completeness - pinkFish.put("REVERSE",new ReverseConsoleAction(true)); - } - - private String pClass; - private String sClass; - private String orig; - private int flags; - private int indent; - private int wrapAt; - - private String data; - - public ElephantMUDConsoleAction(String data) { - Matcher m = mudMode.matcher(data); - if(m.matches()) { - String tmp; - tmp = m.group(1); - if(tmp.length()>1) pClass = tmp.substring(1,tmp.length()-1); - tmp = m.group(2); - if(tmp.length()>1) sClass = tmp.substring(1,tmp.length()-1); - tmp = m.group(3); - if(tmp.length()>1) orig = tmp.substring(1,tmp.length()-1); - flags = Integer.parseInt(m.group(4)); - indent = Integer.parseInt(m.group(5)); - wrapAt = Integer.parseInt(m.group(6)); - this.data = m.group(7); - } else { - this.data = data; - } - } - - public ElephantMUDConsoleAction( - String pClass,String sClass,String orig, - int flags, int indent, int wrapAt, String data - ) - { - this.pClass = pClass; - this.sClass = sClass; - this.orig = orig; - this.flags = flags; - this.indent = indent; - this.wrapAt = wrapAt; - this.data = data; - } - - public String getPrimaryClass() { - return pClass; - } - - public String getSecondaryClass() { - return sClass; - } - - public String getOrigin() { - return orig; - } - - public int getFlags() { - return flags; - } - - public int getIndent() { - return indent; - } - - public int getWrapAt() { - return wrapAt; - } - - public String getData() { - return data; - } - - public void apply(Console con) { - int w = con.getWidth(); - int h = con.getHeight(); - String[] lines = data.split("\r?\n"); - - // Check cursor position: If not at 0, newline - if(con.getCursorX() != 0) { - con.setCursorX(0); - con.moveCursorY(1); - } - - for(int i=0;i i; j--) { - if (c[j] == ' ') { - con.drawString(c, i, j - i); - i = j + 1; - con.setCursorX(0); - con.moveCursorY(1); - continue LOOP; - } - } - if ( x != 0 ) { - con.setCursorX(0); - con.moveCursorY(1); - continue LOOP; - } - for (int j = i + w - x + 1; j < c.length; j++) { - if (c[j] == ' ') { - con.drawString(c, i, j - i); - i = j + 1; - con.setCursorX(0); - con.moveCursorY(1); - continue LOOP; - } - } - con.drawString(c, i, c.length - i); - break LOOP; - } - } -} diff --git a/mudclient/src/java/org/cyberiantiger/console/FlashConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/FlashConsoleAction.java deleted file mode 100644 index 499b3c29..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/FlashConsoleAction.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.cyberiantiger.console; - -public class FlashConsoleAction extends AbstractConsoleAction { - - private boolean flash; - - public FlashConsoleAction(boolean flash) { - this.flash = flash; - } - - public void apply(Console con) { - con.setFlash(flash); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/console/ForegroundConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/ForegroundConsoleAction.java deleted file mode 100644 index 2a9373e3..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/ForegroundConsoleAction.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.cyberiantiger.console; - -public class ForegroundConsoleAction extends AbstractConsoleAction { - - private int color; - - public ForegroundConsoleAction(int color) { - this.color = color; - } - - public void apply(Console con) { - con.setForeground(color); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/console/MoveCursorXConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/MoveCursorXConsoleAction.java deleted file mode 100644 index c28ee758..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/MoveCursorXConsoleAction.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.cyberiantiger.console; - -public class MoveCursorXConsoleAction extends AbstractConsoleAction { - - private int x; - - public MoveCursorXConsoleAction(int x) { - this.x = x; - } - - public boolean isEndOfLine() { - return true; - } - - public void apply(Console con) { - con.moveCursorX(x); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/console/MoveCursorYConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/MoveCursorYConsoleAction.java deleted file mode 100644 index c8481939..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/MoveCursorYConsoleAction.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.cyberiantiger.console; - -public class MoveCursorYConsoleAction extends AbstractConsoleAction { - - private int y; - - public MoveCursorYConsoleAction(int y) { - this.y = y; - } - - public boolean isEndOfLine() { - return true; - } - - public void apply(Console con) { - con.moveCursorY(y); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/console/NullConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/NullConsoleAction.java deleted file mode 100644 index 3bbdac55..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/NullConsoleAction.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.cyberiantiger.console; - -public class NullConsoleAction extends AbstractConsoleAction { - - public NullConsoleAction() { - } - - public void apply(Console con) { - } - -} diff --git a/mudclient/src/java/org/cyberiantiger/console/ResetConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/ResetConsoleAction.java deleted file mode 100644 index 9f3cf21c..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/ResetConsoleAction.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.cyberiantiger.console; - -public class ResetConsoleAction extends AbstractConsoleAction { - - public ResetConsoleAction() { - } - - public void apply(Console con) { - con.setForeground(con.WHITE); - con.setBackground(con.BLACK); - con.setBold(false); - con.setFlash(false); - con.setReverse(false); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/console/ResizeConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/ResizeConsoleAction.java deleted file mode 100644 index c1a761f2..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/ResizeConsoleAction.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.cyberiantiger.console; - -public class ResizeConsoleAction extends AbstractConsoleAction { - - private int x; - private int y; - - public ResizeConsoleAction(int x, int y) { - this.x = x; - this.y = y; - } - - public void apply(Console con) { - con.resize(x,y); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/console/ReverseConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/ReverseConsoleAction.java deleted file mode 100644 index af44a1ac..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/ReverseConsoleAction.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.cyberiantiger.console; - -public class ReverseConsoleAction extends AbstractConsoleAction { - - private boolean reverse; - - public ReverseConsoleAction(boolean reverse) { - this.reverse = reverse; - } - - public void apply(Console con) { - con.setReverse(reverse); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/console/SetCursorXConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/SetCursorXConsoleAction.java deleted file mode 100644 index c6cfa574..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/SetCursorXConsoleAction.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.cyberiantiger.console; - -public class SetCursorXConsoleAction extends AbstractConsoleAction { - - private int x; - - public SetCursorXConsoleAction(int x) { - this.x = x; - } - - public boolean isEndOfLine() { - return true; - } - - public void apply(Console con) { - con.setCursorX(x); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/console/SetCursorYConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/SetCursorYConsoleAction.java deleted file mode 100644 index 62db4dcc..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/SetCursorYConsoleAction.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.cyberiantiger.console; - -public class SetCursorYConsoleAction extends AbstractConsoleAction { - - private int y; - - public SetCursorYConsoleAction(int y) { - this.y = y; - } - - public boolean isEndOfLine() { - return true; - } - - public void apply(Console con) { - con.setCursorY(y); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/console/StringConsoleAction.java b/mudclient/src/java/org/cyberiantiger/console/StringConsoleAction.java deleted file mode 100644 index 7c39625c..00000000 --- a/mudclient/src/java/org/cyberiantiger/console/StringConsoleAction.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.cyberiantiger.console; - -public class StringConsoleAction extends AbstractConsoleAction { - - private char[] data; - private int offset; - private int len; - - public StringConsoleAction(char[] data, int offset, int len) { - this.data = data; - this.offset = offset; - this.len = len; - } - - public void apply(Console con) { - con.drawString(data,offset,len); - } - - public void appendToBuffer(StringBuffer buffer) { - buffer.append(data,offset,len); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/ElephantApplet.java b/mudclient/src/java/org/cyberiantiger/mudclient/ElephantApplet.java deleted file mode 100644 index 417fcd5f..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/ElephantApplet.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.cyberiantiger.mudclient; - -import java.applet.Applet; - -import java.awt.Button; -import java.awt.event.ActionEvent; -import java.awt.BorderLayout; -import java.awt.AWTEvent; - -import java.lang.reflect.Method; - -import java.net.URL; -import java.net.MalformedURLException; - -import java.util.StringTokenizer; - -public class ElephantApplet extends Applet { - - public void init() { - setLayout(new BorderLayout()); - if(checkVersion(System.getProperty("java.version"))) { - add(new LaunchButton(), BorderLayout.CENTER); - } else { - add(new GetJavaButton(), BorderLayout.CENTER); - } - } - - private boolean checkVersion(String version) { - StringTokenizer tokens = new StringTokenizer(version, "."); - - if (!tokens.hasMoreTokens() || !"1".equals(tokens.nextToken())) - return false; - - if (!tokens.hasMoreTokens() || Integer.parseInt(tokens.nextToken()) < 4) - return false; - - return true; - } - - private class GetJavaButton extends Button { - - public GetJavaButton() { - super("Get Java"); - enableEvents(AWTEvent.ACTION_EVENT_MASK); - } - - protected void processActionEvent(ActionEvent ae) { - try { - getAppletContext().showDocument( - new URL("http://www.java.com/") - ); - } catch (MalformedURLException mue) { - } - } - } - - private class LaunchButton extends Button { - - public LaunchButton() { - super("Launch Mudclient"); - enableEvents(AWTEvent.ACTION_EVENT_MASK); - } - - protected void processActionEvent(ActionEvent ae) { - try { - Class clazz = Class.forName("org.cyberiantiger.mudclient.ElephantMudClient"); - Method m = clazz.getMethod("main", new Class[] { String[].class }); - m.invoke(null, new Object[] { new String[0] }); - } catch (Exception e) { - e.printStackTrace(); - } - } - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/ElephantMudClient.java b/mudclient/src/java/org/cyberiantiger/mudclient/ElephantMudClient.java deleted file mode 100644 index 1428eae1..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/ElephantMudClient.java +++ /dev/null @@ -1,186 +0,0 @@ -package org.cyberiantiger.mudclient; - -import java.util.*; -import java.io.*; -import org.cyberiantiger.console.*; -import org.cyberiantiger.mudclient.config.*; -import org.cyberiantiger.mudclient.parser.*; -import org.cyberiantiger.mudclient.net.*; -import org.cyberiantiger.mudclient.input.InputProcessor; -import org.cyberiantiger.mudclient.ui.ControlWindow; -import org.cyberiantiger.mudclient.ui.Connection; - -public class ElephantMudClient implements Display, Connection { - - private boolean echo = true; - private ControlWindow control; - private MudConnection connection; - private ConsoleWriter writer; - private InputProcessor processor; - - private ClientConfiguration config; - - public ElephantMudClient(ClientConfiguration config) { - this.config = config; - writer = new ElephantConsoleWriter(); - processor = new InputProcessor(this, this); - connection = new MudConnection(this); - control = new ControlWindow(processor); - control.show(); - } - - public void exit() { - connection.stop(); // Deprecated. - File configFile = getConfigFile(); - try { - Properties props = config.save(); - props.store(new FileOutputStream(configFile),"Elephant Mud Client"); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - System.exit(0); // Evil, but necessary. - } - - public void connect() { - connection.setParser(new ANSIParser()); - connection.connect(); - } - - public void disconnect() { - connection.disconnect(); - } - - - public void command(String sourceId, String msg) { - connection.command(msg); - } - - public void setWindowSize(int w, int h) { - connection.setWindowSize(w,h); - } - - public void connectionStatusChanged(int newStatus) { - control.connectionStatusChanged(newStatus); - } - - public void connectionDoLocalEcho(boolean echo) { - this.echo = echo; - } - - public boolean getEcho() { - return echo; - } - - public ClientConfiguration getConfiguration() { - return config; - } - - public ConsoleWriter getConsoleWriter() { - return writer; - } - - public void localEcho(String msg) { - if(echo) { - ConsoleWriter ui = control.getCurrentView(); - ui.consoleAction( - new StringConsoleAction(msg.toCharArray(),0,msg.length()) - ); - ui.consoleAction( - new SetCursorXConsoleAction(0) - ); - ui.consoleAction( - new MoveCursorYConsoleAction(1) - ); - } - } - - private class ElephantConsoleWriter implements ConsoleWriter { - - protected ConsoleWriter getView(String name) { - if(name.equals(ClientConfiguration.DEFAULT_VIEW)) { - return control.getDefaultView(); - } else if(name.equals(ClientConfiguration.CURRENT_VIEW)) { - return control.getCurrentView(); - } else { - return control.getView(name); - } - } - - public void consoleAction(ConsoleAction action) { - if(action instanceof ElephantMUDConsoleAction) { - ElephantMUDConsoleAction eAction = - (ElephantMUDConsoleAction) action; - - String pClass = eAction.getPrimaryClass(); - - Set dests = config.getOutputFor(pClass); - - - if(dests == null) { - control.getDefaultView().consoleAction(action); - } else { - Set tmp = new HashSet(); - Iterator i = dests.iterator(); - while(i.hasNext()) { - tmp.add(getView((String)i.next())); - } - - tmp.remove(null); - - i = tmp.iterator(); - while(i.hasNext()) { - ((ConsoleWriter)i.next()).consoleAction(action); - } - } - - } else { - control.getDefaultView().consoleAction(action); - } - } - - } - - private static final File getConfigFile() { - File userHome = new File(System.getProperty("user.home")); - return new File(userHome, ".mudclientrc"); - } - - private static final InputStream getDefaultConfig() { - return ElephantMudClient.class.getResourceAsStream( - "/org/cyberiantiger/mudclient/config.properties" - ); - } - - - - public static void main(String[] args) { - Properties props = new Properties(); - /* Load defaults */ - try { - props.load(getDefaultConfig()); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - if(args.length == 1) { - /* Load args[0] if set */ - try { - props.load(new FileInputStream(args[0])); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } else { - /* Load config file if exists */ - File configFile = getConfigFile(); - if (configFile.exists()) { - try { - props.load(new FileInputStream(configFile)); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } - } - ClientConfiguration config = new ClientConfiguration(); - config.load(props); - new ElephantMudClient(config); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/config/ClientConfiguration.java b/mudclient/src/java/org/cyberiantiger/mudclient/config/ClientConfiguration.java deleted file mode 100644 index 063a96f5..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/config/ClientConfiguration.java +++ /dev/null @@ -1,525 +0,0 @@ -package org.cyberiantiger.mudclient.config; - -import java.util.*; -import java.io.*; -import javax.swing.InputMap; -import javax.swing.KeyStroke; -import java.awt.Font; - -import org.cyberiantiger.mudclient.input.Alias; - -public class ClientConfiguration { - - public static final String DEFAULT_VIEW = "DEFAULT"; - public static final String CURRENT_VIEW = "CURRENT"; - - private String host; - private int port; - private String term; - private List outputs; - private String defaultOutput; - private Map redirects; - private Map outputConfigs; - private InputMap keyBindings; - private List macros; - private Map aliases; - private boolean useProxy; - private boolean useJvmProxy; - private String proxyHost; - private int proxyPort; - private String characterEncoding; - private String font; - private int fontSize; - private boolean bold; - private boolean italic; - - public ClientConfiguration() { - } - - public static int getInt(Properties props, String key, int def) - { - String prop = props.getProperty(key); - if (prop != null) { - try { - return Integer.parseInt(prop); - } catch (NumberFormatException nfe) { - } - } - return def; - } - - public static String getString(Properties props, String key, String def) - { - String prop = props.getProperty(key); - if (prop == null) { - return def; - } else { - return prop; - } - } - - public static boolean getBoolean(Properties props, String key, boolean def) - { - return "yes".equals(props.getProperty(key)); - } - - public void load(Properties props) { - StringTokenizer tmp; - Iterator i; - host = getString(props,"net.host","elephant.org"); - port = getInt(props,"net.port",4444); - term = getString(props,"net.terminal","ansi"); - useProxy = getBoolean(props,"net.useProxy",false); - useJvmProxy = getBoolean(props,"net.useJvmProxy",true); - proxyHost = getString(props,"net.proxyHost",""); - proxyPort = getInt(props,"net.proxyPort",0); - characterEncoding = getString(props,"net.characterEncoding","UTF-8"); - font = getString(props, "ui.font", "Monospaced"); - fontSize = getInt(props, "ui.fontSize", 14); - bold = getBoolean(props, "ui.bold", false); - italic = getBoolean(props, "ui.italic", false); - - tmp = new StringTokenizer(props.getProperty("output"),","); - - outputs = new ArrayList(); - while(tmp.hasMoreTokens()) { - outputs.add(tmp.nextToken()); - } - - outputConfigs = new HashMap(); - - i = outputs.iterator(); - while(i.hasNext()) { - String name = (String) i.next(); - OutputConfiguration outputConfig = new OutputConfiguration(); - outputConfig.load(props,name); - outputConfigs.put(name,outputConfig); - } - - defaultOutput = props.getProperty("output.default"); - - redirects = new HashMap(); - - tmp = new StringTokenizer(props.getProperty("redirect"),","); - - Set redirectTypes = new HashSet(); - while(tmp.hasMoreTokens()) { - redirectTypes.add(tmp.nextToken()); - } - - i = redirectTypes.iterator(); - while(i.hasNext()) { - String type = (String) i.next(); - tmp = new StringTokenizer( - props.getProperty("redirect."+type),"," - ); - Set targets = new HashSet(); - while(tmp.hasMoreTokens()) { - targets.add(tmp.nextToken()); - } - redirects.put(type,targets); - } - - tmp = new StringTokenizer(props.getProperty("action"),","); - - Set actionKeys = new HashSet(); - while(tmp.hasMoreTokens()) { - actionKeys.add(tmp.nextToken()); - } - - keyBindings = new InputMap(); - i = actionKeys.iterator(); - while(i.hasNext()) { - String actionKey = (String) i.next(); - - tmp = new StringTokenizer( - props.getProperty("action."+actionKey),","); - while(tmp.hasMoreTokens()) { - String token = tmp.nextToken(); - KeyStroke ks = KeyStroke.getKeyStroke(token); - if(ks == null) { - System.out.println("Invalid KeyStroke: "+token+" for: "+actionKey); - } else { - keyBindings.put(ks,actionKey); - } - } - } - - /* Load macros */ - { - macros = new ArrayList(); - int count = getInt(props, "macro.count", 0); - for (int a = 0; a < count; a++) { - macros.add(getString(props, "macro." + a, "")); - } - } - - /* Load aliases */ - aliases = new HashMap(); - i = outputConfigs.keySet().iterator(); - while (i.hasNext()) { - String keyName = (String) i.next(); - int count = getInt(props,"alias."+keyName+".count", 0); - if (count == 0) { - continue; - } - int c = 0; - List aliases = new ArrayList(); - while(c++ < count) { - String regexp = props.getProperty("alias."+keyName+"."+c+".regexp"); - String replace = props.getProperty("alias."+keyName+"."+c+".replace"); - boolean terminate = "yes".equals(props.getProperty("alias."+keyName+"."+c+".terminate")); - aliases.add(new Alias(regexp, replace, terminate)); - } - this.aliases.put(keyName, aliases); - } - } - - public Properties save() { - Iterator i; - Properties props = new Properties(); - props.setProperty("net.host", host); - props.setProperty("net.port", "" + port); - props.setProperty("net.terminal", term); - props.setProperty("net.useProxy", useProxy ? "yes" : "no"); - props.setProperty("net.useJvmProxy", useJvmProxy ? "yes" : "no"); - props.setProperty("net.proxyHost", proxyHost); - props.setProperty("net.proxyPort", "" + proxyPort); - props.setProperty("net.characterEncoding", characterEncoding); - props.setProperty("ui.font", font); - props.setProperty("ui.fontSize", "" + fontSize); - props.setProperty("ui.bold", bold ? "yes" : "no"); - props.setProperty("ui.italic", italic ? "yes" : "no"); - - StringBuffer tmp = new StringBuffer(); - i = outputs.iterator(); - while (i.hasNext()) { - String name = (String) i.next(); - tmp.append(name); - if (i.hasNext()) { - tmp.append(','); - } - ((OutputConfiguration) outputConfigs.get(name)).save(props); - } - - props.setProperty("output", tmp.toString()); - props.setProperty("output.default", defaultOutput); - - tmp.setLength(0); - - i = redirects.keySet().iterator(); - while (i.hasNext()) { - tmp.append(i.next()); - if (i.hasNext()) { - tmp.append(","); - } - } - - props.setProperty("redirect", tmp.toString()); - - tmp.setLength(0); - - i = redirects.entrySet().iterator(); - while (i.hasNext()) { - Map.Entry e = (Map.Entry) i.next(); - Iterator j = ((Set)e.getValue()).iterator(); - while (j.hasNext()) { - tmp.append(j.next()); - if (j.hasNext()) { - tmp.append(","); - } - } - props.put("redirect." + e.getKey(), tmp.toString()); - tmp.setLength(0); - } - - KeyStroke[] keys = keyBindings.keys(); - Map actions = new HashMap(); - for (int a = 0; a < keys.length; a++) { - String action = (String) keyBindings.get(keys[a]); - Set keyStrokes; - if (actions.containsKey(action)) { - keyStrokes = (Set) actions.get(action); - } else { - keyStrokes = new HashSet(); - actions.put(action, keyStrokes); - } - keyStrokes.add(keys[a]); - } - - i = actions.keySet().iterator(); - while (i.hasNext()) { - tmp.append(i.next()); - if (i.hasNext()) { - tmp.append(","); - } - } - props.setProperty("action", tmp.toString()); - tmp.setLength(0); - i = actions.entrySet().iterator(); - while (i.hasNext()) { - Map.Entry e = (Map.Entry) i.next(); - Iterator j = ((Set)e.getValue()).iterator(); - while (j.hasNext()) { - tmp.append(j.next()); - if (j.hasNext()) { - tmp.append(","); - } - } - props.setProperty("action." + e.getKey(), tmp.toString()); - tmp.setLength(0); - } - - props.setProperty("macro.count", "" + macros.size()); - for (int a = 0; a < macros.size(); a++) { - props.setProperty("macro."+a, (String)macros.get(a)); - } - - i = aliases.entrySet().iterator(); - while (i.hasNext()) { - Map.Entry e = (Map.Entry) i.next(); - List aliases = (List) e.getValue(); - props.setProperty("alias."+e.getKey()+".count", ""+aliases.size()); - Iterator j = aliases.iterator(); - int c = 1; - while (j.hasNext()) { - Alias alias = (Alias) j.next(); - String key = "alias."+e.getKey()+"."+c; - props.setProperty(key + ".regexp", alias.getRegexp()); - props.setProperty(key + ".replace", alias.getReplace()); - props.setProperty(key + ".terminate", alias.getTerminate() ? "yes" : "no"); - c++; - } - } - return props; - } - - /** - * Get the hostname to connect to - */ - public String getHost() { - return host; - } - - /** - * Set the hostname to connect to - */ - public void setHost(String host) { - this.host = host; - } - - /** - * Get the port to connect to - */ - public int getPort() { - return port; - } - - /** - * Set the port to connect to - */ - public void setPort(int port) { - this.port = port; - } - - /** - * Should we use a webproxy server - */ - public boolean getUseProxy() { - return useProxy; - } - - /** - * Set whether to use a proxy. - */ - public void setUseProxy(boolean useProxy) { - this.useProxy = useProxy; - } - - /** - * Get use jvm proxy flag. - */ - public boolean getUseJvmProxy() { - return useJvmProxy; - } - - /** - * Set use jvm proxy flag. - */ - public void setUseJvmProxy(boolean useJvmProxy) { - this.useJvmProxy = useJvmProxy; - } - - /** - * Get webproxy address. - */ - public String getProxyHost() { - return proxyHost; - } - - /** - * Set proxy address. - */ - public void setProxyHost(String proxyHost) { - this.proxyHost = proxyHost; - } - - /** - * Get jvm proxy address. - */ - public String getJvmProxyHost() { - return System.getProperty("http.proxyHost", ""); - } - - /** - * Get proxy port. - */ - public int getProxyPort() { - return proxyPort; - } - - /** - * Set proxy port - */ - public void setProxyPort(int proxyPort) { - this.proxyPort = proxyPort; - } - - /** - * Get jvm proxy port. - */ - public int getJvmProxyPort() { - try { - return Integer.parseInt(System.getProperty("http.proxyPort", "80")); - } catch (NumberFormatException nfe) { - return 80; - } - } - - /** - * Get character encoding for the connection. - */ - public String getCharacterEncoding() { - return characterEncoding; - } - - /** - * Get the terminal type to send to the mud - */ - public String getTerminalType() { - return term; - } - - /** - * Get the name of the default output - */ - public String getDefaultOutputName() { - return defaultOutput; - } - - /** - * Get the list of output names. - */ - public List getOutputNames() { - return outputs; - } - - /** - * Get the OutputConfiguration for a specific Output - */ - public OutputConfiguration getOutputConfiguration(String name) { - return (OutputConfiguration) outputConfigs.get(name); - } - - /** - * Get the list of outputs which a message of type msgClass should be - * sent to. - */ - public Set getOutputFor(String msgClass) { - return (Set) redirects.get(msgClass); - } - - /** - * Get a map of key name to action name - */ - public InputMap getKeyBindings() { - return keyBindings; - } - - /** - * Get a list of aliases for a specific input id. - */ - public List getAliases(String sourceId) { - return (List) aliases.get(sourceId); - } - - /** - * Get a list of macros. - */ - public List getMacros() { - return macros; - } - - /** - * Set the font name to use - */ - public void setFont(String font) { - this.font = font; - } - - /** - * Get the font name to use - */ - public String getFont() { - return font; - } - - /** - * Set the font size - */ - public void setFontSize(int fontSize) { - this.fontSize = fontSize; - } - - /** - * Get the font size - */ - public int getFontSize() { - return fontSize; - } - - /** - * Set the font bold flag - */ - public void setBold(boolean bold) { - this.bold = bold; - } - - /** - * Get the font bold flag - */ - public boolean getBold() { - return bold; - } - - /** - * Set the font italic flag - */ - public void setItalic(boolean italic) { - this.italic = italic; - } - - /** - * Get the font italic flag - */ - public boolean getItalic() { - return italic; - } - - /** - * Get the java Font object - */ - public Font getJavaFont() { - return new Font(font, (bold ? Font.BOLD : Font.PLAIN) | (italic ? Font.ITALIC : Font.PLAIN), fontSize); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/config/OutputConfiguration.java b/mudclient/src/java/org/cyberiantiger/mudclient/config/OutputConfiguration.java deleted file mode 100644 index a6c448c0..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/config/OutputConfiguration.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.cyberiantiger.mudclient.config; - -import java.util.Properties; - -public class OutputConfiguration { - - private String name; - private int width; - private int height; - private int buffer; - private boolean floating; - private boolean visible; - private boolean visibleOnOutput; - private boolean keepInput; - - public OutputConfiguration() { - } - - public void load(Properties props, String name) { - this.name = name; - this.width = Integer.parseInt( - props.getProperty("output."+name+".width","80")); - this.height = Integer.parseInt( - props.getProperty("output."+name+".height","25")); - this.buffer = Integer.parseInt( - props.getProperty("output."+name+".buffer","2000")); - this.floating = "yes".equals( - props.getProperty("output."+name+".float","no")); - this.visible = "yes".equals( - props.getProperty("output."+name+".visible","yes")); - this.visibleOnOutput = "yes".equals( - props.getProperty("output."+name+".visibleOnOutput","no")); - this.keepInput = "yes".equals( - props.getProperty("output."+name+".keepInput","no")); - } - - public void save(Properties props) { - props.setProperty("output."+name+".width", "" + width); - props.setProperty("output."+name+".height", "" + height); - props.setProperty("output."+name+".buffer", "" + buffer); - props.setProperty("output."+name+".float", floating ? "yes" : "no"); - props.setProperty("output."+name+".visible", visible ? "yes" : "no"); - props.setProperty("output."+name+".visibleOnOutput", visibleOnOutput ? "yes" : "no"); - props.setProperty("output."+name+".keepInput", keepInput ? "yes" : "no"); - } - - public String getName() { - return name; - } - - public int getWidth() { - return width; - } - - public int getHeight() { - return height; - } - - public int getBuffer() { - return buffer; - } - - public boolean getFloating() { - return floating; - } - - public boolean getVisible() { - return visible; - } - - public boolean getVisibleOnOutput() { - return visibleOnOutput; - } - - public boolean keepInput() { - return keepInput; - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/input/Alias.java b/mudclient/src/java/org/cyberiantiger/mudclient/input/Alias.java deleted file mode 100644 index 6a64e4d7..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/input/Alias.java +++ /dev/null @@ -1,280 +0,0 @@ -package org.cyberiantiger.mudclient.input; - -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; - -import java.util.regex.Pattern; -import java.util.regex.Matcher; - - -public class Alias { - private String regexp; - private String replace; - private boolean terminate; - - private Pattern pattern; - private List replacement; - - public Alias(String regexp, String replace, boolean terminate) { - setRegexp(regexp); - setReplace(replace); - setTerminate(terminate); - } - - /** - * Apply this alias to an InputItem. - * - * @return true on a match, false otherwise. - */ - public boolean apply( - InputProcessor input, InputStack stack, InputItem item - ) - { - String msg = item.getMessage(); - Matcher matcher = pattern.matcher(msg); - if (!matcher.matches()) { - return false; - } - - if (terminate) { - Iterator i = replacement.iterator(); - while (i.hasNext()) { - Line line = (Line) i.next(); - input.addCommand(line.replace(matcher)); - } - } else { - int i = replacement.size(); - while (i-- > 0) { - Line line = (Line) replacement.get(i); - stack.pushItem( - new InputItem( - line.replace(matcher), - item.getDepth() + 1 - ) - ); - } - } - return true; - } - - /** - * Get the regular expression string used to create this alias. - */ - public String getRegexp() { - return regexp; - } - - /** - * Set the regular expression string. - * - * @throws PatternSyntaxException if the regexp is invalid. - */ - public void setRegexp(String regexp) { - pattern = Pattern.compile(regexp); - this.regexp = regexp; - } - - /** - * Get the replacement string for this alias. - */ - public String getReplace() { - return replace; - } - - /** - * Set the replacement string for this alias. - * - * @throws ReplacementSyntaxException - */ - public void setReplace(String replace) { - replacement = compileReplacement(replace); - this.replace = replace; - } - - /** - * Set whether this alias's replacement bypasses other aliases. - */ - public void setTerminate(boolean terminate) { - this.terminate = terminate; - } - - /** - * Get whether this alias's replacement bypasses other aliases. - */ - public boolean getTerminate() { - return terminate; - } - - /** - * Compile a replacement string. - * - * "\" - escape character. - * ";" - new line. - * "${0}" - matches entire matched text. - * "${1}" - matches group 1 from the regexp. - * - * @throws ReplacementSyntaxException - */ - protected List compileReplacement(String replace) { - List ret = new ArrayList(); - Line currentLine = new Line(); - StringBuffer currentToken = new StringBuffer(); - int state = 0; - - for (int i = 0; i 0) { - currentLine.addToken( - new StringToken(currentToken.toString()) - ); - currentToken.setLength(0); - } - ret.add(currentLine); - currentLine = new Line(); - } else if (ch == '$') { - if(currentToken.length() > 0) { - currentLine.addToken( - new StringToken(currentToken.toString()) - ); - currentToken.setLength(0); - } - state = 2; - } else { - currentToken.append(ch); - } - break; - case 1: /* Escape */ - currentToken.append(ch); - state = 0; - break; - case 2: /* After $ */ - if (ch != '{') { - throw new ReplacementSyntaxException("$ not followed by {"); - } - state = 3; - break; - case 3: /* After { before } */ - if (ch == '}') { - if (currentToken.length() == 0) { - throw new ReplacementSyntaxException("$ reference didn't contain anything"); - } - currentLine.addToken( - new ReferenceToken(Integer.parseInt(currentToken.toString())) - ); - currentToken.setLength(0); - state = 0; - } else if (ch >= '0' && ch <= '9') { - currentToken.append(ch); - } else { - throw new ReplacementSyntaxException("$ reference not a number"); - } - break; - } - } - if (state != 0) { - throw new ReplacementSyntaxException("Alias ended mid token"); - } - if (currentToken.length() > 0) { - currentLine.addToken(new StringToken(currentToken.toString())); - } - ret.add(currentLine); - return ret; - } - - /** - * Class to replacement a replacement line. - */ - private static class Line { - /** - * List of replacement tokens which make up this line. - */ - private List tokens = new ArrayList(); - - /** - * Return the line replacement for the specific match. - */ - public String replace(Matcher match) { - StringBuffer ret = new StringBuffer(); - Iterator i = tokens.iterator(); - while (i.hasNext()) { - Token t = (Token) i.next(); - ret.append(t.replace(match)); - } - return ret.toString(); - } - - /** - * Add a token to this replacement line. - */ - public void addToken(Token token) { - tokens.add(token); - } - - public String toString() { - StringBuffer ret = new StringBuffer(); - Iterator i = tokens.iterator(); - while(i.hasNext()) { - ret.append(i.next().toString()); - } - return ret.toString(); - } - } - - /** - * An interface to represent a replacment token. - */ - private static interface Token { - /** - * Return the replacement for this token against match. - */ - public String replace(Matcher match); - } - - /** - * A replacment token which represents a string which doesn't change. - */ - private static class StringToken implements Token { - private String msg; - - public StringToken(String msg) { - this.msg = msg; - } - - public String replace(Matcher match) { - return msg; - } - - public String toString() { - return msg; - } - } - - /** - * A replacement token which represents a reference to a matched group. - */ - private static class ReferenceToken implements Token { - private int offset; - - public ReferenceToken(int offset) { - this.offset = offset; - } - - public String replace(Matcher match) { - return match.group(offset); - } - - public String toString() { - return "${"+offset+"}"; - } - } - - /* XXX: Should add VariableReference and FunctionReference */ -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/input/InputItem.java b/mudclient/src/java/org/cyberiantiger/mudclient/input/InputItem.java deleted file mode 100644 index f24e0673..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/input/InputItem.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.cyberiantiger.mudclient.input; - -public class InputItem { - - private String msg; - private int depth; - - public InputItem(String msg, int depth) { - this.msg = msg; - this.depth = depth; - } - - public String getMessage() { - return msg; - } - - public int getDepth() { - return depth; - } - -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/input/InputProcessor.java b/mudclient/src/java/org/cyberiantiger/mudclient/input/InputProcessor.java deleted file mode 100644 index 95a3ca1f..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/input/InputProcessor.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.cyberiantiger.mudclient.input; - -import java.util.Map; -import java.util.HashMap; -import java.util.List; -import java.util.Iterator; - -import org.cyberiantiger.mudclient.ui.Connection; -import org.cyberiantiger.mudclient.net.Display; -import org.cyberiantiger.mudclient.config.ClientConfiguration; - -public class InputProcessor implements Connection { - - public static final int MAX_RECURSE = 16; - - private Display display; - private Connection conn; - private Map aliases = new HashMap(); - private StringBuffer output = new StringBuffer(); - - private boolean parseInput = true; - - public InputProcessor( - Connection conn, - Display display) - { - this.display = display; - this.conn = conn; - } - - public void command(String sourceId, String msg) { - InputStack stack = new InputStack(MAX_RECURSE); - StringBuffer tmp = new StringBuffer(); - boolean inEscape = false; - for (int i = 0; i= maxRecursion) { - throw new RecursionException(); - } - unparsedInput.add(0, item); - } - - /** - * Add an item. - */ - public void addItem(InputItem item) { - unparsedInput.add(item); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/input/RecursionException.java b/mudclient/src/java/org/cyberiantiger/mudclient/input/RecursionException.java deleted file mode 100644 index 1c9abf7c..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/input/RecursionException.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.cyberiantiger.mudclient.input; - -/** - * Exception for when aliases recurse too deeply. - */ -public class RecursionException extends RuntimeException { -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/input/ReplacementSyntaxException.java b/mudclient/src/java/org/cyberiantiger/mudclient/input/ReplacementSyntaxException.java deleted file mode 100644 index d5368ce1..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/input/ReplacementSyntaxException.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.cyberiantiger.mudclient.input; - -/** - * Exception for when parsing a replacement string fails. - */ -public class ReplacementSyntaxException extends RuntimeException { - - public ReplacementSyntaxException(String msg) { - super(msg); - } - -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/net/Display.java b/mudclient/src/java/org/cyberiantiger/mudclient/net/Display.java deleted file mode 100644 index 58c9dd03..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/net/Display.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.cyberiantiger.mudclient.net; - -import org.cyberiantiger.mudclient.config.*; -import org.cyberiantiger.console.ConsoleWriter; - -public interface Display { - - public ClientConfiguration getConfiguration(); - - public void connectionStatusChanged(int status); - - public void connectionDoLocalEcho(boolean echo); - - public ConsoleWriter getConsoleWriter(); - - public boolean getEcho(); - - public void localEcho(String msg); -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/net/MudConnection.java b/mudclient/src/java/org/cyberiantiger/mudclient/net/MudConnection.java deleted file mode 100644 index c053b24a..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/net/MudConnection.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.cyberiantiger.mudclient.net; - -import java.io.*; -import java.net.*; -import org.cyberiantiger.telnet.*; -import org.cyberiantiger.mudclient.parser.Parser; - -public class MudConnection extends Thread { - - public static final int DISCONNECTED = 0; - public static final int CONNECTING = 1; - public static final int CONNECTED = 2; - public static final int DISCONNECTING = 3; - - private int status = DISCONNECTED; - private String destination; - private int port; - private TelnetSocket sock; - private SimpleTelnetSession session; - private Display client; - private Parser parser; - - /** - * Create a new MudConnection for the specified MudClient to the - * destination:port. - */ - public MudConnection(Display client) { - this.client = client; - this.destination = client.getConfiguration().getHost(); - this.port = client.getConfiguration().getPort(); - start(); - } - - /** - * Get the current status of the MudConnection. - * TODO: Make this watchable, so that listeners can recieve notification - * when the state changes. - */ - public int getStatus() { - return status; - } - - /** - * Connect to the mud. - * @return True on a sucessful connection, false otherwise. - */ - public synchronized boolean connect() { - if(status == CONNECTED) return true; - status = CONNECTING; - client.connectionStatusChanged(CONNECTING); - session = new SimpleTelnetSession( - client.getConfiguration().getTerminalType() - ) { - protected void serverWillEcho(boolean echo) { - client.connectionDoLocalEcho(!echo); - } - }; - try { - sock = new TelnetSocket( - SocketFactory.getSocket(client.getConfiguration()), - session, - client.getConfiguration().getCharacterEncoding()); - status = CONNECTED; - client.connectionStatusChanged(CONNECTED); - notify(); - return true; - } catch(IOException ioe) { - ioe.printStackTrace(); - } - status = DISCONNECTED; - client.connectionStatusChanged(DISCONNECTED); - return false; - } - - /** - * Disconnect from the mud. - * @return True on sucessful disconnection. - */ - public synchronized boolean disconnect() { - status = DISCONNECTING; - client.connectionStatusChanged(DISCONNECTING); - if(sock != null) { - try { - sock.close(); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } - sock = null; - status = DISCONNECTED; - client.connectionStatusChanged(DISCONNECTED); - return true; - } - - /** - * Set the window size which is reported to the mud via telnet negotiation. - */ - public void setWindowSize(int width, int height) { - if(session != null) { - try { - session.setWindowSize(width,height); - } catch (IOException ioe) { - disconnect(); - } - } - } - - /** - * Get whether or not we should echo user input to the console. - */ - public boolean getLocalEcho() { - return false; - } - - /** - * Set the parser to use to parse output from the mud. - */ - public void setParser(Parser parser) { - if(this.parser != null) { - synchronized(this.parser) { - parser.flush(client.getConsoleWriter()); - this.parser = parser; - } - } else { - this.parser = parser; - } - } - - public void command(String text) { - if(sock != null) { - Writer out = sock.getWriter(); - if(out != null) { - try { - out.write(text); - out.flush(); - } catch (IOException ioe) { - ioe.printStackTrace(); - disconnect(); - } - } - } - } - - /** - * Read bytes from the TelnetSocket [if it's connected], parse, and - * deliver the appropriate ConsoleActions to the MudClient. - */ - public void run() { - while(true) { - while(status != CONNECTED) { - synchronized(this) { - try { - wait(); - } catch(InterruptedException ie) { - break; - } - - } - } - try { - while(status == CONNECTED) { - int ch = sock.getReader().read(); - if(ch == -1) { - disconnect(); - } else { - if(parser != null) { - synchronized(parser) { - parser.putChar((char)ch); - if(parser.changeParser()) { - setParser(parser.getNewParser()); - } else if(!sock.getReader().ready()) { - parser.flush(client.getConsoleWriter()); - } - } - } - } - } - } catch (Exception e) { - disconnect(); - e.printStackTrace(); - } - } - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/net/SocketFactory.java b/mudclient/src/java/org/cyberiantiger/mudclient/net/SocketFactory.java deleted file mode 100644 index 91d0e910..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/net/SocketFactory.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.cyberiantiger.mudclient.net; - -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.Reader; -import java.io.Writer; -import java.net.Socket; -import java.io.IOException; -import java.io.EOFException; - -import org.cyberiantiger.mudclient.config.ClientConfiguration; - -/** - * XXX: Once we move to java 1.5 as minimum requirement it has it's own - * built in proxy support so alot of this crap can vanish. - */ -public class SocketFactory { - - public static Socket getSocket(ClientConfiguration config) - throws IOException - { - if (config.getUseProxy()) { - - Socket ret; - if (config.getUseJvmProxy()) { - ret = new Socket(config.getJvmProxyHost(), config.getJvmProxyPort()); - } else { - ret = new Socket(config.getProxyHost(), config.getProxyPort()); - } - try { - OutputStreamWriter out = new OutputStreamWriter(ret.getOutputStream(), "ISO-8859-1"); - out.write("CONNECT " + config.getHost() + ":" + config.getPort() + " HTTP/1.1\r\n" + - "Host: " + config.getHost() + ":" + config.getPort() + "\r\n" + - "\r\n"); - out.flush(); - InputStreamReader in = new InputStreamReader(ret.getInputStream(), "ISO-8859-1"); - String response = readLine(in); - /* Read the rest of the response header */ - while (readLine(in).length() != 0); - /* Check response code */ - int i = response.indexOf(' '); - if (i == -1) { - throw new IOException("Proxy server did not send a valid response: " + response); - } - String version = response.substring(0,i); - if (!version.startsWith("HTTP/1.")) { - throw new IOException("Proxy server did not send a valid response: " + response); - } - if (version.length() != 8 || !(version.charAt(7) == '0' || version.charAt(7) == '1')) { - throw new IOException("Proxy server did not send a valid http version: " + response); - } - int j = i + 1; - i = response.indexOf(' ', j); - if (i == -1) { - throw new IOException("Proxy server did not send a valid response: " + response); - } - try { - int rCode = Integer.parseInt(response.substring(j, i)); - - if (rCode != 200) { - throw new IOException("Error: " + response.substring(j)); - } - } catch (NumberFormatException nfe) { - throw new IOException("Proxy server did not send a valid response: " + response); - } - return ret; - } catch (IOException e) { - ret.close(); - throw e; - } - } else { - return new Socket(config.getHost(), config.getPort()); - } - } - - /* Assumes \r\n or just \n */ - private static String readLine(Reader reader) throws IOException { - StringBuffer ret = new StringBuffer(); - boolean eol = false; - while (true) { - int i = reader.read(); - switch (i) { - case -1: - throw new IOException("End of stream before end of line"); - case '\r': - if (eol) { - throw new IOException("Invalid end of line"); - } - eol = true; - break; - case '\n': - return ret.toString(); - default: - if (eol) { - throw new IOException("Invalid end of line"); - } - ret.append((char)i); - } - } - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/parser/ANSIParser.java b/mudclient/src/java/org/cyberiantiger/mudclient/parser/ANSIParser.java deleted file mode 100644 index 9b42895f..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/parser/ANSIParser.java +++ /dev/null @@ -1,224 +0,0 @@ -package org.cyberiantiger.mudclient.parser; - -import java.util.*; -import org.cyberiantiger.mudclient.*; -import org.cyberiantiger.console.*; - -public class ANSIParser implements Parser { - - public static final int NONE = 0; - public static final int ELECLIENT = 1; - - public static final int TEXT = 0; - public static final int ANSI1 = 1; - public static final int ANSI2 = 2; - public static final int ANSI3 = 3; - public static final int ANSI4 = 4; - - private char[] buffer; - private int offset; - private int last_offset; - private int state; - private int parserDetect = NONE; - StringBuffer ansi = new StringBuffer(); - - private List actions = new ArrayList(); - - public ANSIParser() { - buffer = new char[2048]; - offset = 0; - last_offset = 0; - } - - public void putChar(char ch) { - if(offset == buffer.length) { - char[] newBuff = new char[2048]; - System.arraycopy(buffer,last_offset,newBuff,0,buffer.length - last_offset); - offset = buffer.length - last_offset; - last_offset = 0; - buffer = newBuff; - } - switch(state) { - case TEXT: - switch(ch) { - case '\n': - actions.add(new StringConsoleAction(buffer,last_offset,offset-last_offset)); - last_offset = offset; - actions.add(new SetCursorXConsoleAction(0)); - break; - case '\r': - actions.add(new StringConsoleAction(buffer,last_offset,offset-last_offset)); - last_offset = offset; - actions.add(new MoveCursorYConsoleAction(1)); - break; - case '\007': - actions.add(new StringConsoleAction(buffer,last_offset,offset-last_offset)); - last_offset = offset; - actions.add(new BeepConsoleAction()); - break; - case '\014': - actions.add(new ClearScreenConsoleAction()); - last_offset = offset; - break; - case 27: - actions.add(new StringConsoleAction(buffer,last_offset,offset-last_offset)); - last_offset = offset; - state = ANSI1; - break; - default: - buffer[offset++] = ch; - } - break; - case ANSI1: - switch(ch) { - case '[': - state = ANSI2; - break; - case 'D': - // Elephant External Client Detection ! - parserDetect = ELECLIENT; - default: - state = TEXT; - break; - } - break; - case ANSI2: - if( - (ch >= 'A' && ch <= 'Z') || - (ch >= 'a' && ch <= 'z') - ) - { - switch(ch) { - case 'm': - StringTokenizer tokenizer = - new StringTokenizer(ansi.toString(),";"); - while(tokenizer.hasMoreTokens()) { - try { - int i = Integer.parseInt(tokenizer.nextToken()); - ConsoleAction action = null; - switch (i) { - case 0: - actions.add(new BoldConsoleAction(false)); - actions.add(new FlashConsoleAction(false)); - actions.add(new ReverseConsoleAction(false)); - break; - case 1: - action=new BoldConsoleAction(true); - break; - case 4: - // Underscore -> Not implemented. - break; - case 5: - action=new FlashConsoleAction(true); - break; - case 7: - action=new ReverseConsoleAction(true); - break; - case 8: - // Conceal -> Not implemented. - break; - case 30: - action=new ForegroundConsoleAction(Console.BLACK); - break; - case 31: - action=new ForegroundConsoleAction(Console.RED); - break; - case 32: - action=new ForegroundConsoleAction(Console.GREEN); - break; - case 33: - action=new ForegroundConsoleAction(Console.YELLOW); - break; - case 34: - action=new ForegroundConsoleAction(Console.BLUE); - break; - case 35: - action=new ForegroundConsoleAction(Console.MAGENTA); - break; - case 36: - action=new ForegroundConsoleAction(Console.CYAN); - break; - case 37: - action=new ForegroundConsoleAction(Console.WHITE); - break; - case 40: - action=new BackgroundConsoleAction(Console.BLACK); - break; - case 41: - action=new BackgroundConsoleAction(Console.RED); - break; - case 42: - action=new BackgroundConsoleAction(Console.GREEN); - break; - case 43: - action=new BackgroundConsoleAction(Console.YELLOW); - break; - case 44: - action=new BackgroundConsoleAction(Console.BLUE); - break; - case 45: - action=new BackgroundConsoleAction(Console.MAGENTA); - break; - case 46: - action=new BackgroundConsoleAction(Console.CYAN); - break; - case 47: - action=new BackgroundConsoleAction(Console.WHITE); - break; - - } - if(action != null) { - actions.add(action); - } - } catch (NumberFormatException nfe) { - } - } - break; - case 'H': - if(ansi.length() == 0){ - actions.add(new ClearScreenConsoleAction()); - } - break; - default: - ansi.append(ch); - System.out.println("Unknown escape string: \""+ansi+"\""); - } - ansi.setLength(0); - state = TEXT; - } else { - ansi.append(ch); - } - break; - } - } - - public void flush(ConsoleWriter client) { - Iterator i = actions.iterator(); - while(i.hasNext()) { - ConsoleAction action = (ConsoleAction) i.next(); - client.consoleAction(action); - } - actions.clear(); - client.consoleAction( - new StringConsoleAction(buffer,last_offset,offset-last_offset) - ); - last_offset = offset; - } - - public String getName() { - return "ANSI"; - } - - public boolean changeParser() { - return parserDetect != NONE; - } - - public Parser getNewParser() { - switch(parserDetect) { - case ELECLIENT: - return new ElephantMUDParser(); - default: - return this; - } - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/parser/ElephantMUDParser.java b/mudclient/src/java/org/cyberiantiger/mudclient/parser/ElephantMUDParser.java deleted file mode 100644 index 1c4acaab..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/parser/ElephantMUDParser.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.cyberiantiger.mudclient.parser; - -import java.util.*; -import org.cyberiantiger.console.*; - -public class ElephantMUDParser implements Parser { - - private List actions = new ArrayList(); - private boolean changeParser = false; - private boolean haveEscape = false; - - StringBuffer temp = new StringBuffer(); - - public ElephantMUDParser() { - } - - public void putChar(char ch) { - if(haveEscape) { - if(ch == 'D') { - String text = temp.toString(); - temp.setLength(0); - // XXX: A Hack to get around some messages not being - // done correctly - if(!text.startsWith("(/")) { - int i = text.indexOf("(/"); - actions.add( - new ElephantMUDConsoleAction( - "fail",null,null,0,0,0,text.substring(0,i) - ) - ); - text = text.substring(i); - } - actions.add(new ElephantMUDConsoleAction(text)); - } else { - // The mud isn't sending us stuff in external client mode ! - temp.append('\033').append(ch); - changeParser = true; - } - haveEscape = false; - } else { - if(ch == '\033') { - haveEscape = true; - } else { - temp.append(ch); - } - } - } - - public void flush(ConsoleWriter client) { - Iterator i = actions.iterator(); - while(i.hasNext()) { - ConsoleAction action = (ConsoleAction) i.next(); - client.consoleAction(action); - } - actions.clear(); - } - - public String getName() { - return "ELECLIENT"; - } - - public boolean changeParser() { - return changeParser; - } - - public Parser getNewParser() { - if(changeParser) { - Parser newParser = new ANSIParser(); - for(int i=0;i width) { - cursor_x = x % width; - setCursorY(getCursorY()+x/width); - } else if(x < 0) { - cursor_x = 0; - } else { - cursor_x = x; - } - } - - public void setCursorY(int y) { - if(y >= height) { - buffer_offset += y - height + 1; - cursor_y = height - 1; - - if(buffer_offset>bufferSize) { - if(hasSelection) { - start.y -= buffer_offset - bufferSize; - end.y -= buffer_offset - bufferSize; - if(start.y < 0) { - hasSelection = false; - } - } - - while(buffer_offset > bufferSize) { - buffer.remove(0); - buffer_offset--; - } - } - } else if(y<0) { - cursor_y = 0; - } else { - cursor_y = y; - } - } - - public void drawString(String str) { - if(str.length() > 0) { - char[] data = new char[str.length()]; - str.getChars(0,data.length,data,0); - drawString(data,0,data.length); - } - } - - public void drawString(char[] chars) { - drawString(chars,0,chars.length); - } - - public void drawString(char[] chars, int offset, int len) { - if(len > 0) { - Line current = getCurrentLine(); - if(cursor_x + len > width) { - current.overwriteString(cursor_x, attr, chars, offset, width - cursor_x); - offset += width - cursor_x; - len -= width - cursor_x; - setCursorX(0); - setCursorY(cursor_y + 1); - drawString(chars, offset, len); - } else { - current.overwriteString(cursor_x, attr, chars, offset, len); - setCursorX(cursor_x + len); - } - } - } - - public void setForeground(int color) { - attr &= 0xffffff00; - attr |= color; - } - - public void setBackground(int color) { - attr &= 0xffff00ff; - attr |= (color << 8); - } - - public void setBold(boolean bold) { - attr |= BOLD; - if(!bold) { - attr ^= BOLD; - } - } - - public void setFlash(boolean flash) { - attr |= FLASH; - if(!flash) { - attr ^= FLASH; - } - } - - public void setReverse(boolean reverse) { - attr |= REVERSE; - if(!reverse) { - attr ^= REVERSE; - } - } - - public void clearScreen() { - for(int i=0;i= buffer.size()) { - return null; - } else { - return (Line) buffer.get(line); - } - } - - protected Line getCurrentLine() { - if(buffer_offset + cursor_y >= buffer.size()) { - for(int i=buffer.size();i<=buffer_offset + cursor_y;i++) { - buffer.add(null); - } - } - Line ret = (Line) buffer.get(buffer_offset + cursor_y); - if(ret == null) { - ret = new Line(); - buffer.set(buffer_offset + cursor_y, ret); - } - return ret; - } - - // XXX: This stuff shouldn't be here, we should be able to have more than - // one view on the same ConsoleModel at different positions - public void setLineOffset(int lineOffset) { - if(lineOffset < 0) { - this.lineOffset = 0; - } else if(lineOffset > buffer_offset) { - this.lineOffset = buffer_offset; - } else { - this.lineOffset = lineOffset; - } - } - - public int getLineOffset() { - return lineOffset; - } - - public Line getViewLine(int line) { - return getLine(lineOffset + line); - } - - private boolean hasSelection = false; - private Point start; - private Point end; - - public void startSelection(Point start) { - this.start = (Point) start.clone(); - this.start.y += lineOffset; - this.end = this.start; - hasSelection = true; - } - - public void endSelection(Point end) { - if(hasSelection) { - this.end = (Point) end.clone(); - this.end.y += lineOffset; - } - } - - public void cancelSelection() { - hasSelection = false; - } - - public boolean hasSelection() { - return hasSelection && !start.equals(end); - } - - public Point getSelectionStart() { - if(!hasSelection) return null; - Point ret; - if( - start.y < end.y || - ( start.y == end.y && start.x < end.x ) - ) - { - ret = (Point) start.clone(); - } else { - ret = (Point) end.clone(); - } - ret.y -= lineOffset; - if(ret.y < 0) { - ret.y = 0; - ret.x = 0; - } - if(ret.y > getHeight()) { - ret.y = getHeight(); - ret.x = 0; - } - return ret; - } - - public Point getSelectionEnd() { - if(!hasSelection) return null; - Point ret; - if( - start.y < end.y || - ( start.y == end.y && start.x < end.x ) - ) - { - ret = (Point) end.clone(); - } else { - ret = (Point) start.clone(); - } - ret.y -= lineOffset; - if(ret.y < 0) { - ret.y = 0; - ret.x = 0; - } - if(ret.y > getHeight()) { - ret.y = getHeight(); - ret.x = 0; - } - return ret; - } - - public String getSelection() { - if(hasSelection()) { - Point start; - Point end; - if( - this.start.y < this.end.y || - ( this.start.y == this.end.y && this.start.x < this.end.x ) - ) - { - start = this.start; - end = this.end; - } else { - end = this.start; - start = this.end; - } - - StringBuffer ret = new StringBuffer(); - Line tmpLine; - String tmpString; - - // Nasty code to pull a string out - if(start.y == end.y) { - tmpLine = getLine(start.y); - if(tmpLine != null) - { - tmpString = tmpLine.toString(); - if(start.x <= tmpString.length()) { - if(end.x <= tmpString.length()) { - return tmpString.substring(start.x,end.x); - } else { - return tmpString.substring(start.x); - } - } else { - return ""; - } - } else { - return ""; - } - } else { - tmpLine = getLine(start.y); - if(tmpLine != null) - { - tmpString = tmpLine.toString(); - if(start.x <= tmpString.length()) { - ret.append(tmpString.substring(start.x)); - } - } - ret.append(System.getProperty("line.separator")); - for(int i=1;i 1) { - g.fillRect(0,(start.y+1)*rowHeight,model.getWidth()*charWidth, (end.y-start.y-1)*rowHeight); - } - } - } - } - } - } - - public Color getForegroundColor(int attr) { - switch(attr & 7) { - case ConsoleModel.BLACK: - return Color.black; - case ConsoleModel.RED: - return Color.red; - case ConsoleModel.YELLOW: - return Color.yellow; - case ConsoleModel.GREEN: - return Color.green; - case ConsoleModel.CYAN: - return Color.cyan; - case ConsoleModel.BLUE: - return Color.blue; - case ConsoleModel.MAGENTA: - return Color.magenta; - case ConsoleModel.WHITE: - return Color.white; - } - return Color.white; - } - - public Color getBackgroundColor(int attr) { - switch((attr>>8) & 7) { - case ConsoleModel.BLACK: - return Color.black; - case ConsoleModel.RED: - return Color.red; - case ConsoleModel.YELLOW: - return Color.yellow; - case ConsoleModel.GREEN: - return Color.green; - case ConsoleModel.CYAN: - return Color.cyan; - case ConsoleModel.BLUE: - return Color.blue; - case ConsoleModel.MAGENTA: - return Color.magenta; - case ConsoleModel.WHITE: - return Color.white; - } - return Color.black; - } - - public Dimension getPreferredSize() { - return new Dimension( - model.getWidth() * charWidth, - model.getHeight() * rowHeight - ); - - } - - public Dimension getMinimumSize() { - return new Dimension( charWidth, rowHeight); - } - - /** - * Write something to our model - */ - public void consoleAction(ConsoleAction action) { - /* Double synchronize to avoid deadlocks */ - synchronized(getTreeLock()) { - synchronized(this) { - model.addAction(action); - } - } - } - - public Point getCharacterAt(Point p) { - if( - p.x > borderArea.left && - p.x < getWidth()-borderArea.right && - p.y > borderArea.top && - p.y < getHeight() - borderArea.bottom - ) { - return new Point( - (p.x - borderArea.left) / charWidth, - (p.y - borderArea.top) / rowHeight - ); - } else { - return null; - } - } - - protected void processComponentEvent(ComponentEvent ce) { - super.processComponentEvent(ce); - if( - ce.getID() == ComponentEvent.COMPONENT_RESIZED || - ce.getID() == ComponentEvent.COMPONENT_SHOWN - ) - { - resizeConsole(); - } - } - - int xStart; - int yStart; - - protected void processMouseEvent(MouseEvent me) { - super.processMouseEvent(me); - if(me.getID() == MouseEvent.MOUSE_PRESSED) { - Point p = getCharacterAt(me.getPoint()); - if(p!=null) { - model.startSelection(p); - repaint(); - } - } else if(me.getID() == MouseEvent.MOUSE_RELEASED) { - Point p = getCharacterAt(me.getPoint()); - if(p!=null) { - model.endSelection(p); - repaint(); - } - if(model.hasSelection()) { - String selection = model.getSelection(); - if(selection != null) { - Clipboard cp = getToolkit().getSystemSelection(); - if (cp != null) { - cp.setContents(new StringSelection(selection), getClipboardOwner()); - } - cp = getToolkit().getSystemClipboard(); - if (cp != null) { - cp.setContents(new StringSelection(selection), getClipboardOwner()); - } - } - } - } else if(me.getID() == MouseEvent.MOUSE_CLICKED) { - model.cancelSelection(); - } - } - - protected void processMouseMotionEvent(MouseEvent me) { - super.processMouseMotionEvent(me); - if(me.getID() == MouseEvent.MOUSE_DRAGGED) { - Point p = getCharacterAt(me.getPoint()); - if(p!=null) { - model.endSelection(p); - repaint(); - } - } - } - - protected void processMouseWhellEvent(MouseWheelEvent mwe) { - super.processMouseWheelEvent(mwe); - } - - public void consoleChanged() { - repaint(); - } - - private ClipboardOwner clipboardOwner; - - protected ClipboardOwner getClipboardOwner() { - if(clipboardOwner == null) { - clipboardOwner = new ClipboardOwner() - { - public void lostOwnership( - Clipboard clip, - Transferable trans - ) - { - model.cancelSelection(); - repaint(); - } - }; - } - return clipboardOwner; - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/ui/ControlWindow.java b/mudclient/src/java/org/cyberiantiger/mudclient/ui/ControlWindow.java deleted file mode 100644 index 0f374dd0..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/ui/ControlWindow.java +++ /dev/null @@ -1,397 +0,0 @@ -package org.cyberiantiger.mudclient.ui; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Color; -import java.awt.Font; -import java.awt.AWTEvent; -import java.awt.event.*; -import java.awt.EventQueue; -import java.awt.Toolkit; -import javax.swing.*; -import javax.swing.event.*; -import java.util.*; -import org.cyberiantiger.mudclient.net.MudConnection; -import org.cyberiantiger.mudclient.parser.*; -import org.cyberiantiger.mudclient.config.*; -import org.cyberiantiger.console.*; - -public class ControlWindow extends JFrame { - - private Connection client; - - private JMenuBar menuBar; - private JMenu fileMenu; - private JMenu helpMenu; - private JMenuItem connectMenuItem; - private JMenuItem disconnectMenuItem; - private JMenuItem optionsMenuItem; - private JMenuItem exitMenuItem; - private JMenuItem aboutMenuItem; - private JTabbedPane tabbedOutputPane; - private JTextField inputField; - private OptionsDialog options; - private AboutDialog about; - private Map views = new HashMap(); - private ConsoleWriter defaultView; - private List otherFrames = new ArrayList(); - private EQ eq = new EQ(); - - - public ControlWindow(Connection client) { - super("Elephant Mud Client"); - this.client = client; - installEventQueue(); - initComponents(); - options = new OptionsDialog(this); - about = new AboutDialog(this); - } - - private void installEventQueue() { - Toolkit.getDefaultToolkit().getSystemEventQueue().push(eq); - } - - private void initComponents() { - menuBar = new JMenuBar(); - fileMenu = new JMenu("File"); - helpMenu = new JMenu("Help"); - connectMenuItem = new JMenuItem("Connect"); - disconnectMenuItem= new JMenuItem("Disconnect"); - optionsMenuItem = new JMenuItem("Options"); - exitMenuItem = new JMenuItem("Exit"); - aboutMenuItem = new JMenuItem("About"); - - menuBar.add(fileMenu); - menuBar.add(helpMenu); - - fileMenu.add(connectMenuItem); - fileMenu.add(disconnectMenuItem); - fileMenu.add(optionsMenuItem); - fileMenu.add(exitMenuItem); - - helpMenu.add(aboutMenuItem); - - connectMenuItem.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - client.connect(); - } - }); - disconnectMenuItem.setEnabled(false); - disconnectMenuItem.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - client.disconnect(); - } - }); - optionsMenuItem.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - options.show(); - } - }); - exitMenuItem.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - exit(); - } - }); - aboutMenuItem.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - about.show(); - } - }); - setJMenuBar(menuBar); - - getContentPane().setLayout(new BorderLayout()); - tabbedOutputPane = new JTabbedPane( - JTabbedPane.BOTTOM, - JTabbedPane.WRAP_TAB_LAYOUT - ); - tabbedOutputPane.addChangeListener( - new ChangeListener() { - public void stateChanged(ChangeEvent e) { - tabbedOutputPane.setForegroundAt( - tabbedOutputPane.getSelectedIndex(), - Color.black - ); - } - } - ); - getContentPane().add(tabbedOutputPane,BorderLayout.CENTER); - - inputField = new JTextField(); - inputField.setFont(new Font("Monospaced",Font.PLAIN,14)); - - ActionMap actionMap = new ActionMap(); - - actionMap.put("sendCommand",new AbstractAction() { - public void actionPerformed(ActionEvent e) { - client.command( - getCurrentViewName(), - inputField.getText() - ); - if( - client.getConfiguration(). - getOutputConfiguration( - getCurrentViewName() - ).keepInput() - ) - { - inputField.selectAll(); - } else { - inputField.setText(""); - } - - } - }); - actionMap.put("scrollUpLine",new AbstractAction() { - public void actionPerformed(ActionEvent e) { - ((MudClientUI)getCurrentView()).lineUp(); - } - }); - actionMap.put("scrollDownLine",new AbstractAction() { - public void actionPerformed(ActionEvent e) { - ((MudClientUI)getCurrentView()).lineDown(); - } - }); - actionMap.put("scrollUpPage",new AbstractAction() { - public void actionPerformed(ActionEvent e) { - ((MudClientUI)getCurrentView()).pageUp(); - } - }); - actionMap.put("scrollDownPage",new AbstractAction() { - public void actionPerformed(ActionEvent e) { - ((MudClientUI)getCurrentView()).pageDown(); - } - }); - actionMap.put("outputLeft",new AbstractAction() { - public void actionPerformed(ActionEvent e) { - int i = tabbedOutputPane.getSelectedIndex(); - if(i == 0) { - i = tabbedOutputPane.getTabCount(); - } - tabbedOutputPane.setSelectedIndex(i-1); - } - }); - actionMap.put("outputRight",new AbstractAction() { - public void actionPerformed(ActionEvent e) { - int i = tabbedOutputPane.getSelectedIndex(); - i++; - if(i == tabbedOutputPane.getTabCount()) { - i = 0; - } - tabbedOutputPane.setSelectedIndex(i); - } - }); - - List macros = client.getConfiguration().getMacros(); - { - for (int i = 0; i < macros.size(); i++) { - actionMap.put("macro" + i, - new MacroAction((String)macros.get(i))); - } - } - - InputMap inputMap = client.getConfiguration().getKeyBindings(); - inputMap.setParent(inputField.getInputMap()); - - inputField.setInputMap( - JComponent.WHEN_FOCUSED, - inputMap - ); - - getContentPane().add(inputField,BorderLayout.SOUTH); - - java.util.List outputs = client.getConfiguration().getOutputNames(); - Iterator i = outputs.iterator(); - while(i.hasNext()) { - final String outputName = (String) i.next(); - createView(outputName); - actionMap.put("output"+outputName, - new AbstractAction() { - public void actionPerformed(ActionEvent e) { - int idx = tabbedOutputPane.indexOfTab(outputName); - if(idx != -1) { - tabbedOutputPane.setSelectedIndex(idx); - } - } - }); - } - actionMap.setParent(inputField.getActionMap()); - inputField.setActionMap(actionMap); - - defaultView = getView( - client.getConfiguration().getDefaultOutputName() - ); - - ((MudClientUI)defaultView).setConnection(client); - - - pack(); - - enableEvents(AWTEvent.WINDOW_EVENT_MASK); - } - - public ConsoleWriter createView(final String id) { - MudClientUI ui = (MudClientUI) getView(id); - if(ui != null) { - return ui; - } else { - ClientConfiguration clientConfig = client.getConfiguration(); - OutputConfiguration config = - clientConfig.getOutputConfiguration(id); - - if(config != null) { - ui = new MudClientUI(this,config); - ui.setViewFont(clientConfig.getJavaFont()); - views.put(id,ui); - - if(config.getVisible()) { - makeVisible((MudClientUI)ui); - } - - return ui; - } else { - return null; - } - } - } - - public void processWindowEvent(WindowEvent we) { - super.processWindowEvent(we); - if(we.getID() == WindowEvent.WINDOW_CLOSING) { - exit(); - } - if(we.getID() == WindowEvent.WINDOW_ACTIVATED) { - inputField.requestFocus(); - } - } - - public ConsoleWriter getView(String id) { - return (ConsoleWriter) views.get(id); - } - - public ConsoleWriter getDefaultView() { - return defaultView; - } - - public ConsoleWriter getCurrentView() { - return (ConsoleWriter) tabbedOutputPane.getSelectedComponent(); - } - - public String getCurrentViewName() { - return tabbedOutputPane.getTitleAt( - tabbedOutputPane.getSelectedIndex() - ); - } - - public void viewUpdated(MudClientUI ui) { - if(ui != tabbedOutputPane.getSelectedComponent()) { - int i = tabbedOutputPane.indexOfComponent(ui); - if(i>=0) { - tabbedOutputPane.setForegroundAt(i, Color.red); - } - } - } - - public void makeVisible(MudClientUI ui) { - OutputConfiguration config = ui.getConfiguration(); - if(config.getFloating()) { - OutputFrame out = new OutputFrame(ui); - otherFrames.add(out); - out.show(); - } else { - tabbedOutputPane.addTab(config.getName(), (Component) ui); - } - } - - public void connectionStatusChanged(int newStatus) { - switch(newStatus) { - case MudConnection.CONNECTED: - disconnectMenuItem.setEnabled(true); - connectMenuItem.setEnabled(false); - break; - case MudConnection.CONNECTING: - case MudConnection.DISCONNECTING: - disconnectMenuItem.setEnabled(false); - connectMenuItem.setEnabled(false); - break; - case MudConnection.DISCONNECTED: - disconnectMenuItem.setEnabled(false); - connectMenuItem.setEnabled(true); - break; - } - } - - protected void exit() { - client.disconnect(); - Iterator i = otherFrames.iterator(); - while(i.hasNext()) { - JFrame other = (JFrame) i.next(); - other.hide(); - other.dispose(); - } - options.hide(); - options.dispose(); - hide(); - dispose(); - client.exit(); - } - - public ClientConfiguration getConfiguration() { - return client.getConfiguration(); - } - - public void updateFont() { - Font font = client.getConfiguration().getJavaFont(); - Iterator i = views.values().iterator(); - while (i.hasNext()) { - MudClientUI ui = (MudClientUI) i.next(); - ui.setViewFont(font); - ui.resizeConsole(); - } - } - - private class MacroAction extends AbstractAction { - - private String cmd; - - public MacroAction(String cmd) { - this.cmd = cmd; - } - - public void actionPerformed(ActionEvent e) { - eq.dropSubsequentKeyTyped(); - client.command(getCurrentViewName(), cmd); - } - - } - - private static class EQ extends EventQueue { - /* XXX: Evil hack to stop macros from generating a key code - * Check event queue and if the next event in the queue is - * a key typed event, drop it, This may not work on some - * platforms, it assumes that the key typed event immediately - * follows the key pressed event. Some platforms may send - * key typed events before key pressed events, or a bunch - * of other circumstances which might break this. */ - private volatile boolean flag = false; - public void dropSubsequentKeyTyped() { - flag = true; - } - protected void dispatchEvent(AWTEvent e) { - if (flag) { - switch (e.getID()) { - case KeyEvent.KEY_TYPED: - flag = false; - return; - case KeyEvent.KEY_PRESSED: - flag = false; - } - } - super.dispatchEvent(e); - } - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/ui/Line.java b/mudclient/src/java/org/cyberiantiger/mudclient/ui/Line.java deleted file mode 100644 index 1c6237fa..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/ui/Line.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.cyberiantiger.mudclient.ui; - -import java.util.List; -import java.util.ArrayList; - -public class Line { - - public LineSegment first = null; - - public Line() { - } - - public void overwriteString(int offset,int attr,String str) { - LineSegment segment = new LineSegment(str, attr); - overwriteSegment(offset,segment); - } - - public void overwriteString(int offset,int attr,char[] chars,int off,int len) - { - LineSegment segment = new LineSegment(chars,off,len, attr); - overwriteSegment(offset,segment); - } - - public void overwriteSegment(int offset,LineSegment segment) { - if(first == null) { - if(offset != 0) { - first = new LineSegment(offset,ConsoleModel.DEFAULT); - first.next = segment; - } else { - first = segment; - } - } else { - if(offset == 0) { - segment.next = first.deleteChars(segment.len); - first = segment; - } else { - first.overwriteSegment(offset,segment); - } - } - } - - public String toString() { - StringBuffer ret = new StringBuffer(); - LineSegment seg = first; - while(seg != null) { - ret.append(seg.data,seg.offset,seg.len); - seg = seg.next; - } - return ret.toString(); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/ui/LineSegment.java b/mudclient/src/java/org/cyberiantiger/mudclient/ui/LineSegment.java deleted file mode 100644 index cc32e3c3..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/ui/LineSegment.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.cyberiantiger.mudclient.ui; - -public class LineSegment { - - public char[] data; - public int offset; - public int len; - public int attr; - public LineSegment next = null; - - // Create a new segment, consisting of len spaces. - public LineSegment(int len,int attr) { - data = new char[len]; - for (int i=0;i len) { - if(next == null) { - next = new LineSegment(offset-len,ConsoleModel.DEFAULT); - next.next = segment; - } else { - next.overwriteSegment(offset-len, segment); - } - } else if(offset == len) { - if(next == null) { - // appends to this segment - this.next = segment; - } else { - // overwrites the next segment, and maybe the one after that. - segment.next = next.deleteChars(segment.len); - this.next = segment; - } - } else { - if(offset + segment.len > len) { - // Carries on, into next segment - segment.next = next.deleteChars(this.len - offset); - this.next = segment; - this.len = offset; - } else if(offset + segment.len == len) { - // Overwrites the latter half of this segment. - this.len = offset; - segment.next = this.next; - this.next = segment; - } else { - // Splits this segment in two. - LineSegment tail = new LineSegment(data,this.offset + offset + segment.len, len - offset - segment.len, this.attr); - tail.next = this.next; - segment.next = tail; - this.next = segment; - } - } - } - - public LineSegment deleteChars(int number) { - if(number > len) { - if(next != null) { - return next.deleteChars(number - len); - } else { - return null; - } - } else if(number == len) { - return next; - } else { - offset += number; - len -= number; - return this; - } - } - - public String toString() { - return new String(data,offset,len); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/ui/MudClientUI.java b/mudclient/src/java/org/cyberiantiger/mudclient/ui/MudClientUI.java deleted file mode 100644 index 0ecc7f32..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/ui/MudClientUI.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.cyberiantiger.mudclient.ui; - -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import javax.swing.*; -import javax.swing.event.*; -import org.cyberiantiger.console.*; -import org.cyberiantiger.mudclient.net.*; -import org.cyberiantiger.mudclient.config.*; -import org.cyberiantiger.mudclient.parser.*; - -public class MudClientUI extends JPanel -implements ConsoleModelListener, ConsoleWriter { - - private ConsoleModel model; - private ConsoleView view; - private JScrollBar scrollBar; - private ControlWindow control; - private OutputConfiguration config; - - public MudClientUI(ControlWindow control, OutputConfiguration config) { - this.control = control; - this.config = config; - - model = new ConsoleModel( - config.getWidth(), - config.getHeight(), - config.getBuffer() - ); - - view = new ConsoleView(model); - scrollBar = new JScrollBar(JScrollBar.VERTICAL); - - model.addView(this); - - scrollBar.addAdjustmentListener( - new AdjustmentListener() { - public void adjustmentValueChanged(AdjustmentEvent ae) { - model.setLineOffset(scrollBar.getValue()); - view.repaint(); - } - }); - - setLayout(new BorderLayout()); - add(BorderLayout.CENTER,view); - add(BorderLayout.EAST,scrollBar); - } - - public void consoleChanged() { - scrollBar.setBlockIncrement(model.getHeight()); - scrollBar.setValues( - model.getLineOffset(), - model.getHeight(), - 0, - model.getHeight() + model.getBufferSize() - ); - } - - public void consoleAction(ConsoleAction action) { - view.consoleAction(action); - if(getParent() == null && config.getVisibleOnOutput()) { - control.makeVisible(this); - } - control.viewUpdated(this); - } - - public void setConnection(Connection connection) { - view.setConnection(connection); - } - - public OutputConfiguration getConfiguration() { - return config; - } - - public void lineUp() { - model.setLineOffset(model.getLineOffset()-1); - consoleChanged(); - view.repaint(); - } - - public void lineDown() { - model.setLineOffset(model.getLineOffset()+1); - consoleChanged(); - view.repaint(); - } - - public void pageUp() { - model.setLineOffset(model.getLineOffset() - model.getHeight()); - consoleChanged(); - view.repaint(); - } - - public void pageDown() { - model.setLineOffset(model.getLineOffset() + model.getHeight()); - consoleChanged(); - view.repaint(); - } - - public void setViewFont(Font font) { - view.setFont(font); - } - - public void resizeConsole() { - if (getParent() != null) { - view.resizeConsole(); - } - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/ui/OptionsDialog.java b/mudclient/src/java/org/cyberiantiger/mudclient/ui/OptionsDialog.java deleted file mode 100644 index bbc94f7a..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/ui/OptionsDialog.java +++ /dev/null @@ -1,247 +0,0 @@ -package org.cyberiantiger.mudclient.ui; - -import javax.swing.*; -import javax.swing.event.*; -import java.awt.*; -import java.awt.event.*; - -import org.cyberiantiger.mudclient.config.ClientConfiguration; - -public class OptionsDialog extends JDialog { - - private ControlWindow ctrl; - private JLabel hostLabel; - private JLabel portLabel; - private JLabel proxyHostLabel; - private JLabel proxyPortLabel; - private JLabel useProxyLabel; - private JLabel useJvmProxyLabel; - private JLabel boldLabel; - private JLabel italicLabel; - private JLabel fontLabel; - private JLabel fontSizeLabel; - private JTextField host; - private JTextField port; - private JTextField proxyHost; - private JTextField proxyPort; - private JCheckBox useProxy; - private JCheckBox useJvmProxy; - private JButton save; - private JPanel formPanel; - private JPanel buttonPanel; - private JComboBox font; - private JCheckBox bold; - private JCheckBox italic; - private JTextField fontSize; - - public OptionsDialog(ControlWindow ctrl) { - super(ctrl, "Options", true); - this.ctrl = ctrl; - initComponents(); - } - - private void initComponents() { - hostLabel = new JLabel("Address"); - portLabel = new JLabel("Port"); - proxyHostLabel = new JLabel("Proxy address"); - proxyPortLabel = new JLabel("Proxy port"); - useProxyLabel = new JLabel("Use proxy"); - useJvmProxyLabel = new JLabel("Use default proxy"); - boldLabel = new JLabel("Bold"); - italicLabel = new JLabel("Italic"); - fontLabel = new JLabel("Font"); - fontSizeLabel = new JLabel("Font size"); - host = new JTextField(20); - port = new JTextField(20); - proxyHost = new JTextField(20); - proxyPort = new JTextField(20); - useProxy = new JCheckBox(); - useJvmProxy = new JCheckBox(); - save = new JButton("Save"); - formPanel = new JPanel(); - buttonPanel = new JPanel(); - bold = new JCheckBox(); - italic = new JCheckBox(); - font = new JComboBox(); - fontSize = new JTextField(); - - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(formPanel, BorderLayout.CENTER); - getContentPane().add(buttonPanel, BorderLayout.SOUTH); - - formPanel.setLayout(new SpringLayout()); - buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING)); - - buttonPanel.add(save); - - formPanel.add(hostLabel); - formPanel.add(host); - formPanel.add(portLabel); - formPanel.add(port); - formPanel.add(useProxyLabel); - formPanel.add(useProxy); - formPanel.add(useJvmProxyLabel); - formPanel.add(useJvmProxy); - formPanel.add(proxyHostLabel); - formPanel.add(proxyHost); - formPanel.add(proxyPortLabel); - formPanel.add(proxyPort); - formPanel.add(fontLabel); - formPanel.add(font); - formPanel.add(fontSizeLabel); - formPanel.add(fontSize); - formPanel.add(boldLabel); - formPanel.add(bold); - formPanel.add(italicLabel); - formPanel.add(italic); - - SpringUtilities.makeCompactGrid(formPanel, 10, 2, 5, 5, 5, 5); - - pack(); - - save.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - hide(); - saveConfig(); - } - }); - useProxy.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - updateEnabled(); - } - }); - useJvmProxy.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - ClientConfiguration config = ctrl.getConfiguration(); - if (useJvmProxy.isSelected()) { - proxyHost.setText(config.getJvmProxyHost()); - proxyPort.setText("" + config.getJvmProxyPort()); - } else { - proxyHost.setText(config.getProxyHost()); - proxyPort.setText("" + config.getProxyPort()); - } - updateEnabled(); - } - }); - DocumentListener updateListener = - new DocumentListener() { - public void changedUpdate(DocumentEvent e) { - updateEnabled(); - } - public void removeUpdate(DocumentEvent e) { - updateEnabled(); - } - public void insertUpdate(DocumentEvent e) { - updateEnabled(); - } - }; - host.getDocument().addDocumentListener(updateListener); - port.getDocument().addDocumentListener(updateListener); - proxyHost.getDocument().addDocumentListener(updateListener); - proxyPort.getDocument().addDocumentListener(updateListener); - fontSize.getDocument().addDocumentListener(updateListener); - - loadConfig(); - } - - private void updateEnabled() { - if (useProxy.isSelected()) { - useJvmProxy.setEnabled(true); - boolean tmp = !useJvmProxy.isSelected(); - proxyHost.setEnabled(tmp); - proxyPort.setEnabled(tmp); - } else { - useJvmProxy.setEnabled(false); - proxyHost.setEnabled(false); - proxyPort.setEnabled(false); - } - save.setEnabled(formValid()); - } - - private boolean formValid() { - if (host.getText().length() == 0) { - return false; - } - if (port.getText().length() == 0) { - return false; - } - try { - int p = Integer.parseInt(port.getText()); - if (p < 1 || p > 65535) { - return false; - } - } catch (NumberFormatException nfe) { - return false; - } - if (useProxy.isSelected()) { - if (proxyHost.getText().length() == 0) { - return false; - } - if (proxyPort.getText().length() == 0) { - return false; - } - try { - int p = Integer.parseInt(proxyPort.getText()); - if (p < 1 || p > 65535) { - return false; - } - } catch (NumberFormatException nfe) { - return false; - } - } - try { - int f = Integer.parseInt(fontSize.getText()); - if ( f < 1 || f > 72 ) { - return false; - } - } catch (NumberFormatException nfe) { - return false; - } - return true; - } - - protected void loadConfig() { - ClientConfiguration config = ctrl.getConfiguration(); - host.setText(config.getHost()); - port.setText("" + config.getPort()); - useProxy.setSelected(config.getUseProxy()); - useJvmProxy.setSelected(config.getUseJvmProxy()); - proxyHost.setText(config.getUseJvmProxy() ? config.getJvmProxyHost() : config.getProxyHost()); - proxyPort.setText("" + (config.getUseJvmProxy() ? config.getJvmProxyPort() : config.getProxyPort())); - String[] fonts = - GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); - font.removeAllItems(); - int selectedIndex = -1; - for (int i=0; i< fonts.length;i++) { - if (fonts[i].equalsIgnoreCase(config.getFont())) { - selectedIndex = i; - } - font.addItem(fonts[i]); - } - font.setSelectedIndex(selectedIndex); - fontSize.setText("" + config.getFontSize()); - bold.setSelected(config.getBold()); - italic.setSelected(config.getItalic()); - updateEnabled(); - } - - protected void saveConfig() { - ClientConfiguration config = ctrl.getConfiguration(); - config.setHost(host.getText()); - config.setPort(Integer.parseInt(port.getText())); - config.setUseProxy(useProxy.isSelected()); - config.setUseJvmProxy(useJvmProxy.isSelected()); - if (!useJvmProxy.isSelected()) { - config.setProxyHost(proxyHost.getText()); - config.setProxyPort(Integer.parseInt(proxyPort.getText())); - } - config.setFont((String)font.getSelectedItem()); - config.setFontSize(Integer.parseInt(fontSize.getText())); - config.setBold(bold.isSelected()); - config.setItalic(italic.isSelected()); - ctrl.updateFont(); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/ui/OutputFrame.java b/mudclient/src/java/org/cyberiantiger/mudclient/ui/OutputFrame.java deleted file mode 100644 index fe247d88..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/ui/OutputFrame.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.cyberiantiger.mudclient.ui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; -import java.util.*; -import org.cyberiantiger.mudclient.net.MudConnection; -import org.cyberiantiger.mudclient.parser.*; -import org.cyberiantiger.mudclient.config.*; -import org.cyberiantiger.console.*; - -public class OutputFrame extends JFrame { - - private MudClientUI ui; - - public OutputFrame(MudClientUI ui) { - super(ui.getConfiguration().getName()); - this.ui = ui; - initComponents(); - } - - private void initComponents() { - setDefaultCloseOperation(HIDE_ON_CLOSE); - - getContentPane().setLayout(new BorderLayout()); - - getContentPane().add(ui, BorderLayout.CENTER); - - pack(); - - } -} diff --git a/mudclient/src/java/org/cyberiantiger/mudclient/ui/SpringUtilities.java b/mudclient/src/java/org/cyberiantiger/mudclient/ui/SpringUtilities.java deleted file mode 100644 index 3e1af873..00000000 --- a/mudclient/src/java/org/cyberiantiger/mudclient/ui/SpringUtilities.java +++ /dev/null @@ -1,194 +0,0 @@ -package org.cyberiantiger.mudclient.ui; - -import javax.swing.*; -import javax.swing.SpringLayout; -import java.awt.*; - -/** - * A 1.4 file that provides utility methods for - * creating form- or grid-style layouts with SpringLayout. - * These utilities are used by several programs, such as - * SpringBox and SpringCompactGrid. - */ -public class SpringUtilities { - /** - * A debugging utility that prints to stdout the component's - * minimum, preferred, and maximum sizes. - */ - public static void printSizes(Component c) { - System.out.println("minimumSize = " + c.getMinimumSize()); - System.out.println("preferredSize = " + c.getPreferredSize()); - System.out.println("maximumSize = " + c.getMaximumSize()); - } - - /** - * Aligns the first rows * cols - * components of parent in - * a grid. Each component is as big as the maximum - * preferred width and height of the components. - * The parent is made just big enough to fit them all. - * - * @param rows number of rows - * @param cols number of columns - * @param initialX x location to start the grid at - * @param initialY y location to start the grid at - * @param xPad x padding between cells - * @param yPad y padding between cells - */ - public static void makeGrid(Container parent, - int rows, int cols, - int initialX, int initialY, - int xPad, int yPad) { - SpringLayout layout; - try { - layout = (SpringLayout)parent.getLayout(); - } catch (ClassCastException exc) { - System.err.println("The first argument to makeGrid must use SpringLayout."); - return; - } - - Spring xPadSpring = Spring.constant(xPad); - Spring yPadSpring = Spring.constant(yPad); - Spring initialXSpring = Spring.constant(initialX); - Spring initialYSpring = Spring.constant(initialY); - int max = rows * cols; - - //Calculate Springs that are the max of the width/height so that all - //cells have the same size. - Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)). - getWidth(); - Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)). - getWidth(); - for (int i = 1; i < max; i++) { - SpringLayout.Constraints cons = layout.getConstraints( - parent.getComponent(i)); - - maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth()); - maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight()); - } - - //Apply the new width/height Spring. This forces all the - //components to have the same size. - for (int i = 0; i < max; i++) { - SpringLayout.Constraints cons = layout.getConstraints( - parent.getComponent(i)); - - cons.setWidth(maxWidthSpring); - cons.setHeight(maxHeightSpring); - } - - //Then adjust the x/y constraints of all the cells so that they - //are aligned in a grid. - SpringLayout.Constraints lastCons = null; - SpringLayout.Constraints lastRowCons = null; - for (int i = 0; i < max; i++) { - SpringLayout.Constraints cons = layout.getConstraints( - parent.getComponent(i)); - if (i % cols == 0) { //start of new row - lastRowCons = lastCons; - cons.setX(initialXSpring); - } else { //x position depends on previous component - cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST), - xPadSpring)); - } - - if (i / cols == 0) { //first row - cons.setY(initialYSpring); - } else { //y position depends on previous row - cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH), - yPadSpring)); - } - lastCons = cons; - } - - //Set the parent's size. - SpringLayout.Constraints pCons = layout.getConstraints(parent); - pCons.setConstraint(SpringLayout.SOUTH, - Spring.sum( - Spring.constant(yPad), - lastCons.getConstraint(SpringLayout.SOUTH))); - pCons.setConstraint(SpringLayout.EAST, - Spring.sum( - Spring.constant(xPad), - lastCons.getConstraint(SpringLayout.EAST))); - } - - /* Used by makeCompactGrid. */ - private static SpringLayout.Constraints getConstraintsForCell( - int row, int col, - Container parent, - int cols) { - SpringLayout layout = (SpringLayout) parent.getLayout(); - Component c = parent.getComponent(row * cols + col); - return layout.getConstraints(c); - } - - /** - * Aligns the first rows * cols - * components of parent in - * a grid. Each component in a column is as wide as the maximum - * preferred width of the components in that column; - * height is similarly determined for each row. - * The parent is made just big enough to fit them all. - * - * @param rows number of rows - * @param cols number of columns - * @param initialX x location to start the grid at - * @param initialY y location to start the grid at - * @param xPad x padding between cells - * @param yPad y padding between cells - */ - public static void makeCompactGrid(Container parent, - int rows, int cols, - int initialX, int initialY, - int xPad, int yPad) { - SpringLayout layout; - try { - layout = (SpringLayout)parent.getLayout(); - } catch (ClassCastException exc) { - System.err.println("The first argument to makeCompactGrid must use SpringLayout."); - return; - } - - //Align all cells in each column and make them the same width. - Spring x = Spring.constant(initialX); - for (int c = 0; c < cols; c++) { - Spring width = Spring.constant(0); - for (int r = 0; r < rows; r++) { - width = Spring.max(width, - getConstraintsForCell(r, c, parent, cols). - getWidth()); - } - for (int r = 0; r < rows; r++) { - SpringLayout.Constraints constraints = - getConstraintsForCell(r, c, parent, cols); - constraints.setX(x); - constraints.setWidth(width); - } - x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad))); - } - - //Align all cells in each row and make them the same height. - Spring y = Spring.constant(initialY); - for (int r = 0; r < rows; r++) { - Spring height = Spring.constant(0); - for (int c = 0; c < cols; c++) { - height = Spring.max(height, - getConstraintsForCell(r, c, parent, cols). - getHeight()); - } - for (int c = 0; c < cols; c++) { - SpringLayout.Constraints constraints = - getConstraintsForCell(r, c, parent, cols); - constraints.setY(y); - constraints.setHeight(height); - } - y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad))); - } - - //Set the parent's size. - SpringLayout.Constraints pCons = layout.getConstraints(parent); - pCons.setConstraint(SpringLayout.SOUTH, y); - pCons.setConstraint(SpringLayout.EAST, x); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/telnet/AbstractTelnetOption.java b/mudclient/src/java/org/cyberiantiger/telnet/AbstractTelnetOption.java deleted file mode 100644 index 502f528c..00000000 --- a/mudclient/src/java/org/cyberiantiger/telnet/AbstractTelnetOption.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.cyberiantiger.telnet; - -public abstract class AbstractTelnetOption implements TelnetOption { - - protected int option; - - public AbstractTelnetOption(int option) { - this.option = option; - } - - public int getOption() { - return option; - } - - public byte[] getBytes() { - return new byte[] { (byte) IAC, (byte) option }; - } - - public String toString() { - return "IAC " + commandToString(option); - } - - protected String commandToString(int command) { - switch(command) { - case SE: return "SE"; - case NOP: return "NOP"; - case DM: return "DM"; - case BRK: return "BRK"; - case IP: return "IP"; - case AO: return "AO"; - case AYT: return "AYT"; - case EC: return "EC"; - case EL: return "EL"; - case GA: return "GA"; - case SB: return "SB"; - case WILL: return "WILL"; - case WONT: return "WONT"; - case DO: return "DO"; - case DONT: return "DONT"; - case IAC: return "IAC"; - default: return "<" + command + ">"; - } - } - - protected String optionToString(int option) { - switch(option) { - case TOPT_BIN: return "TOPT_BIN"; - case TOPT_ECHO: return "TOPT_ECHO"; - case TOPT_RECN: return "TOPT_RECN"; - case TOPT_SUPP: return "TOPT_SUPP"; - case TOPT_APRX: return "TOPT_APRX"; - case TOPT_STAT: return "TOPT_STAT"; - case TOPT_TIM: return "TOPT_TIM"; - case TOPT_REM: return "TOPT_REM"; - case TOPT_OLW: return "TOPT_OLW"; - case TOPT_OPS: return "TOPT_OPS"; - case TOPT_OCRD: return "TOPT_OCRD"; - case TOPT_OHT: return "TOPT_OHT"; - case TOPT_OHTD: return "TOPT_OHTD"; - case TOPT_OFD: return "TOPT_OFD"; - case TOPT_OVT: return "TOPT_OVT"; - case TOPT_OVTD: return "TOPT_OVTD"; - case TOPT_OLD: return "TOPT_OLD"; - case TOPT_EXT: return "TOPT_EXT"; - case TOPT_LOGO: return "TOPT_LOGO"; - case TOPT_BYTE: return "TOPT_BYTE"; - case TOPT_DATA: return "TOPT_DATA"; - case TOPT_SUP: return "TOPT_SUP"; - case TOPT_SUPO: return "TOPT_SUPO"; - case TOPT_SNDL: return "TOPT_SNDL"; - case TOPT_TERM: return "TOPT_TERM"; - case TOPT_EOR: return "TOPT_EOR"; - case TOPT_TACACS: return "TOPT_TACACS"; - case TOPT_OM: return "TOPT_OM"; - case TOPT_TLN: return "TOPT_TLN"; - case TOPT_3270: return "TOPT_3270"; - case TOPT_X_3: return "TOPT_X_3"; - case TOPT_NAWS: return "TOPT_NAWS"; - case TOPT_TS: return "TOPT_TS"; - case TOPT_RFC: return "TOPT_RFC"; - case TOPT_LINE: return "TOPT_LINE"; - case TOPT_XDL: return "TOPT_XDL"; - case TOPT_AUTH: return "TOPT_AUTH"; - case TOPT_ENVIR: return "TOPT_ENVIR"; - case TOPT_TN3270E: return "TOPT_TN3270E"; - case TOPT_XAUTH: return "TOPT_XAUTH"; - case TOPT_CHARSET: return "TOPT_CHARSET"; - case TOPT_RSP: return "TOPT_RSP"; - case TOPT_COMPORT: return "TOPT_COMPORT"; - case TOPT_SLE: return "TOPT_SLE"; - case TOPT_STARTTLS: return "TOPT_STARTTLS"; - case TOPT_KERMIT: return "TOPT_KERMIT"; - case TOPT_SEND_URL: return "TOPT_SEND_URL"; - case TOPT_EXTOP: return "TOPT_EXTOP"; - default: return "<" + option + ">"; - } - } - - protected String dataToString(byte[] data) { - return "\"" + new String(data) + "\""; - } -} diff --git a/mudclient/src/java/org/cyberiantiger/telnet/AbstractTelnetSubOption.java b/mudclient/src/java/org/cyberiantiger/telnet/AbstractTelnetSubOption.java deleted file mode 100644 index eee6300a..00000000 --- a/mudclient/src/java/org/cyberiantiger/telnet/AbstractTelnetSubOption.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.cyberiantiger.telnet; - -public abstract class AbstractTelnetSubOption extends AbstractTelnetOption { - - protected int suboption; - - public AbstractTelnetSubOption(int option, int suboption) { - super(option); - this.suboption = suboption; - } - - public int getSubOption() { - return suboption; - } - - public byte[] getBytes() { - return new byte[] { (byte) IAC, (byte) option, (byte) suboption }; - } - - public String toString() { - return super.toString() + " " + optionToString(suboption); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/telnet/BinaryData.java b/mudclient/src/java/org/cyberiantiger/telnet/BinaryData.java deleted file mode 100644 index ddfd9355..00000000 --- a/mudclient/src/java/org/cyberiantiger/telnet/BinaryData.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.cyberiantiger.telnet; - -public interface BinaryData { - - public byte[] getBytes(); - -} diff --git a/mudclient/src/java/org/cyberiantiger/telnet/OptionParser.java b/mudclient/src/java/org/cyberiantiger/telnet/OptionParser.java deleted file mode 100644 index 21e093b2..00000000 --- a/mudclient/src/java/org/cyberiantiger/telnet/OptionParser.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.cyberiantiger.telnet; - -import java.io.InputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -/** - * A static class for parsing telnet options, coz it's stateless. - */ -public class OptionParser { - - // No-One can instantiate the class - private OptionParser() {} - - public static TelnetOption parseOption(InputStream in, int option) - throws IOException - { - if(option < 240) { - return new UnknownTelnetOption(option); - } else if(option < 250) { - return new SimpleTelnetOption(option); - } else if(option == TelnetOption.SB) { - int suboption = in.read(); - // Check for end of stream. - if(suboption == -1) return null; - ByteArrayOutputStream out = new ByteArrayOutputStream(40); - while(true) { - int i = in.read(); - // Check for end of stream. - if(i == -1) return null; - if(i == TelnetOption.IAC) { - int j = in.read(); - // Check for end of stream. - if(j == -1) return null; - if(j == TelnetOption.IAC) { - out.write(TelnetOption.IAC); - } else if(j == TelnetOption.SE) { - return new TelnetSubOption(suboption, out.toByteArray()); - } else { - // It's a broken telnet implementation, assume they - // just forgot to double the TelnetOption.IAC. - out.write(TelnetOption.IAC); - out.write(j); - } - } else { - out.write(i); - } - } - } else { - int suboption = in.read(); - if(suboption == -1) return null; - return new TelnetNegotiation(option, suboption); - } - } -} diff --git a/mudclient/src/java/org/cyberiantiger/telnet/SimpleTelnetOption.java b/mudclient/src/java/org/cyberiantiger/telnet/SimpleTelnetOption.java deleted file mode 100644 index a233735b..00000000 --- a/mudclient/src/java/org/cyberiantiger/telnet/SimpleTelnetOption.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.cyberiantiger.telnet; - -public class SimpleTelnetOption extends AbstractTelnetOption { - - public SimpleTelnetOption(int option) { - super(option); - } -} diff --git a/mudclient/src/java/org/cyberiantiger/telnet/SimpleTelnetSession.java b/mudclient/src/java/org/cyberiantiger/telnet/SimpleTelnetSession.java deleted file mode 100644 index 3c285e64..00000000 --- a/mudclient/src/java/org/cyberiantiger/telnet/SimpleTelnetSession.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.cyberiantiger.telnet; - -import java.io.*; - -public abstract class SimpleTelnetSession implements TelnetSession { - - private OutputStream out; - - String term; - int width = 0; - int height = 0; - - boolean nawsOn = false; - boolean termOn = false; - - public SimpleTelnetSession(String term) { - this.term = term; - } - - public void receiveOption(TelnetOption opt) - throws IOException - { - if(opt instanceof TelnetNegotiation) { - TelnetOption reply; - switch(opt.getOption()) { - case TelnetOption.WILL: - switch(((TelnetNegotiation)opt).getSubOption()) { - case TelnetOption.TOPT_ECHO: - serverWillEcho(true); - break; - default: - break; - } - break; - case TelnetOption.WONT: - switch(((TelnetNegotiation)opt).getSubOption()) { - case TelnetOption.TOPT_ECHO: - serverWillEcho(false); - break; - default: - break; - } - break; - case TelnetOption.DO: - switch(((TelnetNegotiation)opt).getSubOption()) { - case TelnetOption.TOPT_TERM: - reply = new TelnetNegotiation( - TelnetOption.WILL, - TelnetOption.TOPT_TERM - ); - out.write(reply.getBytes()); - termOn = true; - break; - case TelnetOption.TOPT_NAWS: - reply = new TelnetNegotiation( - TelnetOption.WILL, - TelnetOption.TOPT_NAWS - ); - out.write(reply.getBytes()); - nawsOn = true; - sendWindowSize(); - break; - default: - // Ignored - break; - } - break; - case TelnetOption.DONT: - break; - } - } else if(opt instanceof TelnetSubOption) { - byte[] data; - data = ((TelnetSubOption)opt).getData(); - switch(((TelnetSubOption)opt).getSubOption()) { - case TelnetOption.TOPT_TERM: - if(data.length == 1 && data[0] == TelnetOption.SEND) { - sendTerminalType(); - } - default: - break; - } - } - } - - public void setOutputStream(OutputStream out) throws IOException { - this.out = out; - } - - public void sendWindowSize() throws IOException { - if(out != null && nawsOn && (width != 0 || height != 0) ) { - TelnetOption opt = new TelnetSubOption( - TelnetOption.TOPT_NAWS, - new byte[] { - ((byte) ((width>>8) & 0xff)), - ((byte) (width & 0xff)), - ((byte) ((height>>8) & 0xff)), - ((byte) (height & 0xff)) - }); - out.write(opt.getBytes()); - } - } - - public void sendTerminalType() throws IOException { - if(out != null && termOn) { - byte[] term = this.term.getBytes(); - byte[] data = new byte[term.length+1]; - data[0] = TelnetOption.IS; - System.arraycopy(term,0,data,1,term.length); - TelnetOption opt = new TelnetSubOption( - TelnetOption.TOPT_TERM, - data); - out.write(opt.getBytes()); - } - } - - public void setWindowSize(int width, int height) throws IOException { - if(this.width != width || this.height != height) { - this.width = width; - this.height = height; - sendWindowSize(); - } - } - - protected abstract void serverWillEcho(boolean echo); -} diff --git a/mudclient/src/java/org/cyberiantiger/telnet/TelnetBufferedInputStream.java b/mudclient/src/java/org/cyberiantiger/telnet/TelnetBufferedInputStream.java deleted file mode 100644 index 8c10be32..00000000 --- a/mudclient/src/java/org/cyberiantiger/telnet/TelnetBufferedInputStream.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.cyberiantiger.telnet; - -import java.io.*; - -/** - * A buffered input stream which will not do a blocking read unless explictely - * told to do so - */ -public class TelnetBufferedInputStream extends FilterInputStream { - - private byte[] buffer = new byte[2048]; - private int off = 0; - private int len = 0; - private boolean allowBlocking = false; - - public TelnetBufferedInputStream(InputStream in) { - super(in); - } - - public int read() throws IOException { - if(allowBlocking && len == 0) { - fillBuffer(); - } - if(len <= 0) { - return -1; - } - len--; - return buffer[off++] & 0xff; - } - - public int read(byte[] b) throws IOException { - return read(b, 0, b.length); - } - - public int read(byte[] b, int bOff, int bLen) throws IOException { - if(allowBlocking && len == 0) { - fillBuffer(); - } - if(len <= 0) { - return -1; - } - if(len > bLen) { - System.arraycopy(buffer,off,b,bOff,bLen); - len -= bLen; - off += bLen; - } else { - System.arraycopy(buffer,off,b,bOff,len); - bLen = len; - len = 0; - } - return bLen; - } - - public void fillBuffer() throws IOException { - if(len != 0) return; - off = 0; - len = in.read(buffer,off,buffer.length - len); - } - - public int available() throws IOException { - return len; - } - - public void setAllowBlocking(boolean allowBlocking) { - this.allowBlocking = allowBlocking; - } -} diff --git a/mudclient/src/java/org/cyberiantiger/telnet/TelnetInputStream.java b/mudclient/src/java/org/cyberiantiger/telnet/TelnetInputStream.java deleted file mode 100644 index e12dd59d..00000000 --- a/mudclient/src/java/org/cyberiantiger/telnet/TelnetInputStream.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.cyberiantiger.telnet; - -import java.io.*; - -public abstract class TelnetInputStream extends FilterInputStream { - - byte[] buffer = new byte[2048]; - int off = 0; - int len = 0; - - boolean inTelnetOpt = false; - int toptVal = -1; - - public TelnetInputStream(InputStream in) { - super(new TelnetBufferedInputStream(in)); - } - - /** - * Fill the buffer in this object. - */ - private void fillBuffer() throws IOException { - if(len != 0) return; - if(in.available() == -1) { - // NO MORE DATA ! - len = -1; - return; - } - off = 0; - if(inTelnetOpt) { - try { - ((TelnetBufferedInputStream)in).setAllowBlocking(true); - if(toptVal == -1) { - int ch = in.read(); - if(ch == -1) { - len = -1; - return; - } else if(ch == TelnetOption.IAC) { - buffer[len++] = (byte) ch; - } else { - TelnetOption opt = OptionParser.parseOption(in,ch); - parseTelnetOption(opt); - } - } else { - TelnetOption opt = OptionParser.parseOption(in,toptVal); - parseTelnetOption(opt); - } - } finally { - inTelnetOpt = false; - ((TelnetBufferedInputStream)in).setAllowBlocking(false); - } - } - if(in.available() == 0) { - ((TelnetBufferedInputStream)in).fillBuffer(); - } - int ch; - while( (ch = in.read()) != -1) { - if(ch == TelnetOption.IAC) { - ch = in.read(); - if(ch != TelnetOption.IAC) { - inTelnetOpt = true; - toptVal = ch; - // Read no more at this point, we have the start of a - // telnet option. - break; - } else { - buffer[len++] = (byte)ch; - } - } else { - buffer[len++] = (byte)ch; - } - } - // Recursive call to ensure we at least have either the end of stream - // or one byte to read when this method exits. - if(len == 0) fillBuffer(); - } - - public int read() throws IOException { - if(len == 0) { - fillBuffer(); - } - if(len == -1) { - return -1; - } - len--; - return buffer[off++] & 0xff; - } - - public int read(byte[] b) throws IOException { - return read(b,0,b.length); - } - - public int read(byte[] b, int bOff, int bLen) throws IOException { - if(len == 0) { - fillBuffer(); - } - if(len == -1) { - return -1; - } - if(len>bLen) { - System.arraycopy(buffer,off,b,bOff,bLen); - len -= bLen; - off += bLen; - } else { - System.arraycopy(buffer,off,b,bOff,len); - bLen = len; - len = 0; - } - return bLen; - } - - public int available() throws IOException { - return len; - } - - public void close() throws IOException { - in.close(); - } - - protected abstract void parseTelnetOption(TelnetOption topt) - throws IOException; -} diff --git a/mudclient/src/java/org/cyberiantiger/telnet/TelnetNegotiation.java b/mudclient/src/java/org/cyberiantiger/telnet/TelnetNegotiation.java deleted file mode 100644 index 927d4b3a..00000000 --- a/mudclient/src/java/org/cyberiantiger/telnet/TelnetNegotiation.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.cyberiantiger.telnet; - -public class TelnetNegotiation extends AbstractTelnetSubOption { - - public TelnetNegotiation(int option, int suboption) { - super(option, suboption); - } - -} diff --git a/mudclient/src/java/org/cyberiantiger/telnet/TelnetOption.java b/mudclient/src/java/org/cyberiantiger/telnet/TelnetOption.java deleted file mode 100644 index f62e62d8..00000000 --- a/mudclient/src/java/org/cyberiantiger/telnet/TelnetOption.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.cyberiantiger.telnet; - -import java.io.IOException; -import java.io.OutputStream; - -public interface TelnetOption extends BinaryData { - - /** - * Top Level Telnet Stuff - */ - public static final int SE = 240; - public static final int NOP = 241; - public static final int DM = 242; - public static final int BRK = 243; - public static final int IP = 244; - public static final int AO = 245; - public static final int AYT = 246; - public static final int EC = 247; - public static final int EL = 248; - public static final int GA = 249; - public static final int SB = 250; - public static final int WILL = 251; - public static final int WONT = 252; - public static final int DO = 253; - public static final int DONT = 254; - public static final int IAC = 255; - - /** - * Telnet Option Types - */ - // TOPT_BIN Binary Transmission 0 Std Rec 856 27 - public static final int TOPT_BIN = 0; - // TOPT_ECHO Echo 1 Std Rec 857 28 - public static final int TOPT_ECHO = 1; - // TOPT_RECN Reconnection 2 Prop Ele ... - public static final int TOPT_RECN = 2; - // TOPT_SUPP Suppress Go Ahead 3 Std Rec 858 29 - public static final int TOPT_SUPP = 3; - // TOPT_APRX Approx Message Size Negotiation 4 Prop Ele ... - public static final int TOPT_APRX = 4; - // TOPT_STAT Status 5 Std Rec 859 30 - public static final int TOPT_STAT = 5; - // TOPT_TIM Timing Mark 6 Std Rec 860 31 - public static final int TOPT_TIM = 6; - // TOPT_REM Remote Controlled Trans and Echo 7 Prop Ele 726 - public static final int TOPT_REM = 7; - // TOPT_OLW Output Line Width 8 Prop Ele ... - public static final int TOPT_OLW = 8; - // TOPT_OPS Output Page Size 9 Prop Ele ... - public static final int TOPT_OPS = 9; - // TOPT_OCRD Output Carriage-Return Disposition 10 Hist Ele 652 * - public static final int TOPT_OCRD = 10; - // TOPT_OHT Output Horizontal Tabstops 11 Hist Ele 653 * - public static final int TOPT_OHT = 11; - // TOPT_OHTD Output Horizontal Tab Disposition 12 Hist Ele 654 * - public static final int TOPT_OHTD = 12; - // TOPT_OFD Output Formfeed Disposition 13 Hist Ele 655 * - public static final int TOPT_OFD = 13; - // TOPT_OVT Output Vertical Tabstops 14 Hist Ele 656 * - public static final int TOPT_OVT = 14; - // TOPT_OVTD Output Vertical Tab Disposition 15 Hist Ele 657 * - public static final int TOPT_OVTD = 15; - // TOPT_OLD Output Linefeed Disposition 16 Hist Ele 658 * - public static final int TOPT_OLD = 16; - // TOPT_EXT Extended ASCII 17 Prop Ele 698 - public static final int TOPT_EXT = 17; - // TOPT_LOGO Logout 18 Prop Ele 727 - public static final int TOPT_LOGO = 18; - // TOPT_BYTE Byte Macro 19 Prop Ele 735 - public static final int TOPT_BYTE = 19; - // TOPT_DATA Data Entry Terminal 20 Prop Ele 1043 - public static final int TOPT_DATA = 20; - // TOPT_SUP SUPDUP 21 Prop Ele 736 - public static final int TOPT_SUP = 21; - // TOPT_SUPO SUPDUP Output 22 Prop Ele 749 - public static final int TOPT_SUPO = 22; - // TOPT_SNDL Send Location 23 Prop Ele 779 - public static final int TOPT_SNDL = 23; - // TOPT_TERM Terminal Type 24 Prop Ele 1091 - public static final int TOPT_TERM = 24; - // TOPT_EOR End of Record 25 Prop Ele 885 - public static final int TOPT_EOR = 25; - // TOPT_TACACS TACACS User Identification 26 Prop Ele 927 - public static final int TOPT_TACACS = 26; - // TOPT_OM Output Marking 27 Prop Ele 933 - public static final int TOPT_OM = 27; - // TOPT_TLN Terminal Location Number 28 Prop Ele 946 - public static final int TOPT_TLN = 28; - // TOPT_3270 Telnet 3270 Regime 29 Prop Ele 1041 - public static final int TOPT_3270 = 29; - // TOPT_X.3 X.3 PAD 30 Prop Ele 1053 - public static final int TOPT_X_3 = 30; - // TOPT_NAWS Negotiate About Window Size 31 Prop Ele 1073 - public static final int TOPT_NAWS = 31; - // TOPT_TS Terminal Speed 32 Prop Ele 1079 - public static final int TOPT_TS = 32; - // TOPT_RFC Remote Flow Control 33 Prop Ele 1372 - public static final int TOPT_RFC = 33; - // TOPT_LINE Linemode 34 Draft Ele 1184 - public static final int TOPT_LINE = 34; - // TOPT_XDL X Display Location 35 Prop Ele 1096 - public static final int TOPT_XDL = 35; - // TOPT_ENVIR Telnet Environment Option 36 Hist Not 1408 - //public static final int TOPT_ENVIR = 36; - // TOPT_AUTH Telnet Authentication Option 37 Exp Ele 1416 - public static final int TOPT_AUTH = 37; - // TOPT_ENVIR Telnet Environment Option 39 Prop Ele 1572 - public static final int TOPT_ENVIR = 39; - // TOPT_TN3270E TN3270 Enhancements 40 Draft Ele 2355 * - public static final int TOPT_TN3270E = 40; - // TOPT_XAUTH Telnet XAUTH 41 Exp - public static final int TOPT_XAUTH = 41; - // TOPT_CHARSET Telnet CHARSET 42 Exp 2066 - public static final int TOPT_CHARSET = 42; - // TOPT_RSP Telnet Remote Serial Port 43 Exp - public static final int TOPT_RSP = 43; - // TOPT_COMPORT Telnet Com Port Control 44 Exp 2217 - public static final int TOPT_COMPORT = 44; - // TOPT_SLE Telnet Suppress Local Echo 45 Exp * - public static final int TOPT_SLE = 45; - // TOPT_STARTTLS Telnet Start TLS 46 Exp * - public static final int TOPT_STARTTLS = 46; - // TOPT_KERMIT Telnet KERMIT 47 Exp * - public static final int TOPT_KERMIT = 47; - // TOPT_SEND-URL Send-URL 48 Exp * - public static final int TOPT_SEND_URL = 48; - // TOPT_EXTOP Extended-Options-List 255 Std Rec 861 32 - public static final int TOPT_EXTOP = 255; - - // First Byte in Subnegotation: IAC SB
  #FFFFFF
 
"; -if(windowMode){ -cp_contents += ""; -} -cp.populate(cp_contents+"\n"); -cp.offsetY = 25; -cp.autoHide(); -return cp; -} - - - - diff --git a/reportrunner/webapp/renderers/htmltable/invertBgColor.js b/reportrunner/webapp/renderers/htmltable/invertBgColor.js deleted file mode 100644 index d0573d27..00000000 --- a/reportrunner/webapp/renderers/htmltable/invertBgColor.js +++ /dev/null @@ -1,91 +0,0 @@ - //HH: Copied from zebra.js - - - // this function is needed to work around - // a bug in IE related to element attributes - function hasClass(obj) { - var result = false; - if (obj.getAttributeNode("class") != null) { - result = obj.getAttributeNode("class").value; - } - return result; - } - - function setTrColor(tr, color) { - tr.bgcolor = color; - - // get all the cells in this row... - var tds = tr.getElementsByTagName("td"); - - // and iterate through them... - for (var j = 0; j < tds.length; j++) { - var mytd = tds[j]; - mytd.style.backgroundColor = color; - } - } - - - function initInvertBgColor(id) { - - var defaultSelected = arguments[1] ? arguments[1] : "#dd0"; - - // obtain a reference to the desired table - // if no such table exists, abort - var table = document.getElementById(id); - if (! table) { return; } - - // by definition, tables can have more than one tbody - // element, so we'll have to get the list of child - // <tbody>s - var tbodies = table.getElementsByTagName("tbody"); - - // and iterate through them... - for (var h = 0; h < tbodies.length; h++) { - - // find all the <tr> elements... - var trs = tbodies[h].getElementsByTagName("tr"); - - // ... and iterate through them - for (var i = 0; i < trs.length; i++) { - var tr = trs[i]; - addEvent(tr, "click", function(event) { - - var selected = document.getElementById('swatch').bgColor; - if(selected == null) { - selected = defaultSelected; - } else { - selected = selected.toLowerCase(); - } - - var td = null; - if(event.target == null) { - td = event.srcElement; - } else { - td = event.target; - } - var obj = td.parentNode; - var unselected = obj.getAttribute('unselected'); - if(unselected == null) { - unselected = td.style.backgroundColor; - obj.setAttribute('unselected', unselected); - } - var color = obj.bgcolor; - if(color == null) { - setTrColor(obj, selected); - return; - } - - color = color.toLowerCase(); - if(color == unselected) { - setTrColor(obj, selected); - } else - if(color == selected) { - setTrColor(obj, unselected); - obj.removeAttribute('unselected'); - } else { - setTrColor(obj, selected); - } - } ); - } - } - } diff --git a/reportrunner/webapp/renderers/htmltable/sorttable.js b/reportrunner/webapp/renderers/htmltable/sorttable.js deleted file mode 100644 index 89758f56..00000000 --- a/reportrunner/webapp/renderers/htmltable/sorttable.js +++ /dev/null @@ -1,183 +0,0 @@ -addEvent(window, "load", sortables_init); - -var SORT_COLUMN_INDEX; - -function sortables_init() { - // Find all tables with class sortable and make them sortable - if (!document.getElementsByTagName) return; - tbls = document.getElementsByTagName("table"); - for (ti=0;ti 0) { - var firstRow = table.rows[0]; - } - if (!firstRow) return; - - // We have a first row: assume it's the header, and make its contents clickable links - for (var i=0;i   '; - } -} - -function ts_getInnerText(el) { - if (typeof el == "string") return el; - if (typeof el == "undefined") { return el }; - if (el.innerText) return el.innerText; //Not needed but it is faster - var str = ""; - - var cs = el.childNodes; - var l = cs.length; - for (var i = 0; i < l; i++) { - switch (cs[i].nodeType) { - case 1: //ELEMENT_NODE - str += ts_getInnerText(cs[i]); - break; - case 3: //TEXT_NODE - str += cs[i].nodeValue; - break; - } - } - return str; -} - -function ts_resortTable(lnk) { - // get the span - var span; - for (var ci=0;ci -<%@ include file="header.inc" %> -<%@ page import="java.io.*" %> -<%@ page import="java.net.*" %> -<%@ page import="org.osjava.reportrunner.*" %> -<%@ page import="org.osjava.reportrunner.servlets.*" %> - -<% - String groupName = request.getParameter(ReportRunnerServlet.GROUP); - String reportName = request.getParameter(ReportRunnerServlet.REPORT); - Report report = ReportFactory.getReport(groupName, reportName); - -String str = request.getRequestURL().toString(); -str += "?"; -str += URLEncoder.encode(request.getQueryString()); -str += "\n\n"; -StringWriter sw = new StringWriter(); -PrintWriter pw = new PrintWriter(sw); -exception.printStackTrace(pw); -str += sw.toString(); -sw.close(); -pw.close(); -str = str.replaceAll("\n", "%0A"); -%> - -

There's been an error, please mail it to <%= report.getAuthor() %> by clicking the following -link.

-
-<%= sw %>
-
- -<%@ include file="footer.inc" %> diff --git a/reportrunner/webapp/style.css b/reportrunner/webapp/style.css deleted file mode 100644 index 9d2a0766..00000000 --- a/reportrunner/webapp/style.css +++ /dev/null @@ -1,41 +0,0 @@ -body, p, td, table, tr { - font-family: Verdana, arial, sans-serif; - font-size: 12px; - line-height: 16px; - color: #000000; - font-weight: normal; -} - -body { - margin: 10px; - padding: 10px; - background-color: #ffffff; -} - -.feedback { - background-color: #f0f0f0; - border: 1px dashed #3c78b5; - padding: 0px 10px 0px 10px; - margin: 10px; -} - -.input { - border: 1px dashed #3c78b5; - padding: 0px 10px 0px 10px; - margin: 10px; -} - -label { - font-weight: bold; - padding-right: 4px; -} - -.chosen-data { - background-color: #ffffff; -} - -.stages a { - border: 1px dashed #3c78b5; - padding: 0px 10px 5px 10px; - margin: 10px; -} diff --git a/reportrunner/xdocs/changes.xml b/reportrunner/xdocs/changes.xml deleted file mode 100644 index 944c2382..00000000 --- a/reportrunner/xdocs/changes.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Henri Yandell - Changes - - - - - - - diff --git a/reportrunner/xdocs/images/1x1.gif b/reportrunner/xdocs/images/1x1.gif deleted file mode 100644 index 8749ca0c..00000000 Binary files a/reportrunner/xdocs/images/1x1.gif and /dev/null differ diff --git a/reportrunner/xdocs/images/osjava.gif b/reportrunner/xdocs/images/osjava.gif deleted file mode 100644 index 8cbe5cb2..00000000 Binary files a/reportrunner/xdocs/images/osjava.gif and /dev/null differ diff --git a/reportrunner/xdocs/navigation.xml b/reportrunner/xdocs/navigation.xml deleted file mode 100644 index 134f14ec..00000000 --- a/reportrunner/xdocs/navigation.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - ReportRunner - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/runsql/LICENSE.txt b/runsql/LICENSE.txt deleted file mode 100644 index b45d5b4d..00000000 --- a/runsql/LICENSE.txt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of OSJava nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/runsql/example/config/CmdLine.properties b/runsql/example/config/CmdLine.properties deleted file mode 100644 index 3b5205b5..00000000 --- a/runsql/example/config/CmdLine.properties +++ /dev/null @@ -1,5 +0,0 @@ -type=javax.sql.DataSource -driver=org.hsqldb.jdbcDriver -url=jdbc:hsqldb:hsql://localhost -user=sa -password= diff --git a/runsql/example/jndi.properties b/runsql/example/jndi.properties deleted file mode 100644 index 3edee80d..00000000 --- a/runsql/example/jndi.properties +++ /dev/null @@ -1,2 +0,0 @@ -java.naming.factory.initial=org.osjava.jndi.PropertiesFactory -org.osjava.jndi.root=example/config/ diff --git a/runsql/example/sql/BOOTSTRAP.sql b/runsql/example/sql/BOOTSTRAP.sql deleted file mode 100644 index 9373894c..00000000 --- a/runsql/example/sql/BOOTSTRAP.sql +++ /dev/null @@ -1,4 +0,0 @@ -INSERT INTO Report (name, sql, age) VALUES ('foo', 'select foo', '95'); -INSERT INTO Report (name, sql, age) VALUES ('bar', 'select poo', '5'); -INSERT INTO Report (name, sql, age) VALUES ('poo', 'delete foo', '9'); -INSERT INTO Report (name, sql, age) VALUES ('barry', 'select wfoo', '9191'); diff --git a/runsql/example/sql/CHECK.sql b/runsql/example/sql/CHECK.sql deleted file mode 100644 index 9be0a1fc..00000000 --- a/runsql/example/sql/CHECK.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT count(*) AS total FROM Report diff --git a/runsql/example/sql/QUERY.sql b/runsql/example/sql/QUERY.sql deleted file mode 100644 index f8cb6ce8..00000000 --- a/runsql/example/sql/QUERY.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT * FROM Bandwidth diff --git a/runsql/example/sql/SCHEMA.sql b/runsql/example/sql/SCHEMA.sql deleted file mode 100644 index bba7192d..00000000 --- a/runsql/example/sql/SCHEMA.sql +++ /dev/null @@ -1,11 +0,0 @@ -DROP TABLE Bandwidth; -CREATE TABLE Bandwidth ( - last_total varchar(255), - this_total varchar(255), - last_in varchar(255), - this_in varchar(255), - last_out varchar(255), - this_out varchar(255), - last_sess varchar(255), - this_sess varchar(255) -); diff --git a/runsql/maven.xml b/runsql/maven.xml deleted file mode 100644 index 5949782c..00000000 --- a/runsql/maven.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/runsql/project.properties b/runsql/project.properties deleted file mode 100644 index cdc7483b..00000000 --- a/runsql/project.properties +++ /dev/null @@ -1,10 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory - -maven.checkstyle.properties=../hen_checkstyle.xml - -maven.xdoc.theme=classic - -maven.javadoc.stylesheet = ../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/runsql/project.xml b/runsql/project.xml deleted file mode 100644 index 842ca197..00000000 --- a/runsql/project.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - 3 - runsql - runsql - 0.1 - - GenerationJava - http://www.generationjava.com/ - /images/initials.jpg - - 2003 - org.osjava.runsql - /images/core-logo.jpg - - - A command line runner of SQL statements. I like piping sql statements into the mysql command on a unix machine. This is designed to let me do the same things in a database independent way. - - - SQL Script Runner - - http://www.osjava.org/runsql/ - www.osjava.org/runsql - /sites/org/osjava/www/runsql/ - /sites/org/osjava/www/builds/releases/runsql/ - - - scm:svn:http://svn.osjava.org/svn/osjava/trunk/runsql - http://svn.osjava.org/svn/osjava/trunk/runsql - - - - - - Henri Yandell - hen - bayard@generationjava.com - GenerationJava - - Java Developer - - - - - - - - commons-dbutils - 1.0 - - - genjava - gj-core - 3.0 - - http://dist.osjava.org/releases/multidoc-jnr - - - - commons-lang - 2.0 - http://jakarta.apache.org/commons/lang.html - - - - - bayard@www.generationjava.com - - src/java - - - diff --git a/runsql/run.sh b/runsql/run.sh deleted file mode 100755 index c927118c..00000000 --- a/runsql/run.sh +++ /dev/null @@ -1,2 +0,0 @@ -LIB=lib/ -java -classpath example:$LIB/oracle/jars/classes12.jar:target/runsql-0.1.jar:$LIB:$LIB/genjava/jars/gj-core-3.0.jar:$LIB/commons-lang/jars/commons-lang-2.0.jar:$LIB/simple-jndi/jars/simple-jndi-0.9.jar:$LIB/commons-dbutils/jars/commons-dbutils-1.0.jar org.osjava.runsql.RunSql GenscapeDS diff --git a/runsql/src/java/org/osjava/runsql/RunSql.java b/runsql/src/java/org/osjava/runsql/RunSql.java deleted file mode 100644 index 6a2944a0..00000000 --- a/runsql/src/java/org/osjava/runsql/RunSql.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.osjava.runsql; - -import java.io.*; -import java.sql.*; -import javax.sql.*; -import javax.naming.*; -import org.apache.commons.dbutils.*; -import org.apache.commons.lang.*; -import com.generationjava.io.*; - -public class RunSql { - - public static void main(String[] args) throws Exception { - String dsname = args[0]; - InitialContext ctxt = new InitialContext(); - DataSource ds = (DataSource)ctxt.lookup(dsname); - Connection conn = ds.getConnection(); - long start = System.currentTimeMillis(); - try { - runScript(conn, System.in); - } catch(SQLException sqle) { - System.err.println("Script failure. "); - sqle.printStackTrace(); - } finally { - DbUtils.closeQuietly(conn); - } - long duration = System.currentTimeMillis() - start; - System.err.println("Script executed in : " + duration); - } - - public static void runScript(Connection conn, InputStream in) throws SQLException { - runScript(conn, FileW.loadFile(in)); - } - - public static void runScript(Connection conn, String script) throws SQLException { - // TODO: Improve so a ; inside a string is ignored. - String[] stmts = StringUtils.split(script, ";"); - Statement stmt = conn.createStatement(); - try { - long start = System.currentTimeMillis(); - for(int i=0; i - - - - - - - - - - - diff --git a/scraping-engine/project.properties b/scraping-engine/project.properties deleted file mode 100644 index bb074f50..00000000 --- a/scraping-engine/project.properties +++ /dev/null @@ -1,20 +0,0 @@ -maven.repo.remote=http://dist.osjava.org/maven/,http://repo1.maven.org/maven/ - -maven.ui.navcol.background=#f4f8d8 -maven.ui.banner.background=#000066 -maven.ui.section.background=#000066 -maven.ui.subsection.background=#000066 -maven.ui.breadcrumbs.background=#f4f8d8 - -maven.xdoc.theme=classic -maven.xdoc.poweredby.image=maven-feather.png -maven.xdoc.includeProjectDocumentation=false -maven.xdoc.date = left -maven.xdoc.version = v${pom.currentVersion} - -maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory - -maven.checkstyle.properties=../hen_checkstyle.xml - -maven.javadoc.stylesheet = ../osjavadoc-style.css -maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/ diff --git a/scraping-engine/project.xml b/scraping-engine/project.xml deleted file mode 100644 index e0bd714e..00000000 --- a/scraping-engine/project.xml +++ /dev/null @@ -1,153 +0,0 @@ - - - - 3 - scraping-engine - scraping-engine - 0.5 - - OSJava - http://www.osjava.org/ - http://www.osjava.org/images/osjava.gif - - 2003 - org.osjava.scraping - http://www.osjava.org/images/1x1.gif - - - A web-scraping engine. - - - A web-scraping engine - - http://www.osjava.org/ - http://issues.osjava.org:8080/jira/browse/BrowseProject.jspa?id=10021 - dist.osjava.org/maven/scraping-engine - /sites/org/osjava/www/maven/scraping-engine/ - /sites/org/osjava/www/releases/official/ - - - scm:svn:http://svn.osjava.org/svn/osjava/trunk/scraping-engine - http://svn.osjava.org/svn/osjava/trunk/scraping-engine - - - - - osjava-users - http://lists.osjava.org/mailman/listinfo/osjava-users - http://lists.osjava.org/mailman/listinfo/osjava-users - http://lists.osjava.org/mailman/private/osjava-users/ - - - - - - - Henri Yandell - hen - bayard@generationjava.com - GenerationJava - - Java Developer - - - - - - - - - oscube - 0.3 - http://www.osjava.org/oscube/ - - http://dist.osjava.org/releases/multidoc-jnr - - - - commons-dbutils - 1.1 - http://jakarta.apache.org/commons/ - - - genjava - gj-config - 1.1 - http://www.osjava.org/genjava/multiproject/gj-config/ - - http://dist.osjava.org/releases/multidoc-jnr - - - - log4j - 1.2.12 - http://logging.apache.org/log4j/ - - - commons-lang - 2.1 - http://jakarta.apache.org/commons/ - - - commons-net - 1.4.0 - http://jakarta.apache.org/commons/ - - - commons-httpclient - 3.0.1 - http://jakarta.apache.org/commons/ - - - genjava - gj-core - 3.1 - http://www.osjava.org/genjava/multiproject/gj-core/ - - http://dist.osjava.org/releases/multidoc-jnr - - - - genjava - gj-scrape - 2.0.1 - http://www.osjava.org/genjava/multiproject/gj-scrape/ - - http://dist.osjava.org/releases/multidoc-jnr - - - - norbert - 0.3 - http://www.osjava.org/norbert/ - - http://dist.osjava.org/releases/multidoc-jnr - - - - - - - bayard@www.generationjava.com - - src/java - - - - - - maven-jxr-plugin - maven-javadoc-plugin - maven-license-plugin - maven-changes-plugin - - - diff --git a/scraping-engine/src/examples/Comics/README.txt b/scraping-engine/src/examples/Comics/README.txt deleted file mode 100644 index 0949b27e..00000000 --- a/scraping-engine/src/examples/Comics/README.txt +++ /dev/null @@ -1,7 +0,0 @@ -The accompanying system is an example of scraping engine at work, downloading various comics from the web. - -IF DOWNLOADED FROM CVS: -To prepare things to run, assemble the jars in dependencies.list in a lib/ directory and run runc.sh to compile the files. - -IF DOWNLOADED AS BINARY OR CVS: -To run the scrapers run test.sh, or to have it run at a certain time each night, run.sh. diff --git a/scraping-engine/src/examples/Comics/build.bat b/scraping-engine/src/examples/Comics/build.bat deleted file mode 100644 index 757b5a96..00000000 --- a/scraping-engine/src/examples/Comics/build.bat +++ /dev/null @@ -1 +0,0 @@ -javac -classpath cron\;lib\commons-collections-2.1.jar;lib\commons-dbutils-SNAPSHOT.jar;lib\commons-httpclient-2.0-rc1.jar;lib\commons-lang-1.0.1.jar;lib\commons-logging-1.0.3.jar;lib\gj-config-1.1.jar;lib\gj-core-3.0.jar;lib\gj-scrape-1.0.jar;lib\log4j-1.2.8.jar;lib\norbert-0.2.jar;lib\oscube-0.1.jar;lib\quartz-1.0.jar;lib\scraping-engine-0.3.jar;lib\simple-jndi-0.9.jar com\generationjava\scrapers\*.java diff --git a/scraping-engine/src/examples/Comics/build.sh b/scraping-engine/src/examples/Comics/build.sh deleted file mode 100755 index 069c7481..00000000 --- a/scraping-engine/src/examples/Comics/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -CP=. -for i in lib/*.jar -do - CP=$CP:$i -done -javac -classpath cron/:$CP com/generationjava/*/*.java diff --git a/scraping-engine/src/examples/Comics/com/generationjava/comics/ApodParser.java b/scraping-engine/src/examples/Comics/com/generationjava/comics/ApodParser.java deleted file mode 100644 index 0081cc68..00000000 --- a/scraping-engine/src/examples/Comics/com/generationjava/comics/ApodParser.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.generationjava.comics; - -import org.osjava.scraping.parser.UrlScraper; - -import com.generationjava.scrape.HtmlScraper; - -public class ApodParser extends UrlScraper { - - protected String scrapeUrl(HtmlScraper scraper) { - return scraper.get("IMG[SRC]"); - } - -} - diff --git a/scraping-engine/src/examples/Comics/com/generationjava/comics/ComicsComParser.java b/scraping-engine/src/examples/Comics/com/generationjava/comics/ComicsComParser.java deleted file mode 100644 index 421eab62..00000000 --- a/scraping-engine/src/examples/Comics/com/generationjava/comics/ComicsComParser.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.generationjava.comics; - -import org.osjava.scraping.parser.UrlScraper; - -import com.generationjava.scrape.HtmlScraper; - -public class ComicsComParser extends UrlScraper { - - protected String scrapeUrl(HtmlScraper scraper) { - scraper.moveToTagWith("ALT", "Today's Comic"); - - return scraper.get("IMG[SRC]"); - } - -} - diff --git a/scraping-engine/src/examples/Comics/com/generationjava/comics/DilbertParser.java b/scraping-engine/src/examples/Comics/com/generationjava/comics/DilbertParser.java deleted file mode 100644 index bd5e6b3e..00000000 --- a/scraping-engine/src/examples/Comics/com/generationjava/comics/DilbertParser.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.generationjava.comics; - -import org.osjava.scraping.parser.UrlScraper; - -import com.generationjava.scrape.HtmlScraper; - -public class DilbertParser extends UrlScraper { - - protected String scrapeUrl(HtmlScraper scraper) { - scraper.moveToTagWith("ALT", "Today's Dilbert Comic"); - - return scraper.get("IMG[SRC]"); - } - -} - diff --git a/scraping-engine/src/examples/Comics/com/generationjava/comics/ElgoonParser.java b/scraping-engine/src/examples/Comics/com/generationjava/comics/ElgoonParser.java deleted file mode 100644 index 07bbdcc0..00000000 --- a/scraping-engine/src/examples/Comics/com/generationjava/comics/ElgoonParser.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.generationjava.comics; - -import org.osjava.scraping.parser.UrlScraper; - -import com.generationjava.scrape.HtmlScraper; - -public class ElgoonParser extends UrlScraper { - - protected String scrapeUrl(HtmlScraper scraper) { - scraper.moveToTagWith("ALT", "comic"); - - return scraper.get("IMG[SRC]"); - } - -} - diff --git a/scraping-engine/src/examples/Comics/com/generationjava/comics/FoxtrotParser.java b/scraping-engine/src/examples/Comics/com/generationjava/comics/FoxtrotParser.java deleted file mode 100644 index 7c34e0b1..00000000 --- a/scraping-engine/src/examples/Comics/com/generationjava/comics/FoxtrotParser.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.generationjava.comics; - -import org.osjava.scraping.parser.UrlScraper; - -import com.generationjava.scrape.HtmlScraper; - -public class FoxtrotParser extends UrlScraper { - - protected String scrapeUrl(HtmlScraper scraper) { - scraper.moveToTagWith("width", "600"); - - return scraper.get("img[src]"); - } - -} - diff --git a/scraping-engine/src/examples/Comics/com/generationjava/comics/SnoopyParser.java b/scraping-engine/src/examples/Comics/com/generationjava/comics/SnoopyParser.java deleted file mode 100644 index ea0c9759..00000000 --- a/scraping-engine/src/examples/Comics/com/generationjava/comics/SnoopyParser.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.generationjava.comics; - -import org.osjava.scraping.parser.UrlScraper; - -import com.generationjava.scrape.HtmlScraper; - -public class SnoopyParser extends UrlScraper { - - protected String scrapeUrl(HtmlScraper scraper) { - scraper.moveToTagWith("ALT", "Today's Strip"); - scraper.moveToTagWith("WIDTH", "485"); - scraper.moveToTagWith("ALT", "Today's Strip"); - - return scraper.get("IMG[SRC]"); - } - -} - diff --git a/scraping-engine/src/examples/Comics/com/generationjava/comics/UbersoftParser.java b/scraping-engine/src/examples/Comics/com/generationjava/comics/UbersoftParser.java deleted file mode 100644 index 59e66756..00000000 --- a/scraping-engine/src/examples/Comics/com/generationjava/comics/UbersoftParser.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.generationjava.comics; - -import org.osjava.scraping.parser.UrlScraper; - -import com.generationjava.scrape.HtmlScraper; - -public class UbersoftParser extends UrlScraper { - - protected String scrapeUrl(HtmlScraper scraper) { - scraper.moveToTagWith("name", "Comic"); - - return scraper.get("IMG[SRC]"); - } - -} - diff --git a/scraping-engine/src/examples/Comics/com/generationjava/comics/UserFriendlyParser.java b/scraping-engine/src/examples/Comics/com/generationjava/comics/UserFriendlyParser.java deleted file mode 100644 index 238e7dd3..00000000 --- a/scraping-engine/src/examples/Comics/com/generationjava/comics/UserFriendlyParser.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.generationjava.comics; - -import org.osjava.scraping.parser.UrlScraper; - -import com.generationjava.scrape.HtmlScraper; - -public class UserFriendlyParser extends UrlScraper { - - protected String scrapeUrl(HtmlScraper scraper) { - scraper.moveToTagWith("ALT", "Latest Strip"); - - return scraper.get("IMG[SRC]"); - } - -} - diff --git a/scraping-engine/src/examples/Comics/cron/conf/default.properties b/scraping-engine/src/examples/Comics/cron/conf/default.properties deleted file mode 100644 index fb8e1cf3..00000000 --- a/scraping-engine/src/examples/Comics/cron/conf/default.properties +++ /dev/null @@ -1,201 +0,0 @@ -org.osjava.oscube.runner=org.osjava.scraping.ScrapingRunner -org.osjava.oscube.prefix=org.osjava.scrapers - -org.osjava.scrapers=UserFriendly - -UserFriendly.uri=http://www.userfriendly.org/static/ -UserFriendly.parser=com.generationjava.comics.UserFriendlyParser -UserFriendly.store=File -UserFriendly.file.saveAs=UserFriendly.gif -UserFriendly.file.path=/sec/lleutranet/comics/ -UserFriendly.scheduler=Quartz -UserFriendly.schedule=Cron -UserFriendly.schedule.cron=0 45 * ? * MON-SAT - -org.osjava.scrapers=Foxtrot - -Foxtrot.uri=http://www.foxtrot.com/ -Foxtrot.parser=com.generationjava.comics.FoxtrotParser -Foxtrot.store=File -Foxtrot.file.saveAs=Foxtrot.gif -Foxtrot.file.path=/sec/lleutranet/comics/ -Foxtrot.scheduler=Quartz -Foxtrot.schedule=Cron -Foxtrot.schedule.cron=0 45 * ? * MON-SAT - -org.osjava.scrapers=Snoopy - -Snoopy.uri=http://www.snoopy.com/ -Snoopy.parser=com.generationjava.comics.SnoopyParser -Snoopy.store=File -Snoopy.file.saveAs=Snoopy.gif -Snoopy.file.path=/sec/lleutranet/comics/ -Snoopy.scheduler=Quartz -Snoopy.schedule=Cron -Snoopy.schedule.cron=0 45 * ? * MON-SAT - -org.osjava.scrapers=Dilbert - -Dilbert.uri=http://www.dilbert.com/ -Dilbert.parser=com.generationjava.comics.DilbertParser -Dilbert.store=File -Dilbert.file.saveAs=Dilbert.gif -Dilbert.file.path=/sec/lleutranet/comics/ -Dilbert.scheduler=Quartz -Dilbert.schedule=Cron -Dilbert.schedule.cron=0 45 * ? * MON-SAT - -org.osjava.scrapers=Apod - -Apod.uri=http://antwrp.gsfc.nasa.gov/apod/astropix.html -Apod.parser=com.generationjava.comics.ApodParser -Apod.store=File -Apod.file.saveAs=Apod.jpg -Apod.file.path=/sec/lleutranet/comics/ -Apod.scheduler=Quartz -Apod.schedule=Cron -Apod.schedule.cron=0 45 * ? * MON-SAT - -org.osjava.scrapers=Bc - -Bc.uri=http://www.comics.com/creators/bc/ -Bc.parser=com.generationjava.comics.ComicsComParser -Bc.store=File -Bc.file.saveAs=Bc.gif -Bc.file.path=/sec/lleutranet/comics/ -Bc.scheduler=Quartz -Bc.schedule=Cron -Bc.schedule.cron=0 45 * ? * MON-SAT - -org.osjava.scrapers=WizardId - -WizardId.uri=http://www.comics.com/creators/wizardofid/ -WizardId.parser=com.generationjava.comics.ComicsComParser -WizardId.store=File -WizardId.file.saveAs=WizardId.gif -WizardId.file.path=/sec/lleutranet/comics/ -WizardId.scheduler=Quartz -WizardId.schedule=Cron -WizardId.schedule.cron=0 45 * ? * MON-SAT - -org.osjava.scrapers=Ubersoft - -Ubersoft.uri=http://www.ubersoft.net/ -Ubersoft.parser=com.generationjava.comics.UbersoftParser -Ubersoft.store=File -Ubersoft.file.saveAs=Ubersoft.png -Ubersoft.file.path=/sec/lleutranet/comics/ -Ubersoft.scheduler=Quartz -Ubersoft.schedule=Cron -Ubersoft.schedule.cron=0 45 * ? * MON-SAT - -org.osjava.scrapers=Elgoon - -Elgoon.uri=http://www.elgoonishshive.com/ -Elgoon.parser=com.generationjava.comics.ElgoonParser -Elgoon.store=File -Elgoon.file.saveAs=Elgoon.gif -Elgoon.file.path=/sec/lleutranet/comics/ -Elgoon.scheduler=Quartz -Elgoon.schedule=Cron -Elgoon.schedule.cron=0 45 * ? * MON-SAT - -org.osjava.scrapers=UserFriendlySunday - -UserFriendlySunday.uri=http://www.userfriendly.org/static/ -UserFriendlySunday.parser=com.generationjava.comics.UserFriendlyParser -UserFriendlySunday.store=File -UserFriendlySunday.file.saveAs=UserFriendlySunday.gif -UserFriendlySunday.file.path=/sec/lleutranet/comics/ -UserFriendlySunday.scheduler=Quartz -UserFriendlySunday.schedule=Cron -UserFriendlySunday.schedule.cron=0 45 * ? * SUN - -org.osjava.scrapers=FoxtrotSunday - -FoxtrotSunday.uri=http://www.foxtrot.com/ -FoxtrotSunday.parser=com.generationjava.comics.FoxtrotParser -FoxtrotSunday.store=File -FoxtrotSunday.file.saveAs=FoxtrotSunday.gif -FoxtrotSunday.file.path=/sec/lleutranet/comics/ -FoxtrotSunday.scheduler=Quartz -FoxtrotSunday.schedule=Cron -FoxtrotSunday.schedule.cron=0 45 * ? * SUN - -org.osjava.scrapers=SnoopySunday - -SnoopySunday.uri=http://www.snoopy.com/ -SnoopySunday.parser=com.generationjava.comics.SnoopyParser -SnoopySunday.store=File -SnoopySunday.file.saveAs=SnoopySunday.gif -SnoopySunday.file.path=/sec/lleutranet/comics/ -SnoopySunday.scheduler=Quartz -SnoopySunday.schedule=Cron -SnoopySunday.schedule.cron=0 45 * ? * SUN - -org.osjava.scrapers=DilbertSunday - -DilbertSunday.uri=http://www.dilbert.com/ -DilbertSunday.parser=com.generationjava.comics.DilbertParser -DilbertSunday.store=File -DilbertSunday.file.saveAs=DilbertSunday.gif -DilbertSunday.file.path=/sec/lleutranet/comics/ -DilbertSunday.scheduler=Quartz -DilbertSunday.schedule=Cron -DilbertSunday.schedule.cron=0 45 * ? * SUN - -org.osjava.scrapers=ApodSunday - -ApodSunday.uri=http://antwrp.gsfc.nasa.gov/apod/astropix.html -ApodSunday.parser=com.generationjava.comics.ApodParser -ApodSunday.store=File -ApodSunday.file.saveAs=ApodSunday.jpg -ApodSunday.file.path=/sec/lleutranet/comics/ -ApodSunday.scheduler=Quartz -ApodSunday.schedule=Cron -ApodSunday.schedule.cron=0 45 * ? * SUN - -org.osjava.scrapers=BcSunday - -BcSunday.uri=http://www.comics.com/creators/bc/ -BcSunday.parser=com.generationjava.comics.ComicsComParser -BcSunday.store=File -BcSunday.file.saveAs=BcSunday.gif -BcSunday.file.path=/sec/lleutranet/comics/ -BcSunday.scheduler=Quartz -BcSunday.schedule=Cron -BcSunday.schedule.cron=0 45 * ? * SUN - -org.osjava.scrapers=WizardIdSunday - -WizardIdSunday.uri=http://www.comics.com/creators/wizardofid/ -WizardIdSunday.parser=com.generationjava.comics.ComicsComParser -WizardIdSunday.store=File -WizardIdSunday.file.saveAs=WizardIdSunday.gif -WizardIdSunday.file.path=/sec/lleutranet/comics/ -WizardIdSunday.scheduler=Quartz -WizardIdSunday.schedule=Cron -WizardIdSunday.schedule.cron=0 45 * ? * SUN - -org.osjava.scrapers=UbersoftSunday - -UbersoftSunday.uri=http://www.ubersoft.net/ -UbersoftSunday.parser=com.generationjava.comics.UbersoftParser -UbersoftSunday.store=File -UbersoftSunday.file.saveAs=UbersoftSunday.png -UbersoftSunday.file.path=/sec/lleutranet/comics/ -UbersoftSunday.scheduler=Quartz -UbersoftSunday.schedule=Cron -UbersoftSunday.schedule.cron=0 45 * ? * SUN - -org.osjava.scrapers=ElgoonSunday - -ElgoonSunday.uri=http://www.elgoonishshive.com/ -ElgoonSunday.parser=com.generationjava.comics.ElgoonParser -ElgoonSunday.store=File -ElgoonSunday.file.saveAs=ElgoonSunday.gif -ElgoonSunday.file.path=/sec/lleutranet/comics/ -ElgoonSunday.scheduler=Quartz -ElgoonSunday.schedule=Cron -ElgoonSunday.schedule.cron=0 45 * ? * SUN - diff --git a/scraping-engine/src/examples/Comics/dependencies.list b/scraping-engine/src/examples/Comics/dependencies.list deleted file mode 100644 index e4828aad..00000000 --- a/scraping-engine/src/examples/Comics/dependencies.list +++ /dev/null @@ -1,15 +0,0 @@ -http://www.ibiblio.org/maven/commons-collections/jars/commons-collections-2.1.jar -http://www.ibiblio.org/maven/commons-dbutils/jars/commons-dbutils-1.0.jar -http://www.ibiblio.org/maven/commons-httpclient/jars/commons-httpclient-2.0.2.jar -http://www.ibiblio.org/maven/commons-net/jars/commons-net-1.4.0.jar -http://www.ibiblio.org/maven/commons-lang/jars/commons-lang-2.1.jar -http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.0.3.jar -http://www.ibiblio.org/maven/genjava/jars/gj-config-1.1.jar -http://www.ibiblio.org/maven/genjava/jars/gj-core-3.1.jar -http://www.ibiblio.org/maven/genjava/jars/gj-scrape-2.0.1.jar -http://www.ibiblio.org/maven/log4j/jars/log4j-1.2.12.jar -http://www.ibiblio.org/maven/norbert/jars/norbert-0.3.jar -http://www.ibiblio.org/maven/oscube/jars/oscube-0.3.jar -http://www.ibiblio.org/maven/quartz/jars/quartz-1.4.5.jar -http://www.ibiblio.org/maven/scraping-engine/jars/scraping-engine-0.5.jar -http://www.ibiblio.org/maven/simple-jndi/jars/simple-jndi-0.11.jar diff --git a/scraping-engine/src/examples/Comics/download.sh b/scraping-engine/src/examples/Comics/download.sh deleted file mode 100755 index 0d267dbc..00000000 --- a/scraping-engine/src/examples/Comics/download.sh +++ /dev/null @@ -1,7 +0,0 @@ -mkdir lib -cd lib -for i in `cat ../dependencies.list` -do - wget $i -done -cd .. diff --git a/scraping-engine/src/examples/Comics/jndi.properties b/scraping-engine/src/examples/Comics/jndi.properties deleted file mode 100644 index 2644012c..00000000 --- a/scraping-engine/src/examples/Comics/jndi.properties +++ /dev/null @@ -1,3 +0,0 @@ -java.naming.factory.initial=org.osjava.sj.SimpleContextFactory - -org.osjava.sj.root=file://conf diff --git a/scraping-engine/src/examples/Comics/log4j.properties b/scraping-engine/src/examples/Comics/log4j.properties deleted file mode 100644 index bc4add8b..00000000 --- a/scraping-engine/src/examples/Comics/log4j.properties +++ /dev/null @@ -1,4 +0,0 @@ -log4j.rootCategory=ERROR, stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%5p (%c) - %m%n diff --git a/scraping-engine/src/examples/Comics/run.bat b/scraping-engine/src/examples/Comics/run.bat deleted file mode 100644 index 5ec1df48..00000000 --- a/scraping-engine/src/examples/Comics/run.bat +++ /dev/null @@ -1 +0,0 @@ -java -classpath .;cron\;lib\commons-collections-2.1.jar;lib\commons-dbutils-SNAPSHOT.jar;lib\commons-httpclient-2.0-rc1.jar;lib\commons-lang-1.0.1.jar;lib\commons-logging-1.0.3.jar;lib\gj-config-1.1.jar;lib\gj-core-3.0.jar;lib\gj-scrape-1.0.jar;lib\log4j-1.2.8.jar;lib\norbert-0.2.jar;lib\oscube-0.1.jar;lib\quartz-1.0.jar;lib\scraping-engine-0.3.jar;lib\simple-jndi-0.9.jar org.osjava.oscube.container.Engine diff --git a/scraping-engine/src/examples/Comics/run.sh b/scraping-engine/src/examples/Comics/run.sh deleted file mode 100755 index d68df3e4..00000000 --- a/scraping-engine/src/examples/Comics/run.sh +++ /dev/null @@ -1,6 +0,0 @@ -CP=. -for i in lib/*.jar -do - CP=$CP:$i -done -java -classpath cron/:$CP org.osjava.oscube.container.Engine diff --git a/scraping-engine/src/examples/Comics/test.bat b/scraping-engine/src/examples/Comics/test.bat deleted file mode 100644 index c542c774..00000000 --- a/scraping-engine/src/examples/Comics/test.bat +++ /dev/null @@ -1 +0,0 @@ -java -classpath .;test\;lib\commons-collections-2.1.jar;lib\commons-dbutils-SNAPSHOT.jar;lib\commons-httpclient-2.0-rc1.jar;lib\commons-lang-1.0.1.jar;lib\commons-logging-1.0.3.jar;lib\gj-config-1.1.jar;lib\gj-core-3.0.jar;lib\gj-scrape-1.0.jar;lib\log4j-1.2.8.jar;lib\norbert-0.2.jar;lib\oscube-0.1.jar;lib\quartz-1.0.jar;lib\scraping-engine-0.3.jar;lib\simple-jndi-0.9.jar org.osjava.oscube.container.Engine diff --git a/scraping-engine/src/examples/Comics/test.sh b/scraping-engine/src/examples/Comics/test.sh deleted file mode 100755 index 8af22f71..00000000 --- a/scraping-engine/src/examples/Comics/test.sh +++ /dev/null @@ -1,6 +0,0 @@ -CP=. -for i in lib/*.jar -do - CP=$CP:$i -done -java -classpath test/:$CP org.osjava.oscube.container.Engine diff --git a/scraping-engine/src/examples/Comics/test/conf/default.properties b/scraping-engine/src/examples/Comics/test/conf/default.properties deleted file mode 100644 index d1a446b8..00000000 --- a/scraping-engine/src/examples/Comics/test/conf/default.properties +++ /dev/null @@ -1,74 +0,0 @@ -org.osjava.oscube.runner=org.osjava.scraping.ScrapingRunner -org.osjava.oscube.prefix=org.osjava.scrapers - -org.osjava.scrapers=UserFriendly - -UserFriendly.uri=http://www.userfriendly.org/static/ -UserFriendly.parser=com.generationjava.comics.UserFriendlyParser -UserFriendly.store=File -UserFriendly.file.saveAs=UserFriendly.gif -UserFriendly.file.path=comics/ - -org.osjava.scrapers=Foxtrot - -Foxtrot.uri=http://www.foxtrot.com/ -Foxtrot.parser=com.generationjava.comics.FoxtrotParser -Foxtrot.store=File -Foxtrot.file.saveAs=Foxtrot.gif -Foxtrot.file.path=comics/ - -org.osjava.scrapers=Snoopy - -Snoopy.uri=http://www.snoopy.com/ -Snoopy.parser=com.generationjava.comics.SnoopyParser -Snoopy.store=File -Snoopy.file.saveAs=Snoopy.gif -Snoopy.file.path=comics/ - -org.osjava.scrapers=Dilbert - -Dilbert.uri=http://www.dilbert.com/ -Dilbert.parser=com.generationjava.comics.DilbertParser -Dilbert.store=File -Dilbert.file.saveAs=Dilbert.gif -Dilbert.file.path=comics/ - -org.osjava.scrapers=Apod - -Apod.uri=http://antwrp.gsfc.nasa.gov/apod/astropix.html -Apod.parser=com.generationjava.comics.ApodParser -Apod.store=File -Apod.file.saveAs=Apod.jpg -Apod.file.path=comics/ - -org.osjava.scrapers=Bc - -Bc.uri=http://www.comics.com/creators/bc/ -Bc.parser=com.generationjava.comics.ComicsComParser -Bc.store=File -Bc.file.saveAs=Bc.gif -Bc.file.path=comics/ - -org.osjava.scrapers=WizardId - -WizardId.uri=http://www.comics.com/creators/wizardofid/ -WizardId.parser=com.generationjava.comics.ComicsComParser -WizardId.store=File -WizardId.file.saveAs=WizardId.gif -WizardId.file.path=comics/ - -org.osjava.scrapers=Ubersoft - -Ubersoft.uri=http://www.ubersoft.net/ -Ubersoft.parser=com.generationjava.comics.UbersoftParser -Ubersoft.store=File -Ubersoft.file.saveAs=Ubersoft.png -Ubersoft.file.path=comics/ - -org.osjava.scrapers=Elgoon - -Elgoon.uri=http://www.elgoonishshive.com/ -Elgoon.parser=com.generationjava.comics.ElgoonParser -Elgoon.store=File -Elgoon.file.saveAs=Elgoon.gif -Elgoon.file.path=comics/ diff --git a/scraping-engine/src/examples/Ftp/conf/default.properties b/scraping-engine/src/examples/Ftp/conf/default.properties deleted file mode 100644 index e524a3ec..00000000 --- a/scraping-engine/src/examples/Ftp/conf/default.properties +++ /dev/null @@ -1,8 +0,0 @@ -org.osjava.oscube.runner=org.osjava.scraping.ScrapingRunner -org.osjava.oscube.prefix=org.osjava.scrapers - -org.osjava.scrapers=KernelOrg - -KernelOrg.uri=ftp://ftp.kernel.org/pub/README_ABOUT_BZ2_FILES -KernelOrg.parser=org.osjava.scraping.parser.PassThroughParser -KernelOrg.store=Console diff --git a/scraping-engine/src/examples/Ftp/dependencies.list b/scraping-engine/src/examples/Ftp/dependencies.list deleted file mode 100644 index e4828aad..00000000 --- a/scraping-engine/src/examples/Ftp/dependencies.list +++ /dev/null @@ -1,15 +0,0 @@ -http://www.ibiblio.org/maven/commons-collections/jars/commons-collections-2.1.jar -http://www.ibiblio.org/maven/commons-dbutils/jars/commons-dbutils-1.0.jar -http://www.ibiblio.org/maven/commons-httpclient/jars/commons-httpclient-2.0.2.jar -http://www.ibiblio.org/maven/commons-net/jars/commons-net-1.4.0.jar -http://www.ibiblio.org/maven/commons-lang/jars/commons-lang-2.1.jar -http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.0.3.jar -http://www.ibiblio.org/maven/genjava/jars/gj-config-1.1.jar -http://www.ibiblio.org/maven/genjava/jars/gj-core-3.1.jar -http://www.ibiblio.org/maven/genjava/jars/gj-scrape-2.0.1.jar -http://www.ibiblio.org/maven/log4j/jars/log4j-1.2.12.jar -http://www.ibiblio.org/maven/norbert/jars/norbert-0.3.jar -http://www.ibiblio.org/maven/oscube/jars/oscube-0.3.jar -http://www.ibiblio.org/maven/quartz/jars/quartz-1.4.5.jar -http://www.ibiblio.org/maven/scraping-engine/jars/scraping-engine-0.5.jar -http://www.ibiblio.org/maven/simple-jndi/jars/simple-jndi-0.11.jar diff --git a/scraping-engine/src/examples/Ftp/download.sh b/scraping-engine/src/examples/Ftp/download.sh deleted file mode 100755 index 0d267dbc..00000000 --- a/scraping-engine/src/examples/Ftp/download.sh +++ /dev/null @@ -1,7 +0,0 @@ -mkdir lib -cd lib -for i in `cat ../dependencies.list` -do - wget $i -done -cd .. diff --git a/scraping-engine/src/examples/Ftp/jndi.properties b/scraping-engine/src/examples/Ftp/jndi.properties deleted file mode 100644 index 2644012c..00000000 --- a/scraping-engine/src/examples/Ftp/jndi.properties +++ /dev/null @@ -1,3 +0,0 @@ -java.naming.factory.initial=org.osjava.sj.SimpleContextFactory - -org.osjava.sj.root=file://conf diff --git a/scraping-engine/src/examples/Ftp/log4j.properties b/scraping-engine/src/examples/Ftp/log4j.properties deleted file mode 100644 index bc4add8b..00000000 --- a/scraping-engine/src/examples/Ftp/log4j.properties +++ /dev/null @@ -1,4 +0,0 @@ -log4j.rootCategory=ERROR, stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%5p (%c) - %m%n diff --git a/scraping-engine/src/examples/Ftp/run.sh b/scraping-engine/src/examples/Ftp/run.sh deleted file mode 100755 index 3200aaeb..00000000 --- a/scraping-engine/src/examples/Ftp/run.sh +++ /dev/null @@ -1,6 +0,0 @@ -CP=. -for i in lib/*.jar -do - CP=$CP:$i -done -java -classpath $CP org.osjava.oscube.container.Engine diff --git a/scraping-engine/src/examples/package-example.sh b/scraping-engine/src/examples/package-example.sh deleted file mode 100755 index 1534ca36..00000000 --- a/scraping-engine/src/examples/package-example.sh +++ /dev/null @@ -1,3 +0,0 @@ -tar -zcf scraping-Comic-examples-for-`grep current ../../project.xml | head -1 | sed 's/<[^>]*>//g' | sed 's/ //g'`.tar.gz --exclude .svn Comics -tar -zcf scraping-Ftp-example-for-`grep current ../../project.xml | head -1 | sed 's/<[^>]*>//g' | sed 's/ //g'`.tar.gz --exclude .svn Ftp -tar -zcf scraping-template-for-`grep current ../../project.xml | head -1 | sed 's/<[^>]*>//g' | sed 's/ //g'`.tar.gz --exclude .svn template diff --git a/scraping-engine/src/examples/template/README.txt b/scraping-engine/src/examples/template/README.txt deleted file mode 100644 index 738d3889..00000000 --- a/scraping-engine/src/examples/template/README.txt +++ /dev/null @@ -1,3 +0,0 @@ -The accompanying system is a basic template for using scraping engine. - -Execute download.sh to grab the necessary dependencies, then execute run.sh to scrape the osjava.org front page. diff --git a/scraping-engine/src/examples/template/conf/default.properties b/scraping-engine/src/examples/template/conf/default.properties deleted file mode 100644 index 5ce5d2ad..00000000 --- a/scraping-engine/src/examples/template/conf/default.properties +++ /dev/null @@ -1,8 +0,0 @@ -org.osjava.oscube.runner=org.osjava.scraping.ScrapingRunner -org.osjava.oscube.prefix=org.osjava.scrapers - -org.osjava.scrapers=Example - -Example.uri=http://www.osjava.org/ -Example.parser=org.osjava.scraping.parser.PassThroughParser -Example.store=Console diff --git a/scraping-engine/src/examples/template/dependencies.list b/scraping-engine/src/examples/template/dependencies.list deleted file mode 100644 index e4828aad..00000000 --- a/scraping-engine/src/examples/template/dependencies.list +++ /dev/null @@ -1,15 +0,0 @@ -http://www.ibiblio.org/maven/commons-collections/jars/commons-collections-2.1.jar -http://www.ibiblio.org/maven/commons-dbutils/jars/commons-dbutils-1.0.jar -http://www.ibiblio.org/maven/commons-httpclient/jars/commons-httpclient-2.0.2.jar -http://www.ibiblio.org/maven/commons-net/jars/commons-net-1.4.0.jar -http://www.ibiblio.org/maven/commons-lang/jars/commons-lang-2.1.jar -http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.0.3.jar -http://www.ibiblio.org/maven/genjava/jars/gj-config-1.1.jar -http://www.ibiblio.org/maven/genjava/jars/gj-core-3.1.jar -http://www.ibiblio.org/maven/genjava/jars/gj-scrape-2.0.1.jar -http://www.ibiblio.org/maven/log4j/jars/log4j-1.2.12.jar -http://www.ibiblio.org/maven/norbert/jars/norbert-0.3.jar -http://www.ibiblio.org/maven/oscube/jars/oscube-0.3.jar -http://www.ibiblio.org/maven/quartz/jars/quartz-1.4.5.jar -http://www.ibiblio.org/maven/scraping-engine/jars/scraping-engine-0.5.jar -http://www.ibiblio.org/maven/simple-jndi/jars/simple-jndi-0.11.jar diff --git a/scraping-engine/src/examples/template/download.sh b/scraping-engine/src/examples/template/download.sh deleted file mode 100755 index 0d267dbc..00000000 --- a/scraping-engine/src/examples/template/download.sh +++ /dev/null @@ -1,7 +0,0 @@ -mkdir lib -cd lib -for i in `cat ../dependencies.list` -do - wget $i -done -cd .. diff --git a/scraping-engine/src/examples/template/jndi.properties b/scraping-engine/src/examples/template/jndi.properties deleted file mode 100644 index 2644012c..00000000 --- a/scraping-engine/src/examples/template/jndi.properties +++ /dev/null @@ -1,3 +0,0 @@ -java.naming.factory.initial=org.osjava.sj.SimpleContextFactory - -org.osjava.sj.root=file://conf diff --git a/scraping-engine/src/examples/template/log4j.properties b/scraping-engine/src/examples/template/log4j.properties deleted file mode 100644 index bc4add8b..00000000 --- a/scraping-engine/src/examples/template/log4j.properties +++ /dev/null @@ -1,4 +0,0 @@ -log4j.rootCategory=ERROR, stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%5p (%c) - %m%n diff --git a/scraping-engine/src/examples/template/run.sh b/scraping-engine/src/examples/template/run.sh deleted file mode 100755 index 3200aaeb..00000000 --- a/scraping-engine/src/examples/template/run.sh +++ /dev/null @@ -1,6 +0,0 @@ -CP=. -for i in lib/*.jar -do - CP=$CP:$i -done -java -classpath $CP org.osjava.oscube.container.Engine diff --git a/scraping-engine/src/java/org/osjava/scraping/AbstractHttpFetcher.java b/scraping-engine/src/java/org/osjava/scraping/AbstractHttpFetcher.java deleted file mode 100644 index 87fd5859..00000000 --- a/scraping-engine/src/java/org/osjava/scraping/AbstractHttpFetcher.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2003, Henri Yandell - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the - * following conditions are met: - * - * + Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * + Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * + Neither the name of OSJava nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.osjava.scraping; - -import org.apache.commons.lang.StringUtils; - -import org.apache.commons.httpclient.*; -import org.apache.commons.httpclient.methods.*; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; - -import java.util.*; - -import org.osjava.norbert.NoRobotClient; -import org.osjava.norbert.NoRobotException; -import com.generationjava.config.Config; -import org.osjava.oscube.container.Session; - -/** - * Fetches a piece of content for a url - */ -public abstract class AbstractHttpFetcher implements Fetcher { - - private static final String SESSION_CACHE_CODE = "HTTPCLIENT"; - - public abstract int getDefaultPort(); - - protected abstract void startSession(URL url, int port, HttpClient client, Config cfg, Session session) throws FetchingException; - - public Page fetch(String uri, Config cfg, Session session) throws FetchingException { - try { - String postQuery = null; - if(cfg.has("method") && "POST".equalsIgnoreCase(""+cfg.get("method")) ) { - int idx = uri.indexOf("?"); - if(idx != -1) { - postQuery = uri.substring(idx+1); - uri = uri.substring(0, idx); - } - } - URL url = new URL(uri); - -// TODO: Handle true/false here, rather than just 'has' - if(!cfg.has("norobots.override")) { - String userAgent = "osjava-scraping-engine"; - if(cfg.has("header")) { - List list = (List) cfg.getList("header"); - if(list != null) { - Iterator itr = list.iterator(); - while(itr.hasNext()) { - String str = (String) itr.next(); - String header = StringUtils.substringBefore(str, "="); - String value = StringUtils.substringAfter(str, "="); - if("User-Agent".equals(header)) { - userAgent = value; - } - } - } - } - if(checkIllegal(url, userAgent)) { - throw new FetchingException("Not allowed to fetch url: "+uri+" due to the NoRobots RFQ. "); - } - } - - HttpClient client = (HttpClient) session.get(SESSION_CACHE_CODE); - if(client == null) { - client = new HttpClient(); - session.put(SESSION_CACHE_CODE, client); - } - - HttpMethod method = null; - - if(postQuery != null) { - PostMethod post = new PostMethod(url.getFile()); - - // split on the & - String[] elements = StringUtils.split(postQuery, "&"); - for(int i=0; i