AnalyzerGuru.java revision 25
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* ident "@(#)AnalyzerGuru.java 1.3 06/02/22 SMI"
*/
/**
* Manages and porvides Analyzers as needed.
* Created on September 22, 2005
*
* @author Chandan
*/
public class AnalyzerGuru {
/*
* If you write your own analyzer please register it here
*/
IgnorantAnalyzer.class,
BZip2Analyzer.class,
FileAnalyzer.class,
XMLAnalyzer.class,
TroffAnalyzer.class,
ELFAnalyzer.class,
JavaClassAnalyzer.class,
ImageAnalyzer.class,
JarAnalyzer.class,
ZipAnalyzer.class,
TarAnalyzer.class,
CAnalyzer.class,
ShAnalyzer.class,
PlainAnalyzer.class,
GZIPAnalyzer.class,
JavaAnalyzer.class
};
/**
* Initializes an AnalyzerGuru
*/
static {
}
// TODO: have a comparator
}
}
try{
//System.err.println(analyzer.getSimpleName() + " = " + suffix);
}
} catch (Exception e) {
// System.err.println("AnalyzerFinder:" + analyzer.getSimpleName() + e);
}
try{
//System.err.println(analyzer.getSimpleName() + " = " + magic);
}
} catch (Exception e) {
// System.err.println("AnalyzerFinder: " + analyzer.getSimpleName() + e);
}
try{
} catch (Exception e) {
}
}
//System.err.println("Exts " + ext);
//System.err.println("Matchers " + matchers);
}
/*
* Get the default Analyzer.
*/
public static FileAnalyzer getAnalyzer() {
Class a = FileAnalyzer.class;
try {
return fa;
} catch (Exception e) {
}
}
return fa;
}
/*
* use this if you want to analyze a file. Analyzers are costly.
*/
if(a == null) {
a = FileAnalyzer.class;
}
if (a != null) {
try {
return fa;
} catch (Exception e) {
}
} else {
return fa;
}
}
return null;
}
try{
// date = hr.getLastCommentDate() //RFE
}
} catch (IOException e) {
}
}
try {
} catch (Exception e) {
}
try {
}
} catch (Exception e) {
// Ignoring any errors while analysing
}
}
return doc;
}
/**
* @return The contentType suitable for printing to response.setContentType()
*/
return getContentType(a);
}
return getContentType(a);
}
if (a != null) {
try {
} catch (Exception e ) {
}
}
return contentType;
}
if (a != null) {
try {
} catch (IllegalArgumentException ex) {
} catch (SecurityException ex) {
} catch (NoSuchMethodException ex) {
} catch (InvocationTargetException ex) {
} catch (IllegalAccessException ex) {
}
}
}
/**
* @return The genre suitable to decide how to display the file
*/
return getGenre(a);
}
return getGenre(a);
}
return getGenre(a);
}
if (a != null) {
try {
} catch (Exception e ) {
e.printStackTrace();
}
}
return g;
}
/**
* Finds a suitable analyser class for an InputStream and a file name
* Use if you just want to find file type.
*/
if(a == null) {
}
return a;
}
int i = 0;
}
if(dotpos >= 0) {
//System.err.println(path.substring(dotpos+1).toUpperCase() + " = " + analyzer.getSimpleName());
return analyzer;
}
}
}
byte[] content = new byte[8];
if (len < 4)
return null;
if(a == null) {
try {
//System.out.println("USING = " + matcher.getName());
return a;
}
} catch (Exception e ) {
}
}
}
return a;
}
}
}
if (a == null) {
}
}
}
return a;
}
try {
while (fields.hasMoreElements()) {
if(field.isTokenized()){
if(r == null) {
}
Token t;
}
}
} else {
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}