Author: rdonkin
Date: Sun Jun 22 03:34:32 2008
New Revision: 670333
URL: http://svn.apache.org/viewvc?rev=670333&view=rev
Log:
Support for parsing RFC3066 Content-Language headers
Added:
james/mime4j/trunk/src/main/java/org/apache/james/mime4j/RFC3066ContentLanguageDescriptor.java
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/language/
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/language/ContentLanguageParser.jj
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/language/ParseException.java
Modified:
james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MaximalBodyDescriptor.java
james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MimeUtil.java
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/contenttype/ContentTypeParser.jj
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/mimeversion/MimeVersionParser.jj
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/mimeversion/ParseException.java
james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java
james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MaximalBodyDescriptorTest.java
Modified:
james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MaximalBodyDescriptor.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MaximalBodyDescriptor.java?rev=670333&r1=670332&r2=670333&view=diff
==============================================================================
---
james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MaximalBodyDescriptor.java
(original)
+++
james/mime4j/trunk/src/main/java/org/apache/james/mime4j/MaximalBodyDescriptor.java
Sun Jun 22 03:34:32 2008
@@ -20,11 +20,13 @@
import java.io.StringReader;
import java.util.Collections;
+import java.util.List;
import java.util.Map;
import org.apache.james.mime4j.field.datetime.DateTime;
import org.apache.james.mime4j.field.datetime.parser.DateTimeParser;
import org.apache.james.mime4j.field.datetime.parser.ParseException;
+import org.apache.james.mime4j.field.language.ContentLanguageParser;
import org.apache.james.mime4j.field.mimeversion.MimeVersionParser;
import org.apache.james.mime4j.util.MimeUtil;
@@ -33,7 +35,8 @@
* Parses and stores values for standard MIME header values.
*
*/
-public class MaximalBodyDescriptor extends DefaultBodyDescriptor implements
RFC2045MimeDescriptor, RFC2183ContentDispositionDescriptor {
+public class MaximalBodyDescriptor extends DefaultBodyDescriptor implements
RFC2045MimeDescriptor,
+ RFC2183ContentDispositionDescriptor, RFC3066ContentLanguageDescriptor {
private static final int DEFAULT_MINOR_VERSION = 0;
private static final int DEFAULT_MAJOR_VERSION = 1;
@@ -56,6 +59,9 @@
private long contentDispositionSize;
private MimeException contentDispositionSizeParseException;
private boolean isContentDispositionSet;
+ private List contentLanguage;
+ private MimeException contentLanguageParseException;
+ private boolean isContentLanguageSet;
protected MaximalBodyDescriptor() {
this(null);
@@ -81,6 +87,9 @@
this.contentDispositionSize = -1;
this.contentDispositionSizeParseException = null;
this.isContentDispositionSet = false;
+ this.contentLanguage = null;
+ this.contentLanguageParseException = null;
+ this.isContentIdSet = false;
}
public void addField(String name, String value) {
@@ -93,10 +102,24 @@
parseContentDescription(value);
} else if (MimeUtil.MIME_HEADER_CONTENT_DISPOSITION.equals(name) &&
!isContentDispositionSet) {
parseContentDisposition(value);
+ } else if (MimeUtil.MIME_HEADER_LANGAUGE.equals(name) &&
!isContentLanguageSet) {
+ parseLanguageTag(value);
} else {
super.addField(name, value);
}
}
+
+ private void parseLanguageTag(final String value) {
+ isContentLanguageSet = true;
+ if (value != null) {
+ try {
+ final ContentLanguageParser parser = new
ContentLanguageParser(new StringReader(value));
+ contentLanguage = parser.parse();
+ } catch (MimeException e) {
+ contentLanguageParseException = e;
+ }
+ }
+ }
private void parseContentDisposition(final String value) {
isContentDispositionSet = true;
@@ -110,7 +133,7 @@
this.contentDispositionModificationDate =
parseDate(contentDispositionModificationDate);
} catch (ParseException e) {
this.contentDispositionModificationDateParseException = e;
- }
+ }
}
final String contentDispositionCreationDate
@@ -300,5 +323,17 @@
return contentDispositionSizeParseException;
}
-
+ /**
+ * @see
org.apache.james.mime4j.RFC3066ContentLanguageDescriptor#getContentLanguage()
+ */
+ public List getContentLanguage() {
+ return contentLanguage;
+ }
+
+ /**
+ * @see
org.apache.james.mime4j.RFC3066ContentLanguageDescriptor#getContentLanguageParseException()
+ */
+ public MimeException getContentLanguageParseException() {
+ return contentLanguageParseException;
+ }
}
Added:
james/mime4j/trunk/src/main/java/org/apache/james/mime4j/RFC3066ContentLanguageDescriptor.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/RFC3066ContentLanguageDescriptor.java?rev=670333&view=auto
==============================================================================
---
james/mime4j/trunk/src/main/java/org/apache/james/mime4j/RFC3066ContentLanguageDescriptor.java
(added)
+++
james/mime4j/trunk/src/main/java/org/apache/james/mime4j/RFC3066ContentLanguageDescriptor.java
Sun Jun 22 03:34:32 2008
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.james.mime4j;
+
+import java.util.List;
+
+/**
+ * Describes RFC3066 content-language headers.
+ */
+public interface RFC3066ContentLanguageDescriptor {
+
+ /**
+ * Get the <code>content-language</code> header values.
+ * Each applicable language tag will be returned in order.
+ * See <a href='http://tools.ietf.org/html/rfc4646'>RFC4646</a>
+ * <cite>http://tools.ietf.org/html/rfc4646</cite>.
+ * @return list of language tag Strings,
+ * or null if no header exists
+ */
+ public abstract List getContentLanguage();
+
+ /**
+ * Gets any exception thrown during the parsing of [EMAIL PROTECTED]
#getContentLanguage()}
+ * @return <code>ParseException</code> when the content-language parse
fails,
+ * null otherwise
+ */
+ public abstract MimeException getContentLanguageParseException();
+
+}
\ No newline at end of file
Modified:
james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MimeUtil.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MimeUtil.java?rev=670333&r1=670332&r2=670333&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MimeUtil.java
(original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/MimeUtil.java
Sun Jun 22 03:34:32 2008
@@ -24,6 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.james.mime4j.BodyDescriptor;
/**
@@ -90,6 +91,11 @@
* See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
*/
public static final String PARAM_SIZE = "size";
+ /**
+ * <code>Langauge-Tag</code> header (lower case).
+ * See <a href='http://www.faqs.org/rfcs/rfc4646.html'>RFC4646</a>.
+ */
+ public static final String MIME_HEADER_LANGAUGE = "content-language";
private MimeUtil() {
// this is an utility class to be used statically.
Modified:
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/contenttype/ContentTypeParser.jj
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/contenttype/ContentTypeParser.jj?rev=670333&r1=670332&r2=670333&view=diff
==============================================================================
---
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/contenttype/ContentTypeParser.jj
(original)
+++
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/contenttype/ContentTypeParser.jj
Sun Jun 22 03:34:32 2008
@@ -29,6 +29,7 @@
STATIC=false;
LOOKAHEAD=1;
JDK_VERSION = "1.4";
+ OUTPUT_DIRECTORY =
"../../../../../../../../../target/generated-sources/javacc";
//DEBUG_PARSER=true;
//DEBUG_TOKEN_MANAGER=true;
}
Modified:
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj?rev=670333&r1=670332&r2=670333&view=diff
==============================================================================
---
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
(original)
+++
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/datetime/DateTimeParser.jj
Sun Jun 22 03:34:32 2008
@@ -28,6 +28,7 @@
options {
STATIC=false;
LOOKAHEAD=1;
+ OUTPUT_DIRECTORY =
"../../../../../../../../../target/generated-sources/javacc";
//DEBUG_PARSER=true;
//DEBUG_TOKEN_MANAGER=true;
}
Added:
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/language/ContentLanguageParser.jj
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/language/ContentLanguageParser.jj?rev=670333&view=auto
==============================================================================
---
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/language/ContentLanguageParser.jj
(added)
+++
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/language/ContentLanguageParser.jj
Sun Jun 22 03:34:32 2008
@@ -0,0 +1,209 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+options {
+ static=false;
+ JDK_VERSION = "1.4";
+ OUTPUT_DIRECTORY =
"../../../../../../../../../target/generated-sources/javacc";
+}
+
+PARSER_BEGIN(ContentLanguageParser)
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+package org.apache.james.mime4j.field.language;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ContentLanguageParser {
+ private ArrayList languages = new ArrayList();
+
+ /**
+ * Parses the input into a list of language tags.
+ * @return list of language tag Strings
+ */
+ public List parse() throws ParseException {
+ try {
+ return doParse();
+ } catch (TokenMgrError e) {
+ // An issue with the TOKENiser
+ // but it's not polite to throw an Error
+ // when executing on a server
+ throw new ParseException(e);
+ }
+ }
+}
+PARSER_END(ContentLanguageParser)
+
+private List doParse() :
+{
+}
+{
+ language() ( "," language() )*
+ {return languages;}
+}
+
+String language() :
+{
+ Token token;
+ StringBuffer languageTag = new StringBuffer();
+ String result;
+}
+{
+ token = <ALPHA>
+ {
+ languageTag.append(token.image);
+ }
+ (
+ "-"
+// This keeps TOKENising simple
+ token = <ALPHA>
+ {
+ languageTag.append('-');
+ languageTag.append(token.image);
+ }
+ |
+ token = <ALPHANUM>
+ {
+ languageTag.append('-');
+ languageTag.append(token.image);
+ }
+ )*
+
+ {
+ result = languageTag.toString();
+ languages.add(result);
+ return result;
+ }
+}
+
+
+
+
+SPECIAL_TOKEN :
+{
+ < WS: ( [" ", "\t", "\r", "\n"] )+ >
+}
+
+TOKEN_MGR_DECLS :
+{
+ // Keeps track of how many levels of comment nesting
+ // we've encountered. This is only used when the 2nd
+ // level is reached, for example ((this)), not (this).
+ // This is because the outermost level must be treated
+ // specially anyway, because the outermost ")" has a
+ // different token type than inner ")" instances.
+ int commentNest;
+}
+
+
+MORE :
+{
+ // starts a comment
+ "(" : INCOMMENT
+}
+
+<INCOMMENT>
+SKIP :
+{
+ // ends a comment
+ < COMMENT: ")" > : DEFAULT
+ // if this is ever changed to not be a SKIP, need
+ // to make sure matchedToken.token = token.toString()
+ // is called.
+}
+
+<INCOMMENT>
+MORE :
+{
+ < <QUOTEDPAIR>> { image.deleteCharAt(image.length() - 2); }
+| "(" { commentNest = 1; } : NESTED_COMMENT
+| < <ANY>>
+}
+
+<NESTED_COMMENT>
+MORE :
+{
+ < <QUOTEDPAIR>> { image.deleteCharAt(image.length() - 2); }
+| "(" { ++commentNest; }
+| ")" { --commentNest; if (commentNest == 0) SwitchTo(INCOMMENT); }
+| < <ANY>>
+}
+// QUOTED STRINGS
+
+MORE :
+{
+ "\"" { image.deleteCharAt(image.length() - 1); } : INQUOTEDSTRING
+}
+
+<INQUOTEDSTRING>
+MORE :
+{
+ < <QUOTEDPAIR>> { image.deleteCharAt(image.length() - 2); }
+| < (~["\"", "\\"])+ >
+}
+
+<INQUOTEDSTRING>
+TOKEN :
+{
+ < QUOTEDSTRING: "\"" > { matchedToken.image = image.substring(0,
image.length() - 1); } : DEFAULT
+}
+
+TOKEN :
+{
+ < DIGITS: ( ["0"-"9"] )+ >
+}
+
+TOKEN :
+{
+ < ALPHA: ( ["a"-"z"] | ["A"-"Z"] )+ >
+}
+
+TOKEN :
+{
+ <ALPHANUM : ( ["0"-"9"] | ["a"-"z"] | ["A"-"Z"] )+>
+}
+
+TOKEN :
+{
+ < DOT: "." >
+}
+
+<*>
+TOKEN :
+{
+ < #QUOTEDPAIR: "\\" <ANY> >
+| < #ANY: ~[] >
+}
\ No newline at end of file
Added:
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/language/ParseException.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/language/ParseException.java?rev=670333&view=auto
==============================================================================
---
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/language/ParseException.java
(added)
+++
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/language/ParseException.java
Sun Jun 22 03:34:32 2008
@@ -0,0 +1,217 @@
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0
*/
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+package org.apache.james.mime4j.field.language;
+
+import org.apache.james.mime4j.MimeException;
+
+/**
+ * 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.
+ *
+ * This class was modified to extend MimeException
+ * and to add a seriaVersionUID.
+ */
+public class ParseException extends MimeException {
+
+ /**
+ * 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("Cannot parse field");
+ 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("Cannot parse field");
+ specialConstructor = false;
+ }
+
+ public ParseException(Throwable t) {
+ this(t.getMessage());
+ initCause(t);
+ }
+
+ 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();
+ }
+
+}
Modified:
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/mimeversion/MimeVersionParser.jj
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/mimeversion/MimeVersionParser.jj?rev=670333&r1=670332&r2=670333&view=diff
==============================================================================
---
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/mimeversion/MimeVersionParser.jj
(original)
+++
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/mimeversion/MimeVersionParser.jj
Sun Jun 22 03:34:32 2008
@@ -20,7 +20,7 @@
options {
static=false;
JDK_VERSION = "1.4";
- OUTPUT_DIRECTORY = "target/generated-sources/javacc";
+ OUTPUT_DIRECTORY =
"../../../../../../../../../target/generated-sources/javacc";
}
PARSER_BEGIN(MimeVersionParser)
Modified:
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/mimeversion/ParseException.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/mimeversion/ParseException.java?rev=670333&r1=670332&r2=670333&view=diff
==============================================================================
---
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/mimeversion/ParseException.java
(original)
+++
james/mime4j/trunk/src/main/javacc/org/apache/james/mime4j/field/mimeversion/ParseException.java
Sun Jun 22 03:34:32 2008
@@ -70,7 +70,7 @@
super("Cannot parse field");
specialConstructor = false;
}
-
+
public ParseException(String message) {
super(message);
specialConstructor = false;
Modified:
james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java?rev=670333&r1=670332&r2=670333&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java
(original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/ExampleMail.java
Sun Jun 22 03:34:32 2008
@@ -134,6 +134,7 @@
"--=-tIdGYVstQJghyEDATnJ+\r\n" +
"Content-Disposition: attachment; filename=rhubarb.txt\r\n" +
"Content-Type: text/plain; name=rhubarb.txt; charset=us-ascii\r\n" +
+ "Content-Language: en, en-US, en-CA\r\n" +
"Content-Transfer-Encoding: quoted-printable\r\n" +
"\r\n" +
"Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb
Rhubarb Rhu=\r\n" +
Modified:
james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MaximalBodyDescriptorTest.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MaximalBodyDescriptorTest.java?rev=670333&r1=670332&r2=670333&view=diff
==============================================================================
---
james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MaximalBodyDescriptorTest.java
(original)
+++
james/mime4j/trunk/src/test/java/org/apache/james/mime4j/MaximalBodyDescriptorTest.java
Sun Jun 22 03:34:32 2008
@@ -106,7 +106,16 @@
assertEquals(10234, descriptor.getContentDispositionSize());
}
- private RFC2183ContentDispositionDescriptor describe(byte[] mail, int
zeroBasedPart) throws Exception {
+ public void testLanguageTagParameters() throws Exception {
+ RFC3066ContentLanguageDescriptor descriptor =
describe(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES, 3);
+ assertNotNull(descriptor.getContentLanguage());
+ assertEquals(3, descriptor.getContentLanguage().size());
+ assertEquals("en", descriptor.getContentLanguage().get(0));
+ assertEquals("en-US", descriptor.getContentLanguage().get(1));
+ assertEquals("en-CA", descriptor.getContentLanguage().get(2));
+ }
+
+ private MaximalBodyDescriptor describe(byte[] mail, int zeroBasedPart)
throws Exception {
ByteArrayInputStream bias = new ByteArrayInputStream(mail);
parser.parse(bias);
int state = parser.next();
@@ -120,7 +129,7 @@
BodyDescriptor descriptor = parser.getBodyDescriptor();
assertNotNull(descriptor);
assertTrue("Parser is maximal so body descriptor should be maximal",
descriptor instanceof MaximalBodyDescriptor);
- return (RFC2183ContentDispositionDescriptor) descriptor;
+ return (MaximalBodyDescriptor) descriptor;
}
private MaximalBodyDescriptor describe(byte[] mail) throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]