Fix compiler warnings with and without Copilot
This commit is contained in:
parent
96f2dce50f
commit
fe81de07e3
36 changed files with 464 additions and 514 deletions
|
@ -41,8 +41,8 @@ public class Commandline {
|
|||
ClassLoader loader = Main.createClassLoader(installDir);
|
||||
|
||||
// get the main server class
|
||||
Class clazz = loader.loadClass("helma.main.CommandlineRunner");
|
||||
Class[] cargs = new Class[]{args.getClass()};
|
||||
Class<?> clazz = loader.loadClass("helma.main.CommandlineRunner");
|
||||
Class<?>[] cargs = new Class<?>[]{args.getClass()};
|
||||
Method main = clazz.getMethod("main", cargs);
|
||||
Object[] nargs = new Object[]{args};
|
||||
|
||||
|
|
|
@ -35,10 +35,10 @@ import java.util.ArrayList;
|
|||
* be able to set up class and install paths.
|
||||
*/
|
||||
public class Main {
|
||||
private Class serverClass;
|
||||
private Class<?> serverClass;
|
||||
private Object server;
|
||||
|
||||
private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
|
||||
private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
|
||||
private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
|
||||
|
||||
/**
|
||||
|
@ -60,7 +60,7 @@ public class Main {
|
|||
ClassLoader loader = createClassLoader(installDir);
|
||||
// get the main server class
|
||||
serverClass = loader.loadClass("helma.main.Server");
|
||||
Class[] cargs = new Class[]{args.getClass()};
|
||||
Class<?>[] cargs = new Class<?>[]{args.getClass()};
|
||||
Method loadServer = serverClass.getMethod("loadServer", cargs);
|
||||
Object[] nargs = new Object[]{args};
|
||||
// and invoke the static loadServer(String[]) method
|
||||
|
@ -111,7 +111,7 @@ public class Main {
|
|||
}
|
||||
}
|
||||
|
||||
static void addJars(ArrayList jarlist, File dir) throws MalformedURLException {
|
||||
static void addJars(ArrayList<URL> jarlist, File dir) throws MalformedURLException {
|
||||
File[] files = dir.listFiles(new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
String n = name.toLowerCase();
|
||||
|
@ -143,7 +143,7 @@ public class Main {
|
|||
|
||||
// set up the class path
|
||||
File libdir = new File(installDir, "lib");
|
||||
ArrayList jarlist = new ArrayList();
|
||||
ArrayList<URL> jarlist = new ArrayList<>();
|
||||
|
||||
// add all jar files from the lib directory
|
||||
addJars(jarlist, libdir);
|
||||
|
|
|
@ -59,7 +59,7 @@ public abstract class HelmaExtension {
|
|||
* with pairs of varname and ESObjects. This method should be <b>synchronized</b>, if it
|
||||
* performs any other self-initialization outside the scripting environment.
|
||||
*/
|
||||
public abstract HashMap initScripting(Application app, ScriptingEngine engine)
|
||||
public abstract HashMap<String, Object> initScripting(Application app, ScriptingEngine engine)
|
||||
throws ConfigurationException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,7 @@ public class DemoExtension extends HelmaExtension {
|
|||
public void init(Server server) throws ConfigurationException {
|
||||
try {
|
||||
// just a demo with the server class itself (which is always there, obviously)
|
||||
Class check = Class.forName("helma.main.Server");
|
||||
Class.forName("helma.main.Server");
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new ConfigurationException("helma-library not present in classpath. make sure helma.jar is included. get it from http://www.helma.org/");
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class DemoExtension extends HelmaExtension {
|
|||
*
|
||||
* @throws ConfigurationException ...
|
||||
*/
|
||||
public HashMap initScripting(Application app, ScriptingEngine engine)
|
||||
public HashMap<String, Object> initScripting(Application app, ScriptingEngine engine)
|
||||
throws ConfigurationException {
|
||||
if (!(engine instanceof RhinoEngine)) {
|
||||
throw new ConfigurationException("scripting engine " + engine.toString() +
|
||||
|
@ -98,7 +98,7 @@ public class DemoExtension extends HelmaExtension {
|
|||
engine.toString());
|
||||
|
||||
// initialize prototypes and global vars here
|
||||
HashMap globals = new HashMap();
|
||||
HashMap<String, Object> globals = new HashMap<>();
|
||||
|
||||
globals.put("demo", Server.getServer());
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public final class Application implements Runnable {
|
|||
private String name;
|
||||
|
||||
// application sources
|
||||
ArrayList repositories;
|
||||
ArrayList<Repository> repositories;
|
||||
|
||||
// properties and db-properties
|
||||
ResourceProperties props;
|
||||
|
@ -96,15 +96,15 @@ public final class Application implements Runnable {
|
|||
/**
|
||||
* Collections for evaluator thread pooling
|
||||
*/
|
||||
protected Stack freeThreads;
|
||||
protected Vector allThreads;
|
||||
protected Stack<RequestEvaluator> freeThreads;
|
||||
protected Vector<RequestEvaluator> allThreads;
|
||||
boolean running = false;
|
||||
boolean debug;
|
||||
long starttime;
|
||||
Hashtable dbSources;
|
||||
Hashtable<String, DbSource> dbSources;
|
||||
|
||||
// map of app modules reflected at app.modules
|
||||
Map modules;
|
||||
Map<String, Object> modules;
|
||||
|
||||
// internal worker thread for scheduler, session cleanup etc.
|
||||
Thread worker;
|
||||
|
@ -113,10 +113,10 @@ public final class Application implements Runnable {
|
|||
ThreadGroup threadgroup;
|
||||
|
||||
// threadlocal variable for the current RequestEvaluator
|
||||
ThreadLocal currentEvaluator = new ThreadLocal();
|
||||
ThreadLocal<RequestEvaluator> currentEvaluator = new ThreadLocal<>();
|
||||
|
||||
// Map of requesttrans -> active requestevaluators
|
||||
Hashtable activeRequests;
|
||||
Hashtable<RequestTrans, RequestEvaluator> activeRequests;
|
||||
|
||||
String logDir;
|
||||
|
||||
|
@ -165,15 +165,15 @@ public final class Application implements Runnable {
|
|||
private long lastPropertyRead = -1L;
|
||||
|
||||
// the set of prototype/function pairs which are allowed to be called via XML-RPC
|
||||
private HashSet xmlrpcAccess;
|
||||
private HashSet<String> xmlrpcAccess;
|
||||
|
||||
// the name under which this app serves XML-RPC requests. Defaults to the app name
|
||||
private String xmlrpcHandlerName;
|
||||
|
||||
// the list of currently active cron jobs
|
||||
Hashtable activeCronJobs = null;
|
||||
Hashtable<String, CronRunner> activeCronJobs = null;
|
||||
// the list of custom cron jobs
|
||||
Hashtable customCronJobs = null;
|
||||
Hashtable<String, CronJob> customCronJobs = null;
|
||||
|
||||
private ResourceComparator resourceComparator;
|
||||
private Resource currentCodeResource;
|
||||
|
@ -230,7 +230,7 @@ public final class Application implements Runnable {
|
|||
|
||||
this.caseInsensitive = "true".equalsIgnoreCase(server.getAppsProperties(name).getProperty("caseInsensitive"));
|
||||
|
||||
this.repositories = new ArrayList();
|
||||
this.repositories = new ArrayList<>();
|
||||
this.repositories.addAll(Arrays.asList(repositories));
|
||||
resourceComparator = new ResourceComparator(this);
|
||||
|
||||
|
@ -304,7 +304,7 @@ public final class Application implements Runnable {
|
|||
|
||||
updateProperties();
|
||||
|
||||
dbSources = new Hashtable();
|
||||
dbSources = new Hashtable<>();
|
||||
modules = new SystemMap();
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,9 @@ public final class Application implements Runnable {
|
|||
|
||||
private void initInternal()
|
||||
throws DatabaseException, IllegalAccessException,
|
||||
InstantiationException, ClassNotFoundException {
|
||||
InstantiationException, ClassNotFoundException,
|
||||
IllegalArgumentException, InvocationTargetException,
|
||||
NoSuchMethodException, SecurityException {
|
||||
running = true;
|
||||
// create and init type mananger
|
||||
typemgr = new TypeManager(Application.this, ignoreDirs);
|
||||
|
@ -381,7 +383,7 @@ public final class Application implements Runnable {
|
|||
}
|
||||
|
||||
if (Server.getServer() != null) {
|
||||
Vector extensions = Server.getServer().getExtensions();
|
||||
Vector<HelmaExtension> extensions = Server.getServer().getExtensions();
|
||||
|
||||
for (int i = 0; i < extensions.size(); i++) {
|
||||
HelmaExtension ext = (HelmaExtension) extensions.get(i);
|
||||
|
@ -396,12 +398,12 @@ public final class Application implements Runnable {
|
|||
}
|
||||
|
||||
// create and init evaluator/thread lists
|
||||
freeThreads = new Stack();
|
||||
allThreads = new Vector();
|
||||
freeThreads = new Stack<>();
|
||||
allThreads = new Vector<>();
|
||||
|
||||
activeRequests = new Hashtable();
|
||||
activeCronJobs = new Hashtable();
|
||||
customCronJobs = new Hashtable();
|
||||
activeRequests = new Hashtable<>();
|
||||
activeCronJobs = new Hashtable<>();
|
||||
customCronJobs = new Hashtable<>();
|
||||
|
||||
// create the skin manager
|
||||
skinmgr = new SkinManager(Application.this);
|
||||
|
@ -442,7 +444,13 @@ public final class Application implements Runnable {
|
|||
// create and init session manager
|
||||
String sessionMgrImpl = props.getProperty("sessionManagerImpl",
|
||||
"helma.framework.core.SessionManager");
|
||||
sessionMgr = (SessionManager) Class.forName(sessionMgrImpl).newInstance();
|
||||
try {
|
||||
sessionMgr = (SessionManager) Class.forName(sessionMgrImpl)
|
||||
.getDeclaredConstructor()
|
||||
.newInstance();
|
||||
} catch (NoSuchMethodException | InvocationTargetException e) {
|
||||
throw new RuntimeException("Error initializing session manager", e);
|
||||
}
|
||||
logEvent("Using session manager class " + sessionMgrImpl);
|
||||
sessionMgr.init(Application.this);
|
||||
|
||||
|
@ -879,7 +887,7 @@ public final class Application implements Runnable {
|
|||
} else {
|
||||
String rootClass = classMapping.getProperty("root");
|
||||
Class c = typemgr.getClassLoader().loadClass(rootClass);
|
||||
rootObject = c.newInstance();
|
||||
rootObject = c.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error creating root object: " +
|
||||
|
|
|
@ -100,7 +100,7 @@ public final class RequestEvaluator implements Runnable {
|
|||
app.setCurrentRequestEvaluator(this);
|
||||
Class clazz = app.getClassLoader().loadClass(engineClassName);
|
||||
|
||||
scriptingEngine = (ScriptingEngine) clazz.newInstance();
|
||||
scriptingEngine = (ScriptingEngine) clazz.getDeclaredConstructor().newInstance();
|
||||
scriptingEngine.init(app, this);
|
||||
} catch (Exception x) {
|
||||
Throwable t = x;
|
||||
|
|
|
@ -72,7 +72,7 @@ public abstract class ImageGenerator {
|
|||
"The imageGenerator class cannot be found: " + className);
|
||||
}
|
||||
try {
|
||||
generator = (ImageGenerator)generatorClass.newInstance();
|
||||
generator = (ImageGenerator) generatorClass.getDeclaredConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(
|
||||
"The ImageGenerator instance could not be created: "
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Vector;
|
|||
* (or input streams).
|
||||
* <p>
|
||||
* Use the class like this:
|
||||
*
|
||||
* <pre>
|
||||
* ImageInfo ii = new ImageInfo();
|
||||
* ii.setInput(in); // in can be InputStream or RandomAccessFile
|
||||
|
@ -45,12 +46,16 @@ import java.util.Vector;
|
|||
* " image(s), " + ii.getNumberOfComments() + " comment(s).");
|
||||
* // there are other properties, check out the API documentation
|
||||
* </pre>
|
||||
*
|
||||
* You can also use this class as a command line program.
|
||||
* Call it with a number of image file names and URLs as parameters:
|
||||
*
|
||||
* <pre>
|
||||
* java ImageInfo *.jpg *.png *.gif http://somesite.tld/image.jpg
|
||||
* </pre>
|
||||
*
|
||||
* or call it without parameters and pipe data to it:
|
||||
*
|
||||
* <pre>
|
||||
* java ImageInfo < image.jpg
|
||||
* </pre>
|
||||
|
@ -64,7 +69,8 @@ import java.util.Vector;
|
|||
* setDetermineImageNumber(true) before calling check().
|
||||
* The complete scan over the GIF file will take additional time.</li>
|
||||
* <li>Transparency information is not included in the bits per pixel count.
|
||||
* Actually, it was my decision not to include those bits, so it's a feature! ;-)</li>
|
||||
* Actually, it was my decision not to include those bits, so it's a feature!
|
||||
* ;-)</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Requirements:
|
||||
|
@ -72,9 +78,12 @@ import java.util.Vector;
|
|||
* <li>Java 1.1 or higher</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* The latest version can be found at <a href="http://www.geocities.com/marcoschmidt.geo/image-info.html">http://www.geocities.com/marcoschmidt.geo/image-info.html</a>.
|
||||
* The latest version can be found at <a href=
|
||||
* "http://www.geocities.com/marcoschmidt.geo/image-info.html">http://www.geocities.com/marcoschmidt.geo/image-info.html</a>.
|
||||
* <p>
|
||||
* Written by <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">Marco Schmidt</a>.
|
||||
* Written by
|
||||
* <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">Marco
|
||||
* Schmidt</a>.
|
||||
* <p>
|
||||
* This class is contributed to the Public Domain.
|
||||
* Use it at your own risk.
|
||||
|
@ -84,35 +93,53 @@ import java.util.Vector;
|
|||
* History:
|
||||
* <ul>
|
||||
* <li><strong>2001-08-24</strong> Initial version.</li>
|
||||
* <li><strong>2001-10-13</strong> Added support for the file formats BMP and PCX.</li>
|
||||
* <li><strong>2001-10-16</strong> Fixed bug in read(int[], int, int) that returned
|
||||
* <li><strong>2002-01-22</strong> Added support for file formats Amiga IFF and Sun Raster (RAS).</li>
|
||||
* <li><strong>2002-01-24</strong> Added support for file formats Portable Bitmap / Graymap / Pixmap (PBM, PGM, PPM) and Adobe Photoshop (PSD).
|
||||
* Added new method getMimeType() to return the MIME type associated with a particular file format.</li>
|
||||
* <li><strong>2002-03-15</strong> Added support to recognize number of images in file. Only works with GIF.
|
||||
* Use {@link #setDetermineImageNumber} with <code>true</code> as argument to identify animated GIFs
|
||||
* ({@link #getNumberOfImages()} will return a value larger than <code>1</code>).</li>
|
||||
* <li><strong>2002-04-10</strong> Fixed a bug in the feature 'determine number of images in animated GIF' introduced with version 1.1.
|
||||
* <li><strong>2001-10-13</strong> Added support for the file formats BMP and
|
||||
* PCX.</li>
|
||||
* <li><strong>2001-10-16</strong> Fixed bug in read(int[], int, int) that
|
||||
* returned
|
||||
* <li><strong>2002-01-22</strong> Added support for file formats Amiga IFF and
|
||||
* Sun Raster (RAS).</li>
|
||||
* <li><strong>2002-01-24</strong> Added support for file formats Portable
|
||||
* Bitmap / Graymap / Pixmap (PBM, PGM, PPM) and Adobe Photoshop (PSD).
|
||||
* Added new method getMimeType() to return the MIME type associated with a
|
||||
* particular file format.</li>
|
||||
* <li><strong>2002-03-15</strong> Added support to recognize number of images
|
||||
* in file. Only works with GIF.
|
||||
* Use {@link #setDetermineImageNumber} with <code>true</code> as argument to
|
||||
* identify animated GIFs
|
||||
* ({@link #getNumberOfImages()} will return a value larger than
|
||||
* <code>1</code>).</li>
|
||||
* <li><strong>2002-04-10</strong> Fixed a bug in the feature 'determine number
|
||||
* of images in animated GIF' introduced with version 1.1.
|
||||
* Thanks to Marcelo P. Lima for sending in the bug report.
|
||||
* Released as 1.1.1.</li>
|
||||
* <li><strong>2002-04-18</strong> Added {@link #setCollectComments(boolean)}.
|
||||
* That new method lets the user specify whether textual comments are to be
|
||||
* stored in an internal list when encountered in an input image file / stream.
|
||||
* Added two methods to return the physical width and height of the image in dpi:
|
||||
* Added two methods to return the physical width and height of the image in
|
||||
* dpi:
|
||||
* {@link #getPhysicalWidthDpi()} and {@link #getPhysicalHeightDpi()}.
|
||||
* If the physical resolution could not be retrieved, these methods return <code>-1</code>.
|
||||
* If the physical resolution could not be retrieved, these methods return
|
||||
* <code>-1</code>.
|
||||
* </li>
|
||||
* <li><strong>2002-04-23</strong> Added support for the new properties physical resolution and
|
||||
* <li><strong>2002-04-23</strong> Added support for the new properties physical
|
||||
* resolution and
|
||||
* comments for some formats. Released as 1.2.</li>
|
||||
* <li><strong>2002-06-17</strong> Added support for SWF, sent in by Michael Aird.
|
||||
* Changed checkJpeg() so that other APP markers than APP0 will not lead to a failure anymore.
|
||||
* <li><strong>2002-06-17</strong> Added support for SWF, sent in by Michael
|
||||
* Aird.
|
||||
* Changed checkJpeg() so that other APP markers than APP0 will not lead to a
|
||||
* failure anymore.
|
||||
* Released as 1.3.</li>
|
||||
* <li><strong>2003-07-28</strong> Bug fix - skip method now takes return values into consideration.
|
||||
* Less bytes than necessary may have been skipped, leading to flaws in the retrieved information in some cases.
|
||||
* <li><strong>2003-07-28</strong> Bug fix - skip method now takes return values
|
||||
* into consideration.
|
||||
* Less bytes than necessary may have been skipped, leading to flaws in the
|
||||
* retrieved information in some cases.
|
||||
* Thanks to Bernard Bernstein for pointing that out.
|
||||
* Released as 1.4.</li>
|
||||
* <li><strong>2004-02-29</strong> Added support for recognizing progressive JPEG and
|
||||
* interlaced PNG and GIF. A new method {@link #isProgressive()} returns whether ImageInfo
|
||||
* <li><strong>2004-02-29</strong> Added support for recognizing progressive
|
||||
* JPEG and
|
||||
* interlaced PNG and GIF. A new method {@link #isProgressive()} returns whether
|
||||
* ImageInfo
|
||||
* has found that the storage type is progressive (or interlaced).
|
||||
* Thanks to Joe Germuska for suggesting the feature.
|
||||
* Bug fix: BMP physical resolution is now correctly determined.
|
||||
|
@ -136,8 +163,10 @@ public class ImageInfo {
|
|||
* of images (GIFs with more than one image are animations).
|
||||
* If you know of a place where GIFs store the physical resolution
|
||||
* of an image, please
|
||||
* <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">send me a mail</a>!
|
||||
* It is determined whether the GIF stream is interlaced (see {@link #isProgressive()}).
|
||||
* <a href="http://www.geocities.com/marcoschmidt.geo/contact.html">send me a
|
||||
* mail</a>!
|
||||
* It is determined whether the GIF stream is interlaced (see
|
||||
* {@link #isProgressive()}).
|
||||
*/
|
||||
public static final int FORMAT_GIF = 1;
|
||||
|
||||
|
@ -146,7 +175,8 @@ public class ImageInfo {
|
|||
* PNG only supports one image per file.
|
||||
* Both physical resolution and comments can be stored with PNG,
|
||||
* but ImageInfo is currently not able to extract those.
|
||||
* It is determined whether the PNG stream is interlaced (see {@link #isProgressive()}).
|
||||
* It is determined whether the PNG stream is interlaced (see
|
||||
* {@link #isProgressive()}).
|
||||
*/
|
||||
public static final int FORMAT_PNG = 2;
|
||||
|
||||
|
@ -203,8 +233,7 @@ public class ImageInfo {
|
|||
* The FORMAT_xyz int constants can be used as index values for
|
||||
* this array.
|
||||
*/
|
||||
private static final String[] FORMAT_NAMES =
|
||||
{"JPEG", "GIF", "PNG", "BMP", "PCX",
|
||||
private static final String[] FORMAT_NAMES = { "JPEG", "GIF", "PNG", "BMP", "PCX",
|
||||
"IFF", "RAS", "PBM", "PGM", "PPM",
|
||||
"PSD", "SWF" };
|
||||
|
||||
|
@ -213,8 +242,8 @@ public class ImageInfo {
|
|||
* The FORMAT_xyz int constants can be used as index values for
|
||||
* this array.
|
||||
*/
|
||||
private static final String[] MIME_TYPE_STRINGS =
|
||||
{"image/jpeg", "image/gif", "image/png", "image/bmp", "image/pcx",
|
||||
private static final String[] MIME_TYPE_STRINGS = { "image/jpeg", "image/gif", "image/png", "image/bmp",
|
||||
"image/pcx",
|
||||
"image/iff", "image/ras", "image/x-portable-bitmap", "image/x-portable-graymap", "image/x-portable-pixmap",
|
||||
"image/psd", "application/x-shockwave-flash" };
|
||||
|
||||
|
@ -222,13 +251,12 @@ public class ImageInfo {
|
|||
private int height;
|
||||
private int bitsPerPixel;
|
||||
private int numColors;
|
||||
private int colorType = COLOR_TYPE_UNKNOWN;
|
||||
private boolean progressive;
|
||||
private int format;
|
||||
private InputStream in;
|
||||
private DataInput din;
|
||||
private boolean collectComments = true;
|
||||
private Vector comments;
|
||||
private Vector<String> comments;
|
||||
private boolean determineNumberOfImages;
|
||||
private int numberOfImages;
|
||||
private int physicalHeightDpi;
|
||||
|
@ -238,7 +266,7 @@ public class ImageInfo {
|
|||
|
||||
private void addComment(String s) {
|
||||
if (comments == null) {
|
||||
comments = new Vector();
|
||||
comments = new Vector<String>();
|
||||
}
|
||||
comments.addElement(s);
|
||||
}
|
||||
|
@ -248,6 +276,7 @@ public class ImageInfo {
|
|||
* using {@link #setInput(InputStream)} or {@link #setInput(DataInput)}.
|
||||
* If true is returned, the file format was known and information
|
||||
* on the file's content can be retrieved using the various getXyz methods.
|
||||
*
|
||||
* @return if information could be retrieved from input
|
||||
*/
|
||||
public boolean check() {
|
||||
|
@ -265,44 +294,25 @@ public class ImageInfo {
|
|||
int b2 = read() & 0xff;
|
||||
if (b1 == 0x47 && b2 == 0x49) {
|
||||
return checkGif();
|
||||
}
|
||||
else
|
||||
if (b1 == 0x89 && b2 == 0x50) {
|
||||
} else if (b1 == 0x89 && b2 == 0x50) {
|
||||
return checkPng();
|
||||
}
|
||||
else
|
||||
if (b1 == 0xff && b2 == 0xd8) {
|
||||
} else if (b1 == 0xff && b2 == 0xd8) {
|
||||
return checkJpeg();
|
||||
}
|
||||
else
|
||||
if (b1 == 0x42 && b2 == 0x4d) {
|
||||
} else if (b1 == 0x42 && b2 == 0x4d) {
|
||||
return checkBmp();
|
||||
}
|
||||
else
|
||||
if (b1 == 0x0a && b2 < 0x06) {
|
||||
} else if (b1 == 0x0a && b2 < 0x06) {
|
||||
return checkPcx();
|
||||
}
|
||||
else
|
||||
if (b1 == 0x46 && b2 == 0x4f) {
|
||||
} else if (b1 == 0x46 && b2 == 0x4f) {
|
||||
return checkIff();
|
||||
}
|
||||
else
|
||||
if (b1 == 0x59 && b2 == 0xa6) {
|
||||
} else if (b1 == 0x59 && b2 == 0xa6) {
|
||||
return checkRas();
|
||||
}
|
||||
else
|
||||
if (b1 == 0x50 && b2 >= 0x31 && b2 <= 0x36) {
|
||||
} else if (b1 == 0x50 && b2 >= 0x31 && b2 <= 0x36) {
|
||||
return checkPnm(b2 - '0');
|
||||
}
|
||||
else
|
||||
if (b1 == 0x38 && b2 == 0x42) {
|
||||
} else if (b1 == 0x38 && b2 == 0x42) {
|
||||
return checkPsd();
|
||||
}
|
||||
else
|
||||
if (b1 == 0x46 && b2 == 0x57) {
|
||||
} else if (b1 == 0x46 && b2 == 0x57) {
|
||||
return checkSwf();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
|
@ -365,11 +375,9 @@ public class ImageInfo {
|
|||
}
|
||||
numberOfImages = 0;
|
||||
int blockType;
|
||||
do
|
||||
{
|
||||
do {
|
||||
blockType = read();
|
||||
switch(blockType)
|
||||
{
|
||||
switch (blockType) {
|
||||
case (0x2c): // image separator
|
||||
{
|
||||
if (read(a, 0, 9) != 9) {
|
||||
|
@ -389,18 +397,14 @@ public class ImageInfo {
|
|||
}
|
||||
skip(1); // initial code length
|
||||
int n;
|
||||
do
|
||||
{
|
||||
do {
|
||||
n = read();
|
||||
if (n > 0) {
|
||||
skip(n);
|
||||
}
|
||||
else
|
||||
if (n == -1) {
|
||||
} else if (n == -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
while (n > 0);
|
||||
} while (n > 0);
|
||||
numberOfImages++;
|
||||
break;
|
||||
}
|
||||
|
@ -410,8 +414,7 @@ public class ImageInfo {
|
|||
if (collectComments && extensionType == 0xfe) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int n;
|
||||
do
|
||||
{
|
||||
do {
|
||||
n = read();
|
||||
if (n == -1) {
|
||||
return false;
|
||||
|
@ -425,22 +428,17 @@ public class ImageInfo {
|
|||
sb.append((char) ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (n > 0);
|
||||
} while (n > 0);
|
||||
} else {
|
||||
int n;
|
||||
do
|
||||
{
|
||||
do {
|
||||
n = read();
|
||||
if (n > 0) {
|
||||
skip(n);
|
||||
}
|
||||
else
|
||||
if (n == -1) {
|
||||
} else if (n == -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
while (n > 0);
|
||||
} while (n > 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -448,13 +446,11 @@ public class ImageInfo {
|
|||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (blockType != 0x3b);
|
||||
} while (blockType != 0x3b);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -523,9 +519,7 @@ public class ImageInfo {
|
|||
if (data[7] == 1) {
|
||||
setPhysicalWidthDpi(getShortBigEndian(data, 8));
|
||||
setPhysicalHeightDpi(getShortBigEndian(data, 10));
|
||||
}
|
||||
else
|
||||
if (data[7] == 2) {
|
||||
} else if (data[7] == 2) {
|
||||
int x = getShortBigEndian(data, 8);
|
||||
int y = getShortBigEndian(data, 10);
|
||||
setPhysicalWidthDpi((int) (x * 2.54f));
|
||||
|
@ -533,9 +527,7 @@ public class ImageInfo {
|
|||
}
|
||||
}
|
||||
skip(size - 14);
|
||||
}
|
||||
else
|
||||
if (collectComments && size > 2 && marker == 0xfffe) { // comment
|
||||
} else if (collectComments && size > 2 && marker == 0xfffe) { // comment
|
||||
size -= 2;
|
||||
byte[] chars = new byte[size];
|
||||
if (read(chars, 0, size) != size) {
|
||||
|
@ -544,9 +536,7 @@ public class ImageInfo {
|
|||
String comment = new String(chars, "iso-8859-1");
|
||||
comment = comment.trim();
|
||||
addComment(comment);
|
||||
}
|
||||
else
|
||||
if (marker >= 0xffc0 && marker <= 0xffcf && marker != 0xffc4 && marker != 0xffc8) {
|
||||
} else if (marker >= 0xffc0 && marker <= 0xffcf && marker != 0xffc4 && marker != 0xffc8) {
|
||||
if (read(data, 0, 6) != 6) {
|
||||
return false;
|
||||
}
|
||||
|
@ -588,8 +578,7 @@ public class ImageInfo {
|
|||
(bits == 1 || bits == 2 || bits == 4 || bits == 8)) {
|
||||
// paletted
|
||||
bitsPerPixel = bits;
|
||||
} else
|
||||
if (planes == 3 && bits == 8) {
|
||||
} else if (planes == 3 && bits == 8) {
|
||||
// RGB truecolor
|
||||
bitsPerPixel = 24;
|
||||
} else {
|
||||
|
@ -630,8 +619,7 @@ public class ImageInfo {
|
|||
format = PNM_FORMATS[(id - 1) % 3];
|
||||
boolean hasPixelResolution = false;
|
||||
String s;
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
s = readLine();
|
||||
if (s != null) {
|
||||
s = s.trim();
|
||||
|
@ -670,9 +658,7 @@ public class ImageInfo {
|
|||
return true;
|
||||
}
|
||||
hasPixelResolution = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int maxSample;
|
||||
try {
|
||||
maxSample = Integer.parseInt(s);
|
||||
|
@ -732,16 +718,15 @@ public class ImageInfo {
|
|||
|
||||
// Written by Michael Aird.
|
||||
private boolean checkSwf() throws IOException {
|
||||
//get rid of the last byte of the signature, the byte of the version and 4 bytes of the size
|
||||
// get rid of the last byte of the signature, the byte of the version and 4
|
||||
// bytes of the size
|
||||
byte[] a = new byte[6];
|
||||
if (read(a) != a.length) {
|
||||
return false;
|
||||
}
|
||||
format = FORMAT_SWF;
|
||||
int bitSize = (int) readUBits(5);
|
||||
int minX = (int)readSBits( bitSize );
|
||||
int maxX = (int) readSBits(bitSize);
|
||||
int minY = (int)readSBits( bitSize );
|
||||
int maxY = (int) readSBits(bitSize);
|
||||
width = maxX / 20; // cause we're in twips
|
||||
height = maxY / 20; // cause we're in twips
|
||||
|
@ -775,8 +760,10 @@ public class ImageInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* If {@link #check()} was successful, returns the image's number of bits per pixel.
|
||||
* If {@link #check()} was successful, returns the image's number of bits per
|
||||
* pixel.
|
||||
* Does not include transparency information like the alpha channel.
|
||||
*
|
||||
* @return number of bits per image pixel
|
||||
*/
|
||||
public int getBitsPerPixel() {
|
||||
|
@ -792,7 +779,9 @@ public class ImageInfo {
|
|||
|
||||
/**
|
||||
* Returns the index'th comment retrieved from the image.
|
||||
* @throws IllegalArgumentException if index is smaller than 0 or larger than or equal
|
||||
*
|
||||
* @throws IllegalArgumentException if index is smaller than 0 or larger than or
|
||||
* equal
|
||||
* to the number of comments retrieved
|
||||
* @see #getNumberOfComments
|
||||
*/
|
||||
|
@ -807,6 +796,7 @@ public class ImageInfo {
|
|||
* If {@link #check()} was successful, returns the image format as one
|
||||
* of the FORMAT_xyz constants from this class.
|
||||
* Use {@link #getFormatName()} to get a textual description of the file format.
|
||||
*
|
||||
* @return file format as a FORMAT_xyz constant
|
||||
*/
|
||||
public int getFormat() {
|
||||
|
@ -816,6 +806,7 @@ public class ImageInfo {
|
|||
/**
|
||||
* If {@link #check()} was successful, returns the image format's name.
|
||||
* Use {@link #getFormat()} to get a unique number.
|
||||
*
|
||||
* @return file format name
|
||||
*/
|
||||
public String getFormatName() {
|
||||
|
@ -829,6 +820,7 @@ public class ImageInfo {
|
|||
/**
|
||||
* If {@link #check()} was successful, returns one the image's vertical
|
||||
* resolution in pixels.
|
||||
*
|
||||
* @return image height in pixels
|
||||
*/
|
||||
public int getHeight() {
|
||||
|
@ -836,16 +828,14 @@ public class ImageInfo {
|
|||
}
|
||||
|
||||
private int getIntBigEndian(byte[] a, int offs) {
|
||||
return
|
||||
(a[offs] & 0xff) << 24 |
|
||||
return (a[offs] & 0xff) << 24 |
|
||||
(a[offs + 1] & 0xff) << 16 |
|
||||
(a[offs + 2] & 0xff) << 8 |
|
||||
a[offs + 3] & 0xff;
|
||||
}
|
||||
|
||||
private int getIntLittleEndian(byte[] a, int offs) {
|
||||
return
|
||||
(a[offs + 3] & 0xff) << 24 |
|
||||
return (a[offs + 3] & 0xff) << 24 |
|
||||
(a[offs + 2] & 0xff) << 16 |
|
||||
(a[offs + 1] & 0xff) << 8 |
|
||||
a[offs] & 0xff;
|
||||
|
@ -854,12 +844,12 @@ public class ImageInfo {
|
|||
/**
|
||||
* If {@link #check()} was successful, returns a String with the
|
||||
* MIME type of the format.
|
||||
*
|
||||
* @return MIME type, e.g. <code>image/jpeg</code>
|
||||
*/
|
||||
public String getMimeType() {
|
||||
if (format >= 0 && format < MIME_TYPE_STRINGS.length) {
|
||||
if (format == FORMAT_JPEG && progressive)
|
||||
{
|
||||
if (format == FORMAT_JPEG && progressive) {
|
||||
return "image/pjpeg";
|
||||
}
|
||||
return MIME_TYPE_STRINGS[format];
|
||||
|
@ -869,15 +859,16 @@ public class ImageInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* If {@link #check()} was successful and {@link #setCollectComments(boolean)} was called with
|
||||
* If {@link #check()} was successful and {@link #setCollectComments(boolean)}
|
||||
* was called with
|
||||
* <code>true</code> as argument, returns the number of comments retrieved
|
||||
* from the input image stream / file.
|
||||
* Any number >= 0 and smaller than this number of comments is then a
|
||||
* valid argument for the {@link #getComment(int)} method.
|
||||
*
|
||||
* @return number of comments retrieved from input image
|
||||
*/
|
||||
public int getNumberOfComments()
|
||||
{
|
||||
public int getNumberOfComments() {
|
||||
if (comments == null) {
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -889,11 +880,12 @@ public class ImageInfo {
|
|||
* Returns the number of images in the examined file.
|
||||
* Assumes that <code>setDetermineImageNumber(true);</code> was called before
|
||||
* a successful call to {@link #check()}.
|
||||
* This value can currently be only different from <code>1</code> for GIF images.
|
||||
* This value can currently be only different from <code>1</code> for GIF
|
||||
* images.
|
||||
*
|
||||
* @return number of images in file
|
||||
*/
|
||||
public int getNumberOfImages()
|
||||
{
|
||||
public int getNumberOfImages() {
|
||||
return numberOfImages;
|
||||
}
|
||||
|
||||
|
@ -901,6 +893,7 @@ public class ImageInfo {
|
|||
* Returns the physical height of this image in dots per inch (dpi).
|
||||
* Assumes that {@link #check()} was successful.
|
||||
* Returns <code>-1</code> on failure.
|
||||
*
|
||||
* @return physical height (in dpi)
|
||||
* @see #getPhysicalWidthDpi()
|
||||
* @see #getPhysicalHeightInch()
|
||||
|
@ -910,8 +903,10 @@ public class ImageInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
|
||||
* If {@link #check()} was successful, returns the physical width of this image
|
||||
* in dpi (dots per inch)
|
||||
* or -1 if no value could be found.
|
||||
*
|
||||
* @return physical height (in dpi)
|
||||
* @see #getPhysicalHeightDpi()
|
||||
* @see #getPhysicalWidthDpi()
|
||||
|
@ -928,8 +923,10 @@ public class ImageInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* If {@link #check()} was successful, returns the physical width of this image in dpi (dots per inch)
|
||||
* If {@link #check()} was successful, returns the physical width of this image
|
||||
* in dpi (dots per inch)
|
||||
* or -1 if no value could be found.
|
||||
*
|
||||
* @return physical width (in dpi)
|
||||
* @see #getPhysicalHeightDpi()
|
||||
* @see #getPhysicalWidthInch()
|
||||
|
@ -943,6 +940,7 @@ public class ImageInfo {
|
|||
* Returns the physical width of an image in inches, or
|
||||
* <code>-1.0f</code> if width information is not available.
|
||||
* Assumes that {@link #check} has been called successfully.
|
||||
*
|
||||
* @return physical width in inches or <code>-1.0f</code> on failure
|
||||
* @see #getPhysicalWidthDpi
|
||||
* @see #getPhysicalHeightInch
|
||||
|
@ -958,8 +956,7 @@ public class ImageInfo {
|
|||
}
|
||||
|
||||
private int getShortBigEndian(byte[] a, int offs) {
|
||||
return
|
||||
(a[offs] & 0xff) << 8 |
|
||||
return (a[offs] & 0xff) << 8 |
|
||||
(a[offs + 1] & 0xff);
|
||||
}
|
||||
|
||||
|
@ -970,6 +967,7 @@ public class ImageInfo {
|
|||
/**
|
||||
* If {@link #check()} was successful, returns one the image's horizontal
|
||||
* resolution in pixels.
|
||||
*
|
||||
* @return image width in pixels
|
||||
*/
|
||||
public int getWidth() {
|
||||
|
@ -977,11 +975,12 @@ public class ImageInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns whether the image is stored in a progressive (also called: interlaced) way.
|
||||
* Returns whether the image is stored in a progressive (also called:
|
||||
* interlaced) way.
|
||||
*
|
||||
* @return true for progressive/interlaced, false otherwise
|
||||
*/
|
||||
public boolean isProgressive()
|
||||
{
|
||||
public boolean isProgressive() {
|
||||
return progressive;
|
||||
}
|
||||
|
||||
|
@ -991,6 +990,7 @@ public class ImageInfo {
|
|||
* printed to standard output, one line per file) or call
|
||||
* it with no parameters. It will then check data given to it
|
||||
* via standard input.
|
||||
*
|
||||
* @param args the program arguments which must be file names
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
@ -1044,8 +1044,7 @@ public class ImageInfo {
|
|||
imageInfo.getPhysicalHeightDpi() + ";" +
|
||||
imageInfo.getPhysicalWidthInch() + ";" +
|
||||
imageInfo.getPhysicalHeightInch() + ";" +
|
||||
imageInfo.isProgressive()
|
||||
);
|
||||
imageInfo.isProgressive());
|
||||
}
|
||||
|
||||
private static void printLine(int indentLevels, String text, float value, float minValidValue) {
|
||||
|
@ -1139,8 +1138,7 @@ public class ImageInfo {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
private long readUBits( int numBits ) throws IOException
|
||||
{
|
||||
private long readUBits(int numBits) throws IOException {
|
||||
if (numBits == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -1155,11 +1153,9 @@ public class ImageInfo {
|
|||
bitPos = 8;
|
||||
}
|
||||
|
||||
while( true )
|
||||
{
|
||||
while (true) {
|
||||
int shift = bitsLeft - bitPos;
|
||||
if( shift > 0 )
|
||||
{
|
||||
if (shift > 0) {
|
||||
// Consume the entire buffer
|
||||
result |= bitBuf << shift;
|
||||
bitsLeft -= bitPos;
|
||||
|
@ -1171,9 +1167,7 @@ public class ImageInfo {
|
|||
bitBuf = din.readByte();
|
||||
}
|
||||
bitPos = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Consume a portion of the buffer
|
||||
result |= bitBuf >> -shift;
|
||||
bitPos -= bitsLeft;
|
||||
|
@ -1187,14 +1181,12 @@ public class ImageInfo {
|
|||
/**
|
||||
* Read a signed value from the given number of bits
|
||||
*/
|
||||
private int readSBits( int numBits ) throws IOException
|
||||
{
|
||||
private int readSBits(int numBits) throws IOException {
|
||||
// Get the number as an unsigned value.
|
||||
long uBits = readUBits(numBits);
|
||||
|
||||
// Is the number negative?
|
||||
if( ( uBits & (1L << (numBits - 1))) != 0 )
|
||||
{
|
||||
if ((uBits & (1L << (numBits - 1))) != 0) {
|
||||
// Yes. Extend the sign.
|
||||
uBits |= -1L << numBits;
|
||||
}
|
||||
|
@ -1202,18 +1194,6 @@ public class ImageInfo {
|
|||
return (int) uBits;
|
||||
}
|
||||
|
||||
private void synchBits()
|
||||
{
|
||||
bitBuf = 0;
|
||||
bitPos = 0;
|
||||
}
|
||||
|
||||
private String readLine(int firstChar) throws IOException {
|
||||
StringBuffer result = new StringBuffer();
|
||||
result.append((char)firstChar);
|
||||
return readLine(result);
|
||||
}
|
||||
|
||||
private static void run(String sourceName, InputStream in, ImageInfo imageInfo, boolean verbose) {
|
||||
imageInfo.setInput(in);
|
||||
imageInfo.setDetermineImageNumber(false);
|
||||
|
@ -1227,12 +1207,12 @@ public class ImageInfo {
|
|||
* Specify whether textual comments are supposed to be extracted from input.
|
||||
* Default is <code>false</code>.
|
||||
* If enabled, comments will be added to an internal list.
|
||||
*
|
||||
* @param newValue if <code>true</code>, this class will read comments
|
||||
* @see #getNumberOfComments
|
||||
* @see #getComment
|
||||
*/
|
||||
public void setCollectComments(boolean newValue)
|
||||
{
|
||||
public void setCollectComments(boolean newValue) {
|
||||
collectComments = newValue;
|
||||
}
|
||||
|
||||
|
@ -1247,11 +1227,11 @@ public class ImageInfo {
|
|||
* the actual number of images can be queried via
|
||||
* {@link #getNumberOfImages()} after a successful call to
|
||||
* {@link #check()}.
|
||||
*
|
||||
* @param newValue will the number of images be determined?
|
||||
* @see #getNumberOfImages
|
||||
*/
|
||||
public void setDetermineImageNumber(boolean newValue)
|
||||
{
|
||||
public void setDetermineImageNumber(boolean newValue) {
|
||||
determineNumberOfImages = newValue;
|
||||
}
|
||||
|
||||
|
@ -1259,6 +1239,7 @@ public class ImageInfo {
|
|||
* Set the input stream to the argument stream (or file).
|
||||
* Note that {@link java.io.RandomAccessFile} implements
|
||||
* {@link java.io.DataInput}.
|
||||
*
|
||||
* @param dataInput the input stream to read from
|
||||
*/
|
||||
public void setInput(DataInput dataInput) {
|
||||
|
@ -1268,6 +1249,7 @@ public class ImageInfo {
|
|||
|
||||
/**
|
||||
* Set the input stream to the argument stream (or file).
|
||||
*
|
||||
* @param inputStream the input stream to read from
|
||||
*/
|
||||
public void setInput(InputStream inputStream) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.io.*;
|
|||
import java.util.*;
|
||||
import javax.imageio.*;
|
||||
import javax.imageio.spi.*;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
|
||||
public class GIFImageWriterSpi extends ImageWriterSpi {
|
||||
|
||||
|
@ -35,7 +36,7 @@ public class GIFImageWriterSpi extends ImageWriterSpi {
|
|||
new String[] {"gif", "GIF"},
|
||||
new String[] {"image/gif", "image/x-gif"},
|
||||
"helma.image.imageio.gif.GIFImageWriter",
|
||||
STANDARD_OUTPUT_TYPE,
|
||||
new Class<?>[] {ImageOutputStream.class},
|
||||
null,
|
||||
false, null, null, null, null,
|
||||
false, null, null, null, null
|
||||
|
|
|
@ -36,9 +36,9 @@ import helma.util.StringUtils;
|
|||
* This class is responsible for starting and stopping Helma applications.
|
||||
*/
|
||||
public class ApplicationManager implements XmlRpcHandler {
|
||||
private Hashtable descriptors;
|
||||
private Hashtable applications;
|
||||
private Hashtable xmlrpcHandlers;
|
||||
private Hashtable<String, AppDescriptor> descriptors;
|
||||
private Hashtable<String, Application> applications;
|
||||
private Hashtable<String, Application> xmlrpcHandlers;
|
||||
private ResourceProperties props;
|
||||
private Server server;
|
||||
private long lastModified;
|
||||
|
@ -54,9 +54,9 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
public ApplicationManager(ResourceProperties props, Server server) {
|
||||
this.props = props;
|
||||
this.server = server;
|
||||
this.descriptors = new Hashtable();
|
||||
this.applications = new Hashtable();
|
||||
this.xmlrpcHandlers = new Hashtable();
|
||||
this.descriptors = new Hashtable<String, AppDescriptor>();
|
||||
this.applications = new Hashtable<String, Application>();
|
||||
this.xmlrpcHandlers = new Hashtable<String, Application>();
|
||||
this.lastModified = 0;
|
||||
this.jetty = server.jetty;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
protected void checkForChanges() {
|
||||
if (this.props.lastModified() > this.lastModified && this.server.getApplicationsOption() == null) {
|
||||
try {
|
||||
for (Enumeration e = this.props.keys(); e.hasMoreElements();) {
|
||||
for (Enumeration<?> e = this.props.keys(); e.hasMoreElements();) {
|
||||
String appName = (String) e.nextElement();
|
||||
|
||||
if ((appName.indexOf(".") == -1) && //$NON-NLS-1$
|
||||
|
@ -80,7 +80,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
}
|
||||
|
||||
// then stop deleted ones
|
||||
for (Enumeration e = this.descriptors.elements(); e.hasMoreElements();) {
|
||||
for (Enumeration<AppDescriptor> e = this.descriptors.elements(); e.hasMoreElements();) {
|
||||
AppDescriptor appDesc = (AppDescriptor) e.nextElement();
|
||||
|
||||
// check if application has been removed and should be stopped
|
||||
|
@ -146,7 +146,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
desc.start();
|
||||
}
|
||||
} else {
|
||||
for (Enumeration e = this.props.keys(); e.hasMoreElements();) {
|
||||
for (Enumeration<?> e = this.props.keys(); e.hasMoreElements();) {
|
||||
String appName = (String) e.nextElement();
|
||||
|
||||
if (appName.indexOf(".") == -1) { //$NON-NLS-1$
|
||||
|
@ -162,7 +162,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
}
|
||||
}
|
||||
|
||||
for (Enumeration e = this.descriptors.elements(); e.hasMoreElements();) {
|
||||
for (Enumeration<AppDescriptor> e = this.descriptors.elements(); e.hasMoreElements();) {
|
||||
AppDescriptor appDesc = (AppDescriptor) e.nextElement();
|
||||
appDesc.bind();
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
* Stop all running applications.
|
||||
*/
|
||||
public void stopAll() {
|
||||
for (Enumeration en = this.descriptors.elements(); en.hasMoreElements();) {
|
||||
for (Enumeration<AppDescriptor> en = this.descriptors.elements(); en.hasMoreElements();) {
|
||||
try {
|
||||
AppDescriptor appDesc = (AppDescriptor) en.nextElement();
|
||||
|
||||
|
@ -206,7 +206,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
/**
|
||||
* Implements org.apache.xmlrpc.XmlRpcHandler.execute()
|
||||
*/
|
||||
public Object execute(String method, Vector params)
|
||||
public Object execute(String method, @SuppressWarnings("rawtypes") Vector params)
|
||||
throws Exception {
|
||||
int dot = method.indexOf("."); //$NON-NLS-1$
|
||||
|
||||
|
@ -365,8 +365,8 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
this.ignoreDirs = conf.getProperty("ignore"); //$NON-NLS-1$
|
||||
|
||||
// read and configure app repositories
|
||||
ArrayList repositoryList = new ArrayList();
|
||||
Class[] parameters = { String.class };
|
||||
ArrayList<Repository> repositoryList = new ArrayList<>();
|
||||
Class<?>[] parameters = { String.class };
|
||||
for (int i = 0; true; i++) {
|
||||
String repositoryArgs = conf.getProperty("repository." + i); //$NON-NLS-1$
|
||||
|
||||
|
@ -491,15 +491,16 @@ public class ApplicationManager implements XmlRpcHandler {
|
|||
rhandler.setResourceBase(staticContent.getPath());
|
||||
rhandler.setWelcomeFiles(staticHome);
|
||||
|
||||
staticContext = ApplicationManager.this.context.addContext(staticMountpoint, ""); //$NON-NLS-1$
|
||||
staticContext = new ContextHandler(staticMountpoint);
|
||||
ApplicationManager.this.context.addHandler(staticContext);
|
||||
staticContext.setHandler(rhandler);
|
||||
|
||||
staticContext.start();
|
||||
}
|
||||
|
||||
appContext = new ServletContextHandler(context, pathPattern, true, true);
|
||||
Class servletClass = servletClassName == null ?
|
||||
EmbeddedServletClient.class : Class.forName(servletClassName);
|
||||
Class<? extends EmbeddedServletClient> servletClass = servletClassName == null ?
|
||||
EmbeddedServletClient.class : Class.forName(servletClassName).asSubclass(EmbeddedServletClient.class);
|
||||
ServletHolder holder = new ServletHolder(servletClass);
|
||||
holder.setInitParameter("application", appName);
|
||||
appContext.addServlet(holder, "/*");
|
||||
|
|
|
@ -41,7 +41,7 @@ public class CommandlineRunner {
|
|||
|
||||
ServerConfig config = new ServerConfig();
|
||||
String commandStr = null;
|
||||
Vector funcArgs = new Vector();
|
||||
Vector<String> funcArgs = new Vector<>();
|
||||
|
||||
// get possible environment setting for helma home
|
||||
if (System.getProperty("helma.home") != null) {
|
||||
|
|
|
@ -30,11 +30,13 @@ import java.util.HashSet;
|
|||
* a utility method <code>getApplication</code> that can be used to determine
|
||||
* the name of the application trying to execute the action in question, if any.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("removal")
|
||||
public class HelmaSecurityManager extends SecurityManager {
|
||||
// The set of actions forbidden to application code.
|
||||
// We are pretty permissive, forbidding only System.exit()
|
||||
// and setting the security manager.
|
||||
private final static HashSet forbidden = new HashSet();
|
||||
private final static HashSet<String> forbidden = new HashSet<>();
|
||||
|
||||
static {
|
||||
forbidden.add("exitVM");
|
||||
|
@ -49,7 +51,7 @@ public class HelmaSecurityManager extends SecurityManager {
|
|||
public void checkPermission(Permission p) {
|
||||
if (p instanceof RuntimePermission) {
|
||||
if (forbidden.contains(p.getName())) {
|
||||
Class[] classes = getClassContext();
|
||||
Class<?>[] classes = getClassContext();
|
||||
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].getClassLoader() instanceof AppClassLoader) {
|
||||
|
@ -98,7 +100,7 @@ public class HelmaSecurityManager extends SecurityManager {
|
|||
* @param status ...
|
||||
*/
|
||||
public void checkExit(int status) {
|
||||
Class[] classes = getClassContext();
|
||||
Class<?>[] classes = getClassContext();
|
||||
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].getClassLoader() instanceof AppClassLoader) {
|
||||
|
@ -287,7 +289,7 @@ public class HelmaSecurityManager extends SecurityManager {
|
|||
* @param clazz ...
|
||||
* @param which ...
|
||||
*/
|
||||
public void checkMemberAccess(Class clazz, int which) {
|
||||
public void checkMemberAccess(Class<?> clazz, int which) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -304,7 +306,7 @@ public class HelmaSecurityManager extends SecurityManager {
|
|||
* does not belong to any application.
|
||||
*/
|
||||
protected String getApplication() {
|
||||
Class[] classes = getClassContext();
|
||||
Class<?>[] classes = getClassContext();
|
||||
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].getClassLoader() instanceof AppClassLoader) {
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
package helma.main;
|
||||
|
||||
import helma.util.*;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* ShutdownHook that shuts down all running Helma applications on exit.
|
||||
*/
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.jetty.server.Connector;
|
|||
import org.eclipse.jetty.server.HttpConfiguration;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
||||
import java.net.URL;
|
||||
|
@ -47,7 +48,7 @@ public class JettyServer {
|
|||
http = new org.eclipse.jetty.server.Server();
|
||||
|
||||
try {
|
||||
XmlConfiguration config = new XmlConfiguration(url);
|
||||
XmlConfiguration config = new XmlConfiguration(Resource.newResource(url));
|
||||
config.configure(http);
|
||||
|
||||
} catch (IOException e) {
|
||||
|
@ -73,7 +74,7 @@ public class JettyServer {
|
|||
connector.setHost(webPort.getAddress().getHostAddress());
|
||||
connector.setPort(webPort.getPort());
|
||||
connector.setIdleTimeout(30000);
|
||||
connector.setSoLingerTime(-1);
|
||||
// Removed deprecated method setSoLingerTime
|
||||
connector.setAcceptorPriorityDelta(0);
|
||||
connector.setAcceptQueueSize(0);
|
||||
|
||||
|
|
|
@ -29,8 +29,6 @@ import java.io.*;
|
|||
import java.util.*;
|
||||
import java.net.*;
|
||||
|
||||
import helma.util.ResourceProperties;
|
||||
|
||||
/**
|
||||
* Helma server main class.
|
||||
*/
|
||||
|
@ -67,14 +65,14 @@ public class Server implements Runnable {
|
|||
// explicitly listed hosts.
|
||||
public boolean paranoid;
|
||||
private ApplicationManager appManager;
|
||||
private Vector extensions;
|
||||
private Vector<HelmaExtension> extensions;
|
||||
private Thread mainThread;
|
||||
|
||||
// configuration
|
||||
ServerConfig config;
|
||||
|
||||
// map of server-wide database sources
|
||||
Hashtable dbSources;
|
||||
Hashtable<String, DbSource> dbSources;
|
||||
|
||||
// the embedded web server
|
||||
// protected Serve websrv;
|
||||
|
@ -432,10 +430,10 @@ public class Server implements Runnable {
|
|||
// logger.debug("TimeZone = " +
|
||||
// TimeZone.getDefault().getDisplayName(Locale.getDefault()));
|
||||
|
||||
dbSources = new Hashtable();
|
||||
dbSources = new Hashtable<String, DbSource>();
|
||||
|
||||
// try to load the extensions
|
||||
extensions = new Vector();
|
||||
extensions = new Vector<HelmaExtension>();
|
||||
if (sysProps.getProperty("extensions") != null) {
|
||||
initExtensions();
|
||||
}
|
||||
|
@ -452,8 +450,8 @@ public class Server implements Runnable {
|
|||
String extClassName = tok.nextToken().trim();
|
||||
|
||||
try {
|
||||
Class extClass = Class.forName(extClassName);
|
||||
HelmaExtension ext = (HelmaExtension) extClass.newInstance();
|
||||
Class<? extends HelmaExtension> extClass = Class.forName(extClassName).asSubclass(HelmaExtension.class);
|
||||
HelmaExtension ext = (HelmaExtension) extClass.getDeclaredConstructor().newInstance();
|
||||
ext.init(this);
|
||||
extensions.add(ext);
|
||||
logger.info("Loaded: " + extClassName);
|
||||
|
@ -572,7 +570,9 @@ public class Server implements Runnable {
|
|||
String secManClass = sysProps.getProperty("securityManager");
|
||||
|
||||
if (secManClass != null) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager secMan = (SecurityManager) Class.forName(secManClass)
|
||||
.getDeclaredConstructor()
|
||||
.newInstance();
|
||||
|
||||
System.setSecurityManager(secMan);
|
||||
|
@ -764,7 +764,7 @@ public class Server implements Runnable {
|
|||
*
|
||||
* @return ...
|
||||
*/
|
||||
public Vector getExtensions() {
|
||||
public Vector<HelmaExtension> getExtensions() {
|
||||
return extensions;
|
||||
}
|
||||
|
||||
|
@ -805,5 +805,3 @@ public class Server implements Runnable {
|
|||
return new InetSocketAddress(addr, port);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package helma.objectmodel;
|
|||
|
||||
import helma.framework.IPathElement;
|
||||
import helma.framework.core.Application;
|
||||
import helma.framework.core.RequestEvaluator;
|
||||
import helma.objectmodel.db.DbMapping;
|
||||
import helma.objectmodel.db.Relation;
|
||||
import helma.objectmodel.db.Node;
|
||||
|
@ -65,6 +64,7 @@ public class TransientNode implements INode, Serializable {
|
|||
this.app=app;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private TransientNode() {
|
||||
app=null;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import helma.objectmodel.*;
|
|||
import helma.objectmodel.dom.XmlDatabase;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
|
@ -59,19 +60,25 @@ public final class NodeManager {
|
|||
* Initialize the NodeManager for the given dbHome and
|
||||
* application properties. An embedded database will be
|
||||
* created in dbHome if one doesn't already exist.
|
||||
* @throws SecurityException
|
||||
* @throws NoSuchMethodException
|
||||
* @throws InvocationTargetException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public void init(File dbHome, Properties props)
|
||||
throws DatabaseException, ClassNotFoundException,
|
||||
IllegalAccessException, InstantiationException {
|
||||
IllegalAccessException, InstantiationException,
|
||||
IllegalArgumentException, InvocationTargetException,
|
||||
NoSuchMethodException, SecurityException {
|
||||
String cacheImpl = props.getProperty("cacheimpl", "helma.util.CacheMap");
|
||||
|
||||
cache = (ObjectCache) Class.forName(cacheImpl).newInstance();
|
||||
cache = (ObjectCache) Class.forName(cacheImpl).getDeclaredConstructor().newInstance();
|
||||
cache.init(app);
|
||||
|
||||
String idgenImpl = props.getProperty("idGeneratorImpl");
|
||||
|
||||
if (idgenImpl != null) {
|
||||
idgen = (IDGenerator) Class.forName(idgenImpl).newInstance();
|
||||
idgen = (IDGenerator) Class.forName(idgenImpl).getDeclaredConstructor().newInstance();
|
||||
idgen.init(app);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ public class SubnodeList implements Serializable {
|
|||
/**
|
||||
* Hide/disable zero argument constructor for subclasses
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private SubnodeList() {}
|
||||
|
||||
/**
|
||||
|
|
|
@ -463,8 +463,6 @@ public class Transactor {
|
|||
node.clearWriteLock();
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
// set last subnode change times in parent nodes
|
||||
for (Iterator i = parentNodes.iterator(); i.hasNext(); ) {
|
||||
Node node = (Node) i.next();
|
||||
|
|
|
@ -48,14 +48,7 @@ public class ScriptingException extends Exception {
|
|||
*/
|
||||
private void setScriptStack(Throwable cause) {
|
||||
if (cause instanceof RhinoException) {
|
||||
FilenameFilter filter = new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(".js") ||
|
||||
name.endsWith(".hac") ||
|
||||
name.endsWith(".hsp");
|
||||
}
|
||||
};
|
||||
scriptStack = ((RhinoException) cause).getScriptStackTrace(filter);
|
||||
scriptStack = ((RhinoException) cause).getScriptStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,11 +48,11 @@ public class CompiledOrInterpretedModuleScriptProvider extends StrongCachingModu
|
|||
// unlikely, but possible exception during loading the module script without compilation
|
||||
Exception exception;
|
||||
// get the application's optimization level
|
||||
int optimizationLevel = cx.getOptimizationLevel();
|
||||
boolean interpretedMode = cx.isInterpretedMode();
|
||||
|
||||
try {
|
||||
// set the optimization level to not compile, but interpret
|
||||
cx.setOptimizationLevel(-1);
|
||||
cx.setInterpretedMode(true);
|
||||
// load the module script with the newly set optimization level
|
||||
ModuleScript moduleScript = super.getModuleScript(cx, moduleId, moduleUri, baseUri, paths);
|
||||
// return the module script
|
||||
|
@ -62,7 +62,7 @@ public class CompiledOrInterpretedModuleScriptProvider extends StrongCachingModu
|
|||
exception = e;
|
||||
} finally {
|
||||
// re-set the optimization
|
||||
cx.setOptimizationLevel(optimizationLevel);
|
||||
cx.setInterpretedMode(interpretedMode);
|
||||
}
|
||||
|
||||
// re-throw the exception catched when trying to load the module script without compilation
|
||||
|
|
|
@ -149,7 +149,7 @@ public class HopObjectCtor extends FunctionObject {
|
|||
private static final long serialVersionUID = -8041352998956882647L;
|
||||
|
||||
public GetById(Scriptable scope) {
|
||||
ScriptRuntime.setFunctionProtoAndParent(this, scope);
|
||||
ScriptRuntime.setFunctionProtoAndParent(this, Context.getCurrentContext(), scope);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,7 +201,7 @@ public class HopObjectCtor extends FunctionObject {
|
|||
private static final long serialVersionUID = -4046933261468527204L;
|
||||
|
||||
public HopCollection(Scriptable scope) {
|
||||
ScriptRuntime.setFunctionProtoAndParent(this, scope);
|
||||
ScriptRuntime.setFunctionProtoAndParent(this, Context.getCurrentContext(), scope);
|
||||
}
|
||||
|
||||
public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
|
||||
|
|
|
@ -67,7 +67,7 @@ import org.mozilla.javascript.*;
|
|||
* @author A. Sundararajan
|
||||
* @since 1.6
|
||||
*/
|
||||
public final class JSAdapter implements Scriptable, Function {
|
||||
public final class JSAdapter implements Function {
|
||||
private JSAdapter(Scriptable obj) {
|
||||
setAdaptee(obj);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class JSONModuleSource extends ModuleSource {
|
|||
content.append("module.exports = "); //$NON-NLS-1$
|
||||
|
||||
try {
|
||||
content.append(IOUtils.toString(this.getUri().toURL().openStream()));
|
||||
content.append(IOUtils.toString(this.getUri().toURL().openStream(), "UTF-8"));
|
||||
} catch (IOException e) {
|
||||
content.append("null"); //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package helma.scripting.rhino;
|
||||
|
||||
import helma.framework.core.*;
|
||||
import helma.framework.ResponseTrans;
|
||||
import helma.framework.repository.Resource;
|
||||
import org.mozilla.javascript.*;
|
||||
import java.lang.reflect.Method;
|
||||
|
|
|
@ -140,8 +140,8 @@ public class NodeModulesProvider extends UrlModuleSourceProvider {
|
|||
// check if the there is a "package.json" file in the directory
|
||||
if (packageFile.exists() && packageFile.isFile()) {
|
||||
// parse the JSON file
|
||||
JsonObject json = new JsonParser()
|
||||
.parse(new String(Files.readAllBytes(packageFile.toPath()))).getAsJsonObject();
|
||||
JsonObject json = JsonParser
|
||||
.parseString(new String(Files.readAllBytes(packageFile.toPath()))).getAsJsonObject();
|
||||
// check if the JSON file defines a main JS file
|
||||
if (json.has("main")) { //$NON-NLS-1$
|
||||
// get the main JS file, removing the filename extension
|
||||
|
|
|
@ -44,7 +44,6 @@ import org.mozilla.javascript.Undefined;
|
|||
import org.mozilla.javascript.WrapFactory;
|
||||
import org.mozilla.javascript.Wrapper;
|
||||
import org.mozilla.javascript.commonjs.module.RequireBuilder;
|
||||
import org.mozilla.javascript.commonjs.module.provider.StrongCachingModuleScriptProvider;
|
||||
import org.mozilla.javascript.tools.debugger.ScopeProvider;
|
||||
|
||||
import java.io.*;
|
||||
|
@ -1233,7 +1232,7 @@ public final class RhinoCore implements ScopeProvider {
|
|||
|
||||
protected void onContextCreated(Context cx) {
|
||||
cx.setWrapFactory(wrapper);
|
||||
cx.setOptimizationLevel(optLevel);
|
||||
cx.setInterpretedMode(optLevel < 0);
|
||||
cx.setInstructionObserverThreshold(10000);
|
||||
if (Context.isValidLanguageVersion(languageVersion)) {
|
||||
cx.setLanguageVersion(languageVersion);
|
||||
|
|
|
@ -49,13 +49,15 @@ class ScriptBeanProxy implements SerializationProxy {
|
|||
* @return the object represented by this proxy
|
||||
*/
|
||||
public Object getObject(RhinoEngine engine) {
|
||||
Object object = null;
|
||||
|
||||
try {
|
||||
Object object = engine.global.get(name, engine.global);
|
||||
object = engine.global.get(name, engine.global);
|
||||
} catch (Exception e) {
|
||||
System.out.println(name);
|
||||
}
|
||||
|
||||
return engine.global.get(name, engine.global);
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,9 @@ public class Profiler implements Debugger {
|
|||
name.substring(prefixLength)
|
||||
};
|
||||
formatter.format("%1$7d ms %2$5d ms %3$6d %4$s%n", args);
|
||||
return formatter.toString();
|
||||
String result = formatter.toString();
|
||||
formatter.close();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package helma.scripting.rhino.debug;
|
||||
|
||||
import helma.framework.ResponseTrans;
|
||||
import helma.util.HtmlEncoder;
|
||||
import org.mozilla.javascript.*;
|
||||
import org.mozilla.javascript.debug.*;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Enumeration;
|
|||
import java.util.Vector;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.*;
|
||||
|
||||
|
@ -62,9 +63,13 @@ public class DatabaseObject {
|
|||
* Create a new database object based on a driver name, with driver on the classpath
|
||||
*
|
||||
* @param driverName The class name of the JDBC driver
|
||||
* @throws SecurityException
|
||||
* @throws NoSuchMethodException
|
||||
* @throws InvocationTargetException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
|
||||
DatabaseObject(String driverName) {
|
||||
DatabaseObject(String driverName) throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
|
||||
this.driverName = driverName;
|
||||
try {
|
||||
Class driverClass = Class.forName(driverName);
|
||||
|
@ -73,7 +78,7 @@ public class DatabaseObject {
|
|||
// System.err.println("##Bad class " + driverClass);
|
||||
lastError = new RuntimeException("Class " + driverClass + " is not a JDBC driver");
|
||||
}
|
||||
driverClass.newInstance(); // may be needed by some drivers, harmless for others
|
||||
driverClass.getDeclaredConstructor().newInstance(); // may be needed by some drivers, harmless for others
|
||||
} catch (ClassNotFoundException e) {
|
||||
// System.err.println("##Cannot find driver class: " + e);
|
||||
// e.printStackTrace();
|
||||
|
@ -448,51 +453,6 @@ public class DatabaseObject {
|
|||
return null;
|
||||
}
|
||||
|
||||
/* FIXME: dunno if this method is still used somewhere
|
||||
public Object getProperty(String propertyName, int hash) {
|
||||
//System.err.println(" &&& Getting property '" + propertyName + "'");
|
||||
|
||||
// Length property is firsy checked
|
||||
|
||||
// First return system or or prototype properties
|
||||
if (propertyName.equals("length")) {
|
||||
return Integer.valueOf(colNames.size());
|
||||
} else {
|
||||
if (resultSet == null) {
|
||||
lastError = new SQLException("Attempt to access a released result set");
|
||||
return null;
|
||||
}
|
||||
if (!firstRowSeen) {
|
||||
lastError = new SQLException("Attempt to access data before the first row is read");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
int index = -1; // indicates not a valid index value
|
||||
try {
|
||||
char c = propertyName.charAt(0);
|
||||
if ('0' <= c && c <= '9') {
|
||||
index = Integer.parseInt(propertyName);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (StringIndexOutOfBoundsException e) { // for charAt
|
||||
}
|
||||
if (index>=0) {
|
||||
return getProperty(index);
|
||||
}
|
||||
Object value = resultSet.getObject(propertyName);
|
||||
// IServer.getLogger().log("&& @VALUE : " + value);
|
||||
lastError = null;
|
||||
return value;
|
||||
} catch (SQLException e) {
|
||||
// System.err.println("##Cannot get property '" + propertyName + "' " + e);
|
||||
// e.printStackTrace();
|
||||
lastError = e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
|
||||
public Object getProperty(int index) {
|
||||
if (!firstRowSeen) {
|
||||
lastError = new SQLException("Attempt to access data before the first row is read");
|
||||
|
|
|
@ -39,7 +39,7 @@ import javax.mail.internet.MimeUtility;
|
|||
* A JavaScript wrapper around a JavaMail message class to send
|
||||
* mail via SMTP from Helma
|
||||
*/
|
||||
public class MailObject extends ScriptableObject implements Serializable {
|
||||
public class MailObject extends ScriptableObject {
|
||||
|
||||
private static final long serialVersionUID = -4834981850233741039L;
|
||||
|
||||
|
|
|
@ -126,7 +126,9 @@ public class XmlObject {
|
|||
writer.setDatabaseMode(dbmode);
|
||||
writer.write(node);
|
||||
writer.flush();
|
||||
return out.toString("UTF-8");
|
||||
String result = out.toString("UTF-8");
|
||||
writer.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -217,7 +217,7 @@ public abstract class AbstractServletClient extends HttpServlet {
|
|||
parseParameters(request, reqtrans, encoding);
|
||||
|
||||
// read file uploads
|
||||
List uploads = null;
|
||||
List<FileItem> uploads = null;
|
||||
ServletRequestContext reqcx = new ServletRequestContext(request);
|
||||
|
||||
if (ServletFileUpload.isMultipartContent(reqcx)) {
|
||||
|
@ -637,7 +637,7 @@ public abstract class AbstractServletClient extends HttpServlet {
|
|||
* Put name and value pair in map. When name already exist, add value
|
||||
* to array of values.
|
||||
*/
|
||||
private static void putMapEntry(Map map, String name, String value) {
|
||||
private static void putMapEntry(Map<String, String[]> map, String name, String value) {
|
||||
String[] newValues = null;
|
||||
String[] oldValues = (String[]) map.get(name);
|
||||
|
||||
|
@ -653,7 +653,7 @@ public abstract class AbstractServletClient extends HttpServlet {
|
|||
map.put(name, newValues);
|
||||
}
|
||||
|
||||
protected List parseUploads(ServletRequestContext reqcx, RequestTrans reqtrans,
|
||||
protected List<FileItem> parseUploads(ServletRequestContext reqcx, RequestTrans reqtrans,
|
||||
final UploadStatus uploadStatus, String encoding)
|
||||
throws FileUploadException, UnsupportedEncodingException {
|
||||
// handle file upload
|
||||
|
@ -672,8 +672,8 @@ public abstract class AbstractServletClient extends HttpServlet {
|
|||
});
|
||||
}
|
||||
|
||||
List uploads = upload.parseRequest(reqcx);
|
||||
Iterator it = uploads.iterator();
|
||||
List<FileItem> uploads = upload.parseRequest(reqcx);
|
||||
Iterator<FileItem> it = uploads.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
FileItem item = (FileItem) it.next();
|
||||
|
@ -705,7 +705,7 @@ public abstract class AbstractServletClient extends HttpServlet {
|
|||
return;
|
||||
}
|
||||
|
||||
HashMap parameters = new HashMap();
|
||||
HashMap<String, String[]> parameters = new HashMap<>();
|
||||
|
||||
// Parse any query string parameters from the request
|
||||
if (queryString != null) {
|
||||
|
@ -764,7 +764,7 @@ public abstract class AbstractServletClient extends HttpServlet {
|
|||
*
|
||||
* @exception UnsupportedEncodingException if the data is malformed
|
||||
*/
|
||||
public static void parseParameters(Map map, byte[] data, String encoding, boolean isPost)
|
||||
public static void parseParameters(Map<String, String[]> map, byte[] data, String encoding, boolean isPost)
|
||||
throws UnsupportedEncodingException {
|
||||
if ((data != null) && (data.length > 0)) {
|
||||
int ix = 0;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package helma.servlet;
|
||||
|
||||
import helma.framework.*;
|
||||
import helma.framework.core.Application;
|
||||
import helma.main.*;
|
||||
import javax.servlet.*;
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.StringTokenizer;
|
|||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
import helma.framework.repository.Resource;
|
||||
import helma.framework.repository.Resource;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue