/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
public class MimeTypeFile {
/**
* The construtor that takes a filename as an argument.
*
* @param new_fname The file name of the mime types file.
*/
try {
} finally {
try {
} catch (IOException e) {
// ignore it
}
}
}
}
/**
* Creates an empty DB.
*/
public MimeTypeFile() {
}
/**
* get the MimeTypeEntry based on the file extension
*/
}
/**
* Get the MIME type string corresponding to the file extension.
*/
return entry.getMIMEType();
else
return null;
}
/**
* Appends string of entries to the types registry, must be valid
* .mime.types format.
* A mime.types entry is one of two forms:
*
* or
*
* Example:
* # this is a test
* type=application/postscript exts=ps,eps
*/
try {
} catch (IOException ex) {
// can't happen
}
}
/**
* Parse a stream of mime.types entries.
*/
else
continue;
}
this.parseEntry(prev);
}
this.parseEntry(prev);
}
/**
* Parse single mime.types entry.
*/
return; // BAIL!
// check to see if this is a comment line?
return; // then we are done!
// is it a new format line or old format?
// new format
while (lt.hasMoreTokens()) {
lt.hasMoreTokens())
if (LogSupport.isLoggable())
return;
}
while (st.hasMoreTokens()) {
if (LogSupport.isLoggable())
}
}
}
} else {
// old format
// count the tokens
return;
while (strtok.hasMoreTokens()) {
if (LogSupport.isLoggable())
}
}
}
// for debugging
/*
public static void main(String[] argv) throws Exception {
MimeTypeFile mf = new MimeTypeFile(argv[0]);
System.out.println("ext " + argv[1] + " type " +
mf.getMIMETypeString(argv[1]));
System.exit(0);
}
*/
}
class LineTokenizer {
private int currentPosition;
private int maxPosition;
/**
* Constructs a tokenizer for the specified string.
* <p>
*
* @param str a string to be parsed.
*/
currentPosition = 0;
}
/**
* Skips white space.
*/
private void skipWhiteSpace() {
while ((currentPosition < maxPosition) &&
}
}
/**
* Tests if there are more tokens available from this tokenizer's string.
*
* @return <code>true</code> if there are more tokens available from this
* tokenizer's string; <code>false</code> otherwise.
*/
public boolean hasMoreTokens() {
return true;
return (currentPosition < maxPosition);
}
/**
* Returns the next token from this tokenizer.
*
* @return the next token from this tokenizer.
* @exception NoSuchElementException if there are no more tokens in this
* tokenizer's string.
*/
if (size > 0) {
return t;
}
if (currentPosition >= maxPosition) {
throw new NoSuchElementException();
}
int start = currentPosition;
if (c == '"') {
boolean filter = false;
while (currentPosition < maxPosition) {
if (c == '\\') {
filter = true;
} else if (c == '"') {
String s;
if (filter) {
if (c != '\\')
}
} else
return s;
}
}
} else {
while ((currentPosition < maxPosition) &&
}
}
}
}
}