harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r350181 [138/198] - in /incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core: ./ depends/ depends/files/ depends/jars/ depends/libs/ depends/libs/linux.IA32/ depends/libs/win.IA32/ depends/oss/ depends/oss/linux.IA32/ depends/oss/win....
Date Thu, 01 Dec 2005 06:04:00 GMT
Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/RuleBasedBreakIterator.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/RuleBasedBreakIterator.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/RuleBasedBreakIterator.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/RuleBasedBreakIterator.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,189 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.text;
+
+
+/*
+ * Default implmentation of BreakIterator, wrap
+ * com.ibm.icu.text.RuleBasedBreakIterator
+ * 
+ */
+class RuleBasedBreakIterator extends BreakIterator {
+
+	/*
+	 * Wraping construction
+	 */
+	RuleBasedBreakIterator(com.ibm.icu.text.BreakIterator iterator) {
+		super(iterator);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.text.BreakIterator#current()
+	 */
+	public int current() {
+		return wrapped.current();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.text.BreakIterator#first()
+	 */
+	public int first() {
+		return wrapped.first();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.text.BreakIterator#following(int)
+	 */
+	public int following(int offset) {
+		validateOffset(offset);
+		return wrapped.following(offset);
+	}
+
+	/*
+	 * check the offset, throw exception if it is invalid
+	 */
+	private void validateOffset(int offset) {
+		CharacterIterator it = wrapped.getText();
+		if (offset < it.getBeginIndex() || offset >= it.getEndIndex()) {
+			throw new IllegalArgumentException();
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.text.BreakIterator#getText()
+	 */
+	public CharacterIterator getText() {
+		return wrapped.getText();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.text.BreakIterator#last()
+	 */
+	public int last() {
+		return wrapped.last();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.text.BreakIterator#next()
+	 */
+	public int next() {
+		return wrapped.next();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.text.BreakIterator#next(int)
+	 */
+	public int next(int n) {
+		return wrapped.next(n);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.text.BreakIterator#previous()
+	 */
+	public int previous() {
+		return wrapped.previous();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.text.BreakIterator#setText(java.text.CharacterIterator)
+	 */
+	public void setText(CharacterIterator newText) {
+		// call a method to check if null pointer
+		newText.current();
+		wrapped.setText(newText);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.text.BreakIterator#isBoundary(int)
+	 */
+	public boolean isBoundary(int offset) {
+		validateOffset(offset);
+		return wrapped.isBoundary(offset);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.text.BreakIterator#preceding(int)
+	 */
+	public int preceding(int offset) {
+		validateOffset(offset);
+		return wrapped.preceding(offset);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#equals(java.lang.Object)
+	 */
+	public boolean equals(Object o) {
+		if (!(o instanceof RuleBasedBreakIterator)) {
+			return false;
+		}
+		return wrapped.equals(((RuleBasedBreakIterator) o).wrapped);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#toString()
+	 */
+	public String toString() {
+		return wrapped.toString();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#hashCode()
+	 */
+	public int hashCode() {
+		return wrapped.hashCode();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		RuleBasedBreakIterator cloned = (RuleBasedBreakIterator) super.clone();
+		cloned.wrapped = (com.ibm.icu.text.RuleBasedBreakIterator) wrapped
+				.clone();
+		return cloned;
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/RuleBasedCollator.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/RuleBasedCollator.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/RuleBasedCollator.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/RuleBasedCollator.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,185 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.text;
+
+
+/**
+ * <code>RuleBasedCollator</code> is a concrete subclass of
+ * <code>Collator</code>. It allows customization of the
+ * <code>Collator</code> via user-specified rule sets.
+ * <code>RuleBasedCollator</code> is designed to be fully compliant to the <a
+ * href="http://www.unicode.org/unicode/reports/tr10/"> Unicode Collation
+ * Algorithm (UCA) </a> and conforms to ISO 14651.
+ * </p>
+ * <p>
+ * Create a <code>RuleBasedCollator</code> from a locale by calling the
+ * <code>getInstance(Locale)</code> factory method in the base class
+ * <code>Collator</code>.<code>Collator.getInstance(Locale)</code> creates
+ * a <code>RuleBasedCollator</code> object based on the collation rules
+ * defined by the argument locale. If a customized collation is required, use
+ * the <code>RuleBasedCollator(String)</code> constructor with the appropriate
+ * rules. The customized <code>RuleBasedCollator</code> will base its ordering
+ * on UCA, while re-adjusting the attributes and orders of the characters in the
+ * specified rule accordingly.
+ * </p>
+ * 
+ */
+public class RuleBasedCollator extends Collator {
+
+	RuleBasedCollator(com.ibm.icu.text.Collator wrapper) {
+		super(wrapper);
+	}
+
+	/**
+	 * Constructs a new instance of <code>RuleBasedCollator</code> using the
+	 * specified <code>rules</code>.
+	 * 
+	 * @param rules
+	 *            the collation rules.
+	 * @throws ParseException
+	 *             when the rules contains an invalid collation rule syntax.
+	 */
+	public RuleBasedCollator(String rules) throws ParseException {
+		try {
+			this.icuColl = new com.ibm.icu.text.RuleBasedCollator(rules);
+		} catch (Exception e) {
+			if (e instanceof ParseException) {
+				throw (ParseException) e;
+			}
+			/*
+			 * -1 means it's not a ParseException. Maybe IOException thrown when
+			 * an error occured while reading internal data.
+			 */
+			throw new ParseException(e.getMessage(), -1);
+		}
+	}
+
+	/**
+	 * Obtains a <code>CollationElementIterator</code> for the given
+	 * <code>CharacterIterator</code>. The source iterator's integrity will
+	 * be preserved since a new copy will be created for use.
+	 * 
+	 * @param source
+	 *            the specified source
+	 * @return a <code>CollationElementIterator</code> for the source.
+	 */
+	public CollationElementIterator getCollationElementIterator(
+			CharacterIterator source) {
+		return new CollationElementIterator(
+				((com.ibm.icu.text.RuleBasedCollator) this.icuColl)
+						.getCollationElementIterator(source));
+	}
+
+	/**
+	 * Obtains a <code>CollationElementIterator</code> for the given String.
+	 * 
+	 * @param source
+	 *            the specified source
+	 * @return a <code>CollationElementIterator</code> for the given String
+	 */
+	public CollationElementIterator getCollationElementIterator(String source) {
+		return new CollationElementIterator(
+				((com.ibm.icu.text.RuleBasedCollator) this.icuColl)
+						.getCollationElementIterator(source));
+	}
+
+	/**
+	 * Obtains the collation rules of the <code>RuleBasedCollator</code>.
+	 * 
+	 * @return the collation rules.
+	 */
+	public String getRules() {
+		return ((com.ibm.icu.text.RuleBasedCollator) this.icuColl).getRules();
+	}
+
+	/**
+	 * Obtains the cloned object of the <code>RuleBasedCollator</code>
+	 * 
+	 * @return the cloned object of the <code>RuleBasedCollator</code>
+	 */
+	public Object clone() {
+		RuleBasedCollator clone = (RuleBasedCollator) super.clone();
+		return clone;
+	}
+
+	/**
+	 * Compares the <code>source</code> text <code>String</code> to the
+	 * <code>target</code> text <code>String</code> according to the
+	 * collation rules, strength and decomposition mode for this
+	 * <code>RuleBasedCollator</code>. See the <code>Collator</code> class
+	 * description for an example of use.
+	 * <p>
+	 * General recommendation: If comparisons are to be done to the same String
+	 * multiple times, it would be more efficient to generate
+	 * <code>CollationKeys</code> for the <code>String</code> s and use
+	 * <code>CollationKey.compareTo(CollationKey)</code> for the comparisons.
+	 * If the each Strings are compared to only once, using the method
+	 * RuleBasedCollator.compare(String, String) will have a better performance.
+	 * </p>
+	 * 
+	 * @param source
+	 *            the source text
+	 * @param target
+	 *            the target text
+	 * @return an integer which may be a negative value, zero, or else a
+	 *         positive value depending on whether <code>source</code> is less
+	 *         than, equivalent to, or greater than <code>target</code>.
+	 */
+	public int compare(String source, String target) {
+		return this.icuColl.compare(source, target);
+	}
+
+	/**
+	 * Obtains the <code>CollationKey</code> for the given source text.
+	 * 
+	 * @param source
+	 *            the speicifed source text
+	 * @return the <code>CollationKey</code> for the given source text.
+	 */
+	public CollationKey getCollationKey(String source) {
+		com.ibm.icu.text.CollationKey icuKey = this.icuColl
+				.getCollationKey(source);
+
+		return new CollationKey(source, icuKey);
+	}
+
+	/**
+	 * Obtains a unique hash code for the <code>RuleBasedCollator</code>
+	 * 
+	 * @return the hash code for the <code>RuleBasedCollator</code>
+	 */
+	public int hashCode() {
+		return ((com.ibm.icu.text.RuleBasedCollator) this.icuColl).getRules()
+				.hashCode();
+	}
+
+	/**
+	 * Compares the equality of two <code>RuleBasedCollator</code> objects.
+	 * <code>RuleBasedCollator</code> objects are equal if they have the same
+	 * collation rules and the same attributes.
+	 * 
+	 * @param obj
+	 *            the other object.
+	 * @return <code>true</code> if this <code>RuleBasedCollator</code> has
+	 *         exactly the same collation behaviour as obj, <code>false</code>
+	 *         otherwise.
+	 */
+	public boolean equals(Object obj) {
+		if (!(obj instanceof Collator))
+			return false;
+		return super.equals(obj);
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/SimpleDateFormat.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/SimpleDateFormat.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/SimpleDateFormat.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/SimpleDateFormat.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,1006 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.text;
+
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.SimpleTimeZone;
+import java.util.TimeZone;
+import java.util.Vector;
+
+/**
+ * SimpleDateFormat is used to format and parse gregorian calendar dates and
+ * times based on a pattern of date and time fields. Each date and time field is
+ * specified in the pattern by a specific character. The characters used can be
+ * either localized or non-localized. For some fields, which have both numeric
+ * and text representations or abbreviated as well as full names, the number of
+ * grouped characters specifies how the field is formatted or parsed.
+ */
+public class SimpleDateFormat extends DateFormat {
+
+	static final long serialVersionUID = 4774881970558875024L;
+
+	private static final String patternChars = "GyMdkHmsSEDFwWahKzZ";
+
+	private String pattern;
+
+	private DateFormatSymbols formatData;
+
+	transient private int creationYear;
+
+	private Date defaultCenturyStart;
+
+	/**
+	 * Constructs a new SimpleDateFormat for formatting and parsing dates and
+	 * times in the SHORT style for the default Locale.
+	 */
+	public SimpleDateFormat() {
+		this(Locale.getDefault());
+		pattern = defaultPattern();
+		formatData = new DateFormatSymbols(Locale.getDefault());
+	}
+
+	/**
+	 * Constructs a new SimpleDateFormat using the specified non-localized
+	 * pattern and the DateFormatSymbols and Calendar for the default Locale.
+	 * 
+	 * @param pattern
+	 *            the pattern
+	 * 
+	 * @exception NullPointerException
+	 *                if a <code>null</code> value of <code>pattern</code>
+	 *                is supplied.
+	 * @exception IllegalArgumentException
+	 *                if <code>pattern</code> is not considered to be useable
+	 *                by this formatter.
+	 */
+	public SimpleDateFormat(String pattern) {
+		this(pattern, Locale.getDefault());
+	}
+
+	/**
+	 * Constructs a new SimpleDateFormat using the specified non-localized
+	 * pattern and DateFormatSymbols and the Calendar for the default Locale.
+	 * 
+	 * @param template
+	 *            the pattern
+	 * @param value
+	 *            the DateFormatSymbols
+	 * 
+	 * @exception NullPointerException
+	 *                if the pattern is null
+	 * @exception IllegalArgumentException
+	 *                if the pattern is invalid
+	 */
+	public SimpleDateFormat(String template, DateFormatSymbols value) {
+		this(Locale.getDefault());
+		validatePattern(template);
+		pattern = template;
+		formatData = (DateFormatSymbols) value.clone();
+	}
+
+	/**
+	 * Constructs a new SimpleDateFormat using the specified non-localized
+	 * pattern and the DateFormatSymbols and Calendar for the specified Locale.
+	 * 
+	 * @param template
+	 *            the pattern
+	 * @param locale
+	 *            the Locale
+	 * 
+	 * @exception NullPointerException
+	 *                if the pattern is null
+	 * @exception IllegalArgumentException
+	 *                if the pattern is invalid
+	 */
+	public SimpleDateFormat(String template, Locale locale) {
+		this(locale);
+		validatePattern(template);
+		pattern = template;
+		formatData = new DateFormatSymbols(locale);
+	}
+
+	private SimpleDateFormat(Locale locale) {
+		numberFormat = NumberFormat.getInstance(locale);
+		numberFormat.setParseIntegerOnly(true);
+		numberFormat.setGroupingUsed(false);
+		calendar = new GregorianCalendar(locale);
+		calendar.add(Calendar.YEAR, -80);
+		creationYear = calendar.get(Calendar.YEAR);
+		defaultCenturyStart = calendar.getTime();
+	}
+
+	private void append(StringBuffer buffer, FieldPosition position,
+			Vector fields, char format, int count) {
+		int field = -1;
+		int index = patternChars.indexOf(format);
+		if (index == -1)
+			throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString(
+					"K002b", format));
+
+		int beginPosition = buffer.length();
+		Field dateFormatField = null;
+
+		switch (index) {
+		case ERA_FIELD:
+			dateFormatField = Field.ERA;
+			buffer.append(formatData.eras[calendar.get(Calendar.ERA)]);
+			break;
+		case YEAR_FIELD:
+			dateFormatField = Field.YEAR;
+			int year = calendar.get(Calendar.YEAR);
+			if (count < 4)
+				appendNumber(buffer, 2, year %= 100);
+			else
+				appendNumber(buffer, 4, year);
+			break;
+		case MONTH_FIELD:
+			dateFormatField = Field.MONTH;
+			int month = calendar.get(Calendar.MONTH);
+			if (count <= 2)
+				appendNumber(buffer, count, month + 1);
+			else if (count == 3)
+				buffer.append(formatData.shortMonths[month]);
+			else
+				buffer.append(formatData.months[month]);
+			break;
+		case DATE_FIELD:
+			dateFormatField = Field.DAY_OF_MONTH;
+			field = Calendar.DATE;
+			break;
+		case HOUR_OF_DAY1_FIELD: // k
+			dateFormatField = Field.HOUR_OF_DAY1;
+			int hour = calendar.get(Calendar.HOUR_OF_DAY);
+			appendNumber(buffer, count, hour == 0 ? 24 : hour);
+			break;
+		case HOUR_OF_DAY0_FIELD: // H
+			dateFormatField = Field.HOUR_OF_DAY0;
+			field = Calendar.HOUR_OF_DAY;
+			break;
+		case MINUTE_FIELD:
+			dateFormatField = Field.MINUTE;
+			field = Calendar.MINUTE;
+			break;
+		case SECOND_FIELD:
+			dateFormatField = Field.SECOND;
+			field = Calendar.SECOND;
+			break;
+		case MILLISECOND_FIELD:
+			dateFormatField = Field.MILLISECOND;
+			int value = calendar.get(Calendar.MILLISECOND);
+			appendNumber(buffer, count, value);
+			break;
+		case DAY_OF_WEEK_FIELD:
+			dateFormatField = Field.DAY_OF_WEEK;
+			int day = calendar.get(Calendar.DAY_OF_WEEK);
+			if (count < 4)
+				buffer.append(formatData.shortWeekdays[day]);
+			else
+				buffer.append(formatData.weekdays[day]);
+			break;
+		case DAY_OF_YEAR_FIELD:
+			dateFormatField = Field.DAY_OF_YEAR;
+			field = Calendar.DAY_OF_YEAR;
+			break;
+		case DAY_OF_WEEK_IN_MONTH_FIELD:
+			dateFormatField = Field.DAY_OF_WEEK_IN_MONTH;
+			field = Calendar.DAY_OF_WEEK_IN_MONTH;
+			break;
+		case WEEK_OF_YEAR_FIELD:
+			dateFormatField = Field.WEEK_OF_YEAR;
+			field = Calendar.WEEK_OF_YEAR;
+			break;
+		case WEEK_OF_MONTH_FIELD:
+			dateFormatField = Field.WEEK_OF_MONTH;
+			field = Calendar.WEEK_OF_MONTH;
+			break;
+		case AM_PM_FIELD:
+			dateFormatField = Field.AM_PM;
+			buffer.append(formatData.ampms[calendar.get(Calendar.AM_PM)]);
+			break;
+		case HOUR1_FIELD: // h
+			dateFormatField = Field.HOUR1;
+			hour = calendar.get(Calendar.HOUR);
+			appendNumber(buffer, count, hour == 0 ? 12 : hour);
+			break;
+		case HOUR0_FIELD: // K
+			dateFormatField = Field.HOUR0;
+			field = Calendar.HOUR;
+			break;
+		case TIMEZONE_FIELD: // z
+			dateFormatField = Field.TIME_ZONE;
+			appendTimeZone(buffer, count, true);
+			break;
+		case (TIMEZONE_FIELD + 1): // Z
+			dateFormatField = Field.TIME_ZONE;
+			appendTimeZone(buffer, count, false);
+			break;
+		}
+		if (field != -1)
+			appendNumber(buffer, count, calendar.get(field));
+
+		if (fields != null) {
+			position = new FieldPosition(dateFormatField);
+			position.setBeginIndex(beginPosition);
+			position.setEndIndex(buffer.length());
+			fields.add(position);
+		} else {
+			// Set to the first occurrence
+			if ((position.getFieldAttribute() == dateFormatField || (position
+					.getFieldAttribute() == null && position.getField() == index))
+					&& position.getEndIndex() == 0) {
+				position.setBeginIndex(beginPosition);
+				position.setEndIndex(buffer.length());
+			}
+		}
+	}
+
+	private void appendTimeZone(StringBuffer buffer, int count,
+			boolean generalTimezone) {
+		// cannot call TimeZone.getDisplayName() because it would not use
+		// the DateFormatSymbols of this SimpleDateFormat
+
+		if (generalTimezone) {
+			String id = calendar.getTimeZone().getID();
+			String[][] zones = formatData.zoneStrings;
+			String[] zone = null;
+			for (int i = 0; i < zones.length; i++) {
+				if (id.equals(zones[i][0])) {
+					zone = zones[i];
+					break;
+				}
+			}
+			if (zone == null) {
+				int offset = calendar.get(Calendar.ZONE_OFFSET)
+						+ calendar.get(Calendar.DST_OFFSET);
+				char sign = '+';
+				if (offset < 0) {
+					sign = '-';
+					offset = -offset;
+				}
+				buffer.append("GMT");
+				buffer.append(sign);
+				appendNumber(buffer, 2, offset / 3600000);
+				buffer.append(':');
+				appendNumber(buffer, 2, (offset % 3600000) / 60000);
+			} else {
+				int daylight = calendar.get(Calendar.DST_OFFSET) == 0 ? 0 : 2;
+				if (count < 4)
+					buffer.append(zone[2 + daylight]);
+				else
+					buffer.append(zone[1 + daylight]);
+			}
+		} else {
+			int offset = calendar.get(Calendar.ZONE_OFFSET)
+					+ calendar.get(Calendar.DST_OFFSET);
+			char sign = '+';
+			if (offset < 0) {
+				sign = '-';
+				offset = -offset;
+			}
+			buffer.append(sign);
+			appendNumber(buffer, 2, offset / 3600000);
+			appendNumber(buffer, 2, (offset % 3600000) / 60000);
+		}
+	}
+
+	private void appendNumber(StringBuffer buffer, int count, int value) {
+		numberFormat.setMinimumIntegerDigits(count);
+		numberFormat.format(new Integer(value), buffer, new FieldPosition(0));
+	}
+
+	/**
+	 * Changes the pattern of this SimpleDateFormat to the specified pattern
+	 * which uses localized pattern characters.
+	 * 
+	 * @param template
+	 *            the localized pattern
+	 */
+	public void applyLocalizedPattern(String template) {
+		pattern = convertPattern(template, formatData.getLocalPatternChars(),
+				patternChars, true);
+	}
+
+	/**
+	 * Changes the pattern of this SimpleDateFormat to the specified pattern
+	 * which uses non-localized pattern characters.
+	 * 
+	 * @param template
+	 *            the non-localized pattern
+	 * 
+	 * @exception NullPointerException
+	 *                if the pattern is null
+	 * @exception IllegalArgumentException
+	 *                if the pattern is invalid
+	 */
+	public void applyPattern(String template) {
+		validatePattern(template);
+		pattern = template;
+	}
+
+	/**
+	 * Answers a new SimpleDateFormat with the same pattern and properties as
+	 * this SimpleDateFormat.
+	 * 
+	 * @return a shallow copy of this SimpleDateFormat
+	 * 
+	 * @see java.lang.Cloneable
+	 */
+	public Object clone() {
+		SimpleDateFormat clone = (SimpleDateFormat) super.clone();
+		clone.formatData = (DateFormatSymbols) formatData.clone();
+		clone.defaultCenturyStart = new Date(defaultCenturyStart.getTime());
+		return clone;
+	}
+
+	private static String defaultPattern() {
+		ResourceBundle bundle = getBundle(Locale.getDefault());
+		String styleName = getStyleName(SHORT);
+		return bundle.getString("Date_" + styleName) + " "
+				+ bundle.getString("Time_" + styleName);
+	}
+
+	/**
+	 * Compares the specified object to this SimpleDateFormat and answer if they
+	 * are equal. The object must be an instance of SimpleDateFormat and have
+	 * the same DateFormat properties, pattern, DateFormatSymbols, and creation
+	 * year.
+	 * 
+	 * @param object
+	 *            the object to compare with this object
+	 * @return true if the specified object is equal to this SimpleDateFormat,
+	 *         false otherwise
+	 * 
+	 * @see #hashCode
+	 */
+	public boolean equals(Object object) {
+		if (this == object)
+			return true;
+		if (!(object instanceof SimpleDateFormat))
+			return false;
+		SimpleDateFormat simple = (SimpleDateFormat) object;
+		return super.equals(object) && pattern.equals(simple.pattern)
+				&& formatData.equals(simple.formatData);
+	}
+
+	private Date error(ParsePosition position, int offset, TimeZone zone) {
+		position.setErrorIndex(offset);
+		calendar.setTimeZone(zone);
+		return null;
+	}
+
+	/**
+	 * Formats the specified object using the rules of this SimpleDateFormat and
+	 * returns an AttributedCharacterIterator with the formatted Date and
+	 * attributes.
+	 * 
+	 * @param object
+	 *            the object to format
+	 * @return an AttributedCharacterIterator with the formatted date and
+	 *         attributes
+	 * 
+	 * @exception IllegalArgumentException
+	 *                when the object cannot be formatted by this Format
+	 */
+	public AttributedCharacterIterator formatToCharacterIterator(Object object) {
+		if (object instanceof Date)
+			return formatToCharacterIteratorImpl((Date) object);
+		if (object instanceof Number)
+			return formatToCharacterIteratorImpl(new Date(((Number) object)
+					.longValue()));
+		throw new IllegalArgumentException();
+	}
+
+	private AttributedCharacterIterator formatToCharacterIteratorImpl(Date date) {
+		StringBuffer buffer = new StringBuffer();
+		Vector fields = new Vector();
+
+		// format the date, and find fields
+		formatImpl(date, buffer, null, fields);
+
+		// create and AttributedString with the formatted buffer
+		AttributedString as = new AttributedString(buffer.toString());
+
+		// add DateFormat field attributes to the AttributedString
+
+		for (int i = 0; i < fields.size(); i++) {
+			FieldPosition pos = (FieldPosition) fields.elementAt(i);
+			Format.Field attribute = pos.getFieldAttribute();
+			as.addAttribute(attribute, attribute, pos.getBeginIndex(), pos
+					.getEndIndex());
+		}
+
+		// return the CharacterIterator from AttributedString
+		return as.getIterator();
+	}
+
+	/**
+	 * Formats the specified Date into the specified StringBuffer using the
+	 * pattern of this SimpleDateFormat. If the field specified by the
+	 * FieldPosition is formatted, set the begin and end index of the formatted
+	 * field in the FieldPosition.
+	 * 
+	 * @param date
+	 *            the Date to format
+	 * @param buffer
+	 *            the StringBuffer
+	 * @param field
+	 *            the FieldPosition
+	 * @return the StringBuffer parameter <code>buffer</code>
+	 * 
+	 * @exception IllegalArgumentException
+	 *                when there are invalid characters in the pattern
+	 */
+	public StringBuffer format(Date date, StringBuffer buffer,
+			FieldPosition field) {
+		return formatImpl(date, buffer, field, null);
+	}
+
+	/**
+	 * Validate the format character.
+	 * 
+	 * @param format
+	 *            the format character
+	 * 
+	 * @throws IllegalArgumentException
+	 *             when the format character is invalid
+	 */
+	private void validateFormat(char format) {
+		int index = patternChars.indexOf(format);
+		if (index == -1)
+			throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString(
+					"K002b", format));
+	}
+
+	/**
+	 * Validate the pattern.
+	 * 
+	 * @param template
+	 *            the pattern to validate.
+	 * 
+	 * @throws NullPointerException
+	 *             if the pattern is null
+	 * @throws IllegalArgumentException
+	 *             if the pattern is invalid
+	 */
+	private void validatePattern(String template) {
+		boolean quote = false;
+		int next, last = -1, count = 0;
+
+		final int patternLength = template.length();
+		for (int i = 0; i < patternLength; i++) {
+			next = (template.charAt(i));
+			if (next == '\'') {
+				if (count > 0) {
+					validateFormat((char) last);
+					count = 0;
+				}
+				if (last == next) {
+					last = -1;
+				} else
+					last = next;
+				quote = !quote;
+				continue;
+			}
+			if (!quote
+					&& (last == next || (next >= 'a' && next <= 'z') || (next >= 'A' && next <= 'Z'))) {
+				if (last == next)
+					count++;
+				else {
+					if (count > 0)
+						validateFormat((char) last);
+					last = next;
+					count = 1;
+				}
+			} else {
+				if (count > 0) {
+					validateFormat((char) last);
+					count = 0;
+				}
+				last = -1;
+			}
+		}
+		if (count > 0)
+			validateFormat((char) last);
+
+		if (quote)
+			throw new IllegalArgumentException(com.ibm.oti.util.Msg
+					.getString("K0019"));
+
+	}
+
+	/**
+	 * Formats the date.
+	 * <p>
+	 * If the FieldPosition <code>field</code> is not null, and the field
+	 * specified by this FieldPosition is formatted, set the begin and end index
+	 * of the formatted field in the FieldPosition.
+	 * <p>
+	 * If the Vector <code>fields</code> is not null, find fields of this
+	 * date, set FieldPositions with these fields, and add them to the fields
+	 * vector.
+	 * 
+	 * @param date
+	 *            Date to Format
+	 * @param buffer
+	 *            StringBuffer to store the resulting formatted String
+	 * @param field
+	 *            FieldPosition to set begin and end index of the field
+	 *            specifed, if it is part of the format for this date
+	 * @param fields
+	 *            Vector used to store the FieldPositions for each field in this
+	 *            date
+	 * 
+	 * @return the formatted Date
+	 * 
+	 * @exception IllegalArgumentException
+	 *                when the object cannot be formatted by this Format
+	 */
+	private StringBuffer formatImpl(Date date, StringBuffer buffer,
+			FieldPosition field, Vector fields) {
+
+		boolean quote = false;
+		int next, last = -1, count = 0;
+		calendar.setTime(date);
+		if (field != null)
+			field.clear();
+
+		final int patternLength = pattern.length();
+		for (int i = 0; i < patternLength; i++) {
+			next = (pattern.charAt(i));
+			if (next == '\'') {
+				if (count > 0) {
+					append(buffer, field, fields, (char) last, count);
+					count = 0;
+				}
+				if (last == next) {
+					buffer.append('\'');
+					last = -1;
+				} else
+					last = next;
+				quote = !quote;
+				continue;
+			}
+			if (!quote
+					&& (last == next || (next >= 'a' && next <= 'z') || (next >= 'A' && next <= 'Z'))) {
+				if (last == next)
+					count++;
+				else {
+					if (count > 0)
+						append(buffer, field, fields, (char) last, count);
+					last = next;
+					count = 1;
+				}
+			} else {
+				if (count > 0) {
+					append(buffer, field, fields, (char) last, count);
+					count = 0;
+				}
+				last = -1;
+				buffer.append((char) next);
+			}
+		}
+		if (count > 0)
+			append(buffer, field, fields, (char) last, count);
+		return buffer;
+	}
+
+	/**
+	 * Answers the Date which is the start of the one hundred year period for
+	 * two digits year values.
+	 * 
+	 * @return a Date
+	 */
+	public Date get2DigitYearStart() {
+		return defaultCenturyStart;
+	}
+
+	/**
+	 * Answers the DateFormatSymbols used by this SimpleDateFormat.
+	 * 
+	 * @return a DateFormatSymbols
+	 */
+	public DateFormatSymbols getDateFormatSymbols() {
+		// Return a clone so the arrays in the ResourceBundle are not modified
+		return (DateFormatSymbols) formatData.clone();
+	}
+
+	/**
+	 * Answers an integer hash code for the receiver. Objects which are equal
+	 * answer the same value for this method.
+	 * 
+	 * @return the receiver's hash
+	 * 
+	 * @see #equals
+	 */
+	public int hashCode() {
+		return super.hashCode() + pattern.hashCode() + formatData.hashCode()
+				+ creationYear;
+	}
+
+	private int parse(String string, int offset, char format, int count) {
+		int index = patternChars.indexOf(format);
+		if (index == -1)
+			throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString(
+					"K002b", format));
+		int field = -1;
+		int absolute = 0;
+		if (count < 0) {
+			count = -count;
+			absolute = count;
+		}
+		switch (index) {
+		case ERA_FIELD:
+			return parseText(string, offset, formatData.eras, Calendar.ERA);
+		case YEAR_FIELD:
+			if (count >= 3)
+				field = Calendar.YEAR;
+			else {
+				ParsePosition position = new ParsePosition(offset);
+				Number result = parseNumber(absolute, string, position);
+				if (result == null)
+					return -position.getErrorIndex() - 1;
+				int year = result.intValue();
+				// A two digit year must be exactly two digits, i.e. 01
+				if ((position.getIndex() - offset) == 2 && year >= 0) {
+					year += creationYear / 100 * 100;
+					if (year < creationYear)
+						year += 100;
+				}
+				calendar.set(Calendar.YEAR, year);
+				return position.getIndex();
+			}
+			break;
+		case MONTH_FIELD:
+			if (count <= 2)
+				return parseNumber(absolute, string, offset, Calendar.MONTH, -1);
+			index = parseText(string, offset, formatData.months, Calendar.MONTH);
+			if (index < 0)
+				return parseText(string, offset, formatData.shortMonths,
+						Calendar.MONTH);
+			return index;
+		case DATE_FIELD:
+			field = Calendar.DATE;
+			break;
+		case HOUR_OF_DAY1_FIELD:
+			ParsePosition position = new ParsePosition(offset);
+			Number result = parseNumber(absolute, string, position);
+			if (result == null)
+				return -position.getErrorIndex() - 1;
+			int hour = result.intValue();
+			if (hour == 24)
+				hour = 0;
+			calendar.set(Calendar.HOUR_OF_DAY, hour);
+			return position.getIndex();
+		case HOUR_OF_DAY0_FIELD:
+			field = Calendar.HOUR_OF_DAY;
+			break;
+		case MINUTE_FIELD:
+			field = Calendar.MINUTE;
+			break;
+		case SECOND_FIELD:
+			field = Calendar.SECOND;
+			break;
+		case MILLISECOND_FIELD:
+			field = Calendar.MILLISECOND;
+			break;
+		case DAY_OF_WEEK_FIELD:
+			index = parseText(string, offset, formatData.weekdays,
+					Calendar.DAY_OF_WEEK);
+			if (index < 0)
+				return parseText(string, offset, formatData.shortWeekdays,
+						Calendar.DAY_OF_WEEK);
+			return index;
+		case DAY_OF_YEAR_FIELD:
+			field = Calendar.DAY_OF_YEAR;
+			break;
+		case DAY_OF_WEEK_IN_MONTH_FIELD:
+			field = Calendar.DAY_OF_WEEK_IN_MONTH;
+			break;
+		case WEEK_OF_YEAR_FIELD:
+			field = Calendar.WEEK_OF_YEAR;
+			break;
+		case WEEK_OF_MONTH_FIELD:
+			field = Calendar.WEEK_OF_MONTH;
+			break;
+		case AM_PM_FIELD:
+			return parseText(string, offset, formatData.ampms, Calendar.AM_PM);
+		case HOUR1_FIELD:
+			position = new ParsePosition(offset);
+			result = parseNumber(absolute, string, position);
+			if (result == null)
+				return -position.getErrorIndex() - 1;
+			hour = result.intValue();
+			if (hour == 12)
+				hour = 0;
+			calendar.set(Calendar.HOUR, hour);
+			return position.getIndex();
+		case HOUR0_FIELD:
+			field = Calendar.HOUR;
+			break;
+		case TIMEZONE_FIELD:
+			return parseTimeZone(string, offset);
+		case (TIMEZONE_FIELD + 1):
+			return parseTimeZone(string, offset);
+		}
+		if (field != -1)
+			return parseNumber(absolute, string, offset, field, 0);
+		return offset;
+	}
+
+	/**
+	 * Parse a Date from the specified String starting at the index specified by
+	 * the ParsePosition. If the string is successfully parsed, the index of the
+	 * ParsePosition is updated to the index following the parsed text.
+	 * 
+	 * @param string
+	 *            the String to parse according to the pattern of this
+	 *            SimpleDateFormat
+	 * @param position
+	 *            the ParsePosition, updated on return with the index following
+	 *            the parsed text, or on error the index is unchanged and the
+	 *            error index is set to the index where the error occurred
+	 * @return the Date resulting from the parse, or null if there is an error
+	 * 
+	 * @exception IllegalArgumentException
+	 *                when there are invalid characters in the pattern
+	 */
+	public Date parse(String string, ParsePosition position) {
+		boolean quote = false;
+		int next, last = -1, count = 0, offset = position.getIndex();
+		int length = string.length();
+		calendar.clear();
+		TimeZone zone = calendar.getTimeZone();
+		final int patternLength = pattern.length();
+		for (int i = 0; i < patternLength; i++) {
+			next = pattern.charAt(i);
+			if (next == '\'') {
+				if (count > 0) {
+					if ((offset = parse(string, offset, (char) last, count)) < 0)
+						return error(position, -offset - 1, zone);
+					count = 0;
+				}
+				if (last == next) {
+					if (offset >= length || string.charAt(offset) != '\'')
+						return error(position, offset, zone);
+					offset++;
+					last = -1;
+				} else
+					last = next;
+				quote = !quote;
+				continue;
+			}
+			if (!quote
+					&& (last == next || (next >= 'a' && next <= 'z') || (next >= 'A' && next <= 'Z'))) {
+				if (last == next)
+					count++;
+				else {
+					if (count > 0) {
+						if ((offset = parse(string, offset, (char) last, -count)) < 0)
+							return error(position, -offset - 1, zone);
+					}
+					last = next;
+					count = 1;
+				}
+			} else {
+				if (count > 0) {
+					if ((offset = parse(string, offset, (char) last, count)) < 0)
+						return error(position, -offset - 1, zone);
+					count = 0;
+				}
+				last = -1;
+				if (offset >= length || string.charAt(offset) != next)
+					return error(position, offset, zone);
+				offset++;
+			}
+		}
+		if (count > 0) {
+			if ((offset = parse(string, offset, (char) last, count)) < 0)
+				return error(position, -offset - 1, zone);
+		}
+		Date date;
+		try {
+			date = calendar.getTime();
+		} catch (IllegalArgumentException e) {
+			return error(position, offset, zone);
+		}
+		position.setIndex(offset);
+		calendar.setTimeZone(zone);
+		return date;
+	}
+
+	private Number parseNumber(int max, String string, ParsePosition position) {
+		if (max == 0)
+			return numberFormat.parse(string, position);
+		int digit, length = string.length(), result = 0;
+		int index = position.getIndex();
+		if (max > 0 && max < length - index)
+			length = index + max;
+		while (index < length
+				&& (digit = Character.digit(string.charAt(index), 10)) != -1) {
+			index++;
+			result = result * 10 + digit;
+		}
+		if (index == position.getIndex()) {
+			position.setErrorIndex(index);
+			return null;
+		}
+		position.setIndex(index);
+		return new Integer(result);
+	}
+
+	private int parseNumber(int max, String string, int offset, int field,
+			int skew) {
+		ParsePosition position = new ParsePosition(offset);
+		Number result = parseNumber(max, string, position);
+		if (result == null)
+			return -position.getErrorIndex() - 1;
+		calendar.set(field, result.intValue() + skew);
+		return position.getIndex();
+	}
+
+	private int parseText(String string, int offset, String[] text, int field) {
+		int found = -1;
+		for (int i = 0; i < text.length; i++) {
+			if (text[i].length() == 0)
+				continue;
+			if (string
+					.regionMatches(true, offset, text[i], 0, text[i].length())) {
+				// Search for the longest match, in case some fields are subsets
+				if (found == -1 || text[i].length() > text[found].length())
+					found = i;
+			}
+		}
+		if (found != -1) {
+			calendar.set(field, found);
+			return offset + text[found].length();
+		}
+		return -offset - 1;
+	}
+
+	private int parseTimeZone(String string, int offset) {
+		String[][] zones = formatData.zoneStrings;
+		boolean foundGMT = string.regionMatches(offset, "GMT", 0, 3);
+		if (foundGMT)
+			offset += 3;
+		char sign;
+		if (offset < string.length()
+				&& ((sign = string.charAt(offset)) == '+' || sign == '-')) {
+			ParsePosition position = new ParsePosition(offset + 1);
+			Number result = numberFormat.parse(string, position);
+			if (result == null)
+				return -position.getErrorIndex() - 1;
+			int hour = result.intValue();
+			int raw = hour * 3600000;
+			int index = position.getIndex();
+			if (index < string.length() && string.charAt(index) == ':') {
+				position.setIndex(index + 1);
+				result = numberFormat.parse(string, position);
+				if (result == null)
+					return -position.getErrorIndex() - 1;
+				int minute = result.intValue();
+				raw += minute * 60000;
+			} else if (hour >= 24)
+				raw = (hour / 100 * 3600000) + (hour % 100 * 60000);
+			if (sign == '-')
+				raw = -raw;
+			calendar.setTimeZone(new SimpleTimeZone(raw, ""));
+			return position.getIndex();
+		}
+		if (foundGMT) {
+			calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
+			return offset;
+		}
+		for (int i = 0; i < zones.length; i++) {
+			for (int j = 1; j < 5; j++) {
+				if (string.regionMatches(true, offset, zones[i][j], 0,
+						zones[i][j].length())) {
+					TimeZone zone = TimeZone.getTimeZone(zones[i][0]);
+					if (zone == null)
+						return -offset - 1;
+					int raw = zone.getRawOffset();
+					if (j >= 3 && zone.useDaylightTime())
+						raw += 3600000;
+					calendar.setTimeZone(new SimpleTimeZone(raw, ""));
+					return offset + zones[i][j].length();
+				}
+			}
+		}
+		return -offset - 1;
+	}
+
+	/**
+	 * Sets the Date which is the start of the one hundred year period for two
+	 * digits year values.
+	 * 
+	 * @param date
+	 *            the Date
+	 */
+	public void set2DigitYearStart(Date date) {
+		defaultCenturyStart = date;
+		Calendar cal = new GregorianCalendar();
+		cal.setTime(date);
+		creationYear = cal.get(Calendar.YEAR);
+	}
+
+	/**
+	 * Sets the DateFormatSymbols used by this SimpleDateFormat.
+	 * 
+	 * @param value
+	 *            the DateFormatSymbols
+	 */
+	public void setDateFormatSymbols(DateFormatSymbols value) {
+		formatData = (DateFormatSymbols) value.clone();
+	}
+
+	/**
+	 * Answers the pattern of this SimpleDateFormat using localized pattern
+	 * characters.
+	 * 
+	 * @return the localized pattern
+	 */
+	public String toLocalizedPattern() {
+		return convertPattern(pattern, patternChars, formatData
+				.getLocalPatternChars(), false);
+	}
+
+	/**
+	 * Answers the pattern of this SimpleDateFormat using non-localized pattern
+	 * characters.
+	 * 
+	 * @return the non-localized pattern
+	 */
+	public String toPattern() {
+		return pattern;
+	}
+
+	private static final ObjectStreamField[] serialPersistentFields = {
+			new ObjectStreamField("defaultCenturyStart", Date.class),
+			new ObjectStreamField("formatData", DateFormatSymbols.class),
+			new ObjectStreamField("pattern", String.class),
+			new ObjectStreamField("serialVersionOnStream", Integer.TYPE), };
+
+	private void writeObject(ObjectOutputStream stream) throws IOException {
+		ObjectOutputStream.PutField fields = stream.putFields();
+		fields.put("defaultCenturyStart", defaultCenturyStart);
+		fields.put("formatData", formatData);
+		fields.put("pattern", pattern);
+		fields.put("serialVersionOnStream", 1);
+		stream.writeFields();
+	}
+
+	private void readObject(ObjectInputStream stream) throws IOException,
+			ClassNotFoundException {
+		ObjectInputStream.GetField fields = stream.readFields();
+		int version = fields.get("serialVersionOnStream", 0);
+		Date date;
+		if (version > 0)
+			date = (Date) fields.get("defaultCenturyStart", new Date());
+		else
+			date = new Date();
+		set2DigitYearStart(date);
+		formatData = (DateFormatSymbols) fields.get("formatData", null);
+		pattern = (String) fields.get("pattern", "");
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/StringCharacterIterator.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/StringCharacterIterator.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/StringCharacterIterator.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/text/src/java/text/StringCharacterIterator.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,266 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.text;
+
+
+/**
+ * StringCharacterIterator is an implementation of CharacterIterator for
+ * Strings.
+ */
+public final class StringCharacterIterator implements CharacterIterator {
+
+	String string;
+
+	int start, end, offset;
+
+	/**
+	 * Constructs a new StringCharacterIterator on the specified String. The
+	 * begin and current indexes are set to the begining of the String, the end
+	 * index is set to the length of the String.
+	 * 
+	 * @param value
+	 *            the new source String to iterate
+	 */
+	public StringCharacterIterator(String value) {
+		string = value;
+		start = offset = 0;
+		end = string.length();
+	}
+
+	/**
+	 * Constructs a new StringCharacterIterator on the specified String with the
+	 * current index set to the specified value. The begin index is set to the
+	 * begining of the String, the end index is set to the length of the String.
+	 * 
+	 * @param value
+	 *            the new source String to iterate
+	 * @param location
+	 *            the current index
+	 * 
+	 * @exception IllegalArgumentException
+	 *                when the current index is less than zero or greater than
+	 *                the length of the String
+	 */
+	public StringCharacterIterator(String value, int location) {
+		string = value;
+		start = 0;
+		end = string.length();
+		if (location < 0 || location > end)
+			throw new IllegalArgumentException();
+		offset = location;
+	}
+
+	/**
+	 * Constructs a new StringCharacterIterator on the specified String with the
+	 * begin, end and current index set to the specified values.
+	 * 
+	 * @param value
+	 *            the new source String to iterate
+	 * @param start
+	 *            the index of the first character to iterate
+	 * @param end
+	 *            the index one past the last character to iterate
+	 * @param location
+	 *            the current index
+	 * 
+	 * @exception IllegalArgumentException
+	 *                when the begin index is less than zero, the end index is
+	 *                greater than the String length, the begin index is greater
+	 *                than the end index, the current index is less than the
+	 *                begin index or greater than the end index
+	 */
+	public StringCharacterIterator(String value, int start, int end,
+			int location) {
+		string = value;
+		if (start < 0 || end > string.length() || start > end
+				|| location < start || location > end)
+			throw new IllegalArgumentException();
+		this.start = start;
+		this.end = end;
+		offset = location;
+	}
+
+	/**
+	 * Answers a new StringCharacterIterator with the same source String, begin,
+	 * end, and current index as this StringCharacterIterator.
+	 * 
+	 * @return a shallow copy of this StringCharacterIterator
+	 * 
+	 * @see java.lang.Cloneable
+	 */
+	public Object clone() {
+		try {
+			return super.clone();
+		} catch (CloneNotSupportedException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * Answers the character at the current index in the source String.
+	 * 
+	 * @return the current character, or DONE if the current index is past the
+	 *         end
+	 */
+	public char current() {
+		if (offset == end)
+			return DONE;
+		return string.charAt(offset);
+	}
+
+	/**
+	 * Compares the specified object to this StringCharacterIterator and answer
+	 * if they are equal. The object must be a StringCharacterIterator iterating
+	 * over the same sequence of characters with the same index.
+	 * 
+	 * @param object
+	 *            the object to compare with this object
+	 * @return true if the specified object is equal to this
+	 *         StringCharacterIterator, false otherwise
+	 * 
+	 * @see #hashCode
+	 */
+	public boolean equals(Object object) {
+		if (!(object instanceof StringCharacterIterator))
+			return false;
+		StringCharacterIterator it = (StringCharacterIterator) object;
+		return string.equals(it.string) && start == it.start && end == it.end
+				&& offset == it.offset;
+	}
+
+	/**
+	 * Sets the current position to the begin index and answers the character at
+	 * the begin index.
+	 * 
+	 * @return the character at the begin index
+	 */
+	public char first() {
+		if (start == end)
+			return DONE;
+		offset = start;
+		return string.charAt(offset);
+	}
+
+	/**
+	 * Answers the begin index in the source String.
+	 * 
+	 * @return the index of the first character to iterate
+	 */
+	public int getBeginIndex() {
+		return start;
+	}
+
+	/**
+	 * Answers the end index in the source String.
+	 * 
+	 * @return the index one past the last character to iterate
+	 */
+	public int getEndIndex() {
+		return end;
+	}
+
+	/**
+	 * Answers the current index in the source String.
+	 * 
+	 * @return the current index
+	 */
+	public int getIndex() {
+		return offset;
+	}
+
+	/**
+	 * Answers an integer hash code for the receiver. Objects which are equal
+	 * answer the same value for this method.
+	 * 
+	 * @return the receiver's hash
+	 * 
+	 * @see #equals
+	 */
+	public int hashCode() {
+		return string.hashCode() + start + end + offset;
+	}
+
+	/**
+	 * Sets the current position to the end index - 1 and answers the character
+	 * at the current position.
+	 * 
+	 * @return the character before the end index
+	 */
+	public char last() {
+		if (start == end)
+			return DONE;
+		offset = end - 1;
+		return string.charAt(offset);
+	}
+
+	/**
+	 * Increments the current index and returns the character at the new index.
+	 * 
+	 * @return the character at the next index, or DONE if the next index is
+	 *         past the end
+	 */
+	public char next() {
+		if (offset >= (end - 1)) {
+			offset = end;
+			return DONE;
+		}
+		return string.charAt(++offset);
+	}
+
+	/**
+	 * Decrements the current index and returns the character at the new index.
+	 * 
+	 * @return the character at the previous index, or DONE if the previous
+	 *         index is past the beginning
+	 */
+	public char previous() {
+		if (offset == start)
+			return DONE;
+		return string.charAt(--offset);
+	}
+
+	/**
+	 * Sets the current index in the source String.
+	 * 
+	 * @return the character at the new index, or DONE if the index is past the
+	 *         end
+	 * 
+	 * @exception IllegalArgumentException
+	 *                when the new index is less than the begin index or greater
+	 *                than the end index
+	 */
+	public char setIndex(int location) {
+		if (location < start || location > end)
+			throw new IllegalArgumentException();
+		offset = location;
+		if (offset == end)
+			return DONE;
+		return string.charAt(offset);
+	}
+
+	/**
+	 * Sets the source String to iterate. The begin and end positions are set to
+	 * the start and end of this String.
+	 * 
+	 * @param value
+	 *            the new source String
+	 */
+	public void setText(String value) {
+		string = value;
+		start = offset = 0;
+		end = value.length();
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/README.txt
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/README.txt?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/README.txt (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/README.txt Wed Nov 30 21:29:27 2005
@@ -0,0 +1 @@
+native-src contains native source files only.

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/build.xml?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/build.xml (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/build.xml Wed Nov 30 21:29:27 2005
@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+     
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+     
+         http://www.apache.org/licenses/LICENSE-2.0
+     
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License. -->
+
+<!-- ====================================================================== 
+     build-native-source    
+     Compile the native source into component shared libs.
+     ====================================================================== -->
+<project name="build-native-source" default="default" basedir=".">
+    <description>
+		Compile the native source into component shared libs.
+    </description>
+
+    <!-- ================================= 
+          target: default              
+         ================================= -->
+    <target name="default" 
+        description="Compile the native source into component shared libs." 
+        depends="overlay-oss, make-clean, make-all, clean-layout, layout" />
+
+
+    <!-- ================================= 
+          target: clean              
+         ================================= -->
+    <target name="clean" depends="make-clean, clean-layout" />
+
+
+    <!-- ================================= 
+          target: properties
+         ================================= -->
+    <target name="properties" depends="init, windows-properties, linux-properties">
+        <property name="target.output" location="../deploy" />
+        <property name="depends.oss" location="../depends/oss" />
+        <property name="depends.libs" location="../depends/libs/${target.platform}" />
+        <property name="build.output" location="../native-bin/${target.platform}" />
+        <property name="native.src.root" location="${basedir}/${target.platform}" />
+
+        <property name="fdlibm.zip" location="${depends.oss}/fdlibm_5.2.zip" />
+        <property name="zlib.zip" location="${depends.oss}/zlib_1.2.3.zip" />
+        <property name="iculib.zip" location="${depends.oss}/${target.platform}/icu4c-3.4-harmony.zip" />
+    </target>
+
+
+    <!-- ================================= 
+          target: windows-properties              
+         ================================= -->
+    <target name="windows-properties" if="is.windows">
+        <property name="target.platform" value="./win.IA32" />
+        <property name="make.command" value="nmake.exe" />
+        <property name="exe.suffix" value=".exe" />
+        <property name="shlib.suffix" value=".dll" />
+    </target>
+
+
+    <!-- ================================= 
+          target: linux-properties              
+         ================================= -->
+    <target name="linux-properties" if="is.linux">
+        <property name="target.platform" value="./linux.IA32" />
+        <property name="make.command" value="make" />
+        <property name="exe.suffix" value="" />
+        <property name="shlib.suffix" value=".so" />
+    </target>
+
+
+    <!-- - - - - - - - - - - - - - - - - - 
+          target: init                      
+         - - - - - - - - - - - - - - - - - -->
+    <target name="init">
+        <!-- Determine our operating system -->
+        <condition property="is.windows">
+            <os family="windows" />
+        </condition>
+
+        <condition property="is.linux">
+            <os name="linux" />
+        </condition>
+    </target>
+
+    <!-- This target invokes make on the all target to compile all natives -->
+    <target name="make-all" depends="properties">
+        <exec failonerror="true" 
+            executable="${make.command}" 
+            dir="${target.platform}" 
+            output="${target.platform}/build.log">
+            <arg line="all" />
+        </exec>
+    </target>
+
+
+    <!-- ================================= 
+          target: make-clean              
+         ================================= -->
+    <target name="make-clean" depends="properties">
+        <exec failonerror="true" 
+            executable="${make.command}" 
+            dir="${target.platform}" 
+            output="${target.platform}/build.log">
+            <arg line="clean" />
+        </exec>
+    </target>
+
+
+    <!-- ================================= 
+          target: layout              
+         ================================= -->
+    <target name="layout" 
+        depends="properties" 
+        description="Construct the correct directory structure for native binaries">
+
+        <!-- Create the structure -->
+        <mkdir dir="${target.output}/jre/bin" />
+
+        <!-- Copy across the built shared libs -->
+        <copy todir="${target.output}/jre/bin" overwrite="yes">
+            <fileset dir="${target.platform}">
+                <patternset includes="*${shlib.suffix}*" />
+                <!-- Don't copy the VMI library. the one we build is a stub that is
+				     replaced by a concrete implementation by the VM-implementor -->
+                <patternset excludes="*vmi*${shlib.suffix}*" />
+            </fileset>
+        </copy>
+
+        <!-- Copy across the built executables -->
+        <copy todir="${target.output}/jre/bin" overwrite="yes">
+            <fileset dir="${target.platform}">
+                <patternset includes="java${exe.suffix}" />
+                <patternset includes="javaw${exe.suffix}" />
+            </fileset>
+        </copy>
+
+        <!-- Make sure the Linux launcher has execute permission -->
+        <chmod file="${target.output}/jre/bin/java${exe.suffix}" perm="ugo+x" />
+
+        <!-- Copy across dependency shared libs -->
+        <copy todir="${target.output}/jre/bin" overwrite="yes">
+            <fileset dir="${depends.libs}" includes="*${shlib.suffix}*" />
+        </copy>
+
+    </target>
+
+
+    <!-- ================================= 
+          target: clean-layout              
+         ================================= -->
+    <target name="clean-layout" depends="properties">
+        <delete includeemptydirs="true" failonerror="false">
+            <fileset dir="${target.output}">
+                <include name="**/bin/java${exe.suffix}" />
+                <include name="**/bin/javaw${exe.suffix}" />
+                <include name="**/bin/*${shlib.suffix}*" />
+            </fileset>
+        </delete>
+    </target>
+
+
+    <!-- ================================= 
+          target: overlay-oss              
+         ================================= -->
+    <target name="overlay-oss" depends="properties">
+        <unzip src="${fdlibm.zip}" dest="${native.src.root}/fdlibm" />
+        <chmod dir="${native.src.root}/fdlibm" perm="ugo+r" />
+
+        <unzip src="${zlib.zip}" dest="${native.src.root}/zlib" />
+        <chmod dir="${native.src.root}/zlib" perm="ugo+r" />
+
+        <unzip src="${iculib.zip}" dest="${native.src.root}" />
+        <chmod dir="${native.src.root}/include/unicode" perm="ugo+r" />
+        <chmod dir="${native.src.root}/text" perm="ugo+r" />
+    </target>
+
+</project>

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/DoxygenSupport.txt
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/DoxygenSupport.txt?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/DoxygenSupport.txt (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/DoxygenSupport.txt Wed Nov 30 21:29:27 2005
@@ -0,0 +1,24 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * This file provides the group definitions required to create the Doxygen generated
+ * output for compounds.  
+ */
+ 
+/**
+ * @defgroup HarmonyNatives Harmony JCL Natives
+ * @brief Native support for the Harmony JCL
+ */

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/adler32.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/adler32.c?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/adler32.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/adler32.c Wed Nov 30 21:29:27 2005
@@ -0,0 +1,45 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "jcl.h"
+#include "zconf.h"
+uLong adler32 PROTOTYPE ((uLong crc, const Bytef * buf, uInt size));
+
+jlong JNICALL
+Java_java_util_zip_Adler32_updateImpl (JNIEnv * env, jobject recv,
+                                       jbyteArray buf, int off, int len,
+                                       jlong crc)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  jbyte *b;
+  jboolean isCopy;
+  jlong result;
+
+  b = (*env)->GetPrimitiveArrayCritical (env, buf, &isCopy);
+  result = (jlong) adler32 ((uLong) crc, (Bytef *) (b + off), (uInt) len);
+  (*env)->ReleasePrimitiveArrayCritical (env, buf, b, JNI_ABORT);
+
+  return result;
+}
+
+jlong JNICALL
+Java_java_util_zip_Adler32_updateByteImpl (JNIEnv * env, jobject recv,
+                                           jint val, jlong crc)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  return adler32 ((uLong) crc, (Bytef *) (&val), 1);
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/archive_copyright.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/archive_copyright.c?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/archive_copyright.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/archive_copyright.c Wed Nov 30 21:29:27 2005
@@ -0,0 +1,20 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* A copyright string included in each DLL and executable */
+
+const char hyCopyright[] =
+  "(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.";
+

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/archiveglob.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/archiveglob.c?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/archiveglob.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/archiveglob.c Wed Nov 30 21:29:27 2005
@@ -0,0 +1,142 @@
+/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* HarmonyDoxygen */
+/**
+ * @file
+ * @ingroup HarmonyNatives
+ * @brief Harmony Archive natives initialization API.
+ */
+
+#include "jcl.h"
+#include "jclglob.h"
+#include "zip.h"
+
+static UDATA keyInitCount = 0;
+
+void *JCL_ID_CACHE = NULL;
+
+static void freeReferences (JNIEnv * env);
+
+/**
+ * This DLL is being loaded, do any initialization required.
+ * This may be called more than once.
+ */
+jint JNICALL
+JNI_OnLoad (JavaVM * vm, void *reserved)
+{
+  JniIDCache *idCache;
+  JNIEnv *env;
+  void *keyInitCountPtr = GLOBAL_DATA (keyInitCount);
+  void **jclIdCache = GLOBAL_DATA (JCL_ID_CACHE);
+
+  if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2) == JNI_OK)
+    {
+      PORT_ACCESS_FROM_ENV (env);
+
+      if (HY_VMLS_FNTBL (env)->
+          HYVMLSAllocKeys (env, keyInitCountPtr, jclIdCache, NULL))
+        {
+          goto fail;
+        }
+
+      /* This allocate must actually be done by hymem_allocate_memory. */
+      idCache = (JniIDCache *) hymem_allocate_memory (sizeof (JniIDCache));
+      if (!idCache)
+        goto fail2;
+
+      memset (idCache, 0, sizeof (JniIDCache));
+      HY_VMLS_SET (env, *jclIdCache, idCache);
+
+      /* Attach to the common library */
+      if (JNI_OK != ClearLibAttach (env))
+        {
+          goto fail2;
+        }
+
+      return JNI_VERSION_1_2;
+    }
+
+fail2:
+  HY_VMLS_FNTBL (env)->HYVMLSFreeKeys (env, keyInitCountPtr, jclIdCache, NULL);
+fail:
+  return 0;
+}
+
+/**
+ * This DLL is being unloaded, do any clean up required.
+ * This may be called more than once!!
+ */
+void JNICALL
+JNI_OnUnload (JavaVM * vm, void *reserved)
+{
+  JNIEnv *env;
+  void *keyInitCountPtr = GLOBAL_DATA (keyInitCount);
+  void **jclIdCache = GLOBAL_DATA (JCL_ID_CACHE);
+
+  if ((*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_2) == JNI_OK)
+    {
+      JniIDCache *idCache = (JniIDCache *) HY_VMLS_GET (env, *jclIdCache);
+
+      if (idCache)
+        {
+          JCLZipFileLink *zipfileHandles;
+          JCLZipFile *jclZipFile;
+
+          PORT_ACCESS_FROM_ENV (env);
+
+          /* Detach from the common library */
+          ClearLibDetach (env);
+
+          /* Close and free the HyZipFile handles */
+          zipfileHandles = JCL_CACHE_GET (env, zipfile_handles);
+          if (zipfileHandles != NULL)
+            {
+              jclZipFile = zipfileHandles->next;
+              while (jclZipFile != NULL)
+                {
+                  JCLZipFile *next = jclZipFile->next;
+                  zip_closeZipFile (PORTLIB, &jclZipFile->hyZipFile);
+                  jclmem_free_memory (env, jclZipFile);
+                  jclZipFile = next;
+                }
+              jclmem_free_memory (env, zipfileHandles);
+            }
+
+          /* Free any global references */
+          freeReferences (env);
+
+          /* Free VMLS keys */
+          idCache = (JniIDCache *) HY_VMLS_GET (env, *jclIdCache);
+          HY_VMLS_FNTBL (env)->HYVMLSFreeKeys (env, keyInitCountPtr,
+                                              jclIdCache, NULL);
+          hymem_free_memory (idCache);
+        }
+    }
+}
+
+/**
+ * @internal
+ */
+static void
+freeReferences (JNIEnv * env)
+{
+  jclass classRef;
+
+  /* clean up class references */
+  classRef = JCL_CACHE_GET (env, CLS_java_util_zip_ZipEntry);
+  if (classRef)
+    (*env)->DeleteWeakGlobalRef (env, (jweak) classRef);
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/deflater.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/deflater.c?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/deflater.c (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/deflater.c Wed Nov 30 21:29:27 2005
@@ -0,0 +1,280 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "jcl.h"
+#include "iohelp.h"
+
+#include "zlib.h"
+#include "inflater.h"
+#include "jclglob.h"
+#include "jclprots.h"
+
+void zfree PROTOTYPE ((void *opaque, void *address));
+void *zalloc PROTOTYPE ((void *opaque, U_32 items, U_32 size));
+
+void JNICALL
+Java_java_util_zip_Deflater_setDictionaryImpl (JNIEnv * env, jobject recv,
+					       jbyteArray dict, int off,
+					       int len, jlong handle)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  int err = 0;
+  char *dBytes;
+  JCLZipStream *stream = (JCLZipStream *) ((IDATA) handle);
+
+  dBytes = jclmem_allocate_memory (env, len);
+  if (dBytes == NULL)
+    {
+      throwNewOutOfMemoryError (env, "");
+      return;
+    }
+  (*env)->GetByteArrayRegion (env, dict, off, len, dBytes);
+  err = deflateSetDictionary (stream->stream, (Bytef *) dBytes, len);
+  if (err != Z_OK)
+    {
+      jclmem_free_memory (env, dBytes);
+      throwNewIllegalArgumentException (env, "");
+      return;
+    }
+  stream->dict = dBytes;
+}
+
+jint JNICALL
+Java_java_util_zip_Deflater_getTotalInImpl (JNIEnv * env, jobject recv,
+					    jlong handle)
+{
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  return stream->stream->total_in;
+}
+
+int JNICALL
+Java_java_util_zip_Deflater_getTotalOutImpl (JNIEnv * env, jobject recv,
+					     jlong handle)
+{
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  return stream->stream->total_out;
+}
+
+jint JNICALL
+Java_java_util_zip_Deflater_getAdlerImpl (JNIEnv * env, jobject recv,
+					  jlong handle)
+{
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+
+  return stream->stream->adler;
+}
+
+/* Create a new stream . This stream cannot be used until it has been properly initialized. */
+jlong JNICALL
+Java_java_util_zip_Deflater_createStream (JNIEnv * env, jobject recv,
+					  jint level, jint strategy,
+					  jboolean noHeader)
+{  
+  PORT_ACCESS_FROM_ENV (env);
+
+  JCLZipStream *jstream;
+  z_stream *stream;
+  int err = 0;
+  int wbits = 15;		/*Use MAX for fastest */
+
+  /*Allocate mem for wrapped struct */
+  jstream = jclmem_allocate_memory (env, sizeof (JCLZipStream));
+  if (jstream == NULL)
+    {
+      throwNewOutOfMemoryError (env, "");
+      return -1;
+    }
+  /*Allocate the z_stream */
+  stream = jclmem_allocate_memory (env, sizeof (z_stream));
+  if (stream == NULL)
+    {
+      jclmem_free_memory (env, jstream);
+      throwNewOutOfMemoryError (env, "");
+      return -1;
+    }
+  stream->opaque = (void *) privatePortLibrary;
+  stream->zalloc = zalloc;
+  stream->zfree = zfree;
+  jstream->stream = stream;
+  jstream->dict = NULL;
+  jstream->inaddr = NULL;
+
+  if (noHeader)			/*Unable to find official doc that this is the way to avoid zlib header use. However doc in zipsup.c claims it is so */
+    wbits = wbits / -1;
+  err = deflateInit2 (stream, level, Z_DEFLATED,	/*Only supported ZLIB method */
+		      wbits,	/*Window bits to use. 15 is fastest but consumes the most memory */
+		      9,	/*Memory allocation for internal compression state. 9 uses the most. */
+		      strategy);
+  if (err != Z_OK)
+    {
+      throwNewIllegalArgumentException (env, "");
+      return -1;
+    }
+
+  return (jlong) ((IDATA) jstream);
+}
+
+void JNICALL
+Java_java_util_zip_Deflater_setInputImpl (JNIEnv * env, jobject recv,
+					  jbyteArray buf, jint off, jint len,
+					  jlong handle)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  jbyte *in;
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  if (stream->inaddr != NULL)	/*Input has already been provided, free the old buffer */
+    jclmem_free_memory (env, stream->inaddr);
+  stream->inaddr = jclmem_allocate_memory (env, len);
+  if (stream->inaddr == NULL)
+    {
+      throwNewOutOfMemoryError (env, "");
+      return;
+    }
+  in = ((*env)->GetPrimitiveArrayCritical (env, buf, 0));
+  if (in == NULL)
+    return;
+  memcpy (stream->inaddr, (in + off), len);
+  ((*env)->ReleasePrimitiveArrayCritical (env, buf, in, JNI_ABORT));
+  stream->stream->next_in = (Bytef *) stream->inaddr;
+  stream->stream->avail_in = len;
+
+  return;
+}
+
+jint JNICALL
+Java_java_util_zip_Deflater_deflateImpl (JNIEnv * env, jobject recv,
+					 jbyteArray buf, int off, int len,
+					 jlong handle, int flushParm)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  jbyte *out;
+  JCLZipStream *stream;
+  jint err = 0;
+  jint sin, sout, inBytes = 0;
+
+  /* We need to get the number of bytes already read */
+  inBytes =
+    ((*env)->
+     GetIntField (env, recv,
+		  JCL_CACHE_GET (env, FID_java_util_zip_Deflater_inRead)));
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  stream->stream->avail_out = len;
+  sin = stream->stream->total_in;
+  sout = stream->stream->total_out;
+  out = ((*env)->GetPrimitiveArrayCritical (env, buf, 0));
+  if (out == NULL)
+    return -1;
+  stream->stream->next_out = (Bytef *) out + off;
+  err = deflate (stream->stream, flushParm);
+  ((*env)->ReleasePrimitiveArrayCritical (env, buf, out, 0));
+  if (err != Z_OK)
+    {
+      if (err == Z_STREAM_END)
+	{
+	  ((*env)->
+	   SetBooleanField (env, recv,
+			    JCL_CACHE_GET (env,
+					   FID_java_util_zip_Deflater_finished),
+			    JNI_TRUE));
+	  return stream->stream->total_out - sout;
+	}
+    }
+  if (flushParm != Z_FINISH)
+    {
+      /* Need to update the number of input bytes read. */
+      ((*env)->
+       SetIntField (env, recv,
+		    JCL_CACHE_GET (env, FID_java_util_zip_Deflater_inRead),
+		    (jint) stream->stream->total_in - sin + inBytes));
+    }
+  return stream->stream->total_out - sout;
+}
+
+void JNICALL
+Java_java_util_zip_Deflater_endImpl (JNIEnv * env, jobject recv, jlong handle)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+
+  deflateEnd (stream->stream);
+  if (stream->inaddr != NULL)
+    jclmem_free_memory (env, stream->inaddr);
+  if (stream->dict != NULL)
+    jclmem_free_memory (env, stream->dict);
+  jclmem_free_memory (env, stream->stream);
+  jclmem_free_memory (env, stream);
+}
+
+void JNICALL
+Java_java_util_zip_Deflater_resetImpl (JNIEnv * env, jobject recv,
+				       jlong handle)
+{
+  JCLZipStream *stream;
+
+  stream = (JCLZipStream *) ((IDATA) handle);
+  deflateReset (stream->stream);
+}
+
+void JNICALL
+Java_java_util_zip_Deflater_setLevelsImpl (JNIEnv * env, jobject recv,
+					   int level, int strategy,
+					   jlong handle)
+{
+  PORT_ACCESS_FROM_ENV (env);
+
+  JCLZipStream *stream;
+  jbyte b = 0;
+  int err = 0;
+
+  if (handle == -1)
+    {
+      throwNewIllegalStateException (env, "");
+      return;
+    }
+  stream = (JCLZipStream *) ((IDATA) handle);
+  stream->stream->next_out = (Bytef *) & b;
+  err = deflateParams (stream->stream, level, strategy);
+  if (err != Z_OK)
+    throwNewIllegalStateException (env, "");
+}
+
+void JNICALL
+Java_java_util_zip_Deflater_oneTimeInitialization (JNIEnv * env, jclass clazz)
+{
+  jfieldID fid;
+
+  fid = (*env)->GetFieldID (env, clazz, "inRead", "I");
+  if (!fid)
+    return;
+  JCL_CACHE_SET (env, FID_java_util_zip_Deflater_inRead, fid);
+
+  fid = (*env)->GetFieldID (env, clazz, "finished", "Z");
+  if (!fid)
+    return;
+  JCL_CACHE_SET (env, FID_java_util_zip_Deflater_finished, fid);
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/hyarchive.exp
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/hyarchive.exp?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/hyarchive.exp (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/linux.IA32/archive/hyarchive.exp Wed Nov 30 21:29:27 2005
@@ -0,0 +1,39 @@
+HYARCHIVE_0.1 {
+	global :
+		Java_java_util_jar_JarFile_getMetaEntriesImpl;
+		Java_java_util_zip_Adler32_updateByteImpl;
+		Java_java_util_zip_Adler32_updateImpl;
+		Java_java_util_zip_CRC32_updateByteImpl;
+		Java_java_util_zip_CRC32_updateImpl;
+		Java_java_util_zip_Deflater_createStream;
+		Java_java_util_zip_Deflater_deflateImpl;
+		Java_java_util_zip_Deflater_endImpl;
+		Java_java_util_zip_Deflater_getAdlerImpl;
+		Java_java_util_zip_Deflater_getTotalInImpl;
+		Java_java_util_zip_Deflater_getTotalOutImpl;
+		Java_java_util_zip_Deflater_oneTimeInitialization;
+		Java_java_util_zip_Deflater_resetImpl;
+		Java_java_util_zip_Deflater_setDictionaryImpl;
+		Java_java_util_zip_Deflater_setInputImpl;
+		Java_java_util_zip_Deflater_setLevelsImpl;
+		Java_java_util_zip_Inflater_createStream;
+		Java_java_util_zip_Inflater_endImpl;
+		Java_java_util_zip_Inflater_getAdlerImpl;
+		Java_java_util_zip_Inflater_getTotalInImpl;
+		Java_java_util_zip_Inflater_getTotalOutImpl;
+		Java_java_util_zip_Inflater_inflateImpl;
+		Java_java_util_zip_Inflater_oneTimeInitialization;
+		Java_java_util_zip_Inflater_resetImpl;
+		Java_java_util_zip_Inflater_setDictionaryImpl;
+		Java_java_util_zip_Inflater_setInputImpl;
+		Java_java_util_zip_ZipFile_00024ZFEnum_getNextEntry;
+		Java_java_util_zip_ZipFile_00024ZFEnum_resetZip;
+		Java_java_util_zip_ZipFile_closeZipImpl;
+		Java_java_util_zip_ZipFile_getEntryImpl;
+		Java_java_util_zip_ZipFile_inflateEntryImpl2;
+		Java_java_util_zip_ZipFile_ntvinit;
+		Java_java_util_zip_ZipFile_openZipImpl;
+		JNI_OnLoad;
+		JNI_OnUnload;
+	local : *;
+};



Mime
View raw message