зеркало из https://github.com/mozilla/pjs.git
REORG of source tree. Hierarchy is much cleaner now. Makefiles will likely be broken until next checkin. You've been warned.
This commit is contained in:
Родитель
3503f69696
Коммит
dbe9de679f
|
@ -0,0 +1,26 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Grendel mail/news client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
SUBDIRS= \
|
||||
util \
|
||||
$(NULL)
|
||||
|
||||
include ../rules.mk
|
|
@ -0,0 +1,292 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
package calypso.util;
|
||||
|
||||
/** A class for counting in a variety of bases.
|
||||
*/
|
||||
|
||||
public class Abacus
|
||||
{
|
||||
|
||||
/************************************************
|
||||
* Formatting Strings
|
||||
************************************************/
|
||||
|
||||
public final static String ones[]=
|
||||
{"zero","one ","two ","three ","four ","five ",
|
||||
"six ","seven ","eight ","nine ","ten "};
|
||||
|
||||
public final static String teens[]=
|
||||
{"ten ","eleven ","twelve ","thirteen ","fourteen ","fifteen ",
|
||||
"sixteen ","seventeen ","eighteen ","nineteen "};
|
||||
|
||||
public final static String tens[]=
|
||||
{"","ten ","twenty ","thirty ","forty ","fifty ",
|
||||
"sixty ","seventy ","eighty ","ninety ","hundred "};
|
||||
|
||||
public final static String bases[] =
|
||||
{"","hundred ","thousand ","million ","billion ","trillion ","quadrillion "};
|
||||
|
||||
protected final static String gAlphaChars = "abcdefghijklmnopqrstuvwxyz";
|
||||
protected final static String gRomanCharsA = "ixcm";
|
||||
protected final static String gRomanCharsB = "vld?";
|
||||
protected final static String gHexChars = "0123456789abcdef";
|
||||
protected final static String gBinaryChars = "01";
|
||||
|
||||
/************************************************
|
||||
* Data members...
|
||||
************************************************/
|
||||
|
||||
//notice that we don't have any?
|
||||
|
||||
/** Formats the value as an alpha string
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* @author gess 05-05-97 12:22pm
|
||||
* @notes
|
||||
*/
|
||||
public static String getAlphaString(int aValue)
|
||||
{
|
||||
return getSeriesString(Math.abs(aValue)-1,gAlphaChars,-1,gAlphaChars.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given integer value into a roman numeral string
|
||||
*
|
||||
* @param aValue - int to be converted to roman
|
||||
* @return new string
|
||||
* @author gess 05-05-97 12:53pm
|
||||
* @notes Those pesky romans used dashed above a value to multiply
|
||||
* that number by 1000. This has the unfortunate side effect
|
||||
* that without special font treatment, we cant represent
|
||||
* numbers in roman above 3999.
|
||||
* THIS METHOD HANDLES VALUES IN THE RANGE [1..3999].
|
||||
* (any other value is converted to simple numeric format.)
|
||||
*/
|
||||
public static String getRomanString(int aValue)
|
||||
{
|
||||
StringBuffer addOn = new StringBuffer();
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuffer decStr = new StringBuffer();
|
||||
|
||||
decStr.append(aValue);
|
||||
|
||||
int len=decStr.length();
|
||||
int romanPos=len;
|
||||
int n,digitPos;
|
||||
boolean negative=(aValue<0);
|
||||
|
||||
aValue=Math.abs(aValue);
|
||||
for(digitPos=0;digitPos<len;digitPos++)
|
||||
{
|
||||
romanPos--;
|
||||
addOn.setLength(0);
|
||||
switch(decStr.charAt(digitPos))
|
||||
{
|
||||
case '3': addOn.append(gRomanCharsA.charAt(romanPos));
|
||||
case '2': addOn.append(gRomanCharsA.charAt(romanPos));
|
||||
case '1': addOn.append(gRomanCharsA.charAt(romanPos));
|
||||
break;
|
||||
|
||||
case '4':
|
||||
addOn.append(gRomanCharsA.charAt(romanPos));
|
||||
|
||||
case '5': case '6':
|
||||
case '7': case '8':
|
||||
addOn.append(gRomanCharsB.charAt(romanPos));
|
||||
for(n=0;n<(decStr.charAt(digitPos)-'5');n++)
|
||||
addOn.append(gRomanCharsA.charAt(romanPos));
|
||||
break;
|
||||
case '9':
|
||||
addOn.append(gRomanCharsA.charAt(romanPos));
|
||||
addOn.append(gRomanCharsA.charAt(romanPos+1));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
result.append(addOn);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given integer value into a hexstring
|
||||
*
|
||||
* @param aValue - int to be converted to hex string
|
||||
* @return new string
|
||||
* @author gess 05-05-97 12:53pm
|
||||
*
|
||||
*/
|
||||
public static String getHexString(int aValue)
|
||||
{
|
||||
if (aValue<0)
|
||||
aValue=65536-Math.abs(aValue);
|
||||
return getSeriesString(aValue,gHexChars,0,gHexChars.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given integer value into a string of binary digits
|
||||
*
|
||||
* @param aValue - int to be converted to binary string
|
||||
* @return new string
|
||||
* @author gess 05-05-97 12:53pm
|
||||
*
|
||||
*/
|
||||
public static String getBinaryString(int aValue)
|
||||
{
|
||||
if (aValue<0)
|
||||
aValue=65536-Math.abs(aValue);
|
||||
return getSeriesString(aValue,gBinaryChars,0,gBinaryChars.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given integer value into spoken string (one, two, three...)
|
||||
*
|
||||
* @param aValue - int to be converted to hex string
|
||||
* @return new stringbuffer
|
||||
* @author gess 05-05-97 12:53pm
|
||||
*
|
||||
*/
|
||||
public static String getSpokenString(int aValue)
|
||||
{
|
||||
int root=1000000000;
|
||||
int expn=4;
|
||||
int modu=0;
|
||||
int div=0;
|
||||
int temp=0;
|
||||
StringBuffer result= new StringBuffer();
|
||||
|
||||
if (aValue<0)
|
||||
result.append('-');
|
||||
|
||||
aValue=Math.abs(aValue);
|
||||
while((0!=root) && (0!=aValue))
|
||||
{
|
||||
temp=aValue/root;
|
||||
if(0!=temp)
|
||||
{
|
||||
div=temp/100;
|
||||
if (0!=div) //start with hundreds part
|
||||
{
|
||||
result.append(ones[div]);
|
||||
result.append(bases[1]);
|
||||
}
|
||||
modu=(temp%10);
|
||||
div=((temp%100)/10);
|
||||
|
||||
if (0!=div)
|
||||
if (div<2)
|
||||
{
|
||||
result.append(teens[modu]);
|
||||
modu=0;
|
||||
}
|
||||
else result.append(tens[div]);
|
||||
if (0!=modu)
|
||||
result.append(ones[modu]); // do remainder.
|
||||
aValue-=(temp*root);
|
||||
if (expn>1) result.append(bases[expn]);
|
||||
}
|
||||
expn--;
|
||||
root/=1000;
|
||||
}
|
||||
if (0==result.length())
|
||||
result.append("zero");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given integer value into a series string. These are any
|
||||
* arbitrary but repeating pattern of characters.
|
||||
*
|
||||
* @param aValue - int to be converted to series string
|
||||
* @return new string
|
||||
* @author gess 05-05-97 12:53pm
|
||||
* @notes this method gets used for binary and hex conversion
|
||||
*/
|
||||
public static String getSeriesString(int aValue,String aCharSet,int anOffset,int aBase)
|
||||
{
|
||||
int ndex=0;
|
||||
int root=1;
|
||||
int next=aBase;
|
||||
int expn=1;
|
||||
StringBuffer result=new StringBuffer();
|
||||
|
||||
aValue=Math.abs(aValue); // must be positive here...
|
||||
while(next<=aValue) // scale up in baseN; exceed current value.
|
||||
{
|
||||
root=next;
|
||||
next*=aBase;
|
||||
expn++;
|
||||
}
|
||||
|
||||
while(0!=(expn--))
|
||||
{
|
||||
ndex = ((root<=aValue) && (0!=root)) ? (aValue/root): 0;
|
||||
aValue%=root;
|
||||
if(root>1)
|
||||
result.append(aCharSet.charAt(ndex+(1*anOffset)));
|
||||
else result.append(aCharSet.charAt(ndex));
|
||||
root/=aBase;
|
||||
};
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static void PadPrint(int aValue,int width)
|
||||
{
|
||||
StringBuffer temp=new StringBuffer();
|
||||
temp.append(aValue);
|
||||
PadPrint(temp.toString(),width);
|
||||
}
|
||||
|
||||
public static void PadPrint(String aString, int aWidth)
|
||||
{
|
||||
System.out.print(aString);
|
||||
int padCount=aWidth-aString.length();
|
||||
if(padCount>0)
|
||||
for(int i=0;i<padCount;i++)
|
||||
System.out.print(" ");
|
||||
}
|
||||
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
int index=0;
|
||||
|
||||
System.out.println(" ");
|
||||
System.out.println("Value Hex Roman Series Binary Spoken ");
|
||||
System.out.println("-----------------------------------------------------------------------------");
|
||||
for(index=1002;index<1205;index++)
|
||||
{
|
||||
PadPrint(index,8);
|
||||
PadPrint(Abacus.getHexString(index),10);
|
||||
PadPrint(Abacus.getRomanString(index),10);
|
||||
PadPrint(Abacus.getSeriesString(index,"ABCD",0,4),10);
|
||||
PadPrint(Abacus.getBinaryString(index),16);
|
||||
PadPrint(Abacus.getSpokenString(index),10);
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ import java.util.*;
|
|||
* This hastable uses identity comparisons on keys
|
||||
*
|
||||
* @author psl 10-15-97 1:22pm
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*/
|
||||
public class AtomHashtable extends HashtableBase
|
|
@ -32,7 +32,7 @@ import java.lang.String;
|
|||
* ByteToCharConverterEnumeration return a Enumeration of String which
|
||||
* represent ByteToCharConverter available in the classpath
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -41,7 +41,7 @@ public class ByteToCharConverterEnumeration extends PrefetchEnumeration {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -52,7 +52,7 @@ public class ByteToCharConverterEnumeration extends PrefetchEnumeration {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -69,7 +69,7 @@ public class ByteToCharConverterEnumeration extends PrefetchEnumeration {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
|
@ -30,7 +30,7 @@ import sun.io.CharToByteConverter;
|
|||
* which represent available CharToByteConverter in the class path
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -40,7 +40,7 @@ public class CharToByteConverterEnumeration extends PrefetchEnumeration {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -52,7 +52,7 @@ public class CharToByteConverterEnumeration extends PrefetchEnumeration {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -69,7 +69,7 @@ public class CharToByteConverterEnumeration extends PrefetchEnumeration {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
|
@ -34,7 +34,7 @@ import java.util.Hashtable;
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -172,7 +172,7 @@ public class ClasspathEntryEnumeration extends PrefetchEnumeration {
|
|||
|
||||
/*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -192,7 +192,7 @@ public class ClasspathEntryEnumeration extends PrefetchEnumeration {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
|
@ -28,7 +28,7 @@ import java.net.URLEncoder;
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -41,7 +41,7 @@ public class DataExtension {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -58,7 +58,7 @@ public class DataExtension {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -76,7 +76,7 @@ public class DataExtension {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
|
@ -0,0 +1,187 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
package calypso.util;
|
||||
|
||||
import java.util.EventListener;
|
||||
import java.util.Vector;
|
||||
import java.util.Enumeration;
|
||||
|
||||
|
||||
/**
|
||||
* ListenersList is a thread-safe, reentrant class which
|
||||
* contains a list of EventListeners and enforce some
|
||||
* policy on event dispatching. <p>
|
||||
|
||||
* This class guarantees that events delivering is correctly
|
||||
* accomplished even if listeners are removed from or added to the list during
|
||||
* event dispatching. Added listeners, though, will not receive the current event. <p>
|
||||
|
||||
* Event listeners are returned <b>LIFO</b>. <p>
|
||||
|
||||
* User of this class must enclose event dispatching between
|
||||
* startDelivering()/stopDelivering() calls and pass the state object
|
||||
* to the nextListener call. <p>
|
||||
* <pre>
|
||||
* ListenerListState state = eventListeners.startDelivering();
|
||||
*
|
||||
* SomeEventListener el = (SomeEventListener)eventListeners.nextListener(state);
|
||||
* while (null != el) {
|
||||
* el.someEvent();
|
||||
* el = (SomeEventListener)eventListeners.nextListener(state);
|
||||
* }
|
||||
*
|
||||
* eventListeners.stopDelivering(state);
|
||||
* </pre>
|
||||
*/
|
||||
public class ListenerList
|
||||
{
|
||||
private Vector fListeners; // list of listeners
|
||||
private Vector fEnumerators; // list of enumerators for this list of listeners
|
||||
|
||||
/**
|
||||
* Construct an array of listeners with the specifed size. <p>
|
||||
* The array size is doubled every time an element is added
|
||||
* to a full array.
|
||||
*
|
||||
* @param aSize the required size
|
||||
*/
|
||||
public ListenerList(int aSize)
|
||||
{
|
||||
fListeners = new Vector(aSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an array of listeners with the specifed size. <p>
|
||||
* The array size is doubled every time an element is added
|
||||
* to a full array.
|
||||
*
|
||||
*/
|
||||
public ListenerList()
|
||||
{
|
||||
fListeners = new Vector(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new event listener for the class of events
|
||||
* this ListenersList is mantaining.
|
||||
*
|
||||
* @param aListener a listener for the specific set of events
|
||||
*/
|
||||
public void addListener(EventListener aListener)
|
||||
{
|
||||
fListeners.addElement(aListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a listener from the list of listeners this
|
||||
* ListenersList is mantaining.<p>
|
||||
* Existing and valid state object are updated to reflect
|
||||
* this change.
|
||||
*
|
||||
* @param aListener a listener for the specific set of events
|
||||
*/
|
||||
public void removeListener(EventListener aListener)
|
||||
{
|
||||
synchronized(fListeners) {
|
||||
// find and remove the element
|
||||
int index = fListeners.indexOf(aListener);
|
||||
if (index != -1) {
|
||||
try {
|
||||
fListeners.removeElementAt(index);
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
Assert.Assertion(false); // no way!!
|
||||
}
|
||||
|
||||
// go through the list of live state objects and update the
|
||||
// index if necessary
|
||||
if (fEnumerators != null) {
|
||||
for (int i =0; i < fEnumerators.size(); i++) {
|
||||
ListenerListState state = (ListenerListState)fEnumerators.elementAt(i);
|
||||
if (index < state.fIndex) {
|
||||
state.fIndex--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A user of this class is starting event delivery. <p>
|
||||
* The state object represents the state of the list for
|
||||
* that user and has to be passed in every nextListener call.
|
||||
*
|
||||
* @param aListener a listener for the specific set of events
|
||||
* @return ListenerListState the state of the list for the caller
|
||||
*/
|
||||
public ListenerListState startDelivering()
|
||||
{
|
||||
synchronized(fListeners) {
|
||||
ListenerListState state = new ListenerListState(fListeners);
|
||||
if (null == fEnumerators) {
|
||||
fEnumerators = new Vector(1);
|
||||
}
|
||||
fEnumerators.addElement(state);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A user completed or aborted event delivering. <p>
|
||||
*
|
||||
* @return aState the state of the list for the caller
|
||||
*/
|
||||
public void stopDelivering(ListenerListState aState)
|
||||
{
|
||||
synchronized(fListeners) {
|
||||
fEnumerators.removeElement(aState);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the next EventListener in the array. <p>
|
||||
* Listeners are returned with a last-in/first-out (LIFO) policy.
|
||||
*
|
||||
* @return aState the state of the list for the caller
|
||||
*/
|
||||
public EventListener nextListener(ListenerListState aState)
|
||||
{
|
||||
synchronized(fListeners) {
|
||||
EventListener listener = null;
|
||||
|
||||
if (--aState.fIndex >= 0) {
|
||||
try {
|
||||
listener = (EventListener)fListeners.elementAt(aState.fIndex);
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
Assert.Assertion(false);
|
||||
aState.fIndex = -1; // invalid state
|
||||
}
|
||||
}
|
||||
|
||||
return listener;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Grendel mail/news client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
SRCS= \
|
||||
Abacus.java \
|
||||
ArrayEnumeration.java \
|
||||
Assert.java \
|
||||
AssertionError.java \
|
||||
AssertionException.java \
|
||||
Atom.java \
|
||||
AtomHashtable.java \
|
||||
AttributeValuePair.java \
|
||||
ByteBuf.java \
|
||||
ByteLineBuffer.java \
|
||||
ByteToCharConverterEnumeration.java \
|
||||
CacheOutputStream.java \
|
||||
CharArray.java \
|
||||
CharArrayIterator.java \
|
||||
CharToByteConverterEnumeration.java \
|
||||
ClasspathEntryEnumeration.java \
|
||||
Comparer.java \
|
||||
ConfigUtils.java \
|
||||
Counter.java \
|
||||
DataExtension.java \
|
||||
DefaultPreferences.java \
|
||||
EnumerationEnumerator.java \
|
||||
HashtableBase.java \
|
||||
HashtableLite.java \
|
||||
HashtableRecycler.java \
|
||||
IDMap.java \
|
||||
LineBufferingInputStream.java \
|
||||
ListenerList.java \
|
||||
ListenerListState.java \
|
||||
MemoryManager.java \
|
||||
MemoryMonitor.java \
|
||||
MemoryPressure.java \
|
||||
NetworkDate.java \
|
||||
NullEnumeration.java \
|
||||
NullJavaEnumeration.java \
|
||||
Preferences.java \
|
||||
PreferencesBase.java \
|
||||
PreferencesFactory.java \
|
||||
PrefetchEnumeration.java \
|
||||
QSort.java \
|
||||
RWLock.java \
|
||||
RandomAccessFileWithByteLines.java \
|
||||
Recycler.java \
|
||||
SelfTest.java \
|
||||
SelfTestAtom.java \
|
||||
SelfTestException.java \
|
||||
SelfTestIDMap.java \
|
||||
SelfTestRWLock.java \
|
||||
SignedInteger.java \
|
||||
SingleEnumeration.java \
|
||||
StringBuf.java \
|
||||
StringBufRecycler.java \
|
||||
StringUtils.java \
|
||||
TempFile.java \
|
||||
TimeBomb.java \
|
||||
URLClassLoader.java \
|
||||
Vec.java \
|
||||
VectorRecycler.java \
|
||||
WeakLink.java \
|
||||
WeakLinkArray.java \
|
||||
WeakLinkArrayEnumeration.java \
|
||||
$(NULL)
|
||||
|
||||
include ../../rules.mk
|
|
@ -0,0 +1,114 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
package calypso.util;
|
||||
|
||||
import java.lang.Runtime;
|
||||
|
||||
/**
|
||||
* A utility class to help track memory usage during development.
|
||||
* The interface is simple. Just create the monitor, do your business,
|
||||
* and then invoke the done method. <p>
|
||||
*
|
||||
* The figure for the ammount of memory allocated should be accurate
|
||||
* but the number for the ammount of garbage can be off by quite a bit
|
||||
* if any garbage collection was done between the monitor's creation
|
||||
* and the call to done. <p>
|
||||
*
|
||||
* Currently, it just prints some stuff to the console. I'd like to
|
||||
* extend it so it creates a window and displays it's info in that.
|
||||
*
|
||||
* @author Thom FillABomb :-)
|
||||
*/
|
||||
public class MemoryMonitor
|
||||
{
|
||||
Runtime fSystem;
|
||||
|
||||
long fFreeAtStart,
|
||||
fFreeAtEnd,
|
||||
fGarbageGenerated;
|
||||
|
||||
String fUserString = null;
|
||||
|
||||
public MemoryMonitor (String monitorDescription)
|
||||
{
|
||||
fUserString = monitorDescription;
|
||||
initialize();
|
||||
}
|
||||
|
||||
public MemoryMonitor ()
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
protected void initialize ()
|
||||
{
|
||||
fSystem = Runtime.getRuntime();
|
||||
beginMonitor();
|
||||
}
|
||||
|
||||
public void done ()
|
||||
{
|
||||
finishMonitor ();
|
||||
|
||||
System.out.println();
|
||||
|
||||
if (fUserString != null)
|
||||
System.out.println (fUserString);
|
||||
|
||||
System.out.println (" Starting Free: " + fFreeAtStart);
|
||||
System.out.println (" Ending Free: " + fFreeAtEnd);
|
||||
System.out.println (" Memory Delta: " + (fFreeAtStart - fFreeAtEnd));
|
||||
System.out.println ("Garbage Generated: " + fGarbageGenerated);
|
||||
}
|
||||
|
||||
protected void freeUpMemory ()
|
||||
{
|
||||
// we might want to tickle Kipp's memory Manager here as well...
|
||||
|
||||
fSystem.runFinalization();
|
||||
// might want to sleep here
|
||||
fSystem.gc();
|
||||
fSystem.gc();
|
||||
}
|
||||
|
||||
void beginMonitor ()
|
||||
{
|
||||
freeUpMemory();
|
||||
fFreeAtStart = fSystem.freeMemory();
|
||||
}
|
||||
|
||||
void finishMonitor ()
|
||||
{
|
||||
long totalUsed, minusGarbage;
|
||||
|
||||
totalUsed = fSystem.freeMemory();
|
||||
freeUpMemory();
|
||||
minusGarbage = fSystem.freeMemory();
|
||||
|
||||
// it would also be interesting to purge the recyclers here and
|
||||
// see how much memory they're occupying
|
||||
|
||||
fGarbageGenerated = minusGarbage - totalUsed;
|
||||
fFreeAtEnd = minusGarbage;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Edwin Woudt <edwin@woudt.nl>
|
||||
*/
|
||||
|
||||
package calypso.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.Properties;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import grendel.util.Constants;
|
||||
|
||||
/**
|
||||
* Contains the File handling logic of the prefs.
|
||||
*/
|
||||
|
||||
class PreferencesBase extends Properties implements Preferences {
|
||||
|
||||
static final File gPrefsPath = Constants.HOMEDIR;
|
||||
static final String gPrefsFile = "grendel.pref";
|
||||
|
||||
PreferencesBase() {
|
||||
super();
|
||||
|
||||
// create the dir if it doesn't exist
|
||||
gPrefsPath.mkdirs();
|
||||
|
||||
File infile = new File(gPrefsPath, gPrefsFile);
|
||||
InputStream in = null;
|
||||
if (infile.exists() && infile.canRead() && infile.canWrite()) {
|
||||
try {
|
||||
in = new FileInputStream(infile);
|
||||
load(in);
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
RandomAccessFile newPrefsFile = new RandomAccessFile(infile, "rw");
|
||||
newPrefsFile.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void writePrefs() {
|
||||
File outfile = new File(gPrefsPath, gPrefsFile);
|
||||
OutputStream out = null;
|
||||
try {
|
||||
out = new FileOutputStream(outfile);
|
||||
save(out, "Grendel User Preferences. Do not directly modify this file!");
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(String name, String defaultValue) {
|
||||
return getProperty(name, defaultValue);
|
||||
}
|
||||
|
||||
public String getString(String name)
|
||||
throws MissingResourceException {
|
||||
String result = getProperty(name);
|
||||
if(result == null) {
|
||||
throw new MissingResourceException(name + " is missing!", "", name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getInt(String name, int defaultValue) {
|
||||
String str = getString(name, null);
|
||||
int result = defaultValue;
|
||||
if (str != null) {
|
||||
try {
|
||||
result = Integer.parseInt(str);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getInt(String name)
|
||||
throws MissingResourceException, NumberFormatException {
|
||||
String str;
|
||||
try {
|
||||
str = getString(name);
|
||||
} catch(MissingResourceException e) {
|
||||
throw e;
|
||||
}
|
||||
int result;
|
||||
try {
|
||||
result = Integer.parseInt(str);
|
||||
} catch (NumberFormatException e) {
|
||||
throw e;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean getBoolean(String name, boolean defaultValue) {
|
||||
String str = getString(name, null);
|
||||
boolean result = defaultValue;
|
||||
if (str != null) {
|
||||
result = Boolean.valueOf(str).booleanValue();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean getBoolean(String name)
|
||||
throws MissingResourceException {
|
||||
String str;
|
||||
try {
|
||||
str = getString(name);
|
||||
} catch(MissingResourceException e) {
|
||||
throw e;
|
||||
}
|
||||
return Boolean.valueOf(str).booleanValue();
|
||||
}
|
||||
|
||||
public File getFile(String name, File defaultValue) {
|
||||
String str = getString(name, null);
|
||||
File result = defaultValue;
|
||||
if (str != null) {
|
||||
result = new File(str);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Assign a String value to the given preference. */
|
||||
public void putString(String prefName, String value) {
|
||||
put(prefName, value);
|
||||
writePrefs();
|
||||
}
|
||||
|
||||
/** Assign an int value to the given preference. */
|
||||
public void putInt(String prefName, int value) {
|
||||
put(prefName, (String)(""+value));
|
||||
writePrefs();
|
||||
}
|
||||
|
||||
/** Assign a boolean value to the given preference. */
|
||||
public void putBoolean(String prefName, boolean value) {
|
||||
put(prefName, (String)(""+value));
|
||||
writePrefs();
|
||||
}
|
||||
|
||||
/** Return the preferences as a Properties object */
|
||||
public Properties getAsProperties() {
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ import java.util.Enumeration;
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -38,7 +38,7 @@ public abstract class PrefetchEnumeration implements Enumeration {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -53,7 +53,7 @@ public abstract class PrefetchEnumeration implements Enumeration {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -68,7 +68,7 @@ public abstract class PrefetchEnumeration implements Enumeration {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
||||
|
@ -81,7 +81,7 @@ public abstract class PrefetchEnumeration implements Enumeration {
|
|||
/*
|
||||
*
|
||||
* @author ftang
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see
|
||||
*
|
||||
*/
|
|
@ -28,7 +28,7 @@ import java.util.*;
|
|||
*
|
||||
*
|
||||
* @author gess 04-16-97 1:44pm
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.1 $
|
||||
* @notes This is a general purpose recycler.
|
||||
* It contains objects of a specified capacity.
|
||||
* If you ask for a recycled object and we have
|
|
@ -0,0 +1,344 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Edwin Woudt <edwin@woudt.nl>
|
||||
*/
|
||||
|
||||
package calypso.util;
|
||||
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.io.*;
|
||||
|
||||
// Simple class loader:
|
||||
// - no signatures
|
||||
// - no security
|
||||
// - no mayscript
|
||||
|
||||
/**
|
||||
* A URL based class loader. This class knows how to load classes from
|
||||
* a given base URL
|
||||
*/
|
||||
public class URLClassLoader extends ClassLoader {
|
||||
private Hashtable classes;
|
||||
private URL codeBaseURL;
|
||||
private URL archiveURL;
|
||||
private ZipFile fZipFile;
|
||||
private TempFile fTempFile;
|
||||
|
||||
static final boolean XXXnoisy = false;
|
||||
|
||||
/**
|
||||
* Create a new URL based class loader. aBaseURL specifies the URL
|
||||
* to load classes relative to. If aArchiveURL is not null then the
|
||||
* archive will be searched first (if it fails then the load will be
|
||||
* attempted from aBaseURL).
|
||||
*/
|
||||
public URLClassLoader(URL aBaseURL, URL aArchiveURL) {
|
||||
codeBaseURL = aBaseURL;
|
||||
archiveURL = aArchiveURL;
|
||||
classes = new Hashtable();
|
||||
if (XXXnoisy) {
|
||||
System.out.println("####### Creating TagClassLoader");
|
||||
System.out.println("### CodeBaseURL=" + codeBaseURL);
|
||||
System.out.println("### ArchiveURL=" + archiveURL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a class from a URL. This does the actual work of loading the
|
||||
* class and then defining it.
|
||||
*/
|
||||
private Class loadClass(String name, URL url, String pathname)
|
||||
throws IOException
|
||||
{
|
||||
byte[] data = readURL(url);
|
||||
if (XXXnoisy) {
|
||||
System.out.println("# loadClass: url="+url+" bytes="+data.length);
|
||||
}
|
||||
// XXX update for netscape security model
|
||||
return defineClass(name, data, 0, data.length);
|
||||
}
|
||||
|
||||
private Class loadClassFromArchive(String name, URL url, String pathname)
|
||||
throws IOException
|
||||
{
|
||||
if (fZipFile == null) {
|
||||
// First time in we copy over the archive URL
|
||||
fTempFile = TempFile.TempName(".zip");
|
||||
copyURL(fTempFile.create(), url);
|
||||
if (XXXnoisy) {
|
||||
System.out.println("### Copying zip file: tempName=" +
|
||||
fTempFile.getName() + " url=" + url);
|
||||
}
|
||||
fZipFile = new ZipFile(fTempFile.getName());
|
||||
}
|
||||
|
||||
// Dig up the class's bits using the zip loader
|
||||
byte[] data = readZipFile(pathname);
|
||||
if (XXXnoisy) {
|
||||
System.out.println("# loadClass: url="+url+"(" +
|
||||
pathname + ") bytes=" + data.length);
|
||||
}
|
||||
// XXX update for netscape security model
|
||||
return defineClass(name, data, 0, data.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a class from this class loader. This method is used by applets
|
||||
* that want to explicitly load a class.
|
||||
*/
|
||||
public Class loadClass(String name) throws ClassNotFoundException {
|
||||
return loadClass(name, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load and resolve a class. This method is called by the java runtime
|
||||
* to get a class that another class needs (e.g. a superclass).
|
||||
*/
|
||||
protected Class loadClass(String name, boolean resolve)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
Class cl = (Class)classes.get(name);
|
||||
if (cl == null) {
|
||||
// XXX: We should call a Security.checksPackageAccess() native
|
||||
// method, and pass name as arg
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
int i = name.lastIndexOf('.');
|
||||
if (i >= 0) {
|
||||
security.checkPackageAccess(name.substring(0, i));
|
||||
}
|
||||
}
|
||||
try {
|
||||
return findSystemClass(name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
cl = findClass(name);
|
||||
}
|
||||
if (cl == null) {
|
||||
throw new ClassNotFoundException(name);
|
||||
}
|
||||
if (resolve) {
|
||||
resolveClass(cl);
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method finds a class. The returned class
|
||||
* may be unresolved. This method has to be synchronized
|
||||
* to avoid two threads loading the same class at the same time.
|
||||
* Must be called with the actual class name.
|
||||
*/
|
||||
protected synchronized Class findClass(String name)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
Class cl = (Class)classes.get(name);
|
||||
if (cl != null) {
|
||||
return cl;
|
||||
}
|
||||
|
||||
// XXX: We should call a Security.checksPackageDefinition() native
|
||||
// method, and pass name as arg
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
int i = name.lastIndexOf('.');
|
||||
if (i >= 0) {
|
||||
security.checkPackageDefinition(name.substring(0, i));
|
||||
}
|
||||
}
|
||||
|
||||
boolean system_class = true;
|
||||
String cname = name.replace('.', '/') + ".class";
|
||||
if (cl == null) {
|
||||
URL url;
|
||||
try {
|
||||
url = new URL(codeBaseURL, cname);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new ClassNotFoundException(name);
|
||||
}
|
||||
if (XXXnoisy) {
|
||||
System.err.println("# Fetching " + url);
|
||||
}
|
||||
|
||||
try {
|
||||
if (archiveURL != null) {
|
||||
cl = loadClassFromArchive(name, archiveURL, cname);
|
||||
// XXX try regular file if archive load fails?
|
||||
} else {
|
||||
cl = loadClass(name, url, cname);
|
||||
}
|
||||
system_class = false;
|
||||
} catch (IOException e) {
|
||||
if (XXXnoisy) {
|
||||
System.out.println("# IOException loading class: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw new ClassNotFoundException(name);
|
||||
}
|
||||
}
|
||||
if (!name.equals(cl.getName())) {
|
||||
Class oldcl = cl;
|
||||
cl = null;
|
||||
throw new ClassFormatError(name + " != " + oldcl.getName());
|
||||
}
|
||||
if (system_class == false) {
|
||||
// setPrincipalAry(cl, cname);
|
||||
}
|
||||
classes.put(name, cl);
|
||||
return cl;
|
||||
}
|
||||
|
||||
// collapse the i/o loops between this code and readZipFile
|
||||
|
||||
private byte[] readURL(URL url) throws IOException {
|
||||
byte[] data;
|
||||
InputStream in = null;
|
||||
try {
|
||||
URLConnection c = url.openConnection();
|
||||
c.setAllowUserInteraction(false);
|
||||
in = c.getInputStream();
|
||||
|
||||
int len = c.getContentLength();
|
||||
data = new byte[(len == -1) ? 4096 : len];
|
||||
int total = 0, n;
|
||||
|
||||
while ((n = in.read(data, total, data.length - total)) >= 0) {
|
||||
if ((total += n) == data.length) {
|
||||
if (len < 0) {
|
||||
byte newdata[] = new byte[total * 2];
|
||||
System.arraycopy(data, 0, newdata, 0, total);
|
||||
data = newdata;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a given file from the underlying zip file named "aName". Return
|
||||
* an array of bytes which contain the decompressed contents of the
|
||||
* file in the zip file.
|
||||
*/
|
||||
private byte[] readZipFile(String aName)
|
||||
throws IOException
|
||||
{
|
||||
ZipEntry entry = fZipFile.getEntry(aName);
|
||||
if (entry == null) {
|
||||
throw new IOException("file not found: " + aName);
|
||||
}
|
||||
|
||||
InputStream in = null;
|
||||
int len = (int) entry.getSize();
|
||||
byte[] data = new byte[(len == -1) ? 4096 : len];
|
||||
try {
|
||||
in = fZipFile.getInputStream(entry);
|
||||
int total = 0, n;
|
||||
while ((n = in.read(data, total, data.length - total)) >= 0) {
|
||||
if ((total += n) == data.length) {
|
||||
if (len < 0) {
|
||||
byte newdata[] = new byte[total * 2];
|
||||
System.arraycopy(data, 0, newdata, 0, total);
|
||||
data = newdata;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private void copyURL(OutputStream aOut, URL aURLSource)
|
||||
throws IOException
|
||||
{
|
||||
InputStream in = null;
|
||||
try {
|
||||
byte[] inputBuf = new byte[4096];
|
||||
|
||||
// open the destination file for writing
|
||||
//SecurityManager.enablePrivilege("UniversalFileAccess");
|
||||
//SecurityManager.enablePrivilege("UniversalConnect");
|
||||
|
||||
URLConnection c = archiveURL.openConnection();
|
||||
c.setAllowUserInteraction(false);
|
||||
in = c.getInputStream();
|
||||
|
||||
// Read all the bytes from the url into the temp file
|
||||
Thread thread = Thread.currentThread();
|
||||
int total = 0, n;
|
||||
while (((n = in.read(inputBuf)) >= 0) && !thread.isInterrupted()) {
|
||||
aOut.write(inputBuf, 0, n);
|
||||
total += n;
|
||||
}
|
||||
if (thread.isInterrupted()) {
|
||||
throw new IOException("interrupted: " + this);
|
||||
}
|
||||
if (XXXnoisy) {
|
||||
System.out.println("# Copying archive: url=" + archiveURL +
|
||||
" tempFile=" + fTempFile.getName() +
|
||||
" copiedBytes=" + total);
|
||||
}
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
if (aOut != null) {
|
||||
aOut.close();
|
||||
}
|
||||
}
|
||||
// SecurityManager.revertPrivilege();
|
||||
}
|
||||
|
||||
public URL getCodeBaseURL() {
|
||||
return codeBaseURL;
|
||||
}
|
||||
|
||||
protected void finalize() {
|
||||
if (fZipFile != null) {
|
||||
try {
|
||||
// First close the zip file
|
||||
fZipFile.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
fZipFile = null;
|
||||
}
|
||||
if (fTempFile != null) {
|
||||
try {
|
||||
// Then remove the temporary file
|
||||
fTempFile.delete();
|
||||
} finally {
|
||||
fTempFile = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Grendel mail/news client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Edwin Woudt
|
||||
# <edwin@woudt.nl> Portions created by Edwin Woudt are
|
||||
# Copyright (C) 1999 Edwin Woudt. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
SUBDIRS= \
|
||||
mail \
|
||||
util \
|
||||
$(NULL)
|
||||
|
||||
include ../rules.mk
|
|
@ -0,0 +1,27 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Grendel mail/news client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Edwin Woudt
|
||||
# <edwin@woudt.nl> Portions created by Edwin Woudt are
|
||||
# Copyright (C) 1999 Edwin Woudt. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
SUBDIRS= \
|
||||
nntp \
|
||||
util \
|
||||
$(NULL)
|
||||
|
||||
include ../../rules.mk
|
|
@ -0,0 +1,28 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Grendel mail/news client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Edwin Woudt
|
||||
# <edwin@woudt.nl> Portions created by Edwin Woudt are
|
||||
# Copyright (C) 1999 Edwin Woudt. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
SRCS= \
|
||||
Article.java \
|
||||
NNTPStore.java \
|
||||
Newsgroup.java \
|
||||
$(NULL)
|
||||
|
||||
include ../../../rules.mk
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,29 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Grendel mail/news client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Edwin Woudt
|
||||
# <edwin@woudt.nl> Portions created by Edwin Woudt are
|
||||
# Copyright (C) 1999 Edwin Woudt. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
SRCS= \
|
||||
CRLFInputStream.java \
|
||||
CRLFOutputStream.java \
|
||||
MessageInputStream.java \
|
||||
MessageOutputStream.java \
|
||||
$(NULL)
|
||||
|
||||
include ../../../rules.mk
|
|
@ -0,0 +1,36 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Grendel mail/news client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Edwin Woudt
|
||||
# <edwin@woudt.nl> Portions created by Edwin Woudt are
|
||||
# Copyright (C) 1999 Edwin Woudt. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
SRCS= \
|
||||
ObjectCollator.java \
|
||||
Referential.java \
|
||||
StatusEvent.java \
|
||||
StatusListener.java \
|
||||
StatusSource.java \
|
||||
Timer.java \
|
||||
TimerEvent.java \
|
||||
TimerListener.java \
|
||||
Tree.java \
|
||||
TreeCollator.java \
|
||||
TreeEvent.java \
|
||||
$(NULL)
|
||||
|
||||
include ../../rules.mk
|
|
@ -0,0 +1,25 @@
|
|||
## Stores
|
||||
|
||||
# POP3 default
|
||||
protocol=pop3; type=store; class=com.sun.mail.pop3.POP3Store; vendor=Sun Microsystems, Inc;
|
||||
# Two POP3 choices
|
||||
protocol=spop3; type=store; class=com.sun.mail.pop3.POP3Store; vendor=Sun Microsystems, Inc
|
||||
protocol=gpop3; type=store; class=grendel.storage.PopStore; vendor=Mozilla.org, Grendel
|
||||
|
||||
# News default
|
||||
protocol=news; type=store; class=grendel.storage.NewsStore; vendor=Mozilla.org, Grendel
|
||||
# Two News choices
|
||||
protocol=gnews; type=store; class=grendel.storage.NewsStore; vendor=Mozilla.org, Grendel
|
||||
protocol=dnews; type=store; class=dog.mail.nntp.NNTPStore; vendor=dog@dog.net.uk;
|
||||
|
||||
# Berkeley local store
|
||||
protocol=berkeley; type=store; class=grendel.storage.BerkeleyStore; vendor=Mozilla.org, Grendel
|
||||
|
||||
# IMAP
|
||||
protocol=imap; type=store; class=com.sun.mail.imap.IMAPStore; vendor=Sun Microsystems, Inc;
|
||||
|
||||
|
||||
## Transports
|
||||
|
||||
# SMTP
|
||||
protocol=smtp; type=transport; class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc;
|
|
@ -0,0 +1,74 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Jeff Galyan <talisman@anamorphic.com>
|
||||
* Joel York <yorkjoe@charlie.acc.iit.edu>
|
||||
* Edwin Woudt <edwin@woudt.nl>
|
||||
*/
|
||||
|
||||
package grendel;
|
||||
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import grendel.prefs.base.UIPrefs;
|
||||
|
||||
import grendel.ui.MessageDisplayManager;
|
||||
import grendel.ui.MultiMessageDisplayManager;
|
||||
import grendel.ui.UnifiedMessageDisplayManager;
|
||||
import grendel.ui.Splash;
|
||||
|
||||
/**
|
||||
* This launches the Grendel GUI.
|
||||
*/
|
||||
|
||||
public class Main {
|
||||
static MessageDisplayManager fManager;
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
Splash splash = new Splash();
|
||||
|
||||
UIPrefs prefs = UIPrefs.GetMaster();
|
||||
|
||||
UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
|
||||
LookAndFeel laf;
|
||||
for (int i = 0; i < info.length; i++) {
|
||||
try {
|
||||
String name = info[i].getClassName();
|
||||
Class c = Class.forName(name);
|
||||
laf = (LookAndFeel)c.newInstance();
|
||||
if (laf.getDescription().equals(prefs.getLookAndFeel())) {
|
||||
UIManager.setLookAndFeel(laf);
|
||||
}
|
||||
} catch (Exception e){
|
||||
}
|
||||
}
|
||||
|
||||
if (prefs.getDisplayManager().equals("multi")) {
|
||||
fManager = new MultiMessageDisplayManager();
|
||||
} else {
|
||||
fManager = new UnifiedMessageDisplayManager();
|
||||
}
|
||||
MessageDisplayManager.SetDefaultManager(fManager);
|
||||
fManager.displayMaster();
|
||||
splash.dispose();
|
||||
}
|
||||
}
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,35 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Grendel mail/news client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Jeff Galyan <talisman@anamorphic.com>
|
||||
# Giao Nguyen <grail@cafebabe.org>
|
||||
|
||||
TOPDIR = ..
|
||||
|
||||
SUBDIRS= \
|
||||
addresscard \
|
||||
$(NULL)
|
||||
|
||||
SRCS= \
|
||||
AddressBook.java \
|
||||
NewCardDialog.java \
|
||||
SearchDirectoryDialog.java \
|
||||
$(NULL)
|
||||
|
||||
include ../rules.mk
|
|
@ -0,0 +1,241 @@
|
|||
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Grendel mail/news client.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1997 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Created: Lester Schueler <lesters@netscape.com>, 14 Nov 1997.
|
||||
*
|
||||
* Contributors: Christoph Toshok <toshok@netscape.com>
|
||||
* Jeff Galyan <talisman@anamorphic.com>
|
||||
*/
|
||||
|
||||
package grendel.addressbook.addresscard;
|
||||
|
||||
import grendel.storage.intertwingle.*;
|
||||
import java.util.Enumeration;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
//import java.util.Vector;
|
||||
|
||||
//************************
|
||||
//************************
|
||||
public class ACS_Personal implements ICardSource, IQuerySet {
|
||||
private DB fDB;
|
||||
|
||||
public ACS_Personal (String FileName, boolean CreateOnOpen) {
|
||||
File DBFile = new File(FileName);
|
||||
try {
|
||||
fDB = new SimpleDB(DBFile);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
/** Get the next card ID for this DB.
|
||||
*/
|
||||
private String getNextCardID () {
|
||||
int nextCardIntID = 0;
|
||||
String nextCardStrID;
|
||||
|
||||
try {
|
||||
//initalize the next card ID
|
||||
nextCardStrID = fDB.findFirst ("Control", "NextCardID", false);
|
||||
|
||||
//if the value wasn't found then assume this is the first time.
|
||||
if ((null == nextCardStrID) || (nextCardStrID.equals (""))) {
|
||||
nextCardIntID = 0;
|
||||
}
|
||||
|
||||
//if the value WAS found then try to extract an integer value from the text.
|
||||
else {
|
||||
try {
|
||||
nextCardIntID = Integer.valueOf(nextCardStrID).intValue();
|
||||
} catch (NumberFormatException nfe) {
|
||||
nextCardIntID = 0;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
nextCardIntID = 0;
|
||||
}
|
||||
|
||||
//create a string representation of the card's ID.
|
||||
nextCardStrID = String.valueOf(++nextCardIntID);
|
||||
|
||||
try {
|
||||
//write the new value out to the DB.
|
||||
fDB.assert ("Control", "NextCardID", nextCardStrID);
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
|
||||
return nextCardStrID;
|
||||
}
|
||||
|
||||
/**
|
||||
* closing the source
|
||||
*/
|
||||
public void close () {
|
||||
try {
|
||||
((BGDB) fDB).flushChanges();
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op implementations for now (just to get this building properly)
|
||||
* (Jeff)
|
||||
*/
|
||||
|
||||
public AC_IDSet opEqual(IAttribute anAttribute) { return null; }
|
||||
|
||||
public AC_IDSet opNotEqual(IAttribute anAttribute) { return null; }
|
||||
|
||||
/**
|
||||
* retrieving address cards
|
||||
*/
|
||||
public ICardSet getCardSet (ITerm aQueryTerm, String[] anAttributesArray) {
|
||||
//get the card ID's that satisfy the query.
|
||||
AC_IDSet CardIDSet = aQueryTerm.evaluate_ACSP (this);
|
||||
|
||||
//create the address card set that'll be returned.
|
||||
AddressCardSet retCardSet = new AddressCardSet ();
|
||||
|
||||
for (int i = 0; i < CardIDSet.size(); i++) {
|
||||
//create an attribute set for the card.
|
||||
AddressCardAttributeSet attrSet = new AddressCardAttributeSet();
|
||||
|
||||
//get all attributes for this card.
|
||||
for (int j = 0; j < anAttributesArray.length; j++) {
|
||||
String attrName = anAttributesArray[j];
|
||||
|
||||
//read the attribute from the DB.
|
||||
try {
|
||||
String attrValue = fDB.findFirst((String) CardIDSet.elementAt(i), attrName, false);
|
||||
|
||||
//if found then add to the attribute set for this card.
|
||||
if (null != attrValue) {
|
||||
attrSet.add (new AddressCardAttribute (attrName, attrValue));
|
||||
}
|
||||
} catch (IOException ioe) {}
|
||||
}
|
||||
|
||||
//create the new card, and add to the return card set.
|
||||
retCardSet.add (new AddressCard(this, attrSet));
|
||||
}
|
||||
|
||||
//return the card set
|
||||
return retCardSet;
|
||||
}
|
||||
|
||||
/** Add a single card to this addressbook.
|
||||
*/
|
||||
public void add (AddressCard aCard, boolean OverWrite) {
|
||||
//give the card a new ID
|
||||
String thisCardID = getNextCardID ();
|
||||
aCard.setID (thisCardID);
|
||||
|
||||
//get the set of attributes and enumerate thruough them.
|
||||
AddressCardAttributeSet attrSet =
|
||||
(AddressCardAttributeSet)aCard.getAttributeSet();
|
||||
|
||||
for (Enumeration enum = attrSet.elements (); enum.hasMoreElements(); ) {
|
||||
//get the next attribute
|
||||
AddressCardAttribute attr = (AddressCardAttribute) enum.nextElement ();
|
||||
|
||||
//write the attribute to the DB
|
||||
try {
|
||||
fDB.assert (thisCardID, attr.getName(), attr.getValue());
|
||||
} catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
|
||||
/** Add a set of cards to this addressbook.
|
||||
*/
|
||||
public void add (AddressCardSet aCardSet, boolean OverWrite) {
|
||||
for (Enumeration enum = aCardSet.getCardEnumeration (); enum.hasMoreElements() ;) {
|
||||
AddressCard card = (AddressCard) enum.nextElement();
|
||||
add (card, OverWrite);
|
||||
}
|
||||
}
|
||||
|
||||
/** No-op implementation of the add(ICard) method from ICardSource
|
||||
*/
|
||||
public void add (ICard card) { }
|
||||
|
||||
/** No-op implementation of update(ICard) from ICardSource
|
||||
*/
|
||||
public void update(ICard card) { }
|
||||
|
||||
/** No-op implementation of delete(ICard) from ICardSource
|
||||
*/
|
||||
public void delete(ICard card) { }
|
||||
|
||||
|
||||
//*******************************
|
||||
//**** Operational functions ****
|
||||
//*******************************
|
||||
|
||||
/** Search the database for all cards that match this value
|
||||
* and return a set Adddress Card ID's (ACID's).
|
||||
*/
|
||||
public AC_IDSet opEqual (AC_Attribute ACA) {
|
||||
AC_IDSet retIDSet = new AC_IDSet();
|
||||
|
||||
if (null != ACA) {
|
||||
try { //the RDFish DB returns an enumeration of a matching card ID's
|
||||
for (Enumeration enum = fDB.findAll(ACA.getName(), ACA.getValue (), false); enum.hasMoreElements() ;) {
|
||||
retIDSet.addElement (enum.nextElement());
|
||||
}
|
||||
} catch (IOException exc) {
|
||||
exc.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return retIDSet;
|
||||
}
|
||||
|
||||
/** Search the database for all cards that DO NOT match this value
|
||||
* and return a set Adddress Card ID's (ACID's).
|
||||
*/
|
||||
public AC_IDSet opNotEqual (AC_Attribute ACA) {
|
||||
AC_IDSet retIDSet = new AC_IDSet();
|
||||
|
||||
return retIDSet;
|
||||
}
|
||||
|
||||
/*
|
||||
1.Boolean RDF_HasAssertion (RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, Boolean tv);
|
||||
Returns true if there is an arc in the graph whose origin is u, whose label is s, whose target is v and whose truth value is true.
|
||||
|
||||
2.void* RDF_GetSlotValue (RDF_Resource u, RDF_Resource s, RDF_ValueType type, Boolean inversep, Boolean tv);
|
||||
Returns the target (whose datatype is type) of (any) one of the arcs whose source is u, label is s and truth value is tv. If inversep is true,
|
||||
then it return the source (whose datatype is type) of (any) one of the arcs whose target is u, label is s and truth value is tv.
|
||||
|
||||
3.RDF_Cursor RDF_GetSlotValues (RDF_Resource u, RDF_Resource s, RDF_ValueType type, Boolean inversep, Boolean tv);
|
||||
Returns a cursor that can be used to enumerate through the targets (of datatype type) of the arcs whose source is u, label is s and truth
|
||||
value is tv. If inversep is true, then the cursor enumerates through the sources of the arcs whose label is s, target is u and truth value is tv.
|
||||
You can store your private data on the pdata field of the cursor. Cursors are cheap.
|
||||
|
||||
4.void* RDF_NextValue(RDF_Cursor c);
|
||||
Returns the next value from this cursor. Returns NULL if there are no more values. The fields value and type hold the value and datatype
|
||||
of the value respectively.
|
||||
|
||||
5.RDF_Error RDF_DisposeCursor (RDF_Cursor c);
|
||||
When you are done with a cursor, call this function. Remember to free your pdata before calling this.
|
||||
*/
|
||||
|
||||
}
|
||||
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче