Android Open Source - coursera-android-pos Options






From Project

Back to project page coursera-android-pos.

License

The source code is released under:

MIT License

If you think the Android project coursera-android-pos listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package edu.vuum.mocca;
/* w  ww .j  a v a  2s  . co  m*/
import java.io.File;
import java.nio.*;
import java.util.*;

/**
 * @class Options
 * 
 * @brief This class implements the Singleton pattern to handle
 *        command-line option processing.
 */
public class Options
{
    /** The singleton @a Options instance. */
    private static Options mUniqueInstance = null;

    /** Maximum number of iterations to run the program (defaults to 10). */
    private int mMaxIterations = 10;

    /** Maximum number of iterations per "turn" (defaults to 1). */
    private int mMaxTurns = 1;

    /**
     * Which synchronization to use, e.g., "SEMA" vs. "COND".
     * Defaults to "SEMA".
     */
    private String mSyncMechanism = "SEMA";

    /** Method to return the one and only singleton uniqueInstance. */
    public static Options instance()
    {
        if (mUniqueInstance == null)
            mUniqueInstance = new Options();

        return mUniqueInstance;
    }

    /** Number of iterations to run the program. */
    public int maxIterations()
    {
        return mMaxIterations;
    }

    /** Number of iterations to run the program. */
    public int maxTurns()
    {
        return mMaxTurns;
    }

    /**
     * Which synchronization to use, e.g., "SEMA" vs. "COND".
     * Defaults to "SEMA".
     */
    public String syncMechanism()
    {
        return mSyncMechanism;
    }

    /**
     * Parse command-line arguments and set the appropriate values.
     */
    public boolean parseArgs(String argv[])
    {
        for (int argc = 0; argc < argv.length; argc += 2)
            if (argv[argc].equals("-i"))
                mMaxIterations = Integer.parseInt(argv[argc + 1]);
            else if (argv[argc].equals("-s"))
                mSyncMechanism = argv[argc + 1];
            else if (argv[argc].equals("-t"))
                mMaxTurns = Integer.parseInt(argv[argc + 1]);
            else
                {
                    printUsage();
                    return false;
                }

        return true;
    }

    /** Print out usage and default values. */
    public void printUsage()
    {
        PlatformStrategy platform = PlatformStrategy.instance();
        platform.errorLog("Options", "\nHelp Invoked on ");
        platform.errorLog("Options", "[-hist] ");
        platform.errorLog("", "");
        platform.errorLog("", "");

        platform.errorLog("Options", "Usage: ");
        platform.errorLog("Options", "-h: invoke help ");
        platform.errorLog("Options", "-i max-number-of-iterations ");
        platform.errorLog("Options", "-s sync-mechanism (e.g., \"SEMA\" or \"COND\"");
        platform.errorLog("Options", "-t max-number-of-turns");
    }

    /**
     * Make the constructor private for a singleton.
     */
    private Options()
    {
    }
}




Java Source Code List

.BuggyLongTest.java
.Main.java
.PingPongWrong.java
.SimpleAtomicLongTest.java
.SimpleAtomicLong.java
edu.vuum.mocca.AndroidPlatformStrategy.java
edu.vuum.mocca.AndroidPlatformStrategy.java
edu.vuum.mocca.AndroidPlatformStrategy.java
edu.vuum.mocca.BuggyLongTest.java
edu.vuum.mocca.BuggyLongTest.java
edu.vuum.mocca.ConsolePlatformStrategy.java
edu.vuum.mocca.ConsolePlatformStrategy.java
edu.vuum.mocca.ConsolePlatformStrategy.java
edu.vuum.mocca.DownloadActivity.java
edu.vuum.mocca.DownloadActivity.java
edu.vuum.mocca.DownloadBase.java
edu.vuum.mocca.DownloadIntentService.java
edu.vuum.mocca.DownloadService.java
edu.vuum.mocca.DownloadUtils.java
edu.vuum.mocca.Main.java
edu.vuum.mocca.Main.java
edu.vuum.mocca.Main.java
edu.vuum.mocca.Options.java
edu.vuum.mocca.Options.java
edu.vuum.mocca.Options.java
edu.vuum.mocca.PingPongActivity.java
edu.vuum.mocca.PingPongActivity.java
edu.vuum.mocca.PingPongRight.java
edu.vuum.mocca.PingPongRight.java
edu.vuum.mocca.PingPongRight.java
edu.vuum.mocca.PlatformStrategyFactory.java
edu.vuum.mocca.PlatformStrategyFactory.java
edu.vuum.mocca.PlatformStrategyFactory.java
edu.vuum.mocca.PlatformStrategy.java
edu.vuum.mocca.PlatformStrategy.java
edu.vuum.mocca.PlatformStrategy.java
edu.vuum.mocca.PlayPingPong.java
edu.vuum.mocca.PlayPingPong.java
edu.vuum.mocca.PlayPingPong.java
edu.vuum.mocca.SimpleAtomicLongMultithreadedTest.java
edu.vuum.mocca.SimpleAtomicLongMultithreadedTest.java
edu.vuum.mocca.SimpleAtomicLongMultithreadedTest.java
edu.vuum.mocca.SimpleAtomicLongSingleThreadedTest.java
edu.vuum.mocca.SimpleAtomicLongSingleThreadedTest.java
edu.vuum.mocca.SimpleAtomicLongSingleThreadedTest.java
edu.vuum.mocca.SimpleAtomicLongTests.java
edu.vuum.mocca.SimpleAtomicLongTests.java
edu.vuum.mocca.SimpleAtomicLongTests.java
edu.vuum.mocca.SimpleAtomicLong.java
edu.vuum.mocca.SimpleAtomicLong.java
edu.vuum.mocca.SimpleAtomicLong.java
edu.vuum.mocca.SimpleAtomicLong.java
edu.vuum.mocca.SimpleAtomicLong.java
edu.vuum.mocca.SimpleSemaphore.java
edu.vuum.mocca.SimpleSemaphore.java
edu.vuum.mocca.SimpleSemaphore.java
edu.vuum.mocca.SimpleSemaphore.java
edu.vuum.mocca.SimpleSemaphore.java
edu.vuum.mocca.SimpleSemaphore.java
edu.vuum.mocca.ThreadPoolDownloadService.java
edu.vuum.mocca.ThreadedDownloads.java
edu.vuum.mocca.provider.MoocSchema.java
edu.vuum.mocca.storage.MoocResolver.java
edu.vuum.mocca.storage.StorageUtilities.java
edu.vuum.mocca.storage.StoryCreator.java
edu.vuum.mocca.storage.StoryData.java
edu.vuum.mocca.ui.CreateStoryActivity.java
edu.vuum.mocca.ui.EditStoryActivity.java
edu.vuum.mocca.ui.ListStoryActivity.java
edu.vuum.mocca.ui.LoginActivity.java
edu.vuum.mocca.ui.SoundRecordActivity.java
edu.vuum.mocca.ui.StoryActivityBase.java
edu.vuum.mocca.ui.StoryDataArrayAdaptor.java
edu.vuum.mocca.ui.ViewStoryActivity.java
edu.vuum.mooca.BuggyBlockingQueue.java
edu.vuum.mooca.BuggyBlockingQueue.java
edu.vuum.mooca.BuggyBlockingQueue.java
edu.vuum.mooca.SynchronizedQueueImpl.java
edu.vuum.mooca.SynchronizedQueueImpl.java
edu.vuum.mooca.SynchronizedQueueTest.java
edu.vuum.mooca.SynchronizedQueueTest.java
edu.vuum.mooca.SynchronizedQueueTest.java
edu.vuum.mooca.SynchronizedQueueTest.java
edu.vuum.mooca.SynchronizedQueueTest.java
edu.vuum.mooca.SynchronizedQueue.java
edu.vuum.mooca.SynchronizedQueue.java
edu.vuum.mooca.SynchronizedQueue.java
edu.vuum.mooca.SynchronizedQueue.java
edu.vuum.mooca.SynchronizedQueue.java.java