FileDocCategorySizeDatePackage
JMAppsCfg.javaAPI DocJMF 2.1.1e23638Mon May 12 12:20:32 BST 2003jmapps.util

JMAppsCfg

public class JMAppsCfg extends Object

Fields Summary
public static final String
KEY_OPEN_FILE
public static final String
KEY_OPEN_RTP
public static final String
KEY_OPEN_URL
public static final String
KEY_CAPTURE_AUDIO
public static final String
KEY_CAPTURE_VIDEO
public static final String
KEY_TRANSMIT_RTP
public static final String
KEY_TRANSMIT_SOURCE
public static final String
KEY_SAVE_FILE_CONTENT
public static final String
KEY_SAVE_FILE_TRACKS
public static final String
KEY_SAVE_FILE_DIR
public static final String
KEY_RECENT_URL
public static final String
KEY_JMSTUDIO_FRAME_POS
public static final String
KEY_AUTO_PLAY
public static final String
KEY_AUTO_LOOP
public static final String
KEY_KEEP_ASPECT
private static String
nameFileCfg
private static final String
signatureFileCfg
private static final String
signatureHashtable
private Hashtable
hashProperties
Constructors Summary
public JMAppsCfg()



       
        try {
            init();
        }
        catch ( Exception exception ) {
            exception.printStackTrace ();
        }
    
Methods Summary
public voidaddRecentUrls(java.lang.String strUrlType, java.lang.String strUrl)

        Object          objValue;
        Vector          vectorUrls = null;
        Hashtable       hashRecentUrls;

        objValue = hashProperties.get ( KEY_RECENT_URL );
        if ( objValue != null  &&  objValue instanceof Hashtable ) {
            hashRecentUrls = (Hashtable) objValue;
        }
        else {
            hashRecentUrls = new Hashtable ();
            hashProperties.put ( KEY_RECENT_URL, hashRecentUrls );
        }

        objValue = hashRecentUrls.get ( strUrlType );
        if ( objValue != null  &&  objValue instanceof Vector ) {
            vectorUrls =(Vector)objValue;
        }
        else {
            vectorUrls = new Vector ();
            hashRecentUrls.put ( strUrlType, vectorUrls );
        }

        if ( vectorUrls.contains(strUrl) )
            vectorUrls.removeElement ( strUrl );
        else if ( vectorUrls.size() >= 16 )
            vectorUrls.removeElementAt ( 15 );
        vectorUrls.insertElementAt ( strUrl, 0 );
    
public jmapps.util.JMAppsCfg$CaptureDeviceDatacreateCaptureDeviceDataObject()

        CaptureDeviceData       dataCaptureDevice;

        dataCaptureDevice = new CaptureDeviceData ();
        return ( dataCaptureDevice );
    
public jmapps.util.JMAppsCfg$RtpDatacreateRtpDataObject()

        RtpData         dataRtp;

        dataRtp = new RtpData ();
        return ( dataRtp );
    
public jmapps.util.JMAppsCfg$TrackDatacreateTrackDataObject()

        TrackData       dataTrack;

        dataTrack = new TrackData ();
        return ( dataTrack );
    
public booleangetAutoLoop()

        Object      objValue;
        boolean     boolValue = true;

        objValue = hashProperties.get ( KEY_AUTO_LOOP );
        if ( objValue != null  &&  objValue instanceof Boolean )
            boolValue = ((Boolean)objValue).booleanValue ();
        return ( boolValue );
    
public booleangetAutoPlay()

        Object      objValue;
        boolean     boolValue = true;

        objValue = hashProperties.get ( KEY_AUTO_PLAY );
        if ( objValue != null  &&  objValue instanceof Boolean )
            boolValue = ((Boolean)objValue).booleanValue ();
        return ( boolValue );
    
public java.awt.PointgetJMStudioFrameLocation(int nFrameIndex)

        int     nCount;
        int     nIndex;
        Object  objValue;
        Point   pointValue = null;
        Vector  vectorValues = null;

        objValue = hashProperties.get ( KEY_JMSTUDIO_FRAME_POS );
        if ( objValue != null  &&  objValue instanceof Vector ) {
            vectorValues = (Vector) objValue;
            nCount = vectorValues.size ();
            if ( nFrameIndex < nCount )
                nIndex = nFrameIndex;
            else
                nIndex = nCount - 1;
            objValue = vectorValues.elementAt ( nIndex );
            if ( objValue != null  &&  objValue instanceof Point ) {
                pointValue = new Point ( (Point)objValue );
                pointValue.x += 20 * (nFrameIndex - nIndex);
                pointValue.y += 20 * (nFrameIndex - nIndex);
            }

        }

        if ( pointValue == null )
            pointValue = new Point ( 20 * nFrameIndex, 20 * nFrameIndex );
        return ( pointValue );
    
public booleangetKeepAspectRatio()

        Object      objValue;
        boolean     boolValue = false;

        objValue = hashProperties.get ( KEY_KEEP_ASPECT );
        if ( objValue != null  &&  objValue instanceof Boolean )
            boolValue = ((Boolean)objValue).booleanValue ();
        return ( boolValue );
    
public jmapps.util.JMAppsCfg$CaptureDeviceDatagetLastCaptureAudioData()

        Object                  objValue;
        CaptureDeviceData       dataCapture = null;

        objValue = hashProperties.get ( KEY_CAPTURE_AUDIO );
        if ( objValue != null  &&  objValue instanceof CaptureDeviceData )
            dataCapture =(CaptureDeviceData)objValue;
        return ( dataCapture );
    
public jmapps.util.JMAppsCfg$CaptureDeviceDatagetLastCaptureVideoData()

        Object                  objValue;
        CaptureDeviceData       dataCapture = null;

        objValue = hashProperties.get ( KEY_CAPTURE_VIDEO );
        if ( objValue != null  &&  objValue instanceof CaptureDeviceData )
            dataCapture =(CaptureDeviceData)objValue;
        return ( dataCapture );
    
public java.lang.StringgetLastOpenFile()

        Object  objValue;
        String  strFile = null;

        objValue = hashProperties.get ( KEY_OPEN_FILE );
        if ( objValue != null )
            strFile = objValue.toString ();
        return ( strFile );
    
public jmapps.util.JMAppsCfg$RtpDatagetLastOpenRtpData()

        Object          objValue;
        RtpData         dataRtp = null;

        objValue = hashProperties.get ( KEY_OPEN_RTP );
        if ( objValue != null  &&  objValue instanceof RtpData )
            dataRtp =(RtpData)objValue;
        return ( dataRtp );
    
public java.lang.StringgetLastOpenUrl()

        Object  objValue;
        String  strValue = null;

        objValue = hashProperties.get ( KEY_OPEN_URL );
        if ( objValue != null )
            strValue = objValue.toString ();
        return ( strValue );
    
public java.lang.StringgetLastSaveFileContentType()

        Object  objValue;
        String  strValue = null;

        objValue = hashProperties.get ( KEY_SAVE_FILE_CONTENT );
        if ( objValue != null )
            strValue = objValue.toString ();
        return ( strValue );
    
public java.lang.StringgetLastSaveFileDir()

        Object  objValue;
        String  strValue = null;

        objValue = hashProperties.get ( KEY_SAVE_FILE_DIR );
        if ( objValue != null )
            strValue = objValue.toString ();
        return ( strValue );
    
public jmapps.util.JMAppsCfg$TrackDatagetLastSaveFileTrackData(java.lang.String strTrack)

        Object          objValue;
        TrackData       dataTrack = null;
        Hashtable       hashSaveFile;

        objValue = hashProperties.get ( KEY_SAVE_FILE_TRACKS );
        if ( objValue != null  &&  objValue instanceof Hashtable ) {
            hashSaveFile = (Hashtable) objValue;
        }
        else {
            hashSaveFile = new Hashtable ();
            hashProperties.put ( KEY_SAVE_FILE_TRACKS, hashSaveFile );
        }

        objValue = hashSaveFile.get ( strTrack );
        if ( objValue != null  &&  objValue instanceof TrackData )
            dataTrack =(TrackData)objValue;
        return ( dataTrack );
    
public jmapps.util.JMAppsCfg$RtpDatagetLastTransmitRtpData(java.lang.String strTrack)

        Object          objValue;
        RtpData         dataRtp = null;
        Hashtable       hashTransmitRtp;

        objValue = hashProperties.get ( KEY_TRANSMIT_RTP );
        if ( objValue != null  &&  objValue instanceof Hashtable ) {
            hashTransmitRtp = (Hashtable) objValue;
        }
        else {
            hashTransmitRtp = new Hashtable ();
            hashProperties.put ( KEY_TRANSMIT_RTP, hashTransmitRtp );
        }

        objValue = hashTransmitRtp.get ( strTrack );
        if ( objValue != null  &&  objValue instanceof RtpData )
            dataRtp =(RtpData)objValue;
        return ( dataRtp );
    
public java.lang.StringgetLastTransmitRtpSource()

        Object  objValue;
        String  strValue = null;

        objValue = hashProperties.get ( KEY_TRANSMIT_SOURCE );
        if ( objValue != null )
            strValue = objValue.toString ();
        return ( strValue );
    
public java.util.EnumerationgetRecentUrlTypes()

        Enumeration     enumTypes = null;
        Object          objValue;
        Hashtable       hashRecentUrls;

        objValue = hashProperties.get ( KEY_RECENT_URL );
        if ( objValue != null  &&  objValue instanceof Hashtable ) {
            hashRecentUrls = (Hashtable) objValue;
            enumTypes = hashRecentUrls.keys ();
        }
        return ( enumTypes );
    
