flute-1.1.6/ 0000755 0001750 0001750 00000000000 11635761110 011303 5 ustar rene rene flute-1.1.6/source/ 0000755 0001750 0001750 00000000000 11365604770 012613 5 ustar rene rene flute-1.1.6/source/org/ 0000755 0001750 0001750 00000000000 11365604770 013402 5 ustar rene rene flute-1.1.6/source/org/w3c/ 0000755 0001750 0001750 00000000000 11365604770 014076 5 ustar rene rene flute-1.1.6/source/org/w3c/flute/ 0000755 0001750 0001750 00000000000 11365604770 015215 5 ustar rene rene flute-1.1.6/source/org/w3c/flute/util/ 0000755 0001750 0001750 00000000000 11365604770 016172 5 ustar rene rene flute-1.1.6/source/org/w3c/flute/util/encoding.properties 0000644 0001750 0001750 00000004341 11365604770 022100 0 ustar rene rene iso-ir-6 = ASCII
ANSI_X3.4-1986 = ASCII
ISO_646.irv:1991 = ASCII
ASCII = ASCII
ISO646-US = ASCII
US-ASCII = ASCII
us = ASCII
IBM367 = ASCII
cp367 = ASCII
csASCII = ASCII
iso-ir-100 = ISO8859_1
ISO_8859-1:1987 = ISO8859_1
ISO_8859-1 = ISO8859_1
ISO-8859-1 = ISO8859_1
latin1 = ISO8859_1
l1 = ISO8859_1
IBM819 = ISO8859_1
CP819 = ISO8859_1
csISOLatin1 = ISO8859_1
iso-ir-101 = ISO8859_2
ISO_8859-2:1987 = ISO8859_2
ISO_8859-2 = ISO8859_2
ISO-8859-2 = ISO8859_2
latin2 = ISO8859_2
l2 = ISO8859_2
csISOLatin2 = ISO8859_2
ISO_8859-3:1988 = ISO8859_3
iso-ir-109 = ISO8859_3
ISO_8859-3 = ISO8859_3
ISO-8859-3 = ISO8859_3
latin3 = ISO8859_3
l3 = ISO8859_3
csISOLatin3 = ISO8859_3
iso-ir-110 = ISO8859_4
ISO_8859-4:1988 = ISO8859_4
ISO_8859-4 = ISO8859_4
ISO-8859-4 = ISO8859_4
latin4 = ISO8859_4
l4 = ISO8859_4
csISOLatin4 = ISO8859_4
iso-ir-127 = ISO8859_6
ISO_8859-6 = ISO8859_6
ISO_8859-6:1987 = ISO8859_6
ISO-8859-6 = ISO8859_6
ECMA-114 = ISO8859_6
ASMO-708 = ISO8859_6
arabic = ISO8859_6
csISOLatinArabic = ISO8859_6
iso-ir-126 = ISO8859_7
ISO_8859-7 = ISO8859_7
ISO_8859-7:1987 = ISO8859_7
ISO-8859-7 = ISO8859_7
ELOT_928 = ISO8859_7
ECMA-118 = ISO8859_7
greek = ISO8859_7
greek8 = ISO8859_7
csISOLatinGreek = ISO8859_7
ISO_8859-8:1988 = ISO8859_8
iso-ir-138 = ISO8859_8
ISO_8859-8 = ISO8859_8
ISO-8859-8 = ISO8859_8
hebrew = ISO8859_8
csISOLatinHebrew = ISO8859_8
ISO_8859-9:1989 = ISO8859_9
iso-ir-148 = ISO8859_9
ISO_8859-9 = ISO8859_9
ISO-8859-9 = ISO8859_9
latin5 = ISO8859_9
l5 = ISO8859_9
csISOLatin5 = ISO8859_9
ISO_8859-15 = ISO8859_15_FDIS
UTF-8 = UTF8
Shift_JIS = SJIS
MS_Kanji = SJIS
csShiftJIS = SJIS
EUC-JP = EUC_JP
csEUCPkdFmtJapanese = EUC_JP
Extended_UNIX_Code_Packed_Format_for_Japanese = EUC_JP
csBig5 = Big5
flute-1.1.6/source/org/w3c/flute/util/Encoding.java 0000644 0001750 0001750 00000003445 11365604770 020571 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 1999 - 2009 Pentaho Corporation, World Wide Web Consortium. All rights reserved.
*/
package org.w3c.flute.util;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class Encoding {
private Encoding() {}
/**
* Converts the format encoding information into Java encoding information.
*/
public static String getJavaEncoding(String encoding) {
String _result = encodings.getProperty(encoding);
if (_result == null) {
return encoding;
}
return _result;
}
static Properties encodings;
static {
encodings = new Properties();
try {
URL url = Encoding.class.getResource("encoding.properties");
InputStream f = url.openStream();
encodings.load(f);
f.close();
} catch (Exception e) {
System.err.println(Encoding.class
+ ": couldn't load encoding properties ");
e.printStackTrace();
}
}
}
flute-1.1.6/source/org/w3c/flute/parser/ 0000755 0001750 0001750 00000000000 11365604770 016511 5 ustar rene rene flute-1.1.6/source/org/w3c/flute/parser/JumpException.java 0000644 0001750 0001750 00000002066 11365604770 022152 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2009 Pentaho Corporation. All rights reserved.
*/
package org.w3c.flute.parser;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class JumpException extends RuntimeException {
/**
* Creates a new JumpException
*/
public JumpException() {
}
}
flute-1.1.6/source/org/w3c/flute/parser/Generic_CharStream.java 0000644 0001750 0001750 00000022067 11365604770 023050 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2009 Pentaho Corporation. All rights reserved.
*/
package org.w3c.flute.parser;
/**
* An implementation of interface CharStream, where the stream is assumed to
* contain only ASCII characters (without unicode processing).
*/
public final class Generic_CharStream implements CharStream
{
public static final boolean staticFlag = false;
int bufsize;
int available;
int tokenBegin;
public int bufpos = -1;
private int bufline[];
private int bufcolumn[];
private int column = 0;
private int line = 1;
private boolean prevCharIsCR = false;
private boolean prevCharIsLF = false;
private java.io.Reader reader;
private char[] buffer;
private int maxNextCharInd = 0;
private int inBuf = 0;
private final 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;
}
private final 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 = reader.read(buffer, maxNextCharInd,
available - maxNextCharInd)) == -1)
{
reader.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 final char BeginToken() throws java.io.IOException
{
tokenBegin = -1;
char c = readChar();
tokenBegin = bufpos;
return c;
}
private final 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 += (8 - (column & 07));
break;
default :
break;
}
bufline[bufpos] = line;
bufcolumn[bufpos] = column;
}
public final char readChar() throws java.io.IOException
{
if (inBuf > 0)
{
--inBuf;
return (char)((char)0xff & buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]);
}
if (++bufpos >= maxNextCharInd)
FillBuff();
char c = (char)((char)0xff & buffer[bufpos]);
UpdateLineColumn(c);
return (c);
}
/**
* @deprecated
* @see #getEndColumn
*/
public final int getColumn() {
return bufcolumn[bufpos];
}
/**
* @deprecated
* @see #getEndLine
*/
public final int getLine() {
return bufline[bufpos];
}
public final int getEndColumn() {
return bufcolumn[bufpos];
}
public final int getEndLine() {
return bufline[bufpos];
}
public final int getBeginColumn() {
return bufcolumn[tokenBegin];
}
public final int getBeginLine() {
return bufline[tokenBegin];
}
public final void backup(int amount) {
inBuf += amount;
if ((bufpos -= amount) < 0)
bufpos += bufsize;
}
public Generic_CharStream(java.io.Reader dstream, int startline,
int startcolumn, int buffersize)
{
reader = dstream;
line = startline;
column = startcolumn - 1;
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
}
public Generic_CharStream(java.io.Reader dstream, int startline,
int startcolumn)
{
this(dstream, startline, startcolumn, 4096);
}
public void ReInit(java.io.Reader dstream, int startline,
int startcolumn, int buffersize)
{
reader = 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 final 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 final 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. this attribute condition can match any attribute.
* this attribute is a class attribute.
* this attribute is an id attribute.
* this attribute is a pseudo-class attribute.
* The simple selector can't be a this attribute condition can match any attribute.
* this attribute is a class attribute.
* this attribute is an id attribute.
* this attribute is a pseudo-class attribute.
*
*/
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];
}
}
flute-1.1.6/source/org/w3c/flute/parser/Parser.jj 0000644 0001750 0001750 00000145742 11365604770 020307 0 ustar rene rene /* -*-java-extended-*-
* Copyright (c) 1999 World Wide Web Consortium
* (Massachusetts Institute of Technology, Institut National de Recherche
* en Informatique et en Automatique, Keio University).
* All Rights Reserved. http://www.w3.org/Consortium/Legal/
*
* $Id: Parser.jj 3056 2007-07-30 13:59:14Z tmorgner $
*/
options {
IGNORE_CASE = true;
STATIC = false;
USER_CHAR_STREAM = true;
/* DEBUG_TOKEN_MANAGER = true;
DEBUG_PARSER = true; */
}
PARSER_BEGIN(Parser)
package org.w3c.flute.parser;
import java.io.*;
import java.net.*;
import java.util.Locale;
import org.w3c.css.sac.ConditionFactory;
import org.w3c.css.sac.Condition;
import org.w3c.css.sac.SelectorFactory;
import org.w3c.css.sac.SelectorList;
import org.w3c.css.sac.Selector;
import org.w3c.css.sac.SimpleSelector;
import org.w3c.css.sac.DocumentHandler;
import org.w3c.css.sac.InputSource;
import org.w3c.css.sac.ErrorHandler;
import org.w3c.css.sac.CSSException;
import org.w3c.css.sac.CSSParseException;
import org.w3c.css.sac.Locator;
import org.w3c.css.sac.LexicalUnit;
import org.w3c.flute.parser.selectors.SelectorFactoryImpl;
import org.w3c.flute.parser.selectors.ConditionFactoryImpl;
import org.w3c.flute.util.Encoding;
/**
* A CSS2 parser
*
* @author Philippe Le Hegaret
* @version $Revision: 3056 $
*/
public class Parser implements org.w3c.css.sac.Parser {
// replaces all \t, \n, etc with this StringBuffer.
static final StringBuffer SPACE = new StringBuffer(" ");
// the document handler for the parser
protected DocumentHandler documentHandler;
// the error handler for the parser
protected ErrorHandler errorHandler;
// the input source for the parser
protected InputSource source;
protected ConditionFactory conditionFactory;
protected SelectorFactory selectorFactory;
// temporary place holder for pseudo-element ...
protected String pseudoElt;
/**
* Creates a new Parser
*/
public Parser() {
this((CharStream) null);
}
/**
* @@TODO
* @exception CSSException Not yet implemented
*/
public void setLocale(Locale locale) throws CSSException {
throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
}
/**
* Set the document handler for this parser
*/
public void setDocumentHandler(DocumentHandler handler) {
this.documentHandler = handler;
}
public void setSelectorFactory(SelectorFactory selectorFactory) {
this.selectorFactory = selectorFactory;
}
public void setConditionFactory(ConditionFactory conditionFactory) {
this.conditionFactory = conditionFactory;
}
/**
* Set the error handler for this parser
*/
public void setErrorHandler(ErrorHandler error) {
this.errorHandler = error;
}
/**
* Main parse methods
*
* @param source the source of the style sheet.
* @exception IOException the source can't be parsed.
* @exception CSSException the source is not CSS valid.
*/
public void parseStyleSheet(InputSource source)
throws CSSException, IOException {
this.source = source;
ReInit(getCharStreamWithLurk(source));
if (selectorFactory == null) {
selectorFactory = new SelectorFactoryImpl();
}
if (conditionFactory == null) {
conditionFactory = new ConditionFactoryImpl();
}
parserUnit();
}
/**
* Convenient method for URIs.
*
* @param systemId the fully resolved URI of the style sheet.
* @exception IOException the source can't be parsed.
* @exception CSSException the source is not CSS valid.
*/
public void parseStyleSheet(String systemId)
throws CSSException, IOException {
parseStyleSheet(new InputSource(systemId));
}
/**
* This method parses only one rule (style rule or at-rule, except @charset).
*
* @param source the source of the rule.
* @exception IOException the source can't be parsed.
* @exception CSSException the source is not CSS valid.
*/
public void parseRule(InputSource source)
throws CSSException, IOException {
this.source = source;
ReInit(getCharStreamWithLurk(source));
if (selectorFactory == null) {
selectorFactory = new SelectorFactoryImpl();
}
if (conditionFactory == null) {
conditionFactory = new ConditionFactoryImpl();
}
_parseRule();
}
/**
* This method parses a style declaration (including the surrounding curly
* braces).
*
* @param source the source of the style declaration.
* @exception IOException the source can't be parsed.
* @exception CSSException the source is not CSS valid.
*/
public void parseStyleDeclaration(InputSource source)
throws CSSException, IOException {
this.source = source;
ReInit(getCharStreamWithLurk(source));
if (selectorFactory == null) {
selectorFactory = new SelectorFactoryImpl();
}
if (conditionFactory == null) {
conditionFactory = new ConditionFactoryImpl();
}
_parseDeclarationBlock();
}
/**
* This methods returns "http://www.w3.org/TR/REC-CSS2".
* @return the string "http://www.w3.org/TR/REC-CSS2".
*/
public String getParserVersion() {
return "http://www.w3.org/TR/REC-CSS2";
}
/**
* Parse methods used by DOM Level 2 implementation.
*/
public void parseImportRule(InputSource source)
throws CSSException, IOException {
this.source = source;
ReInit(getCharStreamWithLurk(source));
if (selectorFactory == null) {
selectorFactory = new SelectorFactoryImpl();
}
if (conditionFactory == null) {
conditionFactory = new ConditionFactoryImpl();
}
_parseImportRule();
}
public void parseMediaRule(InputSource source)
throws CSSException, IOException {
this.source = source;
ReInit(getCharStreamWithLurk(source));
if (selectorFactory == null) {
selectorFactory = new SelectorFactoryImpl();
}
if (conditionFactory == null) {
conditionFactory = new ConditionFactoryImpl();
}
_parseMediaRule();
}
public SelectorList parseSelectors(InputSource source)
throws CSSException, IOException {
this.source = source;
ReInit(getCharStreamWithLurk(source));
if (selectorFactory == null) {
selectorFactory = new SelectorFactoryImpl();
}
if (conditionFactory == null) {
conditionFactory = new ConditionFactoryImpl();
}
return _parseSelectors();
}
public String parseNamespaceToken(InputSource source)
throws CSSException, IOException {
this.source = source;
ReInit(getCharStreamWithLurk(source));
if (selectorFactory == null) {
selectorFactory = new SelectorFactoryImpl();
}
if (conditionFactory == null) {
conditionFactory = new ConditionFactoryImpl();
}
return _parseNamespaceToken();
}
public LexicalUnit parsePropertyValue(InputSource source)
throws CSSException, IOException {
this.source = source;
ReInit(getCharStreamWithLurk(source));
return expr();
}
public boolean parsePriority(InputSource source)
throws CSSException, IOException {
this.source = source;
ReInit(getCharStreamWithLurk(source));
return prio();
}
/**
* Convert the source into a Reader. Used only by DOM Level 2 parser methods.
*/
private Reader getReader(InputSource source) throws IOException {
if (source.getCharacterStream() != null) {
return source.getCharacterStream();
} else if (source.getByteStream() != null) {
// My DOM level 2 implementation doesn't use this case.
if (source.getEncoding() == null) {
// unknown encoding, use ASCII as default.
return new InputStreamReader(source.getByteStream(), "ASCII");
} else {
return new InputStreamReader(source.getByteStream(),
source.getEncoding());
}
} else {
// systemId
// @@TODO
throw new CSSException("not yet implemented");
}
}
/**
* Convert the source into a CharStream with encoding informations.
* The encoding can be found in the InputSource or in the CSS document.
* Since this method marks the reader and make a reset after looking for
* the charset declaration, you'll find the charset declaration into the
* stream.
*/
private CharStream getCharStreamWithLurk(InputSource source)
throws CSSException, IOException {
if (source.getCharacterStream() != null) {
// all encoding are supposed to be resolved by the user
// return the reader
return new Generic_CharStream(source.getCharacterStream(), 1, 1);
} else if (source.getByteStream() == null) {
// @@CONTINUE ME. see also getReader() with systemId
try {
source.setByteStream(new URL(source.getURI()).openStream());
} catch (Exception e) {
try {
source.setByteStream(new FileInputStream(source.getURI()));
} catch (IOException ex) {
throw new CSSException("invalid url ?");
}
}
}
String encoding = "ASCII";
InputStream input = source.getByteStream();
char c = ' ';
if (!input.markSupported()) {
input = new BufferedInputStream(input);
source.setByteStream(input);
}
input.mark(100);
c = (char) input.read();
if (c == '@') {
// hum, is it a charset ?
int size = 100;
byte[] buf = new byte[size];
input.read(buf, 0, 7);
String keyword = new String(buf, 0, 7);
if (keyword.equals("charset")) {
// Yes, this is the charset declaration !
// here I don't use the right declaration : white space are ' '.
while ((c = (char) input.read()) == ' ') {
// find the first quote
}
char endChar = c;
int i = 0;
if ((endChar != '"') && (endChar != '\'')) {
// hum this is not a quote.
throw new CSSException("invalid charset declaration");
}
while ((c = (char) input.read()) != endChar) {
buf[i++] = (byte) c;
if (i == size) {
byte[] old = buf;
buf = new byte[size + 100];
System.arraycopy(old, 0, buf, 0, size);
size += 100;
}
}
while ((c = (char) input.read()) == ' ') {
// find the next relevant character
}
if (c != ';') {
// no semi colon at the end ?
throw new CSSException("invalid charset declaration: "
+ "missing semi colon");
}
encoding = new String(buf, 0, i);
if (source.getEncoding() != null) {
// compare the two encoding informations.
// For example, I don't accept to have ASCII and after UTF-8.
// Is it really good ? That is the question.
if (!encoding.equals(source.getEncoding())) {
throw new CSSException("invalid encoding information.");
}
}
} // else no charset declaration available
}
// ok set the real encoding of this source.
source.setEncoding(encoding);
// set the real reader of this source.
source.setCharacterStream(new InputStreamReader(source.getByteStream(),
Encoding.getJavaEncoding(encoding)));
// reset the stream (leave the charset declaration in the stream).
input.reset();
return new Generic_CharStream(source.getCharacterStream(), 1, 1);
}
private LocatorImpl currentLocator;
private Locator getLocator() {
if (currentLocator == null) {
currentLocator = new LocatorImpl(this);
return currentLocator;
}
return currentLocator.reInit(this);
}
private LocatorImpl getLocator(Token save) {
if (currentLocator == null) {
currentLocator = new LocatorImpl(this, save);
return currentLocator;
}
return currentLocator.reInit(this, save);
}
private void reportError(Locator l, Exception e) {
if (errorHandler != null) {
if (e instanceof ParseException) {
// construct a clean error message.
ParseException pe = (ParseException) e;
if (pe.specialConstructor) {
StringBuffer errorM = new StringBuffer();
if (pe.currentToken != null) {
errorM.append("encountered \"")
.append(pe.currentToken.next);
}
errorM.append('"');
if (pe.expectedTokenSequences.length != 0) {
errorM.append(". Was expecting one of: ");
for (int i = 0; i < pe.expectedTokenSequences.length; i++) {
for (int j = 0; j < pe.expectedTokenSequences[i].length; j++) {
int kind = pe.expectedTokenSequences[i][j];
if (kind != S) {
errorM.append(pe.tokenImage[kind]);
errorM.append(' ');
}
}
}
}
errorHandler.error(new CSSParseException(errorM.toString(),
l, e));
} else {
errorHandler.error(new CSSParseException(e.getMessage(),
l, e));
}
} else if (e == null) {
errorHandler.error(new CSSParseException("error", l, null));
} else {
errorHandler.error(new CSSParseException(e.getMessage(), l, e));
}
}
}
private void reportWarningSkipText(Locator l, String text) {
if (errorHandler != null && text != null) {
errorHandler.warning(new CSSParseException("Skipping: " + text, l));
}
}
}
PARSER_END(Parser)
/*
* The tokenizer
*/
)*
( )* ")" >
}
)? "important" >
}
| ignoreStatement() )*
( importDeclaration() ( ignoreStatement() ( )* )* )*
( namespaceDeclaration() ( ignoreStatement() ( )* )* )*
afterImportDeclaration()
)* n= )* ";"
} catch (ParseException e) {
reportError(getLocator(e.currentToken.next), e);
skipStatement();
// reportWarningSkipText(getLocator(), skipStatement());
} catch (Exception e) {
reportError(getLocator(), e);
skipStatement();
// reportWarningSkipText(getLocator(), skipStatement());
}
}
void afterImportDeclaration() :
{String ret;
Locator l;
}
{
( ( styleRule() | media() | page() | fontFace()
| { l = getLocator(); } ret=skipStatement()
{
if ((ret == null) || (ret.length() == 0)) {
return;
}
reportWarningSkipText(l, ret);
if (ret.charAt(0) == '@') {
documentHandler.ignorableAtRule(ret);
}
}
)
( ignoreStatement() ( )* )* )*
}
void ignoreStatement() :
{}
{
)* ( n= )* ( mediaStatement(ml) )? ";"
( )*
{
if (ml.getLength() == 0) {
// see section 6.3 of the CSS2 recommandation.
ml.addItem("all");
}
documentHandler.importStyle(uri, ml, null);
}
} catch (ParseException e) {
reportError(getLocator(), e);
skipStatement();
// reportWarningSkipText(getLocator(), skipStatement());
}
}
/**
* The namespace statement
*
* @exception ParseException exception during the parse
*/
void namespaceDeclaration() :
{Token n;
Token prefix = null;
String uri;
}
{
try {
)*
(
((
prefix = )*)?
(
n= )*
{
if (prefix == null)
{
this.documentHandler.namespaceDeclaration("", uri);
}
else
{
this.documentHandler.namespaceDeclaration(prefix.image, uri);
}
}
} catch (ParseException e) {
reportError(getLocator(), e);
skipStatement();
// reportWarningSkipText(getLocator(), skipStatement());
}
}
/**
* @exception ParseException exception during the parse
*/
void media() :
{
boolean start = false;
String ret;
MediaListImpl ml = new MediaListImpl();
}
{
try {
)*
mediaStatement(ml)
{ start = true; documentHandler.startMedia(ml); }
)* ( styleRule() | skipUnknownRule() )* )*
} catch (ParseException e) {
reportError(getLocator(), e);
skipStatement();
// reportWarningSkipText(getLocator(), skipStatement());
} finally {
if (start) {
documentHandler.endMedia(ml);
}
}
}
void mediaStatement(MediaListImpl ml) :
{
String m;
}
{
m=medium() ( )* { ml.addItem(m); } m=medium() )*
{ ml.addItem(m); }
}
/**
* @exception ParseException exception during the parse
*/
String medium() : /* tv, projection, screen, ... */
{Token n;}
{
n= )* { return convertIdent(n.image); }
}
/**
* @exception ParseException exception during the parse
*/
void page() :
{
boolean start = false;
Token n = null;
String page = null;
String pseudo = null;
}
{
try {
)* ( n= )* )?
( pseudo=pseudo_page() )?
{
if (n != null) {
page = convertIdent(n.image);
}
}
)*
{
start = true;
documentHandler.startPage(page, pseudo);
}
(
(
declaration()
)?
(
";" ( )* ( declaration() )?
)*
(
atRuleDeclaration()
)*
)
)*
} catch (ParseException e) {
if (errorHandler != null) {
LocatorImpl li = new LocatorImpl(this,
e.currentToken.next.beginLine,
e.currentToken.next.beginColumn-1);
reportError(li, e);
skipStatement();
// reportWarningSkipText(li, skipStatement());
} else {
skipStatement();
}
} finally {
if (start) {
documentHandler.endPage(page, pseudo);
}
}
}
String pseudo_page() :
{ Token n; }
{
":" n= )* { return convertIdent(n.image); }
}
void fontFace() :
{
boolean start = false;
}
{
try {
)*
)*
{ start = true; documentHandler.startFontFace(); }
( declaration() )? ( ";" ( )* ( declaration() )? )*
)*
} catch (ParseException e) {
reportError(getLocator(), e);
skipStatement();
// reportWarningSkipText(getLocator(), skipStatement());
} finally {
if (start) {
documentHandler.endFontFace();
}
}
}
/**
* @exception ParseException exception during the parse
*/
void atRuleDeclaration() :
{Token n;
String ret;
}
{
n= )* { return '+'; }
| ">" ( )* { return '>'; }
| ( ( "+" { connector = '+'; }
| ">" { connector = '>'; } )
( )* )? { return connector; }
}
/**
* @exception ParseException exception during the parse
*/
String property() :
{Token n; }
{
n= )* { return convertIdent(n.image); }
}
/**
* @exception ParseException exception during the parse
*/
void styleRule() :
{
boolean start = false;
SelectorList l = null;
Token save;
Locator loc;
}
{
try {
l=selectorList() { save = token; } )*
{
start = true;
documentHandler.startSelector(l);
}
( declaration() )? ( ";" ( )* ( declaration() )? )*
)*
} catch (ThrowedParseException e) {
if (errorHandler != null) {
LocatorImpl li = new LocatorImpl(this,
e.e.currentToken.next.beginLine,
e.e.currentToken.next.beginColumn-1);
reportError(li, e.e);
}
} catch (ParseException e) {
reportError(getLocator(), e);
skipStatement();
// reportWarningSkipText(getLocator(), skipStatement());
} catch (TokenMgrError e) {
reportWarningSkipText(getLocator(), skipStatement());
} finally {
if (start) {
documentHandler.endSelector(l);
}
}
}
SelectorList selectorList() :
{
SelectorListImpl selectors = new SelectorListImpl();
Selector selector;
}
{
selector=selector() ( )* { selectors.addSelector(selector); }
selector=selector() )*
{ selectors.addSelector(selector);
return selectors;
}
}
/**
* @exception ParseException exception during the parse
*/
Selector selector() :
{
Selector selector;
char comb;
}
{
try {
selector=simple_selector(null, ' ')
( LOOKAHEAD(2) comb=combinator()
selector=simple_selector(selector, comb) )* ()*
{
return selector;
}
} catch (ParseException e) {
/*
Token t = getToken(1);
StringBuffer s = new StringBuffer();
s.append(getToken(0).image);
while ((t.kind != COMMA) && (t.kind != SEMICOLON)
&& (t.kind != LBRACE) && (t.kind != EOF)) {
s.append(t.image);
getNextToken();
t = getToken(1);
}
reportWarningSkipText(getLocator(), s.toString());
*/
Token t = getToken(1);
while ((t.kind != COMMA) && (t.kind != SEMICOLON)
&& (t.kind != LBRACE) && (t.kind != EOF)) {
getNextToken();
t = getToken(1);
}
throw new ThrowedParseException(e);
}
}
/**
* @exception ParseException exception during the parse
*/
Selector simple_selector(Selector selector, char comb) :
{
SimpleSelector simple_current = null;
Condition cond = null;
pseudoElt = null;
}
{
(
simple_current=element_name()
(
cond=hash(cond)
| cond=_class(cond)
| cond=attrib(cond)
| cond=pseudo(cond)
)*
| cond=hash(cond)
(
cond=_class(cond)
| cond=attrib(cond)
| cond=pseudo(cond)
)*
| cond=_class(cond)
(
cond=hash(cond)
| cond=_class(cond)
| cond=attrib(cond)
| cond=pseudo(cond)
)*
| cond=pseudo(cond)
(
cond=hash(cond)
| cond=_class(cond)
| cond=attrib(cond)
| cond=pseudo(cond)
)*
| cond=attrib(cond)
(
cond=hash(cond)
| cond=_class(cond)
| cond=attrib(cond)
| cond=pseudo(cond)
)*
)
{
if (simple_current == null) {
simple_current = selectorFactory.createElementSelector(null, null);
}
if (cond != null) {
simple_current = selectorFactory.createConditionalSelector(simple_current,
cond);
}
if (selector != null) {
switch (comb) {
case ' ':
selector = selectorFactory.createDescendantSelector(selector,
simple_current);
break;
case '+':
selector =
selectorFactory.createDirectAdjacentSelector((short) 1,
selector,
simple_current);
break;
case '>':
selector = selectorFactory.createChildSelector(selector,
simple_current);
break;
default:
throw new ParseException("invalid state. send a bug report");
}
} else {
selector= simple_current;
}
if (pseudoElt != null) {
selector = selectorFactory.createChildSelector(selector,
selectorFactory.createPseudoElementSelector(null, pseudoElt));
}
return selector;
}
}
/**
* @exception ParseException exception during the parse
*/
Condition _class(Condition pred) :
{Token n;
Condition c;
}
{
"." n= )*
(
att= )*
(
( "="
{
cases = 1;
}
| )*
(
val= )*
)? "]"
{
String name = convertIdent(att.image);
Condition c;
switch (cases) {
case 0:
c = conditionFactory.createAttributeCondition(name, null, false, null);
break;
case 1:
c = conditionFactory.createAttributeCondition(name, null, false,
attValue);
break;
case 2:
c = conditionFactory.createOneOfAttributeCondition(name, null, false,
attValue);
break;
case 3:
c = conditionFactory.createBeginHyphenAttributeCondition(name, null,
false,
attValue);
break;
default:
// never reached.
c = null;
}
if (pred == null) {
return c;
} else {
return conditionFactory.createAndCondition(pred, c);
}
}
}
/**
* @exception ParseException exception during the parse
*/
Condition pseudo(Condition pred) :
{Token n;
Token language;
}
{
":" ( n= )* language= )* ")"
{
String f = convertIdent(n.image);
if (f.equals("lang(")) {
Condition d =
conditionFactory.createLangCondition(convertIdent(language.image));
if (pred == null) {
return d;
} else {
return conditionFactory.createAndCondition(pred, d);
}
} else {
throw new CSSParseException("invalid pseudo function name "
+ f, getLocator());
}
}
)
)
}
/**
* @exception ParseException exception during the parse
*/
Condition hash(Condition pred) :
{Token n; }
{
n= )* exp=expr() ( important=prio() )?
{
documentHandler.property(name, exp, important);
}
} catch (JumpException e) {
skipAfterExpression();
// reportWarningSkipText(getLocator(), skipAfterExpression());
} catch (NumberFormatException e) {
if (errorHandler != null) {
errorHandler.error(new CSSParseException("Invalid number "
+ e.getMessage(),
getLocator(),
e));
}
reportWarningSkipText(getLocator(), skipAfterExpression());
} catch (ParseException e) {
if (errorHandler != null) {
if (e.currentToken != null) {
LocatorImpl li = new LocatorImpl(this,
e.currentToken.next.beginLine,
e.currentToken.next.beginColumn-1);
reportError(li, e);
} else {
reportError(getLocator(), e);
}
skipAfterExpression();
/*
LocatorImpl loc = (LocatorImpl) getLocator();
loc.column--;
reportWarningSkipText(loc, skipAfterExpression());
*/
} else {
skipAfterExpression();
}
}
}
/**
* @exception ParseException exception during the parse
*/
boolean prio() :
{}
{
)* { return true; }
}
/**
* @exception ParseException exception during the parse
*/
LexicalUnitImpl operator(LexicalUnitImpl prev) :
{Token n;}
{
n="/" ( )* { return LexicalUnitImpl.createSlash(n.beginLine,
n.beginColumn,
prev); }
| n="," ( )* { return LexicalUnitImpl.createComma(n.beginLine,
n.beginColumn,
prev); }
}
/**
* @exception ParseException exception during the parse
*/
LexicalUnit expr() :
{
LexicalUnitImpl first, res;
char op;
}
{
first=term(null) { res = first; }
( ( res=operator(res) )? res=term(res) )*
{ return first; }
}
/**
* @exception ParseException exception during the parse
*/
char unaryOperator() :
{}
{
"-" { return '-'; }
| "+" { return '+'; }
}
/**
* @exception ParseException exception during the parse
*/
LexicalUnitImpl term(LexicalUnitImpl prev) :
{ LexicalUnitImpl result = null;
Token n = null;
char op = ' ';
}
{
( ( ( op=unaryOperator() )?
( n= )*
{
return result;
}
}
/**
* Handle all CSS2 functions.
* @exception ParseException exception during the parse
*/
LexicalUnitImpl function(char operator, LexicalUnitImpl prev) :
{Token n;
LexicalUnit params = null;
}
{
n= )* ( params=expr() )? ")"
{
if (operator != ' ') {
throw new CSSParseException("invalid operator before a function.",
getLocator());
}
String f = convertIdent(n.image);
LexicalUnitImpl l = (LexicalUnitImpl) params;
boolean loop = true;
if ("rgb(".equals(f)) {
// this is a RGB declaration (e.g. rgb(255, 50%, 0) )
int i = 0;
while (loop && l != null && i < 5) {
switch (i) {
case 0:
case 2:
case 4:
if ((l.getLexicalUnitType() != LexicalUnit.SAC_INTEGER)
&& (l.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE)) {
loop = false;
}
break;
case 1:
case 3:
if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
loop = false;
}
break;
default:
throw new ParseException("implementation error");
}
if (loop) {
l = (LexicalUnitImpl) l.getNextLexicalUnit();
i ++;
}
}
if ((i == 5) && loop && (l == null)) {
return LexicalUnitImpl.createRGBColor(n.beginLine,
n.beginColumn,
prev, params);
} else {
if (errorHandler != null) {
String errorText;
Locator loc;
if (i < 5) {
if (params == null) {
loc = new LocatorImpl(this, n.beginLine,
n.beginColumn-1);
errorText = "not enough parameters.";
} else if (l == null) {
loc = new LocatorImpl(this, n.beginLine,
n.beginColumn-1);
errorText = "not enough parameters: "
+ params.toString();
} else {
loc = new LocatorImpl(this, l.getLineNumber(),
l.getColumnNumber());
errorText = "invalid parameter: "
+ l.toString();
}
} else {
loc = new LocatorImpl(this, l.getLineNumber(),
l.getColumnNumber());
errorText = "too many parameters: "
+ l.toString();
}
errorHandler.error(new CSSParseException(errorText, loc));
}
throw new JumpException();
}
} else if ("counter".equals(f)) {
int i = 0;
while (loop && l != null && i < 3) {
switch (i) {
case 0:
case 2:
if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) {
loop = false;
}
break;
case 1:
if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
loop = false;
}
break;
default:
throw new ParseException("implementation error");
}
l = (LexicalUnitImpl) l.getNextLexicalUnit();
i ++;
}
if (((i == 1) || (i == 3)) && loop && (l == null)) {
return LexicalUnitImpl.createCounter(n.beginLine, n.beginColumn,
prev, params);
}
} else if ("counters(".equals(f)) {
int i = 0;
while (loop && l != null && i < 5) {
switch (i) {
case 0:
case 4:
if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) {
loop = false;
}
break;
case 2:
if (l.getLexicalUnitType() != LexicalUnit.SAC_STRING_VALUE) {
loop = false;
}
break;
case 1:
case 3:
if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
loop = false;
}
break;
default:
throw new ParseException("implementation error");
}
l = (LexicalUnitImpl) l.getNextLexicalUnit();
i ++;
}
if (((i == 3) || (i == 5)) && loop && (l == null)) {
return LexicalUnitImpl.createCounters(n.beginLine, n.beginColumn,
prev, params);
}
} else if ("attr(".equals(f)) {
if ((l != null)
&& (l.getNextLexicalUnit() == null)
&& (l.getLexicalUnitType() == LexicalUnit.SAC_IDENT)) {
return LexicalUnitImpl.createAttr(l.getLineNumber(),
l.getColumnNumber(),
prev, l.getStringValue());
}
} else if ("rect(".equals(f)) {
int i = 0;
while (loop && l != null && i < 7) {
switch (i) {
case 0:
case 2:
case 4:
case 6:
switch (l.getLexicalUnitType()) {
case LexicalUnit.SAC_INTEGER:
if (l.getIntegerValue() != 0) {
loop = false;
}
break;
case LexicalUnit.SAC_IDENT:
if (!l.getStringValue().equals("auto")) {
loop = false;
}
break;
case LexicalUnit.SAC_EM:
case LexicalUnit.SAC_EX:
case LexicalUnit.SAC_PIXEL:
case LexicalUnit.SAC_CENTIMETER:
case LexicalUnit.SAC_MILLIMETER:
case LexicalUnit.SAC_INCH:
case LexicalUnit.SAC_POINT:
case LexicalUnit.SAC_PICA:
// nothing
break;
default:
loop = false;
}
break;
case 1:
case 3:
case 5:
if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
loop = false;
}
break;
default:
throw new ParseException("implementation error");
}
l = (LexicalUnitImpl) l.getNextLexicalUnit();
i ++;
}
if ((i == 7) && loop && (l == null)) {
return LexicalUnitImpl.createRect(n.beginLine, n.beginColumn,
prev, params);
}
}
return LexicalUnitImpl.createFunction(n.beginLine, n.beginColumn, prev,
f.substring(0,
f.length() -1),
params);
}
}
LexicalUnitImpl unicode(LexicalUnitImpl prev) :
{ Token n;
}
{
n= )*
( importDeclaration() | styleRule() | media() | page()
| fontFace() | ret=skipStatement()
{
if ((ret == null) || (ret.length() == 0)) {
return;
}
if (ret.charAt(0) == '@') {
documentHandler.ignorableAtRule(ret);
} else {
throw new CSSParseException("unrecognize rule: " + ret,
getLocator());
}
}
)
}
void _parseImportRule() :
{
}
{
( )* importDeclaration()
}
void _parseMediaRule() :
{
}
{
( )* media()
}
void _parseDeclarationBlock() :
{
}
{
( )*
( declaration() )? ( ";" ( )* ( declaration() )? )*
}
SelectorList _parseSelectors() :
{ SelectorList p = null;
}
{
try {
( )* p = selectorList()
{ return p; }
} catch (ThrowedParseException e) {
throw (ParseException) e.e;//.fillInStackTrace();
}
}
String _parseNamespaceToken() :
{
Token retval = null;
}
{
(
retval = Condition.
*/
public short getConditionType() {
return Condition.SAC_ID_CONDITION;
}
/**
* Returns the
* namespace
* URI of this attribute condition.
* NULL if :
*
*
*/
public String getNamespaceURI() {
return null;
}
/**
* Returns the
* local part
* of the
* qualified
* name of this attribute.
* NULL if :
*
*
*/
public String getLocalName() {
return null;
}
/**
* Returns true if the attribute must have an explicit value
* in the original document, false otherwise.
*/
public boolean getSpecified() {
return false;
}
/**
* Returns the value of the attribute.
* If this attribute is a class or a pseudo class attribute, you'll get
* the class name (or psedo class name) without the '.' or ':'.
*/
public String getValue() {
return value;
}
}
flute-1.1.6/source/org/w3c/flute/parser/selectors/ConditionalSelectorImpl.java 0000644 0001750 0001750 00000004003 11365604770 026142 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2000 - 2009 Pentaho Corporation, World Wide Web Consortium,. All rights reserved.
*/
package org.w3c.flute.parser.selectors;
import org.w3c.css.sac.ConditionalSelector;
import org.w3c.css.sac.Selector;
import org.w3c.css.sac.SimpleSelector;
import org.w3c.css.sac.Condition;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class ConditionalSelectorImpl implements ConditionalSelector {
SimpleSelector simpleSelector;
Condition condition;
/**
* An integer indicating the type of Selector
*/
public short getSelectorType() {
return Selector.SAC_CONDITIONAL_SELECTOR;
}
/**
* Creates a new ConditionalSelectorImpl
*/
public ConditionalSelectorImpl(SimpleSelector simpleSelector,
Condition condition) {
this.simpleSelector = simpleSelector;
this.condition = condition;
}
/**
* Returns the simple selector.
* ConditionalSelector.Condition.
*/
public short getConditionType() {
return Condition.SAC_PSEUDO_CLASS_CONDITION;
}
/**
* Returns the
* namespace
* URI of this attribute condition.
* NULL if :
*
*
*/
public String getNamespaceURI() {
return null;
}
/**
* Returns the
* local part
* of the
* qualified
* name of this attribute.
* NULL if :
*
*
*/
public String getLocalName() {
return null;
}
/**
* Returns true if the attribute must have an explicit value
* in the original document, false otherwise.
*/
public boolean getSpecified() {
return true;
}
/**
* Returns the value of the attribute.
* If this attribute is a class or a pseudo class attribute, you'll get
* the class name (or psedo class name) without the '.' or ':'.
*/
public String getValue() {
return value;
}
}
flute-1.1.6/source/org/w3c/flute/parser/selectors/PseudoElementSelectorImpl.java 0000644 0001750 0001750 00000004160 11365604770 026454 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2000 - 2009 Pentaho Corporation, World Wide Web Consortium,. All rights reserved.
*/
package org.w3c.flute.parser.selectors;
import org.w3c.css.sac.ElementSelector;
import org.w3c.css.sac.Selector;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class PseudoElementSelectorImpl implements ElementSelector {
String localName;
/**
* Creates a new ElementSelectorImpl
*/
public PseudoElementSelectorImpl(String localName) {
this.localName = localName;
}
/**
* An integer indicating the type of Selector
*/
public short getSelectorType() {
return Selector.SAC_PSEUDO_ELEMENT_SELECTOR;
}
/**
* Returns the
* namespace
* URI of this element selector.
* NULL if this element selector can match any namespace.NULL if this element selector can match any element.NULL if this element
* selector can match any element.
NULL if this
* element selector can match any pseudo element.
* @return the element selector
* @exception CSSException If this selector is not supported.
*/
public ElementSelector createPseudoElementSelector(String namespaceURI,
String pseudoName)
throws CSSException {
if (namespaceURI != null) {
throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
} else {
return new PseudoElementSelectorImpl(pseudoName);
}
}
/**
* Creates a descendant selector.
*
* @param parent the parent selector
* @param descendant the descendant selector
* @return the combinator selector.
* @exception CSSException If this selector is not supported.
*/
public DescendantSelector createDescendantSelector(Selector parent,
SimpleSelector descendant)
throws CSSException {
return new DescendantSelectorImpl(parent, descendant);
}
/**
* Creates a child selector.
*
* @param parent the parent selector
* @param child the child selector
* @return the combinator selector.
* @exception CSSException If this selector is not supported.
*/
public DescendantSelector createChildSelector(Selector parent,
SimpleSelector child)
throws CSSException {
return new ChildSelectorImpl(parent, child);
}
/**
* Creates a direct adjacent selector.
*
* @param child the child selector
* @param adjacent the direct adjacent selector
* @return the combinator selector.
* @exception CSSException If this selector is not supported.
*/
public SiblingSelector createDirectAdjacentSelector(short nodeType,
Selector child,
SimpleSelector directAdjacent)
throws CSSException {
if (nodeType != 1) {
throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
} else {
return new DirectAdjacentSelectorImpl(child, directAdjacent);
}
}
}
flute-1.1.6/source/org/w3c/flute/parser/selectors/LangConditionImpl.java 0000644 0001750 0001750 00000002766 11365604770 024744 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2000 - 2009 Pentaho Corporation, World Wide Web Consortium,. All rights reserved.
*/
package org.w3c.flute.parser.selectors;
import org.w3c.css.sac.LangCondition;
import org.w3c.css.sac.Condition;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class LangConditionImpl implements LangCondition {
String lang;
/**
* Creates a new LangConditionImpl
*/
public LangConditionImpl(String lang) {
this.lang = lang;
}
/**
* An integer indicating the type of Condition.
*/
public short getConditionType() {
return Condition.SAC_LANG_CONDITION;
}
/**
* Returns the language
*/
public String getLang() {
return lang;
}
}
flute-1.1.6/source/org/w3c/flute/parser/selectors/BeginHyphenAttributeConditionImpl.java 0000644 0001750 0001750 00000005703 11365604770 030141 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2000 - 2009 Pentaho Corporation, World Wide Web Consortium,. All rights reserved.
*/
package org.w3c.flute.parser.selectors;
import org.w3c.css.sac.AttributeCondition;
import org.w3c.css.sac.Condition;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class BeginHyphenAttributeConditionImpl implements AttributeCondition {
String localName;
String value;
/**
* Creates a new AttributeConditionImpl
*/
public BeginHyphenAttributeConditionImpl(String localName, String value) {
this.localName = localName;
this.value = value;
}
/**
* An integer indicating the type of Condition.
*/
public short getConditionType() {
return Condition.SAC_BEGIN_HYPHEN_ATTRIBUTE_CONDITION;
}
/**
* Returns the
* namespace
* URI of this attribute condition.
* NULL if :
*
NULL if :
*
this attribute condition can match any attribute. *
this attribute is a class attribute. *
this attribute is an id attribute. *
this attribute is a pseudo-class attribute. *
true if the attribute must have an explicit value
* in the original document, false otherwise.
*/
public boolean getSpecified() {
return false;
}
/**
* Returns the value of the attribute.
* If this attribute is a class or a pseudo class attribute, you'll get
* the class name (or psedo class name) without the '.' or ':'.
*/
public String getValue() {
return value;
}
}
flute-1.1.6/source/org/w3c/flute/parser/selectors/AttributeConditionImpl.java 0000644 0001750 0001750 00000005640 11365604770 026020 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2000 - 2009 Pentaho Corporation, World Wide Web Consortium,. All rights reserved.
*/
package org.w3c.flute.parser.selectors;
import org.w3c.css.sac.AttributeCondition;
import org.w3c.css.sac.Condition;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class AttributeConditionImpl implements AttributeCondition {
String localName;
String value;
/**
* Creates a new AttributeConditionImpl
*/
public AttributeConditionImpl(String localName, String value) {
this.localName = localName;
this.value = value;
}
/**
* An integer indicating the type of Condition.
*/
public short getConditionType() {
return Condition.SAC_ATTRIBUTE_CONDITION;
}
/**
* Returns the
* namespace
* URI of this attribute condition.
* NULL if :
*
NULL if :
*
this attribute condition can match any attribute. *
this attribute is a class attribute. *
this attribute is an id attribute. *
this attribute is a pseudo-class attribute. *
true if the attribute must have an explicit value
* in the original document, false otherwise.
*/
public boolean getSpecified() {
return false;
}
/**
* Returns the value of the attribute.
* If this attribute is a class or a pseudo class attribute, you'll get
* the class name (or psedo class name) without the '.' or ':'.
*/
public String getValue() {
return value;
}
}
flute-1.1.6/source/org/w3c/flute/parser/selectors/DescendantSelectorImpl.java 0000644 0001750 0001750 00000003530 11365604770 025753 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2000 - 2009 Pentaho Corporation, World Wide Web Consortium,. All rights reserved.
*/
package org.w3c.flute.parser.selectors;
import org.w3c.css.sac.DescendantSelector;
import org.w3c.css.sac.Selector;
import org.w3c.css.sac.SimpleSelector;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class DescendantSelectorImpl implements DescendantSelector {
Selector parent;
SimpleSelector simpleSelector;
/**
* An integer indicating the type of Selector
*/
public short getSelectorType() {
return Selector.SAC_DESCENDANT_SELECTOR;
}
/**
* Creates a new DescendantSelectorImpl
*/
public DescendantSelectorImpl(Selector parent, SimpleSelector simpleSelector) {
this.parent = parent;
this.simpleSelector = simpleSelector;
}
/**
* Returns the parent selector.
*/
public Selector getAncestorSelector() {
return parent;
}
/*
* Returns the simple selector.
*/
public SimpleSelector getSimpleSelector() {
return simpleSelector;
}
}
flute-1.1.6/source/org/w3c/flute/parser/selectors/ElementSelectorImpl.java 0000644 0001750 0001750 00000004142 11365604770 025274 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2000 - 2009 Pentaho Corporation, World Wide Web Consortium,. All rights reserved.
*/
package org.w3c.flute.parser.selectors;
import org.w3c.css.sac.ElementSelector;
import org.w3c.css.sac.Selector;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class ElementSelectorImpl implements ElementSelector {
String localName;
/**
* Creates a new ElementSelectorImpl
*/
public ElementSelectorImpl(String localName) {
this.localName = localName;
}
/**
* An integer indicating the type of Selector
*/
public short getSelectorType() {
return Selector.SAC_ELEMENT_NODE_SELECTOR;
}
/**
* Returns the
* namespace
* URI of this element selector.
* NULL if this element selector can match any namespace.
NULL if this element selector can match any element.
Selector
*/
public short getSelectorType() {
return Selector.SAC_CHILD_SELECTOR;
}
/**
* Creates a new ChildSelectorImpl
*/
public ChildSelectorImpl(Selector parent, SimpleSelector child) {
this.parent = parent;
this.child = child;
}
/**
* Returns the parent selector.
*/
public Selector getAncestorSelector() {
return parent;
}
/*
* Returns the simple selector.
*/
public SimpleSelector getSimpleSelector() {
return child;
}
}
flute-1.1.6/source/org/w3c/flute/parser/selectors/DirectAdjacentSelectorImpl.java 0000644 0001750 0001750 00000003620 11365604770 026547 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2000 - 2009 Pentaho Corporation, World Wide Web Consortium,. All rights reserved.
*/
package org.w3c.flute.parser.selectors;
import org.w3c.css.sac.SiblingSelector;
import org.w3c.css.sac.Selector;
import org.w3c.css.sac.SimpleSelector;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class DirectAdjacentSelectorImpl implements SiblingSelector {
Selector child;
SimpleSelector directAdjacent;
/**
* An integer indicating the type of Selector
*/
public short getSelectorType() {
return Selector.SAC_DIRECT_ADJACENT_SELECTOR;
}
/**
* Creates a new DescendantSelectorImpl
*/
public DirectAdjacentSelectorImpl(Selector child,
SimpleSelector directAdjacent) {
this.child = child;
this.directAdjacent = directAdjacent;
}
public short getNodeType() {
return 1;
}
/**
* Returns the parent selector.
*/
public Selector getSelector() {
return child;
}
/*
* Returns the simple selector.
*/
public SimpleSelector getSiblingSelector() {
return directAdjacent;
}
}
flute-1.1.6/source/org/w3c/flute/parser/selectors/OneOfAttributeConditionImpl.java 0000644 0001750 0001750 00000005661 11365604770 026752 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2000 - 2009 Pentaho Corporation, World Wide Web Consortium,. All rights reserved.
*/
package org.w3c.flute.parser.selectors;
import org.w3c.css.sac.AttributeCondition;
import org.w3c.css.sac.Condition;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class OneOfAttributeConditionImpl implements AttributeCondition {
String localName;
String value;
/**
* Creates a new AttributeConditionImpl
*/
public OneOfAttributeConditionImpl(String localName, String value) {
this.localName = localName;
this.value = value;
}
/**
* An integer indicating the type of Condition.
*/
public short getConditionType() {
return Condition.SAC_ONE_OF_ATTRIBUTE_CONDITION;
}
/**
* Returns the
* namespace
* URI of this attribute condition.
* NULL if :
*
NULL if :
*
this attribute condition can match any attribute. *
this attribute is a class attribute. *
this attribute is an id attribute. *
this attribute is a pseudo-class attribute. *
true if the attribute must have an explicit value
* in the original document, false otherwise.
*/
public boolean getSpecified() {
return false;
}
/**
* Returns the value of the attribute.
* If this attribute is a class or a pseudo class attribute, you'll get
* the class name (or psedo class name) without the '.' or ':'.
*/
public String getValue() {
return value;
}
}
flute-1.1.6/source/org/w3c/flute/parser/selectors/ClassConditionImpl.java 0000644 0001750 0001750 00000005503 11365604770 025120 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2000 - 2009 Pentaho Corporation, World Wide Web Consortium,. All rights reserved.
*/
package org.w3c.flute.parser.selectors;
import org.w3c.css.sac.AttributeCondition;
import org.w3c.css.sac.Condition;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class ClassConditionImpl implements AttributeCondition {
String value;
/**
* Creates a new AttributeConditionImpl
*/
public ClassConditionImpl(String value) {
this.value = value;
}
/**
* An integer indicating the type of Condition.
*/
public short getConditionType() {
return Condition.SAC_CLASS_CONDITION;
}
/**
* Returns the
* namespace
* URI of this attribute condition.
* NULL if :
*
NULL if :
*
this attribute condition can match any attribute. *
this attribute is a class attribute. *
this attribute is an id attribute. *
this attribute is a pseudo-class attribute. *
true if the attribute must have an explicit value
* in the original document, false otherwise.
*/
public boolean getSpecified() {
return false;
}
/**
* Returns the value of the attribute.
* If this attribute is a class or a pseudo class attribute, you'll get
* the class name (or psedo class name) without the '.' or ':'.
*/
public String getValue() {
return value;
}
}
flute-1.1.6/source/org/w3c/flute/parser/selectors/AndConditionImpl.java 0000644 0001750 0001750 00000003467 11365604770 024564 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2000 - 2009 Pentaho Corporation, World Wide Web Consortium,. All rights reserved.
*/
package org.w3c.flute.parser.selectors;
import org.w3c.css.sac.CombinatorCondition;
import org.w3c.css.sac.Condition;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class AndConditionImpl implements CombinatorCondition {
Condition firstCondition;
Condition secondCondition;
/**
* Creates a new AndConditionImpl
*/
public AndConditionImpl(Condition firstCondition, Condition secondCondition) {
this.firstCondition = firstCondition;
this.secondCondition = secondCondition;
}
/**
* An integer indicating the type of Condition.
*/
public short getConditionType() {
return Condition.SAC_AND_CONDITION;
}
/**
* Returns the first condition.
*/
public Condition getFirstCondition() {
return firstCondition;
}
/**
* Returns the second condition.
*/
public Condition getSecondCondition() {
return secondCondition;
}
}
flute-1.1.6/source/org/w3c/flute/parser/selectors/ConditionFactoryImpl.java 0000644 0001750 0001750 00000020767 11365604770 025473 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2000 - 2009 Pentaho Corporation, World Wide Web Consortium,. All rights reserved.
*/
package org.w3c.flute.parser.selectors;
import org.w3c.css.sac.CSSException;
import org.w3c.css.sac.Condition;
import org.w3c.css.sac.AttributeCondition;
import org.w3c.css.sac.LangCondition;
import org.w3c.css.sac.ContentCondition;
import org.w3c.css.sac.CombinatorCondition;
import org.w3c.css.sac.PositionalCondition;
import org.w3c.css.sac.NegativeCondition;
import org.w3c.css.sac.ConditionFactory;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
public class ConditionFactoryImpl implements ConditionFactory {
/**
* Creates an and condition
*
* @param first the first condition
* @param second the second condition
* @return A combinator condition
* @exception CSSException if this exception is not supported.
*/
public CombinatorCondition createAndCondition(Condition first,
Condition second)
throws CSSException {
return new AndConditionImpl(first, second);
}
/**
* Creates an or condition
*
* @param first the first condition
* @param second the second condition
* @return A combinator condition
* @exception CSSException if this exception is not supported.
*/
public CombinatorCondition createOrCondition(Condition first,
Condition second)
throws CSSException {
throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
}
/**
* Creates a negative condition
*
* @param condition the condition
* @return A negative condition
* @exception CSSException if this exception is not supported.
*/
public NegativeCondition createNegativeCondition(Condition condition)
throws CSSException {
throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
}
/**
* Creates a positional condition
*
* @param position the position of the node in the list.
* @param typeNode true if the list should contain
* only nodes of the same type (element, text node, ...).
* @param type true true if the list should contain
* only nodes of the same node (for element, same localName
* and same namespaceURI).
* @return A positional condition
* @exception CSSException if this exception is not supported.
*/
public PositionalCondition createPositionalCondition(int position,
boolean typeNode,
boolean type)
throws CSSException {
throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
}
/**
* creates an attribute condition
*
* @param localName the localName of the attribute
* @param namespaceURI the namespace URI of the attribute
* @param specified true if the attribute must be specified
* in the document.
* @param value the value of this attribute.
* @return An attribute condition
* @exception CSSException if this exception is not supported.
*/
public AttributeCondition createAttributeCondition(String localName,
String namespaceURI,
boolean specified,
String value)
throws CSSException {
if ((namespaceURI != null) || specified) {
throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
} else {
return new AttributeConditionImpl(localName, value);
}
}
/**
* Creates an id condition
*
* @param value the value of the id.
* @return An Id condition
* @exception CSSException if this exception is not supported.
*/
public AttributeCondition createIdCondition(String value)
throws CSSException {
return new IdConditionImpl(value);
}
/**
* Creates a lang condition
*
* @param value the value of the language.
* @return A lang condition
* @exception CSSException if this exception is not supported.
*/
public LangCondition createLangCondition(String lang)
throws CSSException {
return new LangConditionImpl(lang);
}
/**
* Creates a "one of" attribute condition
*
* @param localName the localName of the attribute
* @param namespaceURI the namespace URI of the attribute
* @param specified true if the attribute must be specified
* in the document.
* @param value the value of this attribute.
* @return A "one of" attribute condition
* @exception CSSException if this exception is not supported.
*/
public AttributeCondition createOneOfAttributeCondition(String localName,
String namespaceURI,
boolean specified,
String value)
throws CSSException {
if ((namespaceURI != null) || specified) {
throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
} else {
return new OneOfAttributeConditionImpl(localName, value);
}
}
/**
* Creates a "begin hyphen" attribute condition
*
* @param localName the localName of the attribute
* @param namespaceURI the namespace URI of the attribute
* @param specified true if the attribute must be specified
* in the document.
* @param value the value of this attribute.
* @return A "begin hyphen" attribute condition
* @exception CSSException if this exception is not supported.
*/
public AttributeCondition createBeginHyphenAttributeCondition(String localName,
String namespaceURI,
boolean specified,
String value)
throws CSSException {
if ((namespaceURI != null) || specified) {
throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
} else {
return new BeginHyphenAttributeConditionImpl(localName, value);
}
}
/**
* Creates a class condition
*
* @param localName the localName of the attribute
* @param namespaceURI the namespace URI of the attribute
* @param specified true if the attribute must be specified
* in the document.
* @param value the name of the class.
* @return A class condition
* @exception CSSException if this exception is not supported.
*/
public AttributeCondition createClassCondition(String namespaceURI,
String value)
throws CSSException {
return new ClassConditionImpl(value);
}
/**
* Creates a pseudo class condition
*
* @param namespaceURI the namespace URI of the attribute
* @param value the name of the pseudo class
* @return A pseudo class condition
* @exception CSSException if this exception is not supported.
*/
public AttributeCondition createPseudoClassCondition(String namespaceURI,
String value)
throws CSSException {
return new PseudoClassConditionImpl(value);
}
/**
* Creates a "only one" child condition
*
* @return A "only one" child condition
* @exception CSSException if this exception is not supported.
*/
public Condition createOnlyChildCondition() throws CSSException {
throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
}
/**
* Creates a "only one" type condition
*
* @return A "only one" type condition
* @exception CSSException if this exception is not supported.
*/
public Condition createOnlyTypeCondition() throws CSSException {
throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
}
/**
* Creates a content condition
*
* @param data the data in the content
* @return A content condition
* @exception CSSException if this exception is not supported.
*/
public ContentCondition createContentCondition(String data)
throws CSSException {
throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR);
}
}
flute-1.1.6/source/org/w3c/flute/parser/LexicalUnitImpl.java 0000644 0001750 0001750 00000032114 11365604770 022420 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 1999 - 2009 Pentaho Corporation, World Wide Web Consortium. All rights reserved.
*/
package org.w3c.flute.parser;
import org.w3c.css.sac.LexicalUnit;
/**
* @version $Revision: 9877 $
* @author Philippe Le Hegaret
*/
class LexicalUnitImpl implements LexicalUnit {
LexicalUnit prev;
LexicalUnit next;
short type;
int line;
int column;
int i;
float f;
short dimension;
String sdimension;
String s;
String fname;
LexicalUnitImpl params;
LexicalUnitImpl(short type, int line, int column, LexicalUnitImpl p) {
if (p != null) {
prev = p;
p.next = this;
}
this.line = line;
this.column = column -1;
this.type = type;
}
LexicalUnitImpl(int line, int column, LexicalUnitImpl previous, int i) {
this(SAC_INTEGER, line, column, previous);
this.i = i;
}
LexicalUnitImpl(int line, int column, LexicalUnitImpl previous,
short dimension, String sdimension, float f) {
this(dimension, line, column, previous);
this.f = f;
this.dimension = dimension;
this.sdimension = sdimension;
}
LexicalUnitImpl(int line, int column, LexicalUnitImpl previous,
short type, String s) {
this(type, line, column, previous);
this.s = s;
}
LexicalUnitImpl(short type, int line, int column,
LexicalUnitImpl previous, String fname,
LexicalUnitImpl params) {
this(type, line, column, previous);
this.fname = fname;
this.params = params;
}
public int getLineNumber() {
return line;
}
public int getColumnNumber() {
return column;
}
public short getLexicalUnitType() {
return type;
}
public LexicalUnit getNextLexicalUnit() {
return next;
}
public LexicalUnit getPreviousLexicalUnit() {
return prev;
}
public int getIntegerValue() {
return i;
}
void setIntegerValue(int i) {
this.i = i;
}
public float getFloatValue() {
return f;
}
void setFloatValue(float f) {
this.f = f;
}
public String getDimensionUnitText() {
switch (type) {
case SAC_PERCENTAGE:
return "%";
case SAC_EM:
return "em";
case SAC_EX:
return "ex";
case SAC_PIXEL:
return "px";
case SAC_CENTIMETER:
return "cm";
case SAC_MILLIMETER:
return "mm";
case SAC_INCH:
return "in";
case SAC_POINT:
return "pt";
case SAC_PICA:
return "pc";
case SAC_DEGREE:
return "deg";
case SAC_RADIAN:
return "rad";
case SAC_GRADIAN:
return "grad";
case SAC_MILLISECOND:
return "ms";
case SAC_SECOND:
return "s";
case SAC_HERTZ:
return "Hz";
case SAC_KILOHERTZ:
return "kHz";
case SAC_DIMENSION:
return sdimension;
default:
throw new IllegalStateException("invalid dimension " + type);
}
}
public String getStringValue() {
return s;
}
public String getFunctionName() {
return fname;
}
public org.w3c.css.sac.LexicalUnit getParameters() {
return params;
}
public org.w3c.css.sac.LexicalUnit getSubValues() {
return params;
}
public String toString() {
String text;
switch (type) {
case SAC_OPERATOR_COMMA:
text = ",";
break;
case SAC_OPERATOR_PLUS:
text = "+";
break;
case SAC_OPERATOR_MINUS:
text = "-";
break;
case SAC_OPERATOR_MULTIPLY:
text = "*";
break;
case SAC_OPERATOR_SLASH:
text = "/";
break;
case SAC_OPERATOR_MOD:
text = "%";
break;
case SAC_OPERATOR_EXP:
text = "^";
break;
case SAC_OPERATOR_LT:
text = "<";
break;
case SAC_OPERATOR_GT:
text = ">";
break;
case SAC_OPERATOR_LE:
text = "<=";
break;
case SAC_OPERATOR_GE:
text = "=>";
break;
case SAC_OPERATOR_TILDE:
text = "~";
break;
case SAC_INHERIT:
text = "inherit";
break;
case SAC_INTEGER:
text = Integer.toString(i, 10);
break;
case SAC_REAL:
text = f + "";
break;
case SAC_EM:
case SAC_EX:
case SAC_PIXEL:
case SAC_INCH:
case SAC_CENTIMETER:
case SAC_MILLIMETER:
case SAC_POINT:
case SAC_PICA:
case SAC_PERCENTAGE:
case SAC_DEGREE:
case SAC_GRADIAN:
case SAC_RADIAN:
case SAC_MILLISECOND:
case SAC_SECOND:
case SAC_HERTZ:
case SAC_KILOHERTZ:
case SAC_DIMENSION:
String fs = null;
int i = (int) f;
if (((float) i) == f) {
text = i + getDimensionUnitText();
} else {
text = f + getDimensionUnitText();
}
break;
case SAC_URI:
text = "uri(" + s + ")";
break;
case SAC_COUNTER_FUNCTION:
case SAC_COUNTERS_FUNCTION:
case SAC_RGBCOLOR:
case SAC_RECT_FUNCTION:
case SAC_FUNCTION:
text = getFunctionName() + "(" + getParameters() + ")";
break;
case SAC_IDENT:
text = getStringValue();
break;
case SAC_STRING_VALUE:
// @@SEEME. not exact
text = "\"" + getStringValue() + "\"";
break;
case SAC_ATTR:
text = "attr(" + getStringValue() + ")";
break;
case SAC_UNICODERANGE:
text = "@@TODO";
break;
case SAC_SUB_EXPRESSION:
text = getSubValues().toString();
break;
default:
text = "@unknown";
break;
}
if (next != null) {
return text + ' ' + next;
} else {
return text;
}
}
// here some useful function for creation
static LexicalUnitImpl createNumber(int line, int column,
LexicalUnitImpl previous, float v) {
int i = (int) v;
if (v == ((float) i)) {
return new LexicalUnitImpl(line, column, previous, i);
} else {
return new LexicalUnitImpl(line, column, previous, SAC_REAL, "", v);
}
}
static LexicalUnitImpl createInteger(int line, int column,
LexicalUnitImpl previous, int i) {
return new LexicalUnitImpl(line, column, previous, i);
}
static LexicalUnitImpl createPercentage(int line, int column,
LexicalUnitImpl previous, float v) {
return new LexicalUnitImpl(line, column, previous,
SAC_PERCENTAGE, null, v);
}
static LexicalUnitImpl createEMS(int line, int column,
LexicalUnitImpl previous, float v) {
return new LexicalUnitImpl(line, column, previous,
SAC_EM, null, v);
}
static LexicalUnitImpl createEXS(int line, int column,
LexicalUnitImpl previous, float v) {
return new LexicalUnitImpl(line, column, previous,
SAC_EX, null, v);
}
static LexicalUnitImpl createPX(int line, int column,
LexicalUnitImpl previous, float v) {
return new LexicalUnitImpl(line, column, previous, SAC_PIXEL,
null, v);
}
static LexicalUnitImpl createCM(int line, int column,
LexicalUnitImpl previous, float v) {
return new LexicalUnitImpl(line, column, previous,
SAC_CENTIMETER, null, v);
}
static LexicalUnitImpl createMM(int line, int column,
LexicalUnitImpl previous, float v) {
return new LexicalUnitImpl(line, column, previous,
SAC_MILLIMETER, null, v);
}
static LexicalUnitImpl createIN(int line, int column,
LexicalUnitImpl previous, float v) {
return new LexicalUnitImpl(line, column, previous, SAC_INCH,
null, v);
}
static LexicalUnitImpl createPT(int line, int column,
LexicalUnitImpl previous, float v) {
return new LexicalUnitImpl(line, column, previous, SAC_POINT,
null, v);
}
static LexicalUnitImpl createPC(int line, int column,
LexicalUnitImpl previous, float v) {
return new LexicalUnitImpl(line, column, previous, SAC_PICA,
null, v);
}
static LexicalUnitImpl createDEG(int line, int column,
LexicalUnitImpl previous, float v) {
return new LexicalUnitImpl(line, column, previous, SAC_DEGREE,
null, v);
}
static LexicalUnitImpl createRAD(int line, int column,
LexicalUnitImpl previous, float v) {
return new LexicalUnitImpl(line, column, previous, SAC_RADIAN,
null, v);
}
static LexicalUnitImpl createGRAD(int line, int column,
LexicalUnitImpl previous, float v) {
return new LexicalUnitImpl(line, column, previous, SAC_GRADIAN,
null, v);
}
static LexicalUnitImpl createMS(int line, int column,
LexicalUnitImpl previous, float v) {
if (v < 0) {
throw new ParseException("Time values may not be negative");
}
return new LexicalUnitImpl(line, column, previous,
SAC_MILLISECOND, null, v);
}
static LexicalUnitImpl createS(int line, int column,
LexicalUnitImpl previous, float v) {
if (v < 0) {
throw new ParseException("Time values may not be negative");
}
return new LexicalUnitImpl(line, column, previous, SAC_SECOND,
null, v);
}
static LexicalUnitImpl createHZ(int line, int column,
LexicalUnitImpl previous, float v) {
if (v < 0) {
throw new ParseException("Frequency values may not be negative");
}
return new LexicalUnitImpl(line, column, previous, SAC_HERTZ,
null, v);
}
static LexicalUnitImpl createKHZ(int line, int column,
LexicalUnitImpl previous, float v) {
if (v < 0) {
throw new ParseException("Frequency values may not be negative");
}
return new LexicalUnitImpl(line, column, previous,
SAC_KILOHERTZ, null, v);
}
static LexicalUnitImpl createDimen(int line, int column,
LexicalUnitImpl previous,
float v, String s) {
return new LexicalUnitImpl(line, column, previous,
SAC_DIMENSION, s, v);
}
static LexicalUnitImpl createInherit(int line, int column,
LexicalUnitImpl previous) {
return new LexicalUnitImpl(line, column, previous, SAC_INHERIT, "inherit");
}
static LexicalUnitImpl createIdent(int line, int column,
LexicalUnitImpl previous, String s) {
return new LexicalUnitImpl(line, column, previous, SAC_IDENT, s);
}
static LexicalUnitImpl createString(int line, int column,
LexicalUnitImpl previous, String s) {
return new LexicalUnitImpl(line, column, previous,
SAC_STRING_VALUE, s);
}
static LexicalUnitImpl createURL(int line, int column,
LexicalUnitImpl previous, String s) {
return new LexicalUnitImpl(line, column, previous, SAC_URI, s);
}
static LexicalUnitImpl createAttr(int line, int column,
LexicalUnitImpl previous, String s) {
return new LexicalUnitImpl(line, column, previous, SAC_ATTR, s);
}
static LexicalUnitImpl createCounter(int line, int column,
LexicalUnitImpl previous,
LexicalUnit params) {
return new LexicalUnitImpl(SAC_COUNTER_FUNCTION, line,
column, previous, "counter",
(LexicalUnitImpl) params);
}
static LexicalUnitImpl createCounters(int line, int column,
LexicalUnitImpl previous,
LexicalUnit params) {
return new LexicalUnitImpl(SAC_COUNTERS_FUNCTION, line,
column, previous, "counters",
(LexicalUnitImpl) params);
}
static LexicalUnitImpl createRGBColor(int line, int column,
LexicalUnitImpl previous,
LexicalUnit params) {
return new LexicalUnitImpl(SAC_RGBCOLOR, line, column,
previous, "color",
(LexicalUnitImpl) params);
}
static LexicalUnitImpl createRect(int line, int column,
LexicalUnitImpl previous,
LexicalUnit params) {
return new LexicalUnitImpl(SAC_RECT_FUNCTION, line, column,
previous, "rect",
(LexicalUnitImpl) params);
}
static LexicalUnitImpl createFunction(int line, int column,
LexicalUnitImpl previous,
String fname,
LexicalUnit params) {
return new LexicalUnitImpl(SAC_FUNCTION, line, column, previous,
fname,
(LexicalUnitImpl) params);
}
static LexicalUnitImpl createUnicodeRange(int line, int column,
LexicalUnit previous,
LexicalUnit params) {
// @@ return new LexicalUnitImpl(line, column, previous, null, SAC_UNICODERANGE, params);
return null;
}
static LexicalUnitImpl createComma(int line, int column,
LexicalUnitImpl previous) {
return new LexicalUnitImpl(SAC_OPERATOR_COMMA, line, column, previous);
}
static LexicalUnitImpl createSlash(int line, int column,
LexicalUnitImpl previous) {
return new LexicalUnitImpl(SAC_OPERATOR_SLASH, line, column, previous);
}
}
flute-1.1.6/source/org/w3c/flute/parser/ParserConstants.java 0000644 0001750 0001750 00000006775 11365604770 022524 0 ustar rene rene /*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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 Lesser General Public License for more details.
*
* Copyright (c) 2009 Pentaho Corporation. All rights reserved.
*/
package org.w3c.flute.parser;
public interface ParserConstants {
int EOF = 0;
int S = 1;
int CDO = 5;
int CDC = 6;
int LBRACE = 7;
int RBRACE = 8;
int DASHMATCH = 9;
int INCLUDES = 10;
int EQ = 11;
int PLUS = 12;
int MINUS = 13;
int COMMA = 14;
int SEMICOLON = 15;
int PRECEDES = 16;
int DIV = 17;
int LBRACKET = 18;
int RBRACKET = 19;
int ANY = 20;
int DOT = 21;
int LPARAN = 22;
int RPARAN = 23;
int COLON = 24;
int NONASCII = 25;
int H = 26;
int UNICODE = 27;
int ESCAPE = 28;
int NMSTART = 29;
int NMCHAR = 30;
int STRINGCHAR = 31;
int D = 32;
int NAME = 33;
int NNAME = 34;
int STRING = 35;
int IDENT = 36;
int NUMBER = 37;
int _URL = 38;
int URL = 39;
int NAMESPACE_IDENT = 40;
int PERCENTAGE = 41;
int PT = 42;
int MM = 43;
int CM = 44;
int PC = 45;
int IN = 46;
int PX = 47;
int EMS = 48;
int EXS = 49;
int DEG = 50;
int RAD = 51;
int GRAD = 52;
int MS = 53;
int SECOND = 54;
int HZ = 55;
int KHZ = 56;
int DIMEN = 57;
int HASH = 58;
int IMPORT_SYM = 59;
int MEDIA_SYM = 60;
int CHARSET_SYM = 61;
int PAGE_SYM = 62;
int NAMESPACE_SYM = 63;
int FONT_FACE_SYM = 64;
int ATKEYWORD = 65;
int IMPORTANT_SYM = 66;
int RANGE0 = 67;
int RANGE1 = 68;
int RANGE2 = 69;
int RANGE3 = 70;
int RANGE4 = 71;
int RANGE5 = 72;
int RANGE6 = 73;
int RANGE = 74;
int UNI = 75;
int UNICODERANGE = 76;
int FUNCTION = 77;
int UNKNOWN = 78;
int DEFAULT = 0;
int IN_COMMENT = 1;
String[] tokenImage = {
"Note: The original version of the W3C Software Copyright Notice and License could be found at http://www.w3.org/Consortium/Legal/copyright-software-19980720
This W3C work (including software, documents, or other related items) is being provided by the copyright holders under the following license. By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions:
Permission to use, copy, and modify this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications, that you make:
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.
flute-1.1.6/ChangeLog.txt 0000644 0001750 0001750 00000000000 11365604770 013671 0 ustar rene rene flute-1.1.6/devresource/ 0000755 0001750 0001750 00000000000 11365604770 013641 5 ustar rene rene flute-1.1.6/devresource/META-INF/ 0000755 0001750 0001750 00000000000 11365604770 015001 5 ustar rene rene flute-1.1.6/devresource/META-INF/MANIFEST.MF 0000644 0001750 0001750 00000000437 11365604770 016437 0 ustar rene rene Specification-Title: flute Specification-Vendor: The World-Wide-Web Consortium Implementation-Title: flute Implementation-Vendor: Pentaho Corporation Implementation-ProductID: flute Release-Major-Number: 1 Release-Minor-Number: 3 Release-Milestone-Number: 0 Release-Candidate-Token: dev flute-1.1.6/dev-lib/ 0000755 0001750 0001750 00000000000 11365604774 012641 5 ustar rene rene flute-1.1.6/.classpath 0000644 0001750 0001750 00000001413 11365604770 013275 0 ustar rene rene