libextractor-java

GNU libextractor
Log | Files | Refs | README | LICENSE

commit 4b8f98396d9ce9d193ad3d38ad8820858b658788
parent 8fc12b309e3c9cb70b558585a429792a1e560584
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri,  1 Jan 2010 00:28:58 +0000

updating code to work with libextractor 0.6

Diffstat:
MChangeLog | 5+++++
MINSTALL | 141++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
MREADME.debian | 2+-
Mconfigure.ac | 14+++++++-------
Mnative/Makefile.am | 2+-
Mnative/extractor.c | 319+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Anative/org_gnu_libextractor_Extractor.h | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dnative/org_gnunet_libextractor_Extractor.h | 117-------------------------------------------------------------------------------
Morg/Makefile.am | 2+-
Rorg/gnunet/Makefile.am -> org/gnu/Makefile.am | 0
Rorg/gnunet/libextractor/.cvsignore -> org/gnu/libextractor/.cvsignore | 0
Aorg/gnu/libextractor/Extractor.java | 244+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aorg/gnu/libextractor/Makefile.am | 14++++++++++++++
Aorg/gnu/libextractor/Xtract.java | 45+++++++++++++++++++++++++++++++++++++++++++++
Dorg/gnunet/libextractor/Extractor.java | 436-------------------------------------------------------------------------------
Dorg/gnunet/libextractor/Makefile.am | 12------------
Dorg/gnunet/libextractor/Xtract.java | 45---------------------------------------------
17 files changed, 666 insertions(+), 809 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jan 1 00:22:43 CET 2010 + Changing API and implementation to work with libextractor 0.6. + Changing package to 'org.gnu.libextractor' to avoid conflicts + with previous versions (and to fit the package better as well). + Sat Apr 21 17:09:03 MDT 2007 Added method to support extracting data from in-memory byte array. Changed API to use ArrayList instead of Vector. diff --git a/INSTALL b/INSTALL @@ -1,5 +1,8 @@ -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software -Foundation, Inc. +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. @@ -7,7 +10,10 @@ unlimited permission to copy, distribute and modify it. Basic Installation ================== - These are generic installation instructions. + Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses @@ -20,9 +26,9 @@ debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is +the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale -cache files.) +cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail @@ -32,20 +38,17 @@ some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You only need -`configure.ac' if you want to change it or regenerate `configure' using -a newer version of `autoconf'. +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. + `./configure' to configure the package for your system. - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. 2. Type `make' to compile the package. @@ -64,6 +67,9 @@ The simplest way to compile this package is: all sorts of other programs in order to regenerate files that came with the distribution. + 6. Often, you can also type `make uninstall' to remove the installed + files again. + Compilers and Options ===================== @@ -75,7 +81,7 @@ for details on some of the pertinent environment variables. by setting variables in the command line or in the environment. Here is an example: - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. @@ -84,34 +90,46 @@ Compiling For Multiple Architectures You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the +own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. Installation Names ================== - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular +options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. @@ -134,6 +152,38 @@ find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `<wchar.h>' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + + On Solaris, don't put `/usr/ucb' early in your `PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. + + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common + Specifying the System Type ========================== @@ -149,14 +199,15 @@ type, such as `sun4', or a canonical name which has the form: where SYSTEM can have one of these forms: - OS KERNEL-OS + OS + KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should -use the `--target=TYPE' option to select the type of system they will +use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a @@ -186,9 +237,14 @@ them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc -will cause the specified gcc to be used as the C compiler (unless it is +causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + `configure' Invocation ====================== @@ -197,7 +253,14 @@ operates. `--help' `-h' - Print a summary of the options to `configure', and exit. + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. `--version' `-V' @@ -224,6 +287,16 @@ operates. Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. +`--prefix=DIR' + Use DIR as the installation prefix. *Note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. diff --git a/README.debian b/README.debian @@ -17,7 +17,7 @@ For Subversion access and compilation: subversion autoconf -automake1.8 +automake ============================================== diff --git a/configure.ac b/configure.ac @@ -1,8 +1,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.57) -AC_INIT([libextractor-java], [0.5.18], [bug-libextractor@gnu.org]) +AC_INIT([libextractor-java], [0.6.0], [bug-libextractor@gnu.org]) AC_REVISION($Revision: 1.67 $) -AM_INIT_AUTOMAKE([libextractor-java], [0.5.18]) +AM_INIT_AUTOMAKE([libextractor-java], [0.6.0]) AM_CONFIG_HEADER(native/config.h) AH_TOP([#define _GNU_SOURCE 1]) @@ -111,14 +111,14 @@ AC_ARG_WITH(extractor, ;; yes) AC_CHECK_HEADERS(extractor.h, - AC_CHECK_LIB([extractor], [EXTRACTOR_loadDefaultLibraries], + AC_CHECK_LIB([extractor], [EXTRACTOR_plugin_add_defaults], extractor=1)) ;; *) LDFLAGS="-L$with_extractor/lib $LDFLAGS" CPPFLAGS="-I$with_extractor/include $CPPFLAGS" AC_CHECK_HEADERS(extractor.h, - AC_CHECK_LIB([extractor], [EXTRACTOR_loadDefaultLibraries], + AC_CHECK_LIB([extractor], [EXTRACTOR_plugin_add_defaults], EXT_LIB_PATH="-L$with_extractor/lib $EXT_LIB_PATH" extractor=1)) ;; @@ -126,7 +126,7 @@ AC_ARG_WITH(extractor, ], [AC_MSG_RESULT([--with-extractor not specified]) AC_CHECK_HEADERS(extractor.h, - AC_CHECK_LIB([extractor], [EXTRACTOR_loadDefaultLibraries], + AC_CHECK_LIB([extractor], [EXTRACTOR_plugin_add_defaults], extractor=1))]) if test "$extractor" != 1 then @@ -138,8 +138,8 @@ AC_CONFIG_FILES([ Makefile native/Makefile org/Makefile -org/gnunet/Makefile -org/gnunet/libextractor/Makefile +org/gnu/Makefile +org/gnu/libextractor/Makefile ]) AC_OUTPUT diff --git a/native/Makefile.am b/native/Makefile.am @@ -10,4 +10,4 @@ libextractor_java_la_LIBADD = \ libextractor_java_la_SOURCES = \ extractor.c jni.h \ - org_gnunet_libextractor_Extractor.h + org_gnu_libextractor_Extractor.h diff --git a/native/extractor.c b/native/extractor.c @@ -32,238 +32,247 @@ #define JNICALL #endif -#include "org_gnunet_libextractor_Extractor.h" +#include "org_gnu_libextractor_Extractor.h" -#define HIGHEST_TYPE_NUMBER EXTRACTOR_getHighestKeywordTypeNumber() +#define HIGHEST_TYPE_NUMBER EXTRACTOR_metatype_get_max() /* - * Class: org_gnunet_libextractor_Extractor + * Class: org_gnu_libextractor_Extractor * Method: loadDefaultInternal * Signature: ()J */ JNIEXPORT jlong JNICALL -Java_org_gnunet_libextractor_Extractor_loadDefaultInternal(JNIEnv * env, +Java_org_gnu_libextractor_Extractor_loadDefaultInternal(JNIEnv * env, jclass c) { - return (jlong) (long) EXTRACTOR_loadDefaultLibraries(); + return (jlong) (long) EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY); } /* - * Class: org_gnunet_libextractor_Extractor + * Class: org_gnu_libextractor_Extractor * Method: unloadInternal * Signature: (J)V */ JNIEXPORT void JNICALL -Java_org_gnunet_libextractor_Extractor_unloadInternal(JNIEnv * env, - jclass c, - jlong arg) { - EXTRACTOR_removeAll((EXTRACTOR_ExtractorList*) (long) arg); +Java_org_gnu_libextractor_Extractor_unloadAllInternal(JNIEnv * env, + jclass c, + jlong arg) { + EXTRACTOR_plugin_remove_all((struct EXTRACTOR_PluginList*) (long) arg); } /* - * Class: org_gnunet_libextractor_Extractor - * Method: extractInternal - * Signature: (JLjava/lang/String;)J - */ -JNIEXPORT jlong JNICALL -Java_org_gnunet_libextractor_Extractor_extractInternal(JNIEnv * env, - jclass c, - jlong arg, - jstring f) { - const char * fname; - jboolean bo; - jlong ret; - - bo = JNI_FALSE; - fname = (*env)->GetStringUTFChars(env, - f, - &bo); - if (fname == NULL) - return 0; - ret = (jlong) (long) EXTRACTOR_getKeywords((EXTRACTOR_ExtractorList*) (long) arg, - fname); - (*env)->ReleaseStringUTFChars(env, - f, - fname); - return ret; -} - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: extractInternal - * Signature: (J[B)J - */ -JNIEXPORT jlong JNICALL -Java_org_gnunet_libextractor_Extractor_extractInternal2(JNIEnv * env, - jclass c, - jlong arg, - jbyteArray f) { - void * data; - jboolean bo; - jlong ret; - jsize asize; - - bo = JNI_FALSE; - asize = (*env)->GetArrayLength(env, f); - data = (*env)->GetPrimitiveArrayCritical(env, - f, - &bo); - if (data == NULL) - return 0; - ret = (jlong) (long) EXTRACTOR_getKeywords2((EXTRACTOR_ExtractorList*) (long) arg, - data, - (size_t) asize); - (*env)->ReleasePrimitiveArrayCritical(env, - f, - data, - JNI_ABORT); - return ret; -} - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: freeInternal - * Signature: (J)V - */ -JNIEXPORT void JNICALL -Java_org_gnunet_libextractor_Extractor_freeInternal(JNIEnv * env, - jclass c, - jlong list) { - EXTRACTOR_freeKeywords( (EXTRACTOR_KeywordList*) (long) list); -} - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: typeInternal - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_org_gnunet_libextractor_Extractor_typeInternal(JNIEnv * env, - jclass c, - jlong list) { - if (list == 0) - return -1; /* error! */ - return ((EXTRACTOR_KeywordList*) (long) list)->keywordType; -} - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: keywordInternal - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_org_gnunet_libextractor_Extractor_keywordInternal(JNIEnv * env, - jclass c, - jlong list) { - char * str; - if (list == 0) - return NULL; /* error! */ - str = ((EXTRACTOR_KeywordList*) (long) list)->keyword; - return (*env)->NewStringUTF(env, str); -} - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: nextInternal - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_org_gnunet_libextractor_Extractor_nextInternal(JNIEnv * env, - jclass j, - jlong list) { - if (list == 0) - return 0; /* error! */ - return (jlong) (long) ((EXTRACTOR_KeywordList*) (long) list)->next; -} - -/* - * Class: org_gnunet_libextractor_Extractor + * Class: org_gnu_libextractor_Extractor * Method: getTypeAsStringInternal * Signature: (I)Ljava/lang/String; */ JNIEXPORT jstring JNICALL -Java_org_gnunet_libextractor_Extractor_getTypeAsStringInternal(JNIEnv * env, +Java_org_gnu_libextractor_Extractor_getTypeAsStringInternal(JNIEnv * env, jclass c, jint type) { const char * str; + if ( (type < 0) || (type > HIGHEST_TYPE_NUMBER) ) return NULL; /* error! */ - str = EXTRACTOR_getKeywordTypeAsString((EXTRACTOR_KeywordType)type); + str = EXTRACTOR_metatype_to_string((enum EXTRACTOR_MetaType)type); if (str == NULL) return NULL; - return (*env)->NewStringUTF(env, - str); + return (*env)->NewStringUTF(env, str); } - /* - * Class: org_gnunet_libextractor_Extractor + * Class: org_gnu_libextractor_Extractor * Method: getVersionInternal * Signature: ()I */ JNIEXPORT jint JNICALL -Java_org_gnunet_libextractor_Extractor_getVersionInternal(JNIEnv * env, +Java_org_gnu_libextractor_Extractor_getVersionInternal(JNIEnv * env, jclass c) { return EXTRACTOR_VERSION; } /* - * Class: org_gnunet_libextractor_Extractor + * Class: org_gnu_libextractor_Extractor * Method: getMaxTypeInternal * Signature: ()I */ JNIEXPORT jint JNICALL -Java_org_gnunet_libextractor_Extractor_getMaxTypeInternal(JNIEnv * env, +Java_org_gnu_libextractor_Extractor_getMaxTypeInternal(JNIEnv * env, jclass c) { return HIGHEST_TYPE_NUMBER; } /* - * Class: org_gnunet_libextractor_Extractor + * Class: org_gnu_libextractor_Extractor * Method: unloadPlugin * Signature: (JLjava/lang/String;)J */ JNIEXPORT jlong JNICALL -Java_org_gnunet_libextractor_Extractor_unloadPlugin(JNIEnv * env, - jclass c, - jlong handle, - jstring name) { +Java_org_gnu_libextractor_Extractor_unloadPluginInternal(JNIEnv * env, + jclass c, + jlong handle, + jstring name) { const char * lname; jboolean bo; jlong ret; bo = JNI_FALSE; lname = (*env)->GetStringUTFChars(env, name, &bo); - ret = (jlong) (long) EXTRACTOR_removeLibrary((EXTRACTOR_ExtractorList*) (long) handle, + ret = (jlong) (long) EXTRACTOR_plugin_remove((struct EXTRACTOR_PluginList*) (long) handle, lname); (*env)->ReleaseStringUTFChars(env, name, lname); return ret; } /* - * Class: org_gnunet_libextractor_Extractor + * Class: org_gnu_libextractor_Extractor * Method: loadPlugin * Signature: (JLjava/lang/String;Z)J */ JNIEXPORT jlong JNICALL -Java_org_gnunet_libextractor_Extractor_loadPlugin(JNIEnv * env, - jclass c, - jlong handle, - jstring name, - jboolean place) { +Java_org_gnu_libextractor_Extractor_loadPluginInternal(JNIEnv * env, + jclass c, + jlong handle, + jstring name) { const char * lname; jboolean bo; jlong ret; bo = JNI_FALSE; lname = (*env)->GetStringUTFChars(env, name, &bo); - if (place == JNI_TRUE) { - ret = (jlong) (long) EXTRACTOR_addLibraryLast((EXTRACTOR_ExtractorList*) (long) handle, - lname); - } else { - ret = (jlong) (long) EXTRACTOR_addLibrary((EXTRACTOR_ExtractorList*) (long) handle, - lname); - } + ret = (jlong) (long) EXTRACTOR_plugin_add((struct EXTRACTOR_PluginList*) (long) handle, + lname, + NULL, + EXTRACTOR_OPTION_DEFAULT_POLICY); (*env)->ReleaseStringUTFChars(env, name, lname); return ret; } + +/** + * Closure of 'add_meta' function. + */ +struct AddMetaContext +{ + JNIEnv *env; + jobject ret; + jclass metadata; + jmethodID meta_ctor; + jmethodID alist_add; +}; + + +/** + * Function called by libextractor for each meta data item. + */ +static int +add_meta (void *cls, + const char *plugin_name, + enum EXTRACTOR_MetaType type, + enum EXTRACTOR_MetaFormat format, + const char *data_mime_type, + const char *data, + size_t data_len) +{ + struct AddMetaContext *ctx = cls; + jbyteArray bdata; + jstring mimestring; + jobject metadata; + + mimestring = (*ctx->env)->NewStringUTF (ctx->env, + data_mime_type); + bdata = (*ctx->env)->NewByteArray (ctx->env, + data_len); + (*ctx->env)->SetByteArrayRegion (ctx->env, + bdata, + 0, + data_len, + (jbyte*) data); + metadata = (*ctx->env)->NewObject (ctx->env, + ctx->metadata, + ctx->meta_ctor, + type, format, bdata, + mimestring); + (*ctx->env)->CallBooleanMethod (ctx->env, + ctx->ret, + ctx->alist_add, + metadata); + return 0; +} + + +/* + * Class: org_gnu_libextractor_Extractor + * Method: extractInternal + * Signature: (JLjava/lang/String;[BLjava/util/ArrayList;)V + */ +JNIEXPORT void JNICALL Java_org_gnu_libextractor_Extractor_extractInternal + (JNIEnv *env, jclass c, jlong arg, jstring f, jbyteArray ba, jobject ret) +{ + const char * fname; + void * data; + jboolean bo; + jsize asize; + struct AddMetaContext am_ctx; + jclass alist; + + am_ctx.env = env; + am_ctx.ret = ret; + am_ctx.metadata = (*env)->FindClass (env, "org/gnu/libextractor/MetaData"); + if (am_ctx.metadata == 0) + return; + am_ctx.meta_ctor = (*env)->GetMethodID (env, + am_ctx.metadata, + "<init>", + "(II[BLjava/lang/String;)V"); + if (am_ctx.meta_ctor == 0) + return; + alist = (*env)->FindClass (env, "java/util/ArrayList"); + if (alist == 0) + return; + am_ctx.alist_add = (*env)->GetMethodID (env, + alist, + "add", + "(Ljava/lang/Object;)Z"); + if (am_ctx.alist_add == 0) + return; + bo = JNI_FALSE; + if (f != 0) + { + fname = (*env)->GetStringUTFChars(env, + f, + &bo); + } + else + { + fname = NULL; + } + if (ba != 0) + { + asize = (*env)->GetArrayLength(env, ba); + data = (*env)->GetPrimitiveArrayCritical(env, + ba, + &bo); + } + else + { + asize = 0; + data = 0; + } + if ( (data == NULL) && (fname == NULL) ) + return; + EXTRACTOR_extract((struct EXTRACTOR_PluginList*) (long) arg, + fname, + data, + (size_t) asize, + &add_meta, + &am_ctx); + if (fname != NULL) + (*env)->ReleaseStringUTFChars(env, + f, + fname); + if (data != NULL) + (*env)->ReleasePrimitiveArrayCritical(env, + f, + data, + JNI_ABORT); +} + diff --git a/native/org_gnu_libextractor_Extractor.h b/native/org_gnu_libextractor_Extractor.h @@ -0,0 +1,77 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class org_gnu_libextractor_Extractor */ + +#ifndef _Included_org_gnu_libextractor_Extractor +#define _Included_org_gnu_libextractor_Extractor +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_gnu_libextractor_Extractor + * Method: unloadPluginInternal + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_gnu_libextractor_Extractor_unloadPluginInternal + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: org_gnu_libextractor_Extractor + * Method: loadPluginInternal + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_gnu_libextractor_Extractor_loadPluginInternal + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: org_gnu_libextractor_Extractor + * Method: loadDefaultInternal + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_gnu_libextractor_Extractor_loadDefaultInternal + (JNIEnv *, jclass); + +/* + * Class: org_gnu_libextractor_Extractor + * Method: unloadAllInternal + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_gnu_libextractor_Extractor_unloadAllInternal + (JNIEnv *, jclass, jlong); + +/* + * Class: org_gnu_libextractor_Extractor + * Method: extractInternal + * Signature: (JLjava/lang/String;[BLjava/util/ArrayList;)J + */ +JNIEXPORT void JNICALL Java_org_gnu_libextractor_Extractor_extractInternal + (JNIEnv *, jclass, jlong, jstring, jbyteArray, jobject); + +/* + * Class: org_gnu_libextractor_Extractor + * Method: getVersionInternal + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_gnu_libextractor_Extractor_getVersionInternal + (JNIEnv *, jclass); + +/* + * Class: org_gnu_libextractor_Extractor + * Method: getTypeAsStringInternal + * Signature: (I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_gnu_libextractor_Extractor_getTypeAsStringInternal + (JNIEnv *, jclass, jint); + +/* + * Class: org_gnu_libextractor_Extractor + * Method: getMaxTypeInternal + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_gnu_libextractor_Extractor_getMaxTypeInternal + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/native/org_gnunet_libextractor_Extractor.h b/native/org_gnunet_libextractor_Extractor.h @@ -1,117 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_gnunet_libextractor_Extractor */ - -#ifndef _Included_org_gnunet_libextractor_Extractor -#define _Included_org_gnunet_libextractor_Extractor -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_gnunet_libextractor_Extractor - * Method: loadDefaultInternal - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_org_gnunet_libextractor_Extractor_loadDefaultInternal - (JNIEnv *, jclass); - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: unloadInternal - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_gnunet_libextractor_Extractor_unloadInternal - (JNIEnv *, jclass, jlong); - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: extractInternal - * Signature: (JLjava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_org_gnunet_libextractor_Extractor_extractInternal__JLjava_lang_String_2 - (JNIEnv *, jclass, jlong, jstring); - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: extractInternal - * Signature: (J[B)J - */ -JNIEXPORT jlong JNICALL Java_org_gnunet_libextractor_Extractor_extractInternal__J_3B - (JNIEnv *, jclass, jlong, jbyteArray); - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: freeInternal - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_org_gnunet_libextractor_Extractor_freeInternal - (JNIEnv *, jclass, jlong); - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: typeInternal - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_org_gnunet_libextractor_Extractor_typeInternal - (JNIEnv *, jclass, jlong); - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: keywordInternal - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_org_gnunet_libextractor_Extractor_keywordInternal - (JNIEnv *, jclass, jlong); - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: nextInternal - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_org_gnunet_libextractor_Extractor_nextInternal - (JNIEnv *, jclass, jlong); - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: getTypeAsStringInternal - * Signature: (I)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_org_gnunet_libextractor_Extractor_getTypeAsStringInternal - (JNIEnv *, jclass, jint); - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: getVersionInternal - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_org_gnunet_libextractor_Extractor_getVersionInternal - (JNIEnv *, jclass); - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: getMaxTypeInternal - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_org_gnunet_libextractor_Extractor_getMaxTypeInternal - (JNIEnv *, jclass); - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: unloadPlugin - * Signature: (JLjava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_org_gnunet_libextractor_Extractor_unloadPlugin - (JNIEnv *, jclass, jlong, jstring); - -/* - * Class: org_gnunet_libextractor_Extractor - * Method: loadPlugin - * Signature: (JLjava/lang/String;Z)J - */ -JNIEXPORT jlong JNICALL Java_org_gnunet_libextractor_Extractor_loadPlugin - (JNIEnv *, jclass, jlong, jstring, jboolean); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/org/Makefile.am b/org/Makefile.am @@ -1 +1 @@ -SUBDIRS = gnunet +SUBDIRS = gnu diff --git a/org/gnunet/Makefile.am b/org/gnu/Makefile.am diff --git a/org/gnunet/libextractor/.cvsignore b/org/gnu/libextractor/.cvsignore diff --git a/org/gnu/libextractor/Extractor.java b/org/gnu/libextractor/Extractor.java @@ -0,0 +1,244 @@ +/* + This file is part of libextractor. + (C) 2002, 2003, 2004, 2007, 2010 Vidyut Samanta and Christian Grothoff + + libextractor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 2, or (at your + option) any later version. + + libextractor 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 for more details. + + You should have received a copy of the GNU General Public License + along with libextractor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + */ +package org.gnu.libextractor; + +import java.util.ArrayList; +import java.io.File; +import java.io.FileInputStream; + +/** + * Java Binding for libextractor. Each Extractor instance + * represents a set of meta data extraction plugins. + * + * @see Xtract + * @see MetaData + * @author Christian Grothoff + */ +public final class Extractor { + + + private static final boolean warn_; + + /** + * LE version. 0 if LE was compiled without JNI/Java support, in which + * case we better not call any native methods... + */ + private static final int version_; + + static { + // first, initialize warn_ + boolean warn = false; + try { + if (System.getProperty("libextractor.warn") != null) + warn = true; + } catch (SecurityException se) { + // ignore + } finally { + warn_ = true; // warn; + } + + // next, load library and determine version_ + int ver = 0; + try { + System.loadLibrary("extractor_java"); + } catch (UnsatisfiedLinkError ule) { + ver = -1; + warn("Did not find libextractor_java library: " + ule); + } + if (ver == 0) { + try { + ver = getVersionInternal(); + } catch (UnsatisfiedLinkError ule) { + // warn: libextractor compiled without Java support + warn("libextractor library compiled without Java support: " + ule); + } + } + version_ = ver; + } + + + private static void warn(String warning) { + if (warn_) + System.err.println("WARNING: " + warning); + } + + + /** + * @return -1 if LE library was not found, 0 if LE library + * was found but compiled without JNI support, otherwise + * the LE version number + */ + public static int getVersion() { + return version_; + } + + + /** + * Get the 'default' extractor, that is an extractor that loads + * the default set of extractor plugins. + */ + public static Extractor getDefault() { + if (version_ > 0) + return new Extractor(loadDefaultInternal()); + return new Extractor(0); + } + + + /** + * Get the 'empty' extractor, that is an extractor that does not + * have any plugins loaded. This is useful to manually construct + * an Extractor from scratch. + */ + public static Extractor getEmpty() { + return new Extractor(0L); + } + + + /** + * Handle to the list of plugins (a C pointer, long to support + * 64-bit architectures!). + */ + private long pluginHandle_; + + + /** + * Creates an extractor. + * + * @param pluginHandle the internal handle (C pointer!) refering + * to the list of plugins. 0 means no plugins. + */ + private Extractor(long pluginHandle) { + pluginHandle_ = pluginHandle; + } + + + /** + * Unloads all loaded plugins on "exit". + */ + protected void finalize() { + if (pluginHandle_ != 0) + unloadAllInternal(pluginHandle_); + } + + + /** + * Remove a plugin from the list of plugins. + * + * @param pluginName name of the plugin to unload + */ + public void unloadPlugin(String pluginName) { + if (pluginHandle_ != 0) + pluginHandle_ = unloadPluginInternal(pluginHandle_, + pluginName); + } + + + /** + * Add an additional plugin to the list of plugins + * used. + * + * @param pluginName name of the plugin to load + */ + public void loadPlugin(String pluginName) { + if (version_ <= 0) + return; + pluginHandle_ = loadPluginInternal(pluginHandle_, + pluginName); + } + + + /** + * Extract keywords (meta-data) from the given file. + * + * @param f the file to extract meta-data from + * @return extracted meta data (ArrayList<MetaData>) + */ + public ArrayList extract(File f) { + return extract(f.getAbsolutePath()); + } + + + /** + * Extract keywords (meta-data) from the given file. + * + * @param file the name of the file + * @return extracted meta data (ArrayList<MetaData>) + */ + public ArrayList extract(String filename) { + ArrayList ret = new ArrayList(0); + if (pluginHandle_ == 0) + return ret; // fast way out + extractInternal(pluginHandle_, + filename, + null, + ret); + return ret; + } + + + /** + * Extract keywords (meta-data) from the given block + * of data. + * + * @param data the file data + * @return extracted meta data (ArrayList<MetaData>) + */ + public ArrayList extract(byte[] data) { + ArrayList ret = new ArrayList(0); + if (pluginHandle_ == 0) + return ret; // fast way out + extractInternal(pluginHandle_, + null, + data, + ret); + return ret; + } + + + /* ********************* native calls ******************** */ + + private static native long unloadPluginInternal(long handle, + String pluginName); + + private static native long loadPluginInternal(long handle, + String pluginName); + + private static native long loadDefaultInternal(); + + private static native void unloadAllInternal(long handle); + + private static native void extractInternal(long handle, + String filename, + byte[] data, + ArrayList result); + + private static native int getVersionInternal(); + + /** + * Not private since we use this from "MetaData". + */ + static native String getTypeAsStringInternal(int type); + + /** + * Not private since we use this from "MetaData". + */ + static native int getMaxTypeInternal(); + +} // end of Extractor diff --git a/org/gnu/libextractor/Makefile.am b/org/gnu/libextractor/Makefile.am @@ -0,0 +1,14 @@ +SUBDIRS = . +noinst_JAVA = \ + Extractor.java \ + MetaData.java \ + Xtract.java + +EXTRA_DIST = \ + Extractor.java \ + MetaData.java \ + Xtract.java + +install-exec-local: + mkdir -p $(prefix)/share/java + cd ../../..; @JAR@ -cvf $(prefix)/share/java/libextractor.jar org/gnu/libextractor/*.class diff --git a/org/gnu/libextractor/Xtract.java b/org/gnu/libextractor/Xtract.java @@ -0,0 +1,44 @@ +/* + This file is part of libextractor. + (C) 2002, 2003, 2004, 2007, 2010 Vidyut Samanta and Christian Grothoff + + libextractor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 2, or (at your + option) any later version. + + libextractor 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 for more details. + + You should have received a copy of the GNU General Public License + along with libextractor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ +package org.gnu.libextractor; + +import java.util.ArrayList; + +/** + * Java version of extract. This is just a tiny demo-application + * to show how to use the Java API. The C version of extract is + * much better and should probably be used in practice. + * + * @author Christian Grothoff + */ +public final class Xtract { + + public static void main(String[] args) { + Extractor ex = Extractor.getDefault(); + for (int i=0;i<args.length;i++) { + ArrayList keywords = ex.extract(args[i]); + System.out.println("Keywords for " + args[i] + ":"); + for (int j=0;j<keywords.size();j++) + System.out.println(keywords.get(j)); + } + // no need to unload, finalizer does the rest... + } + +} // end of Xtract +\ No newline at end of file diff --git a/org/gnunet/libextractor/Extractor.java b/org/gnunet/libextractor/Extractor.java @@ -1,436 +0,0 @@ -/* - This file is part of libextractor. - (C) 2002, 2003, 2004, 2007 Vidyut Samanta and Christian Grothoff - - libextractor is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 2, or (at your - option) any later version. - - libextractor 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 for more details. - - You should have received a copy of the GNU General Public License - along with libextractor; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - */ -package org.gnunet.libextractor; - -import java.util.ArrayList; -import java.io.File; - -/** - * Java Binding for libextractor. - * - * @see Xtract - * @author Christian Grothoff - */ -public final class Extractor { - - - private static final boolean warn_; - - /** - * LE version. 0 if LE was compiled without JNI/Java support, in which - * case we better not call any native methods... - */ - private static final int version_; - - /** - * Cached list of Strings describing keyword types. - */ - private final static String[] typeCache_; - - static { - // first, initialize warn_ - boolean warn = false; - try { - if (System.getProperty("libextractor.warn") != null) - warn = true; - } catch (SecurityException se) { - // ignore - } finally { - warn_ = warn; - } - - // next, load library and determine version_ - int ver = 0; - try { - System.loadLibrary("extractor_java"); - } catch (UnsatisfiedLinkError ule) { - ver = -1; - warn("Did not find libextractor_java library: " + ule); - } - if (ver == 0) { - try { - ver = getVersionInternal(); - } catch (UnsatisfiedLinkError ule) { - // warn: libextractor compiled without Java support - warn("libextractor library compiled without Java support: " + ule); - } - } - version_ = ver; - - // finally, initialize typeCache_ - if (ver > 0) { - typeCache_ = new String[getMaxTypeInternal()]; - } else { - typeCache_ = null; - } - } - - private static void warn(String warning) { - if (warn_) - System.err.println("WARNING: " + warning); - } - - /** - * @return -1 if LE library was not found, 0 if LE library - * was found but compiled without JNI support, otherwise - * the LE version number - */ - public static int getVersion() { - return version_; - } - - /** - * Get the 'default' extractor, that is an extractor that loads - * the default set of extractor plugins. - */ - public static Extractor getDefault() { - if (version_ > 0) - return new Extractor(loadDefaultInternal()); - return new Extractor(0); - } - - /** - * Get the 'empty' extractor, that is an extractor that does not - * have any plugins loaded. This is useful to manually construct - * an Extractor from scratch. - */ - public static Extractor getEmpty() { - return new Extractor(0L); - } - - /** - * Note that the current implementation of function is quite - * costly, we should probably build a cache (String[]) of all - * keyword types on startup and keep that around instead of - * doing a native call each time (initialize cache lazily!, - * just determine the size in the static initializer!). - * - * @throws IllegalArgumentException if the type is not within range - * @return an empty string if LE was not loaded - */ - public static String getTypeAsString(int type) { - if (version_ > 0) { - if ( (type >= 0) && - (type <= typeCache_.length) ) { - if (typeCache_[type] == null) - typeCache_[type] - = getTypeAsStringInternal(type); - return typeCache_[type]; - } - throw new IllegalArgumentException("Type out of range [0,"+typeCache_.length+")"); - } - return ""; - } - - /** - * Handle to the list of plugins (a C pointer, long to support - * 64-bit architectures!). - */ - private long pluginHandle_; - - /** - * Creates an extractor. - * - * @param pluginHandle the internal handle (C pointer!) refering - * to the list of plugins. 0 means no plugins. - */ - private Extractor(long pluginHandle) { - pluginHandle_ = pluginHandle; - } - - protected void finalize() { - if (pluginHandle_ != 0) - unloadInternal(pluginHandle_); - } - - public void unloadPlugin(String pluginName) { - if (pluginHandle_ != 0) - pluginHandle_ = unloadPlugin(pluginHandle_, - pluginName); - } - - /** - * @param append if true, add the plugin at the end, otherwise at the - * beginning - */ - public void loadPlugin(String pluginName, - boolean append) { - if (version_ <= 0) - return; - pluginHandle_ = loadPlugin(pluginHandle_, - pluginName, - append); - } - - /** - * Extract keywords (meta-data) from the given file. - * - * @param f the file to extract meta-data from - * @return a ArrayList of Extractor.Keywords - */ - public ArrayList extract(File f) { - return extract(f.getAbsolutePath()); - } - - /** - * Extract keywords (meta-data) from the given file. - * - * @param file the name of the file - * @return a ArrayList of Extractor.Keywords - */ - public ArrayList extract(String filename) { - if (pluginHandle_ == 0) - return new ArrayList(0); // fast way out - long list - = extractInternal(pluginHandle_, - filename); // toChars? - ArrayList ret = convert(list); - freeInternal(list); - return ret; - } - - /** - * Extract keywords (meta-data) from the given block - * of data. - * - * @param data the file data - * @return a ArrayList of Extractor.Keywords - */ - public ArrayList extract(byte[] data) { - if (pluginHandle_ == 0) - return new ArrayList(0); // fast way out - long list - = extractInternal2(pluginHandle_, - data); - ArrayList ret = convert(list); - freeInternal(list); - return ret; - } - - /** - * Convert a list of keywords in C to an ArrayList - * in Java. - */ - private ArrayList convert(long list) { - long pos - = list; - ArrayList res - = new ArrayList(); - while (pos != 0) { - int type - = typeInternal(pos); - String keyword - = keywordInternal(pos); - res.add(new Keyword(type, keyword)); - pos = nextInternal(pos); - } - return res; - } - - - /* ********************* native calls ******************** */ - - private static native long loadDefaultInternal(); - - private static native void unloadInternal(long handle); - - private static native long extractInternal(long handle, - String filename); - - private static native long extractInternal2(long handle, - byte[] data); - - // free memory allocated by extractInternal - private static native void freeInternal(long list); - - private static native int typeInternal(long pos); - - private static native String keywordInternal(long pos); - - private static native long nextInternal(long pos); - - private static native String getTypeAsStringInternal(int type); - - private static native int getVersionInternal(); - - private static native int getMaxTypeInternal(); - - private static native long unloadPlugin(long handle, - String pluginName); - - /** - * @param append if true, add the plugin at the end, otherwise at the - * beginning - */ - private static native long loadPlugin(long handle, - String pluginName, - boolean append); - - /** - * Representation of a keyword. Each keyword in libextractor - * has a type (in Java modeled as an int) which describes what - * the keyword is about. - * - * @author Christian Grothoff - */ - public static final class Keyword { - - //Keyword types - public static final int EXTRACTOR_UNKNOWN = 0; - public static final int EXTRACTOR_FILENAME = 1; - public static final int EXTRACTOR_MIMETYPE = 2; - public static final int EXTRACTOR_TITLE = 3; - public static final int EXTRACTOR_AUTHOR = 4; - public static final int EXTRACTOR_ARTIST = 5; - public static final int EXTRACTOR_DESCRIPTION = 6; - public static final int EXTRACTOR_COMMENT = 7; - public static final int EXTRACTOR_DATE = 8; - public static final int EXTRACTOR_PUBLISHER = 9; - public static final int EXTRACTOR_LANGUAGE = 10; - public static final int EXTRACTOR_ALBUM = 11; - public static final int EXTRACTOR_GENRE = 12; - public static final int EXTRACTOR_LOCATION = 13; - public static final int EXTRACTOR_VERSIONNUMBER = 14; - public static final int EXTRACTOR_ORGANIZATION = 15; - public static final int EXTRACTOR_COPYRIGHT = 16; - public static final int EXTRACTOR_SUBJECT = 17; - public static final int EXTRACTOR_KEYWORDS = 18; - public static final int EXTRACTOR_CONTRIBUTOR = 19; - public static final int EXTRACTOR_RESOURCE_TYPE = 20; - public static final int EXTRACTOR_FORMAT = 21; - public static final int EXTRACTOR_RESOURCE_IDENTIFIER = 22; - public static final int EXTRACTOR_SOURCE = 23; - public static final int EXTRACTOR_RELATION = 24; - public static final int EXTRACTOR_COVERAGE = 25; - public static final int EXTRACTOR_SOFTWARE = 26; - public static final int EXTRACTOR_DISCLAIMER = 27; - public static final int EXTRACTOR_WARNING = 28; - public static final int EXTRACTOR_TRANSLATED = 29; - public static final int EXTRACTOR_CREATION_DATE = 30; - public static final int EXTRACTOR_MODIFICATION_DATE = 31; - public static final int EXTRACTOR_CREATOR = 32; - public static final int EXTRACTOR_PRODUCER = 33; - public static final int EXTRACTOR_PAGE_COUNT = 34; - public static final int EXTRACTOR_PAGE_ORIENTATION = 35; - public static final int EXTRACTOR_PAPER_SIZE = 36; - public static final int EXTRACTOR_USED_FONTS = 37; - public static final int EXTRACTOR_PAGE_ORDER = 38; - public static final int EXTRACTOR_CREATED_FOR = 39; - public static final int EXTRACTOR_MAGNIFICATION = 40; - public static final int EXTRACTOR_RELEASE = 41; - public static final int EXTRACTOR_GROUP = 42; - public static final int EXTRACTOR_SIZE = 43; - public static final int EXTRACTOR_SUMMARY = 44; - public static final int EXTRACTOR_PACKAGER = 45; - public static final int EXTRACTOR_VENDOR = 46; - public static final int EXTRACTOR_LICENSE = 47; - public static final int EXTRACTOR_DISTRIBUTION = 48; - public static final int EXTRACTOR_BUILDHOST = 49; - public static final int EXTRACTOR_OS = 50; - public static final int EXTRACTOR_DEPENDENCY = 51; - public static final int EXTRACTOR_HASH_MD4 = 52; - public static final int EXTRACTOR_HASH_MD5 = 53; - public static final int EXTRACTOR_HASH_SHA0 = 54; - public static final int EXTRACTOR_HASH_SHA1 = 55; - public static final int EXTRACTOR_HASH_RMD160 = 56; - public static final int EXTRACTOR_RESOLUTION = 57; - public static final int EXTRACTOR_CATEGORY = 58; - public static final int EXTRACTOR_BOOKTITLE = 59; - public static final int EXTRACTOR_PRIORITY = 60; - public static final int EXTRACTOR_CONFLICTS = 61; - public static final int EXTRACTOR_REPLACES = 62; - public static final int EXTRACTOR_PROVIDES = 63; - public static final int EXTRACTOR_CONDUCTOR = 64; - public static final int EXTRACTOR_INTERPRET = 65; - public static final int EXTRACTOR_OWNER = 66; - public static final int EXTRACTOR_LYRICS = 67; - public static final int EXTRACTOR_MEDIA_TYPE = 68; - public static final int EXTRACTOR_CONTACT = 69; - public static final int EXTRACTOR_THUMBNAIL_DATA = 70; - public static final int EXTRACTOR_PUBLICATION_DATE = 71; - public static final int EXTRACTOR_CAMERA_MAKE = 72; - public static final int EXTRACTOR_CAMERA_MODEL = 73; - public static final int EXTRACTOR_EXPOSURE = 74; - public static final int EXTRACTOR_APERTURE = 75; - public static final int EXTRACTOR_EXPOSURE_BIAS = 76; - public static final int EXTRACTOR_FLASH = 77; - public static final int EXTRACTOR_FLASH_BIAS = 78; - public static final int EXTRACTOR_FOCAL_LENGTH = 79; - public static final int EXTRACTOR_FOCAL_LENGTH_35MM = 80; - public static final int EXTRACTOR_ISO_SPEED = 81; - public static final int EXTRACTOR_EXPOSURE_MODE = 82; - public static final int EXTRACTOR_METERING_MODE = 83; - public static final int EXTRACTOR_MACRO_MODE = 84; - public static final int EXTRACTOR_IMAGE_QUALITY = 85; - public static final int EXTRACTOR_WHITE_BALANCE = 86; - public static final int EXTRACTOR_ORIENTATION = 87; - public static final int EXTRACTOR_TEMPLATE = 88; - public static final int EXTRACTOR_SPLIT = 89; - public static final int EXTRACTOR_PRODUCTVERSION = 90; - public static final int EXTRACTOR_LAST_SAVED_BY = 91; - public static final int EXTRACTOR_LAST_PRINTED = 92; - public static final int EXTRACTOR_WORD_COUNT = 93; - public static final int EXTRACTOR_CHARACTER_COUNT = 94; - public static final int EXTRACTOR_TOTAL_EDITING_TIME = 95; - public static final int EXTRACTOR_THUMBNAILS = 96; - public static final int EXTRACTOR_SECURITY = 97; - public static final int EXTRACTOR_CREATED_BY_SOFTWARE = 98; - public static final int EXTRACTOR_MODIFIED_BY_SOFTWARE = 99; - public static final int EXTRACTOR_REVISION_HISTORY = 100; - public static final int EXTRACTOR_LOWERCASE = 101; - public static final int EXTRACTOR_COMPANY = 102; - public static final int EXTRACTOR_GENERATOR = 103; - public static final int EXTRACTOR_CHARACTER_SET = 104; - public static final int EXTRACTOR_LINE_COUNT = 105; - public static final int EXTRACTOR_PARAGRAPH_COUNT = 106; - public static final int EXTRACTOR_EDITING_CYCLES = 107; - public static final int EXTRACTOR_SCALE = 108; - public static final int EXTRACTOR_MANAGER = 109; - public static final int EXTRACTOR_MOVIE_DIRECTOR = 110; - public static final int EXTRACTOR_DURATION = 111; - public static final int EXTRACTOR_INFORMATION = 112; - public static final int EXTRACTOR_FULL_NAME = 113; - public static final int EXTRACTOR_CHAPTER = 114; - - private final int type_; - - private final String keyword_; - - Keyword(int type, - String key) { - this.type_ = type; - this.keyword_ = key; - } - - public String toString() { - return getTypeAsString(type_) + ": " + keyword_; - } - - public int getType() { - return type_; - } - - public String getKeyword() { - return keyword_; - } - - } // end of Extractor.Keyword - -} // end of Extractor diff --git a/org/gnunet/libextractor/Makefile.am b/org/gnunet/libextractor/Makefile.am @@ -1,12 +0,0 @@ -SUBDIRS = . -noinst_JAVA = \ - Extractor.java \ - Xtract.java - -EXTRA_DIST = \ - Extractor.java \ - Xtract.java - -install-exec-local: - mkdir -p $(prefix)/share/java - cd ../../..; @JAR@ -cvf $(prefix)/share/java/libextractor.jar org/gnunet/libextractor/*.class diff --git a/org/gnunet/libextractor/Xtract.java b/org/gnunet/libextractor/Xtract.java @@ -1,44 +0,0 @@ -/* - This file is part of libextractor. - (C) 2002, 2003, 2004, 2007 Vidyut Samanta and Christian Grothoff - - libextractor is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 2, or (at your - option) any later version. - - libextractor 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 for more details. - - You should have received a copy of the GNU General Public License - along with libextractor; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - */ -package org.gnunet.libextractor; - -import java.util.ArrayList; - -/** - * Java version of extract. This is just a tiny demo-application - * to show how to use the Java API. The C version of extract is - * much better and should probably be used in practice. - * - * @author Christian Grothoff - */ -public final class Xtract { - - public static void main(String[] args) { - Extractor ex = Extractor.getDefault(); - for (int i=0;i<args.length;i++) { - ArrayList keywords = ex.extract(args[i]); - System.out.println("Keywords for " + args[i] + ":\n"); - for (int j=0;j<keywords.size();j++) - System.out.println(keywords.get(j)); - } - // no need to unload, finalizer does the rest... - } - -} // end of Xtract -\ No newline at end of file