diff options
author | david_williams | 2005-02-12 07:41:38 +0000 |
---|---|---|
committer | david_williams | 2005-02-12 07:41:38 +0000 |
commit | 57b01a5ba68ecc39cfadf95382a455eddc8fa944 (patch) | |
tree | 3526f0284b9385965dc4d74ec15d49541d76ba6c /bundles/org.eclipse.wst.xml.core/src/org | |
parent | f39421ff856625da2a77ca5d25e5266d69df8101 (diff) | |
download | webtools.sourceediting-57b01a5ba68ecc39cfadf95382a455eddc8fa944.tar.gz webtools.sourceediting-57b01a5ba68ecc39cfadf95382a455eddc8fa944.tar.xz webtools.sourceediting-57b01a5ba68ecc39cfadf95382a455eddc8fa944.zip |
consolidated encoding classes
Diffstat (limited to 'bundles/org.eclipse.wst.xml.core/src/org')
6 files changed, 104 insertions, 36 deletions
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/IntStack.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/IntStack.java new file mode 100644 index 0000000000..1b662ae106 --- /dev/null +++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/IntStack.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2001, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Jens Lukowski/Innoopract - initial renaming/restructuring + * + *******************************************************************************/ +package org.eclipse.wst.xml.core.contenttype; + +/* + * + * A non-resizable class implementing the behavior of java.util.Stack, but + * directly for the <code> integer </code> primitive. + */ +import java.util.EmptyStackException; + +public class IntStack { + private int[] list = null; + + private int size = 0; + + public IntStack() { + this(100); + } + + public IntStack(int maxdepth) { + super(); + list = new int[maxdepth]; + initialize(); + } + + public void clear() { + initialize(); + } + + public boolean empty() { + return size == 0; + } + + public int get(int slot) { + return list[slot]; + } + + private void initialize() { + for (int i = 0; i < list.length; i++) + list[i] = -1; + } + + /** + * Returns the int at the top of the stack without removing it + * + * @return int at the top of this stack. + * @exception EmptyStackException + * when empty. + */ + public int peek() { + if (size == 0) + throw new EmptyStackException(); + return list[size - 1]; + } + + /** + * Removes and returns the int at the top of the stack + * + * @return int at the top of this stack. + * @exception EmptyStackException + * when empty. + */ + public int pop() { + int value = peek(); + list[size - 1] = -1; + size--; + return value; + } + + /** + * Pushes an item onto the top of this stack. + * + * @param newValue - + * the int to be pushed onto this stack. + * @return the <code>newValue</code> argument. + */ + public int push(int newValue) { + if (size == list.length) { + throw new StackOverflowError(); + } + list[size++] = newValue; + return newValue; + } + + public int size() { + return list.length; + } +} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLHeadTokenizer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLHeadTokenizer.java index 35ca57cf57..af326f70bd 100644 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLHeadTokenizer.java +++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLHeadTokenizer.java @@ -18,8 +18,6 @@ package org.eclipse.wst.xml.core.contenttype; import java.io.IOException; import java.io.Reader; -import org.eclipse.wst.common.encoding.IntStack; -import org.eclipse.wst.xml.core.internal.contenttype.EncodingParserConstants; import org.eclipse.wst.xml.core.internal.contenttype.HeadParserToken; diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/EncodingParserConstants.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/EncodingParserConstants.java deleted file mode 100644 index 95c8417123..0000000000 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/EncodingParserConstants.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * - *******************************************************************************/ -package org.eclipse.wst.xml.core.internal.contenttype; - -/** - * @deprecated - * Use the one from org.eclipse.wst.common.encoding - */ - -public interface EncodingParserConstants { - - final String EOF = "EOF"; //$NON-NLS-1$ - final String InvalidTerminatedStringValue = "InvalidTerminatedStringValue"; //$NON-NLS-1$ - final String InvalidTermintatedUnDelimitedStringValue = "InvalidTermintatedUnDelimitedStringValue"; //$NON-NLS-1$ - final String MAX_CHARS_REACHED = "MAX_CHARS_REACHED"; //$NON-NLS-1$ - final String StringValue = "strval"; //$NON-NLS-1$ - final String UnDelimitedStringValue = "UnDelimitedStringValue"; //$NON-NLS-1$ - String UTF16BE = "UTF16BE"; //$NON-NLS-1$ - String UTF16LE = "UTF16LE"; //$NON-NLS-1$ - - - String UTF83ByteBOM = "UTF83ByteBOM"; //$NON-NLS-1$ - -} diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLDeclDetector.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLDeclDetector.java index 5843f61c4f..dbc25c5c2d 100644 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLDeclDetector.java +++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLDeclDetector.java @@ -20,6 +20,7 @@ import java.io.Reader; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; +import org.eclipse.wst.xml.core.contenttype.EncodingParserConstants; public class XMLDeclDetector { private static final int MAX_BUF_SIZE = 1024 * 2; diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizer.java index b4a9b6ebba..6f516702fe 100644 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizer.java +++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizer.java @@ -18,6 +18,8 @@ package org.eclipse.wst.xml.core.internal.contenttype; import java.io.IOException; import java.io.Reader; +import org.eclipse.wst.xml.core.contenttype.EncodingParserConstants; + /** diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizerConstants.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizerConstants.java index 3321348059..05c799bcab 100644 --- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizerConstants.java +++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizerConstants.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.wst.xml.core.internal.contenttype; +import org.eclipse.wst.xml.core.contenttype.EncodingParserConstants; + public interface XMLHeadTokenizerConstants extends EncodingParserConstants { |