public java.util.VectorgetRecentUrls(java.lang.String strUrlType)

        Object          objValue;
        Vector          vectorUrls = null;
        Hashtable       hashRecentUrls;

        objValue = hashProperties.get ( KEY_RECENT_URL );
        if ( objValue != null  &&  objValue instanceof Hashtable ) {
            hashRecentUrls = (Hashtable) objValue;
        }
        else {
            hashRecentUrls = new Hashtable ();
            hashProperties.put ( KEY_RECENT_URL, hashRecentUrls );
        }

        objValue = hashRecentUrls.get ( strUrlType );
        if ( objValue != null  &&  objValue instanceof Vector )
            vectorUrls =(Vector)objValue;
        return ( vectorUrls );
    
protected voidinit()

        readFile ();
    
private voidreadFile()

        FileInputStream         streamFile = null;
        ObjectInputStream       streamObject = null;
        String                  strSignatue;
        String                  strVersion;
        Object                  objValue;
        String                  strPath;

        try {
            strPath = System.getProperty ( "user.home" );
            if ( strPath != null )
                nameFileCfg = strPath + File.separator + nameFileCfg;
            streamFile = new FileInputStream ( nameFileCfg );
        }
        catch ( Exception exception ) {
            // so we will start from scratch
            return;
        }

        try {
            streamObject = new ObjectInputStream ( streamFile );

            strSignatue = streamObject.readUTF ();
            strVersion = streamObject.readUTF ();

            objValue = streamObject.readObject ();
            if ( objValue.toString().equals(signatureHashtable) )
                hashProperties = readHashtable ( streamObject );
        }
        catch ( Exception exception ) {
            MessageDialog.createErrorDialog ( null,
                                JMFI18N.getResource("jmstudio.error.cfgfile.read"),
                                exception );
        }

        try {
            if ( streamObject != null )
                streamObject.close ();
            if ( streamFile != null )
                streamFile.close ();
        }
        catch ( Exception exception ) {
            MessageDialog.createErrorDialog ( null,
                                JMFI18N.getResource("jmstudio.error.cfgfile.close"),
                                exception );
        }
    
private java.util.HashtablereadHashtable(java.io.ObjectInputStream streamObject)

        int             i;
        int             nSize;
        String          strKey;
        Object          objValue;
        Hashtable       hashRead;

        hashRead = new Hashtable ();
        nSize = streamObject.readInt ();
        for ( i = 0;  i < nSize;  i++ ) {
            strKey = streamObject.readUTF ();
            objValue = streamObject.readObject ();
            if ( objValue != null  &&  objValue.toString().equals(signatureHashtable) ) {
                objValue = readHashtable ( streamObject );
            }
            hashRead.put ( strKey, objValue );
        }
        return ( hashRead );
    
public voidsave()

        saveFile ();
    
private voidsaveFile()

        FileOutputStream        streamFile = null;
        ObjectOutputStream      streamObject = null;
        String                  strVersion;
        int                     nSize;
        Enumeration             enumKeys;
        String                  strKey;
        Object                  objValue;


        try {
            streamFile = new FileOutputStream ( nameFileCfg );
            streamObject = new ObjectOutputStream ( streamFile );
        }
        catch ( Exception exception ) {
//            MessageDialog.createErrorDialog ( null,
//                                JMFI18N.getResource("jmstudio.error.cfgfile.create"),
//                                exception );
            System.out.println ( JMFI18N.getResource("jmstudio.error.cfgfile.create")
                                                + " " + exception.getMessage() );
       	    return; 
	}

        try {
            streamObject.writeUTF ( signatureFileCfg );
            strVersion = Manager.getVersion ();
            streamObject.writeUTF ( strVersion );

            writeHashtable ( streamObject, hashProperties );
        }
        catch ( Exception exception ) {
            MessageDialog.createErrorDialog ( null,
                                JMFI18N.getResource("jmstudio.error.cfgfile.write"),
                                exception );
        }

        try {
            if ( streamObject != null )
                streamObject.close ();
            if ( streamFile != null )
                streamFile.close ();
        }
        catch ( Exception exception ) {
            MessageDialog.createErrorDialog ( null,
                                JMFI18N.getResource("jmstudio.error.cfgfile.close"),
                                exception );
        }
    
public voidsetAutoLoop(boolean boolValue)

        Boolean     objValue;

        objValue = new Boolean ( boolValue );
        hashProperties.put ( KEY_AUTO_LOOP, objValue );
    
public voidsetAutoPlay(boolean boolValue)

        Boolean     objValue;

        objValue = new Boolean ( boolValue );
        hashProperties.put ( KEY_AUTO_PLAY, objValue );
    
public voidsetJMStudioFrameLocation(java.awt.Point pointValue, int nFrameIndex)

        int     nCount;
        Object  objValue;
        Vector  vectorValues = null;

        objValue = hashProperties.get ( KEY_JMSTUDIO_FRAME_POS );
        if ( objValue != null  &&  objValue instanceof Vector ) {
            vectorValues = (Vector) objValue;
        }
        else {
            vectorValues = new Vector ();
            hashProperties.put ( KEY_JMSTUDIO_FRAME_POS, vectorValues );
        }

        nCount = vectorValues.size ();
        if ( nFrameIndex < nCount )
            vectorValues.setElementAt ( pointValue, nFrameIndex );
        else
            vectorValues.addElement ( pointValue );
    
public voidsetKeepAspectRatio(boolean boolValue)

        Boolean     objValue;

        objValue = new Boolean ( boolValue );
        hashProperties.put ( KEY_KEEP_ASPECT, objValue );
    
public voidsetLastCaptureAudioData(jmapps.util.JMAppsCfg$CaptureDeviceData dataCapture)

        hashProperties.put ( KEY_CAPTURE_AUDIO, dataCapture );
    
public voidsetLastCaptureVideoData(jmapps.util.JMAppsCfg$CaptureDeviceData dataCapture)

        hashProperties.put ( KEY_CAPTURE_VIDEO, dataCapture );
    
public voidsetLastOpenFile(java.lang.String strFile)

        hashProperties.put ( KEY_OPEN_FILE, strFile );
    
public voidsetLastOpenRtpData(jmapps.util.JMAppsCfg$RtpData dataRtp)

        hashProperties.put ( KEY_OPEN_RTP, dataRtp );
    
public voidsetLastOpenUrl(java.lang.String strValue)

        hashProperties.put ( KEY_OPEN_URL, strValue );
    
public voidsetLastSaveFileContentType(java.lang.String strValue)

        hashProperties.put ( KEY_SAVE_FILE_CONTENT, strValue );
    
public voidsetLastSaveFileDir(java.lang.String strValue)

        hashProperties.put ( KEY_SAVE_FILE_DIR, strValue );
    
public voidsetLastSaveFileTrackData(jmapps.util.JMAppsCfg$TrackData dataTrack, java.lang.String strTrack)

        Object          objValue;
        Hashtable       hashSaveFile;

        objValue = hashProperties.get ( KEY_SAVE_FILE_TRACKS );
        if ( objValue != null  &&  objValue instanceof Hashtable ) {
            hashSaveFile = (Hashtable) objValue;
        }
        else {
            hashSaveFile = new Hashtable ();
            hashProperties.put ( KEY_SAVE_FILE_TRACKS, hashSaveFile );
        }
        hashSaveFile.put ( strTrack, dataTrack );
    
public voidsetLastTransmitRtpData(jmapps.util.JMAppsCfg$RtpData dataRtp, java.lang.String strTrack)

        Object          objValue;
        Hashtable       hashTransmitRtp;

        objValue = hashProperties.get ( KEY_TRANSMIT_RTP );
        if ( objValue != null  &&  objValue instanceof Hashtable ) {
            hashTransmitRtp = (Hashtable) objValue;
        }
        else {
            hashTransmitRtp = new Hashtable ();
            hashProperties.put ( KEY_TRANSMIT_RTP, hashTransmitRtp );
        }
        hashTransmitRtp.put ( strTrack, dataRtp );
    
public voidsetLastTransmitRtpSource(java.lang.String strValue)

        hashProperties.put ( KEY_TRANSMIT_SOURCE, strValue );
    
private voidwriteHashtable(java.io.ObjectOutputStream streamObject, java.util.Hashtable hashWrite)

        int             nSize;
        Enumeration     enumKeys;
        String          strKey;
        Object          objValue;


        streamObject.writeObject ( signatureHashtable );
        nSize = hashWrite.size ();
        streamObject.writeInt ( nSize );
        enumKeys = hashWrite.keys ();
        while ( enumKeys.hasMoreElements() ) {
            strKey = (String) enumKeys.nextElement();

            objValue = hashWrite.get ( strKey );
//System.out.println ( "AAAAA Writing object: " + objValue.getClass().getName() );
            if ( objValue instanceof Hashtable ) {
                streamObject.writeUTF ( strKey );
                writeHashtable ( streamObject, (Hashtable)objValue );
            }
            else if ( !(objValue instanceof Serializable) ) {
/*CHANGE*/
                System.out.println ( "Error. Not Serializable object" );
            }
            else {
                streamObject.writeUTF ( strKey );
                streamObject.writeObject ( objValue );
            }
            streamObject.flush ();
        }