/**************************************************************************
* Copyright (c) 2007 by Chris Gray, /k/ Embedded Java Solutions. *
* All rights reserved. *
**************************************************************************/
package java.lang;
import java.io.InputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
/*
** Package-protected class used to implement the built-in system properties
** which are derived from compile-time constants, environment variables, etc..
** In practice this is a singleton, but we don't enforce this; the single
** instance is generated by the constructor of java.lang.DefaultProperties.
**
** TODO: override all the methods of Hashtable and Properties we don't implement?
** (Maybe not necessary, so long as no one can invoke them).
*/
class NativeProperties extends Properties {
String[] native_property_names;
NativeProperties() {
native_property_names = init();
}
public Enumeration keys() {
class KeyEnum implements Enumeration {
int i = 0;
int n = native_property_names.length;
public boolean hasMoreElements() {
return i < n;
}
public Object nextElement() {
return native_property_names[i++];
}
}
return new KeyEnum();
}
public native String[] init();
public native Object get(Object key);
public Object setProperty(String key, String value){
throw new UnknownError("Someone trying to change a native property?");
}
public void load(InputStream in) throws IOException {
throw new UnknownError("Someone trying to load the native properties?");
}
public Enumeration propertyNames() {
return keys();
}
}