You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/07/31 16:08:55 UTC
svn commit: r427121 [12/29] - in
/incubator/harmony/enhanced/classlib/trunk/modules/swing: make/
src/main/java/common/javax/swing/ src/main/java/common/javax/swing/text/
src/main/java/common/javax/swing/text/html/
src/main/java/common/javax/swing/text/...
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/NOTE.txt
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/NOTE.txt?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/NOTE.txt (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/NOTE.txt Mon Jul 31 07:08:47 2006
@@ -0,0 +1,9 @@
+Files
+ CSSParser.java
+ CSSParserConstants.java
+ CSSParserTokenManager.java
+ ParseException.java
+ SimpleCharStream.java
+ Token.java
+ TokenMgrError.java
+are created from source file CSSGrammar.jj by JavaCC 4.0 available at https://javacc.dev.java.net/.
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/ParseException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/ParseException.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/ParseException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/ParseException.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,192 @@
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
+package org.apache.harmony.x.swing.text.html.cssparser;
+
+/**
+ * This exception is thrown when parse errors are encountered.
+ * You can explicitly create objects of this exception type by
+ * calling the method generateParseException in the generated
+ * parser.
+ *
+ * You can modify this class to customize your error reporting
+ * mechanisms so long as you retain the public fields.
+ */
+public class ParseException extends Exception {
+
+ /**
+ * This constructor is used by the method "generateParseException"
+ * in the generated parser. Calling this constructor generates
+ * a new object of this type with the fields "currentToken",
+ * "expectedTokenSequences", and "tokenImage" set. The boolean
+ * flag "specialConstructor" is also set to true to indicate that
+ * this constructor was used to create this object.
+ * This constructor calls its super class with the empty string
+ * to force the "toString" method of parent class "Throwable" to
+ * print the error message in the form:
+ * ParseException: <result of getMessage>
+ */
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal,
+ String[] tokenImageVal
+ )
+ {
+ super("");
+ specialConstructor = true;
+ currentToken = currentTokenVal;
+ expectedTokenSequences = expectedTokenSequencesVal;
+ tokenImage = tokenImageVal;
+ }
+
+ /**
+ * The following constructors are for use by you for whatever
+ * purpose you can think of. Constructing the exception in this
+ * manner makes the exception behave in the normal way - i.e., as
+ * documented in the class "Throwable". The fields "errorToken",
+ * "expectedTokenSequences", and "tokenImage" do not contain
+ * relevant information. The JavaCC generated code does not use
+ * these constructors.
+ */
+
+ public ParseException() {
+ super();
+ specialConstructor = false;
+ }
+
+ public ParseException(String message) {
+ super(message);
+ specialConstructor = false;
+ }
+
+ /**
+ * This variable determines which constructor was used to create
+ * this object and thereby affects the semantics of the
+ * "getMessage" method (see below).
+ */
+ protected boolean specialConstructor;
+
+ /**
+ * This is the last token that has been consumed successfully. If
+ * this object has been created due to a parse error, the token
+ * followng this token will (therefore) be the first error token.
+ */
+ public Token currentToken;
+
+ /**
+ * Each entry in this array is an array of integers. Each array
+ * of integers represents a sequence of tokens (by their ordinal
+ * values) that is expected at this point of the parse.
+ */
+ public int[][] expectedTokenSequences;
+
+ /**
+ * This is a reference to the "tokenImage" array of the generated
+ * parser within which the parse error occurred. This array is
+ * defined in the generated ...Constants interface.
+ */
+ public String[] tokenImage;
+
+ /**
+ * This method has the standard behavior when this object has been
+ * created using the standard constructors. Otherwise, it uses
+ * "currentToken" and "expectedTokenSequences" to generate a parse
+ * error message and returns it. If this object has been created
+ * due to a parse error, and you do not catch it (it gets thrown
+ * from the parser), then this method is called during the printing
+ * of the final stack trace, and hence the correct error message
+ * gets displayed.
+ */
+ public String getMessage() {
+ if (!specialConstructor) {
+ return super.getMessage();
+ }
+ StringBuffer expected = new StringBuffer();
+ int maxSize = 0;
+ for (int i = 0; i < expectedTokenSequences.length; i++) {
+ if (maxSize < expectedTokenSequences[i].length) {
+ maxSize = expectedTokenSequences[i].length;
+ }
+ for (int j = 0; j < expectedTokenSequences[i].length; j++) {
+ expected.append(tokenImage[expectedTokenSequences[i][j]]).append(" ");
+ }
+ if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
+ expected.append("...");
+ }
+ expected.append(eol).append(" ");
+ }
+ String retval = "Encountered \"";
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0) retval += " ";
+ if (tok.kind == 0) {
+ retval += tokenImage[0];
+ break;
+ }
+ retval += add_escapes(tok.image);
+ tok = tok.next;
+ }
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
+ retval += "." + eol;
+ if (expectedTokenSequences.length == 1) {
+ retval += "Was expecting:" + eol + " ";
+ } else {
+ retval += "Was expecting one of:" + eol + " ";
+ }
+ retval += expected.toString();
+ return retval;
+ }
+
+ /**
+ * The end of line string for this machine.
+ */
+ protected String eol = System.getProperty("line.separator", "\n");
+
+ /**
+ * Used to convert raw characters to their escaped version
+ * when these raw version cannot be used as part of an ASCII
+ * string literal.
+ */
+ protected String add_escapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/SimpleCharStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/SimpleCharStream.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/SimpleCharStream.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/SimpleCharStream.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,439 @@
+/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.0 */
+package org.apache.harmony.x.swing.text.html.cssparser;
+
+/**
+ * An implementation of interface CharStream, where the stream is assumed to
+ * contain only ASCII characters (without unicode processing).
+ */
+
+public class SimpleCharStream
+{
+ public static final boolean staticFlag = false;
+ int bufsize;
+ int available;
+ int tokenBegin;
+ public int bufpos = -1;
+ protected int bufline[];
+ protected int bufcolumn[];
+
+ protected int column = 0;
+ protected int line = 1;
+
+ protected boolean prevCharIsCR = false;
+ protected boolean prevCharIsLF = false;
+
+ protected java.io.Reader inputStream;
+
+ protected char[] buffer;
+ protected int maxNextCharInd = 0;
+ protected int inBuf = 0;
+ protected int tabSize = 8;
+
+ protected void setTabSize(int i) { tabSize = i; }
+ protected int getTabSize(int i) { return tabSize; }
+
+
+ protected void ExpandBuff(boolean wrapAround)
+ {
+ char[] newbuffer = new char[bufsize + 2048];
+ int newbufline[] = new int[bufsize + 2048];
+ int newbufcolumn[] = new int[bufsize + 2048];
+
+ try
+ {
+ if (wrapAround)
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer,
+ bufsize - tokenBegin, bufpos);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
+ bufcolumn = newbufcolumn;
+
+ maxNextCharInd = (bufpos += (bufsize - tokenBegin));
+ }
+ else
+ {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ bufcolumn = newbufcolumn;
+
+ maxNextCharInd = (bufpos -= tokenBegin);
+ }
+ }
+ catch (Throwable t)
+ {
+ throw new Error(t.getMessage());
+ }
+
+
+ bufsize += 2048;
+ available = bufsize;
+ tokenBegin = 0;
+ }
+
+ protected void FillBuff() throws java.io.IOException
+ {
+ if (maxNextCharInd == available)
+ {
+ if (available == bufsize)
+ {
+ if (tokenBegin > 2048)
+ {
+ bufpos = maxNextCharInd = 0;
+ available = tokenBegin;
+ }
+ else if (tokenBegin < 0)
+ bufpos = maxNextCharInd = 0;
+ else
+ ExpandBuff(false);
+ }
+ else if (available > tokenBegin)
+ available = bufsize;
+ else if ((tokenBegin - available) < 2048)
+ ExpandBuff(true);
+ else
+ available = tokenBegin;
+ }
+
+ int i;
+ try {
+ if ((i = inputStream.read(buffer, maxNextCharInd,
+ available - maxNextCharInd)) == -1)
+ {
+ inputStream.close();
+ throw new java.io.IOException();
+ }
+ else
+ maxNextCharInd += i;
+ return;
+ }
+ catch(java.io.IOException e) {
+ --bufpos;
+ backup(0);
+ if (tokenBegin == -1)
+ tokenBegin = bufpos;
+ throw e;
+ }
+ }
+
+ public char BeginToken() throws java.io.IOException
+ {
+ tokenBegin = -1;
+ char c = readChar();
+ tokenBegin = bufpos;
+
+ return c;
+ }
+
+ protected void UpdateLineColumn(char c)
+ {
+ column++;
+
+ if (prevCharIsLF)
+ {
+ prevCharIsLF = false;
+ line += (column = 1);
+ }
+ else if (prevCharIsCR)
+ {
+ prevCharIsCR = false;
+ if (c == '\n')
+ {
+ prevCharIsLF = true;
+ }
+ else
+ line += (column = 1);
+ }
+
+ switch (c)
+ {
+ case '\r' :
+ prevCharIsCR = true;
+ break;
+ case '\n' :
+ prevCharIsLF = true;
+ break;
+ case '\t' :
+ column--;
+ column += (tabSize - (column % tabSize));
+ break;
+ default :
+ break;
+ }
+
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+
+ public char readChar() throws java.io.IOException
+ {
+ if (inBuf > 0)
+ {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ return buffer[bufpos];
+ }
+
+ if (++bufpos >= maxNextCharInd)
+ FillBuff();
+
+ char c = buffer[bufpos];
+
+ UpdateLineColumn(c);
+ return (c);
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndColumn
+ */
+
+ public int getColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ /**
+ * @deprecated
+ * @see #getEndLine
+ */
+
+ public int getLine() {
+ return bufline[bufpos];
+ }
+
+ public int getEndColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ public int getEndLine() {
+ return bufline[bufpos];
+ }
+
+ public int getBeginColumn() {
+ return bufcolumn[tokenBegin];
+ }
+
+ public int getBeginLine() {
+ return bufline[tokenBegin];
+ }
+
+ public void backup(int amount) {
+
+ inBuf += amount;
+ if ((bufpos -= amount) < 0)
+ bufpos += bufsize;
+ }
+
+ public SimpleCharStream(java.io.Reader dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ }
+
+ public SimpleCharStream(java.io.Reader dstream, int startline,
+ int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public SimpleCharStream(java.io.Reader dstream)
+ {
+ this(dstream, 1, 1, 4096);
+ }
+ public void ReInit(java.io.Reader dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ if (buffer == null || buffersize != buffer.length)
+ {
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ }
+ prevCharIsLF = prevCharIsCR = false;
+ tokenBegin = inBuf = maxNextCharInd = 0;
+ bufpos = -1;
+ }
+
+ public void ReInit(java.io.Reader dstream, int startline,
+ int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream)
+ {
+ ReInit(dstream, 1, 1, 4096);
+ }
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
+ {
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException
+ {
+ this(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
+ {
+ this(dstream, encoding, 1, 1, 4096);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream)
+ {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize)
+ {
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(dstream, encoding, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream)
+ {
+ ReInit(dstream, 1, 1, 4096);
+ }
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException
+ {
+ ReInit(dstream, encoding, startline, startcolumn, 4096);
+ }
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn)
+ {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+ public String GetImage()
+ {
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+ new String(buffer, 0, bufpos + 1);
+ }
+
+ public char[] GetSuffix(int len)
+ {
+ char[] ret = new char[len];
+
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else
+ {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+ len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
+
+ return ret;
+ }
+
+ public void Done()
+ {
+ buffer = null;
+ bufline = null;
+ bufcolumn = null;
+ }
+
+ /**
+ * Method to adjust line and column numbers for the start of a token.
+ */
+ public void adjustBeginLineColumn(int newLine, int newCol)
+ {
+ int start = tokenBegin;
+ int len;
+
+ if (bufpos >= tokenBegin)
+ {
+ len = bufpos - tokenBegin + inBuf + 1;
+ }
+ else
+ {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
+
+ int i = 0, j = 0, k = 0;
+ int nextColDiff = 0, columnDiff = 0;
+
+ while (i < len &&
+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
+ {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
+
+ if (i < len)
+ {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
+
+ while (i++ < len)
+ {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
+
+ line = bufline[j];
+ column = bufcolumn[j];
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/Token.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/Token.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/Token.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/Token.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,81 @@
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
+package org.apache.harmony.x.swing.text.html.cssparser;
+
+/**
+ * Describes the input token stream.
+ */
+
+public class Token {
+
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /**
+ * The string image of the token.
+ */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /**
+ * Returns the image.
+ */
+ public String toString()
+ {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ *
+ * case MyParserConstants.ID : return new IDToken();
+ *
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ */
+ public static final Token newToken(int ofKind)
+ {
+ switch(ofKind)
+ {
+ default : return new Token();
+ }
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/TokenMgrError.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/TokenMgrError.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/TokenMgrError.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/TokenMgrError.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,133 @@
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
+package org.apache.harmony.x.swing.text.html.cssparser;
+
+public class TokenMgrError extends Error
+{
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /**
+ * Lexical error occured.
+ */
+ static final int LEXICAL_ERROR = 0;
+
+ /**
+ * An attempt wass made to create a second instance of a static token manager.
+ */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /**
+ * Tried to change to an invalid lexical state.
+ */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /**
+ * Detected (and bailed out of) an infinite loop in the token manager.
+ */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+
+ /**
+ * Replaces unprintable characters by their espaced (or unicode escaped)
+ * equivalents in the given string
+ */
+ protected static final String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i))
+ {
+ case 0 :
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u" + s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ continue;
+ }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * Returns a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ * Parameters :
+ * EOFSeen : indicates if EOF caused the lexicl error
+ * curLexState : lexical state in which this error occured
+ * errorLine : line number when the error occured
+ * errorColumn : column number when the error occured
+ * errorAfter : prefix that was seen before this error occured
+ * curchar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ */
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
+ return("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ *
+ * "Internal Error : Please file a bug report .... "
+ *
+ * from this method for such cases in the release version of your parser.
+ */
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ public TokenMgrError() {
+ }
+
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/TokenResolver.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/TokenResolver.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/TokenResolver.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/TokenResolver.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+ * @author Anton Avtamonov, Alexey A. Ivanov
+ * @version $Revision$
+ */
+package org.apache.harmony.x.swing.text.html.cssparser;
+
+public class TokenResolver {
+ private static final String SEPARATOR = " ";
+
+ public static String resolve(final Token token) {
+ return token.image;
+ }
+
+ public static String resolve(final Token start, final Token end, final boolean allowSeparation) {
+ StringBuffer result = new StringBuffer();
+ Token nextToken = start;
+ do {
+ if (allowSeparation && result.length() != 0) {
+ result.append(SEPARATOR);
+ }
+ result.append(resolve(nextToken));
+ if (nextToken == end) {
+ break;
+ }
+ nextToken = nextToken.next;
+ } while (nextToken != null);
+
+ return result.toString();
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/metamodel/Property.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/metamodel/Property.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/metamodel/Property.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/metamodel/Property.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+ * @author Anton Avtamonov, Alexey A. Ivanov
+ * @version $Revision$
+ */
+package org.apache.harmony.x.swing.text.html.cssparser.metamodel;
+
+public final class Property {
+ private final String name;
+ private final String value;
+ private boolean important;
+
+
+ public Property(final String name, final String value,
+ final boolean isImportant) {
+ this.name = name;
+ this.value = value;
+ this.important = isImportant;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public boolean isImportant() {
+ return important;
+ }
+
+ public String toString() {
+ return name + ": " + value + (important ? "!" : "");
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/metamodel/RuleSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/metamodel/RuleSet.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/metamodel/RuleSet.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/metamodel/RuleSet.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+ * @author Anton Avtamonov, Alexey A. Ivanov
+ * @version $Revision$
+ */
+package org.apache.harmony.x.swing.text.html.cssparser.metamodel;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.LinkedList;
+
+public final class RuleSet {
+ private final List selectors = new LinkedList();
+ private final List properties = new LinkedList();
+
+ public void addSelector(final String selector) {
+ if (selector == null) {
+ return;
+ }
+ selectors.add(selector);
+ }
+
+ public void addProperty(final Property p) {
+ if (p == null) {
+ return;
+ }
+ properties.add(p);
+ }
+
+ public Iterator getSelectors() {
+ return selectors.iterator();
+ }
+
+ public Iterator getProperties() {
+ return properties.iterator();
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append("\nselectors:")
+ .append(selectors)
+ .append('\n')
+ .append("properties:")
+ .append(properties)
+ .append('\n');
+
+ return result.toString();
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/metamodel/Sheet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/metamodel/Sheet.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/metamodel/Sheet.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/cssparser/metamodel/Sheet.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+ * @author Anton Avtamonov, Alexey A. Ivanov
+ * @version $Revision$
+ */
+package org.apache.harmony.x.swing.text.html.cssparser.metamodel;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.LinkedList;
+
+public final class Sheet {
+ private final List imports = new LinkedList();
+ private final List ruleSets = new LinkedList();
+
+
+ public void addImport(final String imp) {
+ if (imp == null) {
+ return;
+ }
+
+ imports.add(imp);
+ }
+
+ public void addRuleSet(final RuleSet ruleSet) {
+ if (ruleSet == null) {
+ return;
+ }
+
+ ruleSets.add(ruleSet);
+ }
+
+ public List getRuleSets() {
+ return ruleSets;
+ }
+
+ public Iterator getRuleSetIterator() {
+ return getRuleSets().iterator();
+ }
+
+ public List getImports() {
+ return imports;
+ }
+
+ public Iterator getImportsIterator() {
+ return getImports().iterator();
+ }
+
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append("imports:")
+ .append(imports)
+ .append("\n")
+ .append("ruleSets:")
+ .append(ruleSets);
+
+ return result.toString();
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/Form.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/Form.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/Form.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/Form.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+* @author Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package org.apache.harmony.x.swing.text.html.form;
+
+import java.util.ArrayList;
+
+import javax.swing.text.AttributeSet;
+
+public class Form {
+ private final ArrayList elements = new ArrayList();
+ private final AttributeSet attributes;
+
+ public Form(final AttributeSet attr) {
+ attributes = attr.copyAttributes();
+ }
+
+ public int getElementsCount() {
+ return elements.size();
+ }
+
+ public void addElement(final FormElement element) {
+ elements.add(element);
+ }
+
+ public void removeElement(final FormElement element) {
+ elements.remove(element);
+ }
+
+ public FormElement getElement(final int index) {
+ return (0 <= index && index < elements.size()) ? (FormElement)elements.get(index) : null;
+ }
+
+ public AttributeSet getAttributes() {
+ return attributes;
+ }
+
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormAttributes.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormAttributes.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormAttributes.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormAttributes.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+* @author Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package org.apache.harmony.x.swing.text.html.form;
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTML.Tag;
+
+public class FormAttributes {
+ public static final String INPUT_TYPE_BUTTON = "button";
+ public static final String INPUT_TYPE_CHECKBOX = "checkbox";
+ public static final String INPUT_TYPE_FILE = "file";
+ public static final String INPUT_TYPE_IMAGE = "image";
+ public static final String INPUT_TYPE_PASSWORD = "password";
+ public static final String INPUT_TYPE_RADIO = "radio";
+ public static final String INPUT_TYPE_RESET = "reset";
+ public static final String INPUT_TYPE_SUBMIT = "submit";
+ public static final String INPUT_TYPE_TEXT = "text";
+
+ public static final int INPUT_TYPE_INDEX_UNDEFINED = -1;
+ public static final int INPUT_TYPE_BUTTON_INDEX = 0;
+ public static final int INPUT_TYPE_CHECKBOX_INDEX = 1;
+ public static final int INPUT_TYPE_FILE_INDEX = 2;
+ public static final int INPUT_TYPE_IMAGE_INDEX = 3;
+ public static final int INPUT_TYPE_PASSWORD_INDEX = 4;
+ public static final int INPUT_TYPE_RADIO_INDEX = 5;
+ public static final int INPUT_TYPE_RESET_INDEX = 6;
+ public static final int INPUT_TYPE_SUBMIT_INDEX = 7;
+ public static final int INPUT_TYPE_TEXT_INDEX = 8;
+
+ public static final int TEXTAREA_TYPE_INDEX = 9;
+ public static final int SELECT_LIST_TYPE_INDEX = 10;
+ public static final int SELECT_COMBOBOX_TYPE_INDEX = 11;
+ public static final int FIELDSET_TYPE_INDEX = 12;
+
+ public static int getTypeAttributeIndex(final String type) {
+ if (INPUT_TYPE_BUTTON.compareToIgnoreCase(type) == 0) {
+ return INPUT_TYPE_BUTTON_INDEX;
+ } else if (INPUT_TYPE_CHECKBOX.compareToIgnoreCase(type) == 0) {
+ return INPUT_TYPE_CHECKBOX_INDEX;
+ } else if (INPUT_TYPE_IMAGE.compareToIgnoreCase(type) == 0) {
+ return INPUT_TYPE_IMAGE_INDEX;
+ } else if (INPUT_TYPE_PASSWORD.compareToIgnoreCase(type) == 0) {
+ return INPUT_TYPE_PASSWORD_INDEX;
+ } else if (INPUT_TYPE_RADIO.compareToIgnoreCase(type) == 0) {
+ return INPUT_TYPE_RADIO_INDEX;
+ } else if (INPUT_TYPE_RESET.compareToIgnoreCase(type) == 0) {
+ return INPUT_TYPE_RESET_INDEX;
+ } else if (INPUT_TYPE_SUBMIT.compareToIgnoreCase(type) == 0) {
+ return INPUT_TYPE_SUBMIT_INDEX;
+ } else if (INPUT_TYPE_TEXT.compareToIgnoreCase(type) == 0) {
+ return INPUT_TYPE_TEXT_INDEX;
+ } else if (INPUT_TYPE_FILE.compareToIgnoreCase(type) == 0) {
+ return INPUT_TYPE_FILE_INDEX;
+ }
+
+ return INPUT_TYPE_INDEX_UNDEFINED;
+ }
+
+ public static int getElementTypeIndex(final AttributeSet attr) {
+ Object tag = attr.getAttribute(StyleConstants.NameAttribute);
+ if (Tag.INPUT.equals(tag)) {
+ return getTypeAttributeIndex(attr);
+ } else if (Tag.TEXTAREA.equals(tag)) {
+ return TEXTAREA_TYPE_INDEX;
+ } else if (HTML.getTag("fieldset").equals(tag)) {
+ return FIELDSET_TYPE_INDEX;
+ } else if (Tag.SELECT.equals(tag)) {
+ return isListSelect(attr) ? SELECT_LIST_TYPE_INDEX : SELECT_COMBOBOX_TYPE_INDEX;
+ }
+ /*
+ * Uncomment when BUTTON is implemented
+ *
+ * else if (HTML.Tag.BUTTON.equals(tag)) {
+ * return BUTTON_TYPE_INDEX;
+ * }
+ */
+ return INPUT_TYPE_INDEX_UNDEFINED;
+ }
+
+ public static boolean isListSelect(final AttributeSet attr) {
+ boolean result = attr.getAttribute(HTML.Attribute.MULTIPLE) != null;
+ result |= (getSelectSize(attr) > 1);
+ return result;
+ }
+
+ public static int getSelectSize(final AttributeSet attrs) {
+ final String sizeAttr = (String)attrs.getAttribute(HTML.Attribute.SIZE);
+ int result = 0;
+ if (sizeAttr != null) {
+ try {
+ result = Integer.parseInt(sizeAttr);
+ } catch (NumberFormatException e) {
+ }
+ }
+ return result;
+ }
+
+ public static int getTypeAttributeIndex(final AttributeSet attr) {
+ final String type = (String)attr.getAttribute(HTML.Attribute.TYPE);
+ if (type == null) {
+ return INPUT_TYPE_INDEX_UNDEFINED;
+ }
+ return getTypeAttributeIndex(type);
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormButtonModel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormButtonModel.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormButtonModel.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormButtonModel.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+* @author Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package org.apache.harmony.x.swing.text.html.form;
+
+import javax.swing.DefaultButtonModel;
+import javax.swing.text.AttributeSet;
+
+public class FormButtonModel extends DefaultButtonModel implements FormElement {
+ private final Form form;
+ private final AttributeSet attributes;
+
+ public FormButtonModel(final Form form, final AttributeSet attr) {
+ this.form = form;
+ attributes = attr.copyAttributes();
+ }
+
+ public Form getForm() {
+ return form;
+ }
+
+ public AttributeSet getAttributes() {
+ return attributes;
+ }
+
+ public int getElementType() {
+ return FormAttributes.getTypeAttributeIndex(attributes);
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormElement.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormElement.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormElement.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormElement.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+* @author Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package org.apache.harmony.x.swing.text.html.form;
+
+import javax.swing.text.AttributeSet;
+
+public interface FormElement {
+ Form getForm();
+ AttributeSet getAttributes();
+ int getElementType();
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormFieldsetModel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormFieldsetModel.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormFieldsetModel.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormFieldsetModel.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+* @author Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package org.apache.harmony.x.swing.text.html.form;
+
+import javax.swing.text.AttributeSet;
+
+public class FormFieldsetModel implements FormElement {
+ private final Form form;
+ private final AttributeSet attributes;
+ private AttributeSet legendAttributes;
+ private String legend;
+
+ public FormFieldsetModel(final Form form, final AttributeSet attr) {
+ this.form = form;
+ attributes = attr.copyAttributes();
+ }
+
+ public Form getForm() {
+ return form;
+ }
+
+ public AttributeSet getAttributes() {
+ return attributes;
+ }
+
+ public int getElementType() {
+ return FormAttributes.FIELDSET_TYPE_INDEX;
+ }
+
+ public void setLegend(final String legend) {
+ this.legend = legend;
+ }
+
+ public String getLegend() {
+ return legend;
+ }
+
+ public void setLegendAttributes(final AttributeSet attr) {
+ legendAttributes = attr.copyAttributes();
+ }
+
+ public AttributeSet getLegendAttributes() {
+ return legendAttributes;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormOption.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormOption.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormOption.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormOption.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+ * @author Alexander T. Simbirtsev
+ * @version $Revision$
+ */
+package org.apache.harmony.x.swing.text.html.form;
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.Option;
+
+public class FormOption extends Option {
+
+ private final FormOptionGroup group;
+
+ public FormOption(final FormOptionGroup group, final AttributeSet attr) {
+ super(attr);
+ this.group = group;
+ }
+
+ public FormOption(final AttributeSet attr) {
+ this(null, attr);
+ }
+
+ public int getDepth() {
+ return (group != null) ? group.getDepth() + 1 : 0;
+ }
+
+ public String getTitle() {
+ final String title = (String)getAttributes().getAttribute(HTML.Attribute.TITLE);
+ return title != null ? title : ((group != null) ? group.getTitle() : null);
+ }
+
+ public boolean isEnabled() {
+ final boolean enabled = (getAttributes().getAttribute(HTML.getAttributeKey("disabled")) == null);
+ return enabled && (group == null || group.isEnabled());
+ }
+}
\ No newline at end of file
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormOptionGroup.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormOptionGroup.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormOptionGroup.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormOptionGroup.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+* @author Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package org.apache.harmony.x.swing.text.html.form;
+
+import javax.swing.text.AttributeSet;
+
+public class FormOptionGroup extends FormOption {
+ public FormOptionGroup(final AttributeSet attr) {
+ super(attr);
+ }
+
+ public FormOptionGroup(final FormOptionGroup group, final AttributeSet attr) {
+ super(group, attr);
+ }
+
+ public boolean isSelected() {
+ return false;
+ }
+
+ public String getText() {
+ return getLabel();
+ }
+
+ public String getValue() {
+ return null;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormRootOptionGroup.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormRootOptionGroup.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormRootOptionGroup.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormRootOptionGroup.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+* @author Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package org.apache.harmony.x.swing.text.html.form;
+
+import java.util.Stack;
+
+import javax.swing.text.SimpleAttributeSet;
+
+import org.apache.harmony.x.swing.text.html.form.FormSelectModel;
+
+public class FormRootOptionGroup extends FormOptionGroup {
+ private final Stack groupStack = new Stack();
+
+ private final FormSelectModel selectModel;
+
+ public FormRootOptionGroup(final FormSelectModel selectModel) {
+ super(SimpleAttributeSet.EMPTY);
+ this.selectModel = selectModel;
+ }
+
+ public int getDepth() {
+ return -1;
+ }
+
+ public boolean isEnabled() {
+ return selectModel.isEnabled();
+ }
+
+ public String getTitle() {
+ return selectModel.getTitle();
+ }
+
+ public void pushGroup(final FormOptionGroup group) {
+ groupStack.push(group);
+ }
+
+ public void popGroup() {
+ groupStack.pop();
+ }
+
+ public FormOptionGroup getCurrentGroup() {
+ return !groupStack.isEmpty() ? (FormOptionGroup)groupStack.lastElement() : this;
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormSelectComboBoxModel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormSelectComboBoxModel.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormSelectComboBoxModel.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormSelectComboBoxModel.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+* @author Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package org.apache.harmony.x.swing.text.html.form;
+
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.html.HTML;
+
+public class FormSelectComboBoxModel extends DefaultComboBoxModel implements
+ FormSelectModel {
+
+ private final Form form;
+ private final AttributeSet attributes;
+ private final FormRootOptionGroup rootOptionGroup;
+
+ public FormSelectComboBoxModel(final Form form, final AttributeSet attr) {
+ this.form = form;
+ attributes = attr.copyAttributes();
+ rootOptionGroup = new FormRootOptionGroup(this);
+ }
+
+ public void addOption(final FormOption option) {
+ addElement(option);
+ }
+
+ public FormOption getLastOption() {
+ return (getSize() != 0) ? (FormOption)getElementAt(getSize() - 1) : null;
+ }
+
+ public FormOption getOption(final int index) {
+ return (FormOption)getElementAt(index);
+ }
+
+ public Form getForm() {
+ return form;
+ }
+
+ public AttributeSet getAttributes() {
+ return attributes;
+ }
+
+ public int getElementType() {
+ return FormAttributes.SELECT_COMBOBOX_TYPE_INDEX;
+ }
+
+ public FormRootOptionGroup getRootOptionGroup() {
+ return rootOptionGroup;
+ }
+
+ public boolean isEnabled() {
+ return (getAttributes().getAttribute(HTML.getAttributeKey("disabled")) == null);
+ }
+
+ public String getTitle() {
+ return (String)getAttributes().getAttribute(HTML.Attribute.TITLE);
+ }
+
+ public int getOptionCount() {
+ return getSize();
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormSelectListModel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormSelectListModel.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormSelectListModel.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormSelectListModel.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+* @author Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package org.apache.harmony.x.swing.text.html.form;
+
+import javax.swing.DefaultListModel;
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.html.HTML;
+
+public class FormSelectListModel extends DefaultListModel implements
+ FormSelectModel {
+
+ private final Form form;
+ private final AttributeSet attributes;
+ private final FormRootOptionGroup rootOptionGroup;
+ private final ListSelectionModel selectionModel;
+
+ public FormSelectListModel(final Form form, final AttributeSet attr,
+ final ListSelectionModel selectionModel) {
+ this.form = form;
+ attributes = attr.copyAttributes();
+ rootOptionGroup = new FormRootOptionGroup(this);
+ this.selectionModel = selectionModel;
+ }
+
+ public FormSelectListModel(final Form form, final AttributeSet attr) {
+ this(form, attr, new DefaultListSelectionModel());
+ }
+
+ public void addOption(final FormOption option) {
+ addElement(option);
+ }
+
+ public FormOption getLastOption() {
+ return !isEmpty() ? (FormOption)getElementAt(getSize() - 1) : null;
+ }
+
+ public FormOption getOption(final int index) {
+ return (FormOption)getElementAt(index);
+ }
+
+ public Form getForm() {
+ return form;
+ }
+
+ public AttributeSet getAttributes() {
+ return attributes;
+ }
+
+ public int getElementType() {
+ return FormAttributes.SELECT_LIST_TYPE_INDEX;
+ }
+
+ public FormRootOptionGroup getRootOptionGroup() {
+ return rootOptionGroup;
+ }
+
+ public ListSelectionModel getSelectionModel() {
+ return selectionModel;
+ }
+
+ public boolean isEnabled() {
+ return (getAttributes().getAttribute(HTML.getAttributeKey("disabled")) == null);
+ }
+
+ public String getTitle() {
+ return (String)getAttributes().getAttribute(HTML.Attribute.TITLE);
+ }
+
+ public int getOptionCount() {
+ return getSize();
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormSelectModel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormSelectModel.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormSelectModel.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormSelectModel.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+* @author Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package org.apache.harmony.x.swing.text.html.form;
+
+public interface FormSelectModel extends FormElement {
+ void addOption(final FormOption option);
+ FormOption getLastOption();
+ int getOptionCount();
+ FormOption getOption(final int index);
+ FormRootOptionGroup getRootOptionGroup();
+ boolean isEnabled();
+ String getTitle();
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormTextModel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormTextModel.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormTextModel.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormTextModel.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+* @author Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package org.apache.harmony.x.swing.text.html.form;
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.PlainDocument;
+import javax.swing.text.html.HTML;
+
+
+public class FormTextModel extends PlainDocument implements FormElement {
+
+ public static final boolean ENABLE_MAX_LENGTH_BOUND = true;
+ public static final boolean DISABLE_MAX_LENGTH_BOUND = false;
+
+ private final Form form;
+ private final AttributeSet attributes;
+ private final int maxLength;
+ private String initialContent;
+
+ public FormTextModel(final Form form, final AttributeSet attr) {
+ this(form, attr, DISABLE_MAX_LENGTH_BOUND);
+ }
+
+ public FormTextModel(final Form form, final AttributeSet attr, final boolean enableLengthBound) {
+ this.form = form;
+ attributes = attr.copyAttributes();
+ if (enableLengthBound) {
+ String maxLengthAttr = (String)attributes.getAttribute(HTML.Attribute.MAXLENGTH);
+ maxLength = maxLengthAttr != null ? Integer.parseInt(maxLengthAttr) : Integer.MAX_VALUE;
+ } else {
+ maxLength = Integer.MAX_VALUE;
+ }
+ }
+
+ public void replace(int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
+ int insertLength = Math.min(text.length() - length, maxLength - getLength());
+ if (insertLength > 0) {
+ super.replace(offset, length, text.substring(0, insertLength), attrs);
+ }
+ }
+
+ public Form getForm() {
+ return form;
+ }
+
+ public AttributeSet getAttributes() {
+ return attributes;
+ }
+
+ public int getElementType() {
+ int result = FormAttributes.getTypeAttributeIndex(attributes);
+ return result != FormAttributes.INPUT_TYPE_INDEX_UNDEFINED ? result : FormAttributes.TEXTAREA_TYPE_INDEX;
+ }
+
+ public String getInitialContent() {
+ return initialContent;
+ }
+
+ public void setInitialContent(final String initialContent) {
+ this.initialContent = initialContent;
+ try {
+ insertString(getLength(), initialContent, null);
+ } catch (BadLocationException e) { }
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormToggleButtonModel.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormToggleButtonModel.java?rev=427121&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormToggleButtonModel.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/form/FormToggleButtonModel.java Mon Jul 31 07:08:47 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ */
+/**
+* @author Alexander T. Simbirtsev
+* @version $Revision$
+*/
+package org.apache.harmony.x.swing.text.html.form;
+
+import javax.swing.JToggleButton;
+import javax.swing.text.AttributeSet;
+
+public class FormToggleButtonModel extends JToggleButton.ToggleButtonModel
+ implements FormElement {
+
+ private final Form form;
+ private final AttributeSet attributes;
+
+ public FormToggleButtonModel(final Form form, final AttributeSet attr) {
+ this.form = form;
+ attributes = attr.copyAttributes();
+ }
+
+ public Form getForm() {
+ return form;
+ }
+
+ public AttributeSet getAttributes() {
+ return attributes;
+ }
+
+ public int getElementType() {
+ return FormAttributes.getTypeAttributeIndex(attributes);
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/icons/loadingFailedIcon.gif
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/icons/loadingFailedIcon.gif?rev=427121&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/icons/loadingFailedIcon.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/icons/loadingImageIcon.gif
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/icons/loadingImageIcon.gif?rev=427121&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/icons/loadingImageIcon.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/icons/noImageIcon.gif
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/icons/noImageIcon.gif?rev=427121&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/text/html/icons/noImageIcon.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream