forked from jnode/jnode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up
- Loading branch information
Showing
103 changed files
with
913 additions
and
1,035 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,14 +37,12 @@ | |
import java.io.Writer; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.Enumeration; | ||
import java.util.HashMap; | ||
import java.util.Hashtable; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.Vector; | ||
|
||
/** | ||
* XMLElement is a representation of an XML object. The object is able to parse | ||
|
@@ -102,8 +100,7 @@ | |
* <<A href="mailto:[email protected]">[email protected]</A>> | ||
* @version $Name$, $Revision: 1950 $ | ||
*/ | ||
public class XMLElement | ||
{ | ||
public class XMLElement { | ||
|
||
/** | ||
* Serialization serial version ID. | ||
|
@@ -363,9 +360,7 @@ public XMLElement(boolean skipLeadingWhitespace) | |
* @see XMLElement#XMLElement(java.util.Map) | ||
* XMLElement(Hashtable) | ||
*/ | ||
public XMLElement(Map<String, Object> entities, | ||
boolean skipLeadingWhitespace) | ||
{ | ||
public XMLElement(Map<String, Object> entities, boolean skipLeadingWhitespace) { | ||
this(entities, skipLeadingWhitespace, true, true); | ||
} | ||
|
||
|
@@ -404,8 +399,7 @@ public XMLElement(Map<String, Object> entities, | |
*/ | ||
public XMLElement(Map<String, Object> entities, | ||
boolean skipLeadingWhitespace, | ||
boolean ignoreCase) | ||
{ | ||
boolean ignoreCase) { | ||
this(entities, skipLeadingWhitespace, true, ignoreCase); | ||
} | ||
|
||
|
@@ -451,8 +445,7 @@ public XMLElement(Map<String, Object> entities, | |
protected XMLElement(Map<String, Object> entities, | ||
boolean skipLeadingWhitespace, | ||
boolean fillBasicConversionTable, | ||
boolean ignoreCase) | ||
{ | ||
boolean ignoreCase) { | ||
this.ignoreWhitespace = skipLeadingWhitespace; | ||
this.ignoreCase = ignoreCase; | ||
this.name = null; | ||
|
@@ -548,9 +541,7 @@ public void addChild(XMLElement child) | |
* String, boolean) | ||
* getStringAttribute(String, Hashtable, String, boolean) | ||
*/ | ||
public void setAttribute(String name, | ||
Object value) | ||
{ | ||
public void setAttribute(String name, Object value) { | ||
if (this.ignoreCase) { | ||
name = name.toUpperCase(); | ||
} | ||
|
@@ -567,9 +558,7 @@ public void setAttribute(String name, | |
* | ||
* @deprecated Use {@link #setAttribute(String, Object)} instead. | ||
*/ | ||
public void addProperty(String name, | ||
Object value) | ||
{ | ||
public void addProperty(String name, Object value) { | ||
this.setAttribute(name, value); | ||
} | ||
|
||
|
48 changes: 0 additions & 48 deletions
48
core/src/main/java/org/jnode/util/AccessControllerUtils.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,24 +20,27 @@ | |
|
||
package org.jnode.util; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import java.lang.System.Logger.Level; | ||
import java.lang.System.Logger; | ||
|
||
|
||
/** | ||
* @author Ewout Prangsma ([email protected]) | ||
*/ | ||
public class ByteQueueProcessorThread extends Thread { | ||
|
||
private static final Logger bootlog = LogManager.getLogger("bootlog"); | ||
private static final Logger bootlog = System.getLogger("bootlog"); | ||
|
||
/** | ||
* The queue i'm processing | ||
*/ | ||
private final ByteQueue queue; | ||
|
||
/** | ||
* The actual processor | ||
*/ | ||
private final ByteQueueProcessor processor; | ||
|
||
private boolean stop; | ||
|
||
/** | ||
|
@@ -76,19 +79,19 @@ public void stopProcessor() { | |
/** | ||
* Handle an exception thrown during the processing of the object. | ||
* | ||
* @param ex | ||
* @param ex exception | ||
*/ | ||
protected void handleException(Exception ex) { | ||
bootlog.error("Exception in ByteQueueProcessor: " + getName(), ex); | ||
bootlog.log(Level.ERROR, "Exception in ByteQueueProcessor: " + getName(), ex); | ||
} | ||
|
||
/** | ||
* Handle an exception thrown during the processing of the object. | ||
* | ||
* @param ex | ||
* @param ex exception | ||
*/ | ||
protected void handleError(Error ex) { | ||
bootlog.error("Error in ByteQueueProcessor: " + getName(), ex); | ||
bootlog.log(Level.ERROR, "Error in ByteQueueProcessor: " + getName(), ex); | ||
} | ||
|
||
/** | ||
|
@@ -117,5 +120,4 @@ public void run() { | |
public ByteQueue getQueue() { | ||
return queue; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,21 +29,24 @@ | |
import java.io.OutputStreamWriter; | ||
import java.io.Reader; | ||
import java.io.Writer; | ||
import java.lang.System.Logger; | ||
import java.lang.System.Logger.Level; | ||
import java.lang.reflect.Field; | ||
import java.security.AccessController; | ||
import java.security.PrivilegedAction; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import static java.lang.System.getLogger; | ||
|
||
|
||
/** | ||
* Common utility code for higher-level operations on IO streams. Notwithstanding the | ||
* nominal access for the class and its methods, user (command) code should avoid using | ||
* this class directly. You should program against the | ||
* {@link org.jnode.shell.io.CommandIO} API instead. | ||
* this class directly. | ||
* | ||
* @author [email protected] | ||
*/ | ||
public class IOUtils { | ||
|
||
private static final Logger log = getLogger(IOUtils.class.getName()); | ||
|
||
// FIXME ... these utils (in some cases) attempt to access non-public fields | ||
// of various stream classes in order to figure out what the underlying stream | ||
// is. Currently, we have to explicitly grant the calling application permissions | ||
|
@@ -121,71 +124,59 @@ public static Closeable findBaseStream(Closeable stream) { | |
} | ||
|
||
private static InputStream findInputStream(final FilterInputStream inputStream) { | ||
PrivilegedAction<InputStream> pa = () -> { | ||
try { | ||
Class<FilterInputStream> cls = FilterInputStream.class; | ||
Field field = cls.getDeclaredField("in"); | ||
field.setAccessible(true); | ||
Object in = field.get(inputStream); | ||
field.setAccessible(false); | ||
return (InputStream) in; | ||
} catch (Exception ex) { | ||
LogManager.getLogger(IOUtils.class).error("Cannot extract the 'in' field", ex); | ||
return null; | ||
} | ||
}; | ||
return AccessController.doPrivileged(pa); | ||
try { | ||
Class<FilterInputStream> cls = FilterInputStream.class; | ||
Field field = cls.getDeclaredField("in"); | ||
field.setAccessible(true); | ||
Object in = field.get(inputStream); | ||
field.setAccessible(false); | ||
return (InputStream) in; | ||
} catch (Exception ex) { | ||
log.log(Level.ERROR, "Cannot extract the 'in' field", ex); | ||
return null; | ||
} | ||
} | ||
|
||
private static OutputStream findOutputStream(final FilterOutputStream outputStream) { | ||
PrivilegedAction<OutputStream> pa = () -> { | ||
try { | ||
Class<FilterOutputStream> cls = FilterOutputStream.class; | ||
Field field = cls.getDeclaredField("out"); | ||
field.setAccessible(true); | ||
Object out = field.get(outputStream); | ||
return (OutputStream) out; | ||
} catch (Exception ex) { | ||
LogManager.getLogger(IOUtils.class).error("Cannot extract the 'out' field", ex); | ||
return null; | ||
} | ||
}; | ||
return AccessController.doPrivileged(pa); | ||
try { | ||
Class<FilterOutputStream> cls = FilterOutputStream.class; | ||
Field field = cls.getDeclaredField("out"); | ||
field.setAccessible(true); | ||
Object out = field.get(outputStream); | ||
return (OutputStream) out; | ||
} catch (Exception ex) { | ||
log.log(Level.ERROR, "Cannot extract the 'out' field", ex); | ||
return null; | ||
} | ||
} | ||
|
||
private static OutputStream findOutputStream(final OutputStreamWriter writer) { | ||
// This implementation is based on the knowledge that an OutputStreamWriter | ||
// uses the underlying OutputStream as its 'lock' object. | ||
PrivilegedAction<OutputStream> pa = () -> { | ||
try { | ||
Class<Writer> cls = Writer.class; | ||
Field field = cls.getDeclaredField("lock"); | ||
field.setAccessible(true); | ||
Object lock = field.get(writer); | ||
return (OutputStream) lock; | ||
} catch (Exception ex) { | ||
LogManager.getLogger(IOUtils.class).error("Cannot extract the 'lock' field", ex); | ||
return null; | ||
} | ||
}; | ||
return AccessController.doPrivileged(pa); | ||
try { | ||
Class<Writer> cls = Writer.class; | ||
Field field = cls.getDeclaredField("lock"); | ||
field.setAccessible(true); | ||
Object lock = field.get(writer); | ||
return (OutputStream) lock; | ||
} catch (Exception ex) { | ||
log.log(Level.ERROR, "Cannot extract the 'lock' field", ex); | ||
return null; | ||
} | ||
} | ||
|
||
private static InputStream findInputStream(final InputStreamReader reader) { | ||
// This implementation is based on the knowledge that an InputStreamReader | ||
// uses the underlying InputStream as its 'lock' object. | ||
PrivilegedAction<InputStream> pa = () -> { | ||
try { | ||
Class<Reader> cls = Reader.class; | ||
Field field = cls.getDeclaredField("lock"); | ||
field.setAccessible(true); | ||
Object lock = field.get(reader); | ||
return (InputStream) lock; | ||
} catch (Exception ex) { | ||
LogManager.getLogger(IOUtils.class).error("Cannot extract the 'lock' field", ex); | ||
return null; | ||
} | ||
}; | ||
return AccessController.doPrivileged(pa); | ||
try { | ||
Class<Reader> cls = Reader.class; | ||
Field field = cls.getDeclaredField("lock"); | ||
field.setAccessible(true); | ||
Object lock = field.get(reader); | ||
return (InputStream) lock; | ||
} catch (Exception ex) { | ||
log.log(Level.ERROR, "Cannot extract the 'lock' field", ex); | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.