package com.perforce.client.api; import java.util.*; public class StrDict extends Properties { int instance; private boolean javaCreatedTheInstance; // private static native int nNewInstance(); private static native void nDeleteInstance( int instance); /* private StrDict() { this.instance = nNewInstance(); javaCreatedTheInstance = true; } */ StrDict( int instance ) { this.instance = instance; javaCreatedTheInstance = false; } protected void finalize() { if ( javaCreatedTheInstance ) { nDeleteInstance( this.instance ); } } private static native void nSetVar( int instance, String name, String value ); private static native String nGetVar( int instance, String name ); private static native String nGetName( int instance, int index ); public String getProperty( String key ) { return nGetVar( this.instance, key ); } public synchronized Object put( Object key, Object value ) { nSetVar( this.instance, (String)key, (String)value ); return value; } public Enumeration propertyNames() { return new StrDictEnumeration( this ); } private static class StrDictEnumeration implements Enumeration { private int current = 0; private String stringToReturn = null; private StrDict source = null; public StrDictEnumeration( StrDict source ) { this.source = source; } private void preLoadString() { if ( stringToReturn == null ) { stringToReturn = nGetName( source.instance, current ); if ( stringToReturn != null ) { current++; } } } public boolean hasMoreElements() { preLoadString(); return (stringToReturn == null) ? false : true; } public Object nextElement() { preLoadString(); String temp = stringToReturn; stringToReturn = null; return temp; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 783 | paul_hammant |
First cut of P4 Soap API. Uses Glue, can't work yet as DLLs missing. |
||
//guest/michael_bishop/P4APIForJava/java/com/perforce/client/api/StrDict.java | |||||
#1 | 430 | Michael Bishop |
Initial checkin. Seems to work. Not very much testing. Not very much documentation. Some more commenting needs to take place. But, it's there to experiment with. |