id
int32
0
12.9k
code
sequencelengths
2
264k
7,500
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "can", ";", "import", "java", ".", "io", ".", "IOException", ";", "public", "class", "CANTimeoutException", "extends", "IOException", "{", "public", "CANTimeoutException", "(", ")", "{", "super", "(", ")", ";", "}", "}", "</s>" ]
7,501
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "can", ";", "import", "com", ".", "ni", ".", "rio", ".", "NiRioStatus", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "util", ".", "UncleanStatusException", ";", "public", "class", "CANExceptionFactory", "{", "static", "final", "int", "ERR_JaguarCANDriver_InvalidBuffer", "=", "-", "44086", ";", "static", "final", "int", "ERR_JaguarCANDriver_TimedOut", "=", "-", "44087", ";", "static", "final", "int", "ERR_JaguarCANDriver_NotAllowed", "=", "-", "44088", ";", "static", "final", "int", "ERR_JaguarCANDriver_NotInitialized", "=", "-", "44089", ";", "public", "static", "void", "checkStatus", "(", "int", "status", ",", "int", "messageID", ")", "throws", "CANInvalidBufferException", ",", "CANTimeoutException", ",", "CANMessageNotAllowedException", ",", "CANNotInitializedException", ",", "UncleanStatusException", "{", "switch", "(", "status", ")", "{", "case", "NiRioStatus", ".", "kRioStatusSuccess", ":", "return", ";", "case", "ERR_JaguarCANDriver_InvalidBuffer", ":", "case", "NiRioStatus", ".", "kRIOStatusBufferInvalidSize", ":", "throw", "new", "CANInvalidBufferException", "(", ")", ";", "case", "ERR_JaguarCANDriver_TimedOut", ":", "case", "NiRioStatus", ".", "kRIOStatusOperationTimedOut", ":", "throw", "new", "CANTimeoutException", "(", ")", ";", "case", "ERR_JaguarCANDriver_NotAllowed", ":", "case", "NiRioStatus", ".", "kRIOStatusFeatureNotSupported", ":", "throw", "new", "CANMessageNotAllowedException", "(", "\"MessageID", "=", "\"", "+", "Integer", ".", "toString", "(", "messageID", ")", ")", ";", "case", "ERR_JaguarCANDriver_NotInitialized", ":", "case", "NiRioStatus", ".", "kRIOStatusResourceNotInitialized", ":", "throw", "new", "CANNotInitializedException", "(", ")", ";", "default", ":", "throw", "new", "UncleanStatusException", "(", "\"\"", "+", "Integer", ".", "toString", "(", "status", ")", ")", ";", "}", "}", "}", "</s>" ]
7,502
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "communication", ";", "import", "com", ".", "sun", ".", "cldc", ".", "jna", ".", "Function", ";", "import", "com", ".", "sun", ".", "cldc", ".", "jna", ".", "BlockingFunction", ";", "import", "com", ".", "sun", ".", "cldc", ".", "jna", ".", "Pointer", ";", "import", "com", ".", "sun", ".", "cldc", ".", "jna", ".", "NativeLibrary", ";", "import", "com", ".", "sun", ".", "cldc", ".", "jna", ".", "Structure", ";", "import", "com", ".", "sun", ".", "cldc", ".", "jna", ".", "TaskExecutor", ";", "public", "final", "class", "FRCControl", "{", "private", "static", "final", "TaskExecutor", "taskExecutor", "=", "new", "TaskExecutor", "(", "\"\"", ")", ";", "private", "static", "final", "BlockingFunction", "getCommonControlDataFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getBlockingFunction", "(", "\"\"", ")", ";", "private", "static", "final", "BlockingFunction", "getDynamicControlDataFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getBlockingFunction", "(", "\"\"", ")", ";", "private", "static", "final", "BlockingFunction", "setStatusDataFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getBlockingFunction", "(", "\"\"", ")", ";", "private", "static", "final", "BlockingFunction", "setErrorDataFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getBlockingFunction", "(", "\"setErrorData\"", ")", ";", "private", "static", "final", "BlockingFunction", "setUserDsLcdDataFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getBlockingFunction", "(", "\"\"", ")", ";", "private", "static", "final", "BlockingFunction", "overrideIOConfigFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getBlockingFunction", "(", "\"\"", ")", ";", "private", "static", "final", "BlockingFunction", "setNewDataSemFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getBlockingFunction", "(", "\"\"", ")", ";", "private", "static", "final", "Function", "observeUserProgramStartingFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"\"", ")", ";", "static", "{", "getCommonControlDataFn", ".", "setTaskExecutor", "(", "taskExecutor", ")", ";", "getDynamicControlDataFn", ".", "setTaskExecutor", "(", "taskExecutor", ")", ";", "setStatusDataFn", ".", "setTaskExecutor", "(", "taskExecutor", ")", ";", "setErrorDataFn", ".", "setTaskExecutor", "(", "taskExecutor", ")", ";", "setUserDsLcdDataFn", ".", "setTaskExecutor", "(", "taskExecutor", ")", ";", "setNewDataSemFn", ".", "setTaskExecutor", "(", "taskExecutor", ")", ";", "overrideIOConfigFn", ".", "setTaskExecutor", "(", "taskExecutor", ")", ";", "}", "public", "static", "final", "int", "IO_CONFIG_DATA_SIZE", "=", "32", ";", "public", "static", "final", "int", "USER_CONTROL_DATA_SIZE", "=", "936", "-", "IO_CONFIG_DATA_SIZE", ";", "public", "static", "final", "int", "USER_STATUS_DATA_SIZE", "=", "984", ";", "public", "static", "final", "int", "USER_DS_LCD_DATA_SIZE", "=", "128", ";", "private", "FRCControl", "(", ")", "{", "}", "public", "static", "class", "CachedNativeBuffer", "{", "private", "Pointer", "buffer", ";", "public", "Pointer", "getBufferSized", "(", "int", "size", ")", "{", "if", "(", "buffer", "==", "null", ")", "{", "buffer", "=", "new", "Pointer", "(", "size", ")", ";", "}", "if", "(", "size", ">", "buffer", ".", "getSize", "(", ")", ")", "{", "buffer", ".", "free", "(", ")", ";", "buffer", "=", "new", "Pointer", "(", "size", ")", ";", "}", "return", "buffer", ";", "}", "public", "void", "free", "(", ")", "{", "if", "(", "buffer", "!=", "null", ")", "{", "buffer", ".", "free", "(", ")", ";", "buffer", "=", "null", ";", "}", "}", "}", "public", "static", "abstract", "class", "DynamicControlData", "extends", "Structure", "{", "}", "private", "static", "final", "CachedNativeBuffer", "controlDataCache", "=", "new", "CachedNativeBuffer", "(", ")", ";", "private", "static", "final", "CachedNativeBuffer", "statusDataCacheHigh", "=", "new", "CachedNativeBuffer", "(", ")", ";", "private", "static", "final", "CachedNativeBuffer", "statusDataCacheLow", "=", "new", "CachedNativeBuffer", "(", ")", ";", "private", "static", "final", "CachedNativeBuffer", "ioConfigDataCache", "=", "new", "CachedNativeBuffer", "(", ")", ";", "public", "static", "int", "getCommonControlData", "(", "FRCCommonControlData", "data", ",", "int", "wait_ms", ")", "{", "int", "res", "=", "getCommonControlDataFn", ".", "call2", "(", "data", ".", "getPointer", "(", ")", ",", "wait_ms", ")", ";", "if", "(", "res", "==", "0", ")", "{", "data", ".", "read", "(", ")", ";", "}", "return", "res", ";", "}", "public", "static", "int", "getDynamicControlData", "(", "byte", "type", ",", "DynamicControlData", "dynamicData", ",", "int", "maxLength", ",", "int", "wait_ms", ")", "{", "synchronized", "(", "controlDataCache", ")", "{", "dynamicData", ".", "write", "(", ")", ";", "int", "res", "=", "getDynamicControlDataFn", ".", "call4", "(", "type", ",", "dynamicData", ".", "getPointer", "(", ")", ",", "maxLength", ",", "wait_ms", ")", ";", "if", "(", "res", "==", "0", ")", "dynamicData", ".", "read", "(", ")", ";", "return", "res", ";", "}", "}", "public", "static", "int", "overrideIOConfig", "(", "DynamicControlData", "ioConfig", ",", "int", "wait_ms", ")", "{", "synchronized", "(", "ioConfigDataCache", ")", "{", "ioConfig", ".", "write", "(", ")", ";", "int", "res", "=", "overrideIOConfigFn", ".", "call2", "(", "ioConfig", ".", "getPointer", "(", ")", ",", "wait_ms", ")", ";", "if", "(", "res", "==", "0", ")", "ioConfig", ".", "read", "(", ")", ";", "return", "res", ";", "}", "}", "public", "static", "int", "setStatusData", "(", "double", "battery", ",", "int", "dsDigitalOut", ",", "int", "updateNumber", ",", "byte", "[", "]", "userDataHigh", ",", "int", "userDataHighLength", ",", "byte", "[", "]", "userDataLow", ",", "int", "userDataLowLength", ",", "int", "wait_ms", ")", "{", "synchronized", "(", "statusDataCacheHigh", ")", "{", "Pointer", "userDataPtrHigh", "=", "statusDataCacheHigh", ".", "getBufferSized", "(", "userDataHighLength", ")", ";", "userDataPtrHigh", ".", "setBytes", "(", "0", ",", "userDataHigh", ",", "0", ",", "userDataHighLength", ")", ";", "Pointer", "userDataPtrLow", "=", "statusDataCacheLow", ".", "getBufferSized", "(", "userDataLowLength", ")", ";", "userDataPtrLow", ".", "setBytes", "(", "0", ",", "userDataLow", ",", "0", ",", "userDataLowLength", ")", ";", "int", "res", "=", "setStatusDataFn", ".", "call8", "(", "Float", ".", "floatToIntBits", "(", "(", "float", ")", "battery", ")", ",", "dsDigitalOut", ",", "updateNumber", ",", "userDataPtrHigh", ".", "address", "(", ")", ".", "toUWord", "(", ")", ".", "toPrimitive", "(", ")", ",", "userDataHighLength", ",", "userDataPtrLow", ".", "address", "(", ")", ".", "toUWord", "(", ")", ".", "toPrimitive", "(", ")", ",", "userDataLowLength", ",", "wait_ms", ")", ";", "return", "res", ";", "}", "}", "public", "static", "void", "setErrorData", "(", "byte", "[", "]", "bytes", ",", "int", "length", ",", "int", "timeOut", ")", "{", "Pointer", "textPtr", "=", "new", "Pointer", "(", "bytes", ".", "length", ")", ";", "textPtr", ".", "setBytes", "(", "0", ",", "bytes", ",", "0", ",", "bytes", ".", "length", ")", ";", "setErrorDataFn", ".", "call3", "(", "textPtr", ",", "length", ",", "timeOut", ")", ";", "textPtr", ".", "free", "(", ")", ";", "}", "public", "static", "void", "setErrorData", "(", "Pointer", "textPtr", ",", "int", "length", ",", "int", "timeOut", ")", "{", "if", "(", "length", ">", "textPtr", ".", "getSize", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "setErrorDataFn", ".", "call3", "(", "textPtr", ",", "length", ",", "timeOut", ")", ";", "}", "public", "static", "void", "setUserDsLcdData", "(", "byte", "[", "]", "bytes", ",", "int", "length", ",", "int", "timeOut", ")", "{", "Pointer", "textPtr", "=", "new", "Pointer", "(", "bytes", ".", "length", ")", ";", "textPtr", ".", "setBytes", "(", "0", ",", "bytes", ",", "0", ",", "bytes", ".", "length", ")", ";", "setUserDsLcdDataFn", ".", "call3", "(", "textPtr", ",", "length", ",", "timeOut", ")", ";", "textPtr", ".", "free", "(", ")", ";", "}", "public", "static", "void", "setNewDataSem", "(", "Semaphore", "sem", ")", "{", "if", "(", "sem", "==", "null", "||", "sem", ".", "m_semaphore", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"\"", ")", ";", "}", "setNewDataSemFn", ".", "call1", "(", "sem", ".", "m_semaphore", ")", ";", "}", "public", "static", "void", "observeUserProgramStarting", "(", ")", "{", "observeUserProgramStartingFn", ".", "call0", "(", ")", ";", "}", "}", "</s>" ]
7,503
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "communication", ";", "import", "com", ".", "sun", ".", "cldc", ".", "jna", ".", "Function", ";", "import", "com", ".", "sun", ".", "cldc", ".", "jna", ".", "NativeLibrary", ";", "import", "com", ".", "sun", ".", "cldc", ".", "jna", ".", "Pointer", ";", "import", "com", ".", "sun", ".", "squawk", ".", "platform", ".", "posix", ".", "LibCUtil", ";", "public", "class", "Semaphore", "{", "Pointer", "m_semaphore", ";", "public", "static", "final", "int", "WAIT_FOREVER", "=", "-", "1", ";", "static", "final", "int", "SEM_Q_FIFO", "=", "0x00", ";", "static", "final", "int", "SEM_Q_PRIORITY", "=", "0x01", ";", "static", "final", "int", "SEM_DELETE_SAFE", "=", "0x04", ";", "static", "final", "int", "SEM_INVERSION_SAFE", "=", "0x08", ";", "static", "final", "int", "SEM_EVENTSEND_ERR_NOTIFY", "=", "0x10", ";", "static", "final", "int", "SEM_INTERRUPTIBLE", "=", "0x20", ";", "public", "static", "class", "Options", "{", "int", "value", "=", "0", ";", "public", "void", "setPrioritySorted", "(", "boolean", "priority", ")", "{", "if", "(", "priority", ")", "value", "|=", "SEM_Q_PRIORITY", ";", "else", "value", "&=", "~", "SEM_Q_PRIORITY", ";", "}", "public", "void", "setDeleteSafe", "(", "boolean", "delSafe", ")", "{", "if", "(", "delSafe", ")", "value", "|=", "SEM_DELETE_SAFE", ";", "else", "value", "&=", "~", "SEM_DELETE_SAFE", ";", "}", "public", "void", "setInversionSafe", "(", "boolean", "invSafe", ")", "{", "if", "(", "invSafe", ")", "value", "|=", "SEM_INVERSION_SAFE", ";", "else", "value", "&=", "~", "SEM_INVERSION_SAFE", ";", "}", "public", "void", "setErrorNotify", "(", "boolean", "errNot", ")", "{", "if", "(", "errNot", ")", "value", "|=", "SEM_EVENTSEND_ERR_NOTIFY", ";", "else", "value", "&=", "~", "SEM_EVENTSEND_ERR_NOTIFY", ";", "}", "public", "void", "setInterruptable", "(", "boolean", "intable", ")", "{", "if", "(", "intable", ")", "value", "|=", "SEM_INTERRUPTIBLE", ";", "else", "value", "&=", "~", "SEM_INTERRUPTIBLE", ";", "}", "}", "private", "static", "Function", "semMCreateFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"semMCreate\"", ")", ";", "private", "static", "Function", "semBCreateFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"semBCreate\"", ")", ";", "private", "static", "Function", "semCCreateFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"semCCreate\"", ")", ";", "private", "static", "Function", "semDeleteFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"semDelete\"", ")", ";", "private", "static", "Function", "semFlushFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"semFlush\"", ")", ";", "private", "static", "Function", "semGiveFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"semGive\"", ")", ";", "private", "static", "Function", "semTakeFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"semTake\"", ")", ";", "private", "static", "Function", "semTakeBlockingFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getBlockingFunction", "(", "\"semTake\"", ")", ";", "private", "static", "Function", "semCloseFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"semClose\"", ")", ";", "private", "void", "checkStatus", "(", "int", "status", ")", "throws", "SemaphoreException", "{", "if", "(", "status", "!=", "0", ")", "{", "throw", "new", "SemaphoreException", "(", "LibCUtil", ".", "errno", "(", ")", ")", ";", "}", "}", "public", "Semaphore", "(", "Options", "options", ")", "{", "m_semaphore", "=", "new", "Pointer", "(", "semMCreateFn", ".", "call1", "(", "options", ".", "value", ")", ",", "0", ")", ";", "}", "public", "Semaphore", "(", "Options", "options", ",", "boolean", "initialState", ")", "{", "m_semaphore", "=", "new", "Pointer", "(", "semBCreateFn", ".", "call2", "(", "options", ".", "value", ",", "initialState", "?", "1", ":", "0", ")", ",", "0", ")", ";", "}", "public", "Semaphore", "(", "Options", "options", ",", "int", "count", ")", "{", "m_semaphore", "=", "new", "Pointer", "(", "semCCreateFn", ".", "call2", "(", "options", ".", "value", ",", "count", ")", ",", "0", ")", ";", "}", "public", "Pointer", "getPointer", "(", ")", "{", "return", "m_semaphore", ";", "}", "public", "void", "flush", "(", ")", "throws", "SemaphoreException", "{", "checkStatus", "(", "semFlushFn", ".", "call1", "(", "m_semaphore", ")", ")", ";", "}", "public", "void", "give", "(", ")", "throws", "SemaphoreException", "{", "checkStatus", "(", "semGiveFn", ".", "call1", "(", "m_semaphore", ")", ")", ";", "}", "public", "void", "takeMillis", "(", "int", "timeout", ")", "throws", "SemaphoreException", "{", "checkStatus", "(", "semTakeBlockingFn", ".", "call2", "(", "m_semaphore", ",", "timeout", ")", ")", ";", "}", "public", "void", "takeForever", "(", ")", "throws", "SemaphoreException", "{", "takeMillis", "(", "WAIT_FOREVER", ")", ";", "}", "public", "boolean", "tryTake", "(", ")", "throws", "SemaphoreException", "{", "int", "result", "=", "semTakeFn", ".", "call2", "(", "m_semaphore", ",", "0", ")", ";", "if", "(", "result", "==", "0", ")", "{", "return", "true", ";", "}", "else", "{", "int", "errno", "=", "LibCUtil", ".", "errno", "(", ")", ";", "if", "(", "errno", "==", "SemaphoreException", ".", "S_objLib_OBJ_UNAVAILABLE", ")", "{", "return", "false", ";", "}", "else", "{", "throw", "new", "SemaphoreException", "(", "errno", ")", ";", "}", "}", "}", "public", "void", "close", "(", ")", "throws", "SemaphoreException", "{", "checkStatus", "(", "semCloseFn", ".", "call1", "(", "m_semaphore", ")", ")", ";", "}", "public", "void", "free", "(", ")", "throws", "SemaphoreException", "{", "checkStatus", "(", "semDeleteFn", ".", "call1", "(", "m_semaphore", ")", ")", ";", "}", "}", "</s>" ]
7,504
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "communication", ";", "import", "com", ".", "sun", ".", "cldc", ".", "jna", ".", "*", ";", "public", "class", "AICalibration", "{", "private", "static", "final", "Function", "getLSBWeightFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"\"", ")", ";", "public", "static", "long", "getLSBWeight", "(", "int", "aiSystemIndex", ",", "int", "channel", ")", "{", "long", "lsbWeight", "=", "getLSBWeightFn", ".", "call3", "(", "aiSystemIndex", ",", "channel", ",", "Pointer", ".", "NULL", "(", ")", ")", "&", "0xFFFFFFFFl", ";", "return", "lsbWeight", ";", "}", "private", "static", "final", "Function", "getOffsetFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"\"", ")", ";", "public", "static", "int", "getOffset", "(", "int", "aiSystemIndex", ",", "int", "channel", ")", "{", "int", "offset", "=", "getOffsetFn", ".", "call3", "(", "aiSystemIndex", ",", "channel", ",", "Pointer", ".", "NULL", "(", ")", ")", ";", "return", "offset", ";", "}", "}", "</s>" ]
7,505
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "communication", ";", "import", "com", ".", "sun", ".", "cldc", ".", "jna", ".", "Structure", ";", "public", "final", "class", "FRCCommonControlData", "extends", "Structure", "{", "public", "static", "final", "short", "RESET_BIT", "=", "0x80", ";", "public", "static", "final", "short", "ESTOP_BIT", "=", "0x40", ";", "public", "static", "final", "short", "ENABLED_BIT", "=", "0x20", ";", "public", "static", "final", "short", "AUTONOMOUS_BIT", "=", "0x10", ";", "public", "static", "final", "short", "FMS_ATTATCHED", "=", "0x08", ";", "public", "static", "final", "short", "RESYNCH", "=", "0x04", ";", "public", "static", "final", "short", "CRIO_CHECK_SUM", "=", "0x02", ";", "public", "static", "final", "short", "FPGA_CHECK_SUM", "=", "0x01", ";", "public", "int", "packetIndex", ";", "public", "short", "control", ";", "public", "boolean", "enabled", "(", ")", "{", "return", "(", "control", "&", "ENABLED_BIT", ")", "==", "ENABLED_BIT", ";", "}", "public", "boolean", "autonomous", "(", ")", "{", "return", "(", "control", "&", "AUTONOMOUS_BIT", ")", "==", "AUTONOMOUS_BIT", ";", "}", "public", "short", "dsDigitalIn", ";", "public", "int", "teamID", ";", "public", "char", "dsID_Alliance", ";", "public", "char", "dsID_Position", ";", "public", "byte", "[", "]", "stick0Axes", "=", "new", "byte", "[", "6", "]", ";", "public", "short", "stick0Buttons", ";", "public", "byte", "[", "]", "stick1Axes", "=", "new", "byte", "[", "6", "]", ";", "public", "short", "stick1Buttons", ";", "public", "byte", "[", "]", "stick2Axes", "=", "new", "byte", "[", "6", "]", ";", "public", "short", "stick2Buttons", ";", "public", "byte", "[", "]", "stick3Axes", "=", "new", "byte", "[", "6", "]", ";", "public", "short", "stick3Buttons", ";", "public", "short", "analog1", ";", "public", "short", "analog2", ";", "public", "short", "analog3", ";", "public", "short", "analog4", ";", "public", "FRCCommonControlData", "(", ")", "{", "allocateMemory", "(", ")", ";", "}", "protected", "void", "free", "(", ")", "{", "freeMemory", "(", ")", ";", "}", "public", "void", "read", "(", ")", "{", "packetIndex", "=", "backingNativeMemory", ".", "getShort", "(", "0", ")", "&", "0xFFFF", ";", "control", "=", "(", "short", ")", "(", "backingNativeMemory", ".", "getByte", "(", "2", ")", "&", "0xFF", ")", ";", "dsDigitalIn", "=", "(", "short", ")", "(", "backingNativeMemory", ".", "getByte", "(", "3", ")", "&", "0xFF", ")", ";", "teamID", "=", "backingNativeMemory", ".", "getShort", "(", "4", ")", "&", "0xFFFF", ";", "dsID_Alliance", "=", "(", "char", ")", "backingNativeMemory", ".", "getByte", "(", "6", ")", ";", "dsID_Position", "=", "(", "char", ")", "backingNativeMemory", ".", "getByte", "(", "7", ")", ";", "backingNativeMemory", ".", "getBytes", "(", "8", ",", "stick0Axes", ",", "0", ",", "6", ")", ";", "stick0Buttons", "=", "backingNativeMemory", ".", "getShort", "(", "14", ")", ";", "backingNativeMemory", ".", "getBytes", "(", "16", ",", "stick1Axes", ",", "0", ",", "6", ")", ";", "stick1Buttons", "=", "backingNativeMemory", ".", "getShort", "(", "22", ")", ";", "backingNativeMemory", ".", "getBytes", "(", "24", ",", "stick2Axes", ",", "0", ",", "6", ")", ";", "stick2Buttons", "=", "backingNativeMemory", ".", "getShort", "(", "30", ")", ";", "backingNativeMemory", ".", "getBytes", "(", "32", ",", "stick3Axes", ",", "0", ",", "6", ")", ";", "stick3Buttons", "=", "backingNativeMemory", ".", "getShort", "(", "38", ")", ";", "analog1", "=", "backingNativeMemory", ".", "getShort", "(", "40", ")", ";", "analog2", "=", "backingNativeMemory", ".", "getShort", "(", "42", ")", ";", "analog3", "=", "backingNativeMemory", ".", "getShort", "(", "44", ")", ";", "analog4", "=", "backingNativeMemory", ".", "getShort", "(", "46", ")", ";", "}", "public", "void", "write", "(", ")", "{", "throw", "new", "IllegalStateException", "(", "\"\"", ")", ";", "}", "public", "int", "size", "(", ")", "{", "return", "80", ";", "}", "}", "</s>" ]
7,506
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "communication", ";", "import", "com", ".", "sun", ".", "cldc", ".", "jna", ".", "*", ";", "import", "com", ".", "sun", ".", "squawk", ".", "VM", ";", "public", "class", "BumARioHandle", "{", "private", "static", "Function", "bumFn", ";", "private", "static", "Function", "invalidateFn", ";", "static", "{", "try", "{", "bumFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"\"", ")", ";", "invalidateFn", "=", "NativeLibrary", ".", "getDefaultInstance", "(", ")", ".", "getFunction", "(", "\"\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "bumFn", "=", "null", ";", "invalidateFn", "=", "null", ";", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "}", "public", "static", "int", "bum", "(", "int", "pStatus", ")", "{", "return", "bumFn", ".", "call1", "(", "pStatus", ")", ";", "}", "static", "{", "invalidateFn", ".", "call0", "(", ")", ";", "VM", ".", "addShutdownHook", "(", "new", "Thread", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "invalidateFn", ".", "call0", "(", ")", ";", "}", "}", ")", ")", ";", "}", "}", "</s>" ]
7,507
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "communication", ";", "public", "class", "SemaphoreException", "extends", "Exception", "{", "public", "static", "final", "int", "M_semLib", "=", "22", "<<", "16", ";", "public", "static", "final", "int", "M_objLib", "=", "61", "<<", "16", ";", "public", "final", "static", "int", "S_objLib_OBJ_ID_ERROR", "=", "(", "M_objLib", "|", "1", ")", ";", "public", "final", "static", "int", "S_objLib_OBJ_UNAVAILABLE", "=", "(", "M_objLib", "|", "2", ")", ";", "public", "final", "static", "int", "S_objLib_OBJ_DELETED", "=", "(", "M_objLib", "|", "3", ")", ";", "public", "final", "static", "int", "S_objLib_OBJ_TIMEOUT", "=", "(", "M_objLib", "|", "4", ")", ";", "public", "final", "static", "int", "S_semLib_INVALID_STATE", "=", "(", "M_semLib", "|", "101", ")", ";", "public", "final", "static", "int", "S_semLib_INVALID_OPTION", "=", "(", "M_semLib", "|", "102", ")", ";", "public", "final", "static", "int", "S_semLib_INVALID_QUEUE_TYPE", "=", "(", "M_semLib", "|", "103", ")", ";", "public", "final", "static", "int", "S_semLib_INVALID_OPERATION", "=", "(", "M_semLib", "|", "104", ")", ";", "public", "final", "static", "int", "S_semLib_INVALID_INITIAL_COUNT", "=", "(", "M_semLib", "|", "105", ")", ";", "public", "final", "static", "int", "S_semLib_COUNT_OVERFLOW", "=", "(", "M_semLib", "|", "106", ")", ";", "public", "SemaphoreException", "(", "int", "status", ")", "{", "super", "(", "lookUpCode", "(", "status", ")", ")", ";", "}", "private", "static", "String", "lookUpCode", "(", "int", "status", ")", "{", "switch", "(", "status", ")", "{", "case", "S_objLib_OBJ_ID_ERROR", ":", "return", "\"OBJ_ID_ERROR\"", ";", "case", "S_objLib_OBJ_UNAVAILABLE", ":", "return", "\"\"", ";", "case", "S_objLib_OBJ_DELETED", ":", "return", "\"OBJ_DELETED\"", ";", "case", "S_objLib_OBJ_TIMEOUT", ":", "return", "\"OBJ_TIMEOUT\"", ";", "case", "S_semLib_INVALID_STATE", ":", "return", "\"\"", ";", "case", "S_semLib_INVALID_OPTION", ":", "return", "\"\"", ";", "case", "S_semLib_INVALID_QUEUE_TYPE", ":", "return", "\"\"", ";", "case", "S_semLib_INVALID_OPERATION", ":", "return", "\"\"", ";", "case", "S_semLib_INVALID_INITIAL_COUNT", ":", "return", "\"\"", ";", "case", "S_semLib_COUNT_OVERFLOW", ":", "return", "\"\"", ";", "default", ":", "return", "\"\"", ";", "}", "}", "}", "</s>" ]
7,508
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "defaultCode", ";", "import", "java", ".", "lang", ".", "*", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "*", ";", "public", "class", "MotorControl", "extends", "RobotDrive", "implements", "PIDOutput", "{", "Joystick", "joystick_ch1", ";", "CANJaguar", "frontleft", ";", "CANJaguar", "frontright", ";", "CANJaguar", "backleft", ";", "CANJaguar", "backright", ";", "public", "MotorControl", "(", "CANJaguar", "frontleft", ",", "CANJaguar", "frontright", ",", "CANJaguar", "backleft", ",", "CANJaguar", "backright", ")", "{", "super", "(", "frontleft", ",", "backleft", ",", "frontright", ",", "backright", ")", ";", "joystick_ch1", "=", "new", "Joystick", "(", "1", ")", ";", "this", ".", "frontleft", "=", "frontleft", ";", "this", ".", "frontright", "=", "frontright", ";", "this", ".", "backleft", "=", "backleft", ";", "this", ".", "backright", "=", "backright", ";", "CANSetup", "(", "360", ",", "0.20", ",", "0.000", ",", "0.00", ")", ";", "setMaxOutput", "(", "200", ")", ";", "setInvertedMotor", "(", "MotorType", ".", "kFrontLeft", ",", "true", ")", ";", "setInvertedMotor", "(", "MotorType", ".", "kRearLeft", ",", "true", ")", ";", "}", "public", "void", "CANSetup", "(", "int", "encoderCodesPerRev", ",", "double", "P", ",", "double", "I", ",", "double", "D", ")", "{", "try", "{", "frontleft", ".", "configEncoderCodesPerRev", "(", "encoderCodesPerRev", ")", ";", "frontright", ".", "configEncoderCodesPerRev", "(", "encoderCodesPerRev", ")", ";", "backleft", ".", "configEncoderCodesPerRev", "(", "encoderCodesPerRev", ")", ";", "backright", ".", "configEncoderCodesPerRev", "(", "encoderCodesPerRev", ")", ";", "frontleft", ".", "setPID", "(", "P", ",", "I", ",", "D", ")", ";", "frontright", ".", "setPID", "(", "P", ",", "I", ",", "D", ")", ";", "backleft", ".", "setPID", "(", "P", ",", "I", ",", "D", ")", ";", "backright", ".", "setPID", "(", "P", ",", "I", ",", "D", ")", ";", "frontleft", ".", "enableControl", "(", ")", ";", "frontright", ".", "enableControl", "(", ")", ";", "backleft", ".", "enableControl", "(", ")", ";", "backright", ".", "enableControl", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "public", "void", "setPID", "(", "double", "P", ",", "double", "I", ",", "double", "D", ")", "{", "try", "{", "frontleft", ".", "setPID", "(", "P", ",", "I", ",", "D", ")", ";", "frontright", ".", "setPID", "(", "P", ",", "I", ",", "D", ")", ";", "backleft", ".", "setPID", "(", "P", ",", "I", ",", "D", ")", ";", "backright", ".", "setPID", "(", "P", ",", "I", ",", "D", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "public", "void", "setPID", "(", ")", "{", "setPID", "(", "DriverStation", ".", "getInstance", "(", ")", ".", "getAnalogIn", "(", "1", ")", ",", "DriverStation", ".", "getInstance", "(", ")", ".", "getAnalogIn", "(", "2", ")", ",", "DriverStation", ".", "getInstance", "(", ")", ".", "getAnalogIn", "(", "3", ")", ")", ";", "}", "public", "void", "pidWrite", "(", "double", "gyroPIDoutput", ")", "{", "try", "{", "frontleft", ".", "setX", "(", "-", "deadZone", "(", "400", "*", "joystick_ch1", ".", "getRawAxis", "(", "2", ")", ",", "40", ")", "+", "deadZone", "(", "400", "*", "gyroPIDoutput", ",", "40", ")", ")", ";", "frontright", ".", "setX", "(", "-", "deadZone", "(", "400", "*", "joystick_ch1", ".", "getRawAxis", "(", "2", ")", ",", "40", ")", "+", "deadZone", "(", "400", "*", "gyroPIDoutput", ",", "40", ")", ")", ";", "backleft", ".", "setX", "(", "-", "deadZone", "(", "400", "*", "joystick_ch1", ".", "getRawAxis", "(", "2", ")", ",", "40", ")", "+", "deadZone", "(", "400", "*", "gyroPIDoutput", ",", "40", ")", ")", ";", "backright", ".", "setX", "(", "-", "deadZone", "(", "400", "*", "joystick_ch1", ".", "getRawAxis", "(", "2", ")", ",", "40", ")", "+", "deadZone", "(", "400", "*", "gyroPIDoutput", ",", "40", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "private", "double", "deadZone", "(", "double", "input", ",", "double", "deadzone", ")", "{", "if", "(", "Math", ".", "abs", "(", "input", ")", "<", "deadzone", ")", "{", "return", "0", ";", "}", "else", "{", "return", "input", ";", "}", "}", "}", "</s>" ]
7,509
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "defaultCode", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "AnalogChannel", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "AnalogModule", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "CANJaguar", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Dashboard", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DigitalInput", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DigitalOutput", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DigitalModule", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DriverStation", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "IterativeRobot", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Joystick", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "RobotDrive", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Solenoid", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Timer", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Watchdog", ";", "public", "class", "DefaultRobotA1", "extends", "IterativeRobot", "{", "RobotDrive", "m_robotDrive", ";", "DriverStation", "ds", ";", "CANJaguar", "frontLeftJag", ";", "CANJaguar", "frontRightJag", ";", "CANJaguar", "rearLeftJag", ";", "CANJaguar", "rearRightJag", ";", "CANJaguar", "boomRightJag", ";", "CANJaguar", "boomLeftJag", ";", "CANJaguar", "stickRightJag", ";", "CANJaguar", "stickLeftJag", ";", "int", "currentPreset", "=", "-", "1", ";", "int", "presetStage", "=", "0", ";", "DigitalOutput", "deployServo", ";", "DigitalInput", "leftLineSensor", ";", "DigitalInput", "middleLineSensor", ";", "DigitalInput", "rightLineSensor", ";", "int", "[", "]", "lastThreeLines", "=", "new", "int", "[", "3", "]", ";", "int", "lineLoops", "=", "0", ";", "boolean", "hitY", "=", "false", ";", "boolean", "hasStopped", "=", "false", ";", "int", "ignoreLines", "=", "0", ";", "int", "m_dsPacketsReceivedInCurrentSecond", ";", "Joystick", "m_rightStick", ";", "static", "final", "int", "NUM_BUTTONS", "=", "10", ";", "boolean", "[", "]", "m_buttons", "=", "new", "boolean", "[", "NUM_BUTTONS", "]", ";", "static", "final", "int", "NUM_SOLENOIDS", "=", "2", ";", "Solenoid", "[", "]", "m_solenoids", "=", "new", "Solenoid", "[", "NUM_SOLENOIDS", "]", ";", "static", "final", "int", "UNINITIALIZED_DRIVE", "=", "0", ";", "static", "final", "int", "ARCADE_DRIVE", "=", "1", ";", "static", "final", "int", "TANK_DRIVE", "=", "2", ";", "int", "m_driveMode", ";", "boolean", "slow_drive", "=", "false", ";", "int", "m_autoPeriodicLoops", ";", "int", "m_disabledPeriodicLoops", ";", "int", "m_telePeriodicLoops", ";", "public", "DefaultRobotA1", "(", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "ds", "=", "DriverStation", ".", "getInstance", "(", ")", ";", "try", "{", "frontLeftJag", "=", "new", "CANJaguar", "(", "4", ")", ";", "frontRightJag", "=", "new", "CANJaguar", "(", "5", ")", ";", "rearLeftJag", "=", "new", "CANJaguar", "(", "3", ")", ";", "rearRightJag", "=", "new", "CANJaguar", "(", "2", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "m_robotDrive", "=", "new", "RobotDrive", "(", "frontLeftJag", ",", "rearLeftJag", ",", "frontRightJag", ",", "rearRightJag", ")", ";", "m_robotDrive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kFrontLeft", ",", "true", ")", ";", "m_robotDrive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kRearLeft", ",", "true", ")", ";", "m_robotDrive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kFrontRight", ",", "true", ")", ";", "m_robotDrive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kRearRight", ",", "true", ")", ";", "deployServo", "=", "new", "DigitalOutput", "(", "1", ")", ";", "leftLineSensor", "=", "new", "DigitalInput", "(", "14", ")", ";", "middleLineSensor", "=", "new", "DigitalInput", "(", "13", ")", ";", "rightLineSensor", "=", "new", "DigitalInput", "(", "12", ")", ";", "m_dsPacketsReceivedInCurrentSecond", "=", "0", ";", "m_rightStick", "=", "new", "Joystick", "(", "1", ")", ";", "int", "solenoidNum", "=", "1", ";", "for", "(", "solenoidNum", "=", "0", ";", "solenoidNum", "<", "NUM_SOLENOIDS", ";", "solenoidNum", "++", ")", "{", "m_solenoids", "[", "solenoidNum", "]", "=", "new", "Solenoid", "(", "solenoidNum", "+", "1", ")", ";", "}", "m_driveMode", "=", "ARCADE_DRIVE", ";", "m_autoPeriodicLoops", "=", "0", ";", "m_disabledPeriodicLoops", "=", "0", ";", "m_telePeriodicLoops", "=", "0", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "public", "void", "robotInit", "(", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "public", "void", "disabledInit", "(", ")", "{", "m_disabledPeriodicLoops", "=", "0", ";", "startSec", "=", "(", "int", ")", "(", "Timer", ".", "getUsClock", "(", ")", "/", "1000000.0", ")", ";", "printSec", "=", "startSec", "+", "1", ";", "}", "public", "void", "autonomousInit", "(", ")", "{", "m_autoPeriodicLoops", "=", "0", ";", "}", "public", "void", "teleopInit", "(", ")", "{", "m_telePeriodicLoops", "=", "0", ";", "m_dsPacketsReceivedInCurrentSecond", "=", "0", ";", "m_driveMode", "=", "TANK_DRIVE", ";", "}", "static", "int", "printSec", ";", "static", "int", "startSec", ";", "public", "void", "disabledPeriodic", "(", ")", "{", "updateDashboard", "(", ")", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "=", "0", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "+=", "(", "leftLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "100", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "+=", "(", "middleLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "10", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "+=", "(", "rightLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "1", ";", "lineLoops", "++", ";", "Watchdog", ".", "getInstance", "(", ")", ".", "feed", "(", ")", ";", "m_disabledPeriodicLoops", "++", ";", "lineLoops", "=", "0", ";", "hitY", "=", "false", ";", "hasStopped", "=", "false", ";", "ignoreLines", "=", "0", ";", "}", "public", "void", "autonomousPeriodic", "(", ")", "{", "updateDashboard", "(", ")", ";", "Watchdog", ".", "getInstance", "(", ")", ".", "feed", "(", ")", ";", "m_autoPeriodicLoops", "++", ";", "if", "(", "!", "hasStopped", ")", "{", "boolean", "straightLine", "=", "ds", ".", "getDigitalIn", "(", "1", ")", ";", "boolean", "goLeft", "=", "ds", ".", "getDigitalIn", "(", "2", ")", "&&", "!", "straightLine", ";", "int", "lineReading", "=", "0", ";", "lineReading", "+=", "(", "leftLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "100", ";", "lineReading", "+=", "(", "middleLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "10", ";", "lineReading", "+=", "(", "rightLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "1", ";", "System", ".", "out", ".", "print", "(", "\"\"", "+", "m_autoPeriodicLoops", "+", "\"", "|", "\"", "+", "lineReading", "+", "\"", "|", "\"", ")", ";", "double", "rightMotors", "=", "0", ";", "double", "leftMotors", "=", "0", ";", "switch", "(", "lineReading", ")", "{", "case", "0", ":", "if", "(", "!", "straightLine", "&&", "!", "hitY", ")", "{", "if", "(", "!", "hitY", ")", "{", "if", "(", "goLeft", ")", "{", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "-", "0.7", ";", "lineReading", "=", "100", ";", "}", "else", "{", "leftMotors", "=", "-", "0.7", ";", "rightMotors", "=", "0.7", ";", "lineReading", "=", "1", ";", "}", "}", "}", "else", "{", "rightMotors", "=", "1.2", "*", "(", "lastThreeLines", "[", "0", "]", "%", "10", "+", "lastThreeLines", "[", "1", "]", "%", "10", "+", "lastThreeLines", "[", "2", "]", "%", "10", ")", "/", "3.0", ";", "leftMotors", "=", "1.2", "*", "(", "(", "lastThreeLines", "[", "0", "]", "/", "100", ")", "%", "10", "+", "(", "lastThreeLines", "[", "1", "]", "/", "100", ")", "%", "10", "+", "(", "lastThreeLines", "[", "2", "]", "/", "100", ")", "%", "10", ")", "/", "3.0", ";", "}", "break", ";", "case", "1", ":", "leftMotors", "=", "0.55", ";", "rightMotors", "=", "0.7", ";", "break", ";", "case", "11", ":", "leftMotors", "=", "0.6", ";", "rightMotors", "=", "0.7", ";", "break", ";", "case", "10", ":", "leftMotors", "=", "0.8", ";", "rightMotors", "=", "0.8", ";", "break", ";", "case", "110", ":", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "0.6", ";", "break", ";", "case", "100", ":", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "0.55", ";", "break", ";", "case", "111", ":", "if", "(", "straightLine", "||", "hitY", ")", "{", "hasStopped", "=", "true", ";", "System", ".", "out", ".", "print", "(", "\"STOPPED!", "|", "\"", ")", ";", "}", "else", "{", "if", "(", "goLeft", ")", "{", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "-", "0.7", ";", "lineReading", "=", "100", ";", "}", "else", "{", "leftMotors", "=", "-", "0.7", ";", "rightMotors", "=", "0.7", ";", "lineReading", "=", "1", ";", "}", "hitY", "=", "true", ";", "System", ".", "out", ".", "print", "(", "\"HIT!", "|", "\"", ")", ";", "}", "break", ";", "case", "101", ":", "if", "(", "!", "straightLine", ")", "{", "if", "(", "goLeft", ")", "{", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "-", "0.7", ";", "lineReading", "=", "100", ";", "}", "else", "{", "leftMotors", "=", "-", "0.7", ";", "rightMotors", "=", "0.7", ";", "lineReading", "=", "1", ";", "}", "hitY", "=", "true", ";", "System", ".", "out", ".", "print", "(", "\"HIT!", "|", "\"", ")", ";", "}", "break", ";", "default", ":", "break", ";", "}", "m_robotDrive", ".", "tankDrive", "(", "-", "leftMotors", ",", "-", "rightMotors", ")", ";", "System", ".", "out", ".", "println", "(", "\"Left:", "\"", "+", "leftMotors", "+", "\",", "Right:", "\"", "+", "rightMotors", ")", ";", "if", "(", "lineReading", ">", "0", ")", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "=", "lineReading", ";", "lineLoops", "++", ";", "}", "else", "if", "(", "ignoreLines", ">", "40", ")", "{", "int", "lineReading", "=", "0", ";", "lineReading", "+=", "(", "leftLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "100", ";", "lineReading", "+=", "(", "middleLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "10", ";", "lineReading", "+=", "(", "rightLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "1", ";", "System", ".", "out", ".", "print", "(", "\"\"", "+", "lineReading", "+", "\"", "|", "\"", ")", ";", "double", "rightMotors", "=", "0", ";", "double", "leftMotors", "=", "0", ";", "switch", "(", "lineReading", ")", "{", "case", "0", ":", "leftMotors", "=", "1", "*", "(", "lastThreeLines", "[", "0", "]", "%", "10", "+", "lastThreeLines", "[", "1", "]", "%", "10", "+", "lastThreeLines", "[", "2", "]", "%", "10", ")", "/", "3.0", ";", "rightMotors", "=", "1", "*", "(", "(", "lastThreeLines", "[", "0", "]", "/", "100", ")", "%", "10", "+", "(", "lastThreeLines", "[", "1", "]", "/", "100", ")", "%", "10", "+", "(", "lastThreeLines", "[", "2", "]", "/", "100", ")", "%", "10", ")", "/", "3.0", ";", "break", ";", "case", "1", ":", "leftMotors", "=", "0.4", ";", "rightMotors", "=", "0.8", ";", "break", ";", "case", "10", ":", "leftMotors", "=", "0.9", ";", "rightMotors", "=", "0.9", ";", "break", ";", "case", "11", ":", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "0.9", ";", "break", ";", "case", "100", ":", "leftMotors", "=", "0.8", ";", "rightMotors", "=", "0.4", ";", "break", ";", "case", "110", ":", "leftMotors", "=", "0.9", ";", "rightMotors", "=", "0.7", ";", "break", ";", "case", "111", ":", "leftMotors", "=", "0.8", ";", "rightMotors", "=", "0.8", ";", "break", ";", "case", "101", ":", "leftMotors", "=", "0.8", ";", "rightMotors", "=", "0.8", ";", "break", ";", "default", ":", "break", ";", "}", "m_robotDrive", ".", "tankDrive", "(", "-", "leftMotors", ",", "-", "rightMotors", ")", ";", "System", ".", "out", ".", "println", "(", "\"Left:", "\"", "+", "leftMotors", "+", "\",", "Right:", "\"", "+", "rightMotors", ")", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "=", "lineReading", ";", "lineLoops", "++", ";", "}", "else", "{", "ignoreLines", "++", ";", "m_robotDrive", ".", "tankDrive", "(", "0.8", ",", "-", "0.8", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "}", "public", "void", "teleopPeriodic", "(", ")", "{", "lineLoops", "=", "0", ";", "hitY", "=", "false", ";", "hasStopped", "=", "false", ";", "ignoreLines", "=", "0", ";", "updateDashboard", "(", ")", ";", "Watchdog", ".", "getInstance", "(", ")", ".", "feed", "(", ")", ";", "m_telePeriodicLoops", "++", ";", "m_dsPacketsReceivedInCurrentSecond", "++", ";", "for", "(", "int", "buttonDex", "=", "0", ";", "buttonDex", "<", "NUM_BUTTONS", ";", "buttonDex", "++", ")", "{", "m_buttons", "[", "buttonDex", "]", "=", "m_rightStick", ".", "getRawButton", "(", "buttonDex", ")", ";", "}", "m_robotDrive", ".", "arcadeDrive", "(", "(", "(", "m_buttons", "[", "7", "]", ")", "?", "-", "1", ":", "1", ")", "*", "m_rightStick", ".", "getRawAxis", "(", "2", ")", ",", "m_rightStick", ".", "getRawAxis", "(", "4", ")", "/", "3", "*", "2", ",", "false", ")", ";", "if", "(", "currentPreset", "==", "-", "1", ")", "{", "int", "presetButton", "=", "0", ";", "for", "(", "presetButton", "=", "0", ";", "presetButton", "<", "NUM_BUTTONS", ";", "presetButton", "++", ")", "{", "if", "(", "m_buttons", "[", "presetButton", "]", ")", "break", ";", "}", "currentPreset", "=", "presetButton", ";", "}", "else", "{", "}", "}", "int", "GetLoopsPerSec", "(", ")", "{", "return", "20", ";", "}", "void", "updateDashboard", "(", ")", "{", "Dashboard", "lowDashData", "=", "ds", ".", "getDashboardPackerLow", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "8", ";", "i", "++", ")", "{", "lowDashData", ".", "addFloat", "(", "(", "float", ")", "AnalogModule", ".", "getInstance", "(", "1", ")", ".", "getAverageVoltage", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "8", ";", "i", "++", ")", "{", "lowDashData", ".", "addFloat", "(", "(", "float", ")", "AnalogModule", ".", "getInstance", "(", "2", ")", ".", "getAverageVoltage", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "int", "module", "=", "4", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getAllDIO", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getDIODirection", "(", ")", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "10", ";", "i", "++", ")", "{", "lowDashData", ".", "addByte", "(", "(", "byte", ")", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getPWM", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "int", "module", "=", "6", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getAllDIO", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getDIODirection", "(", ")", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "10", ";", "i", "++", ")", "{", "lowDashData", ".", "addByte", "(", "(", "byte", ")", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getPWM", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addByte", "(", "m_solenoids", "[", "0", "]", ".", "getAll", "(", ")", ")", ";", "lowDashData", ".", "commit", "(", ")", ";", "}", "}", "</s>" ]
7,510
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "defaultCode", ";", "import", "com", ".", "sun", ".", "squawk", ".", "util", ".", "MathUtils", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "AnalogModule", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "CANJaguar", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Compressor", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Dashboard", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DigitalInput", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DigitalModule", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DriverStation", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "IterativeRobot", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Joystick", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "RobotDrive", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Servo", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Solenoid", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Timer", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Watchdog", ";", "public", "class", "DefaultRobot", "extends", "IterativeRobot", "{", "DriverStation", "ds", ";", "boolean", "[", "]", "dsButtons", "=", "new", "boolean", "[", "14", "]", ";", "RobotDrive", "m_robotDrive", ";", "CANJaguar", "frontLeftJag", ";", "CANJaguar", "frontRightJag", ";", "CANJaguar", "rearLeftJag", ";", "CANJaguar", "rearRightJag", ";", "boolean", "arcadeDrive", "=", "true", ";", "boolean", "override", "=", "true", ";", "int", "lastArcadeButton", "=", "0", ";", "int", "lastOverButton", "=", "0", ";", "int", "lastGripperButton", "=", "0", ";", "CANJaguar", "boomRightJag", ";", "CANJaguar", "boomLeftJag", ";", "CANJaguar", "stickRightJag", ";", "CANJaguar", "stickLeftJag", ";", "CANJaguar", "wristJag", ";", "Compressor", "compressor", ";", "int", "lastStartingButton", "=", "0", ";", "Servo", "topLeftRoller", ";", "Servo", "topRightRoller", ";", "Servo", "bottomLeftRoller", ";", "Servo", "bottomRightRoller", ";", "DigitalInput", "gripperButton", ";", "Solenoid", "gripperSolenoid", ";", "double", "rollerValue", "=", "0", ";", "double", "boomAngle", "=", "0.5", ";", "double", "stickAngle", "=", "0.5", ";", "double", "wristAngle", "=", "0.5", ";", "double", "lastTargetHeight", "=", "20", ";", "double", "lastTargetLength", "=", "20", ";", "double", "lastTargetWrist", "=", "0", ";", "double", "currentHeight", "=", "20", ";", "double", "currentLength", "=", "20", ";", "double", "targetLength", "=", "20", ";", "double", "targetHeight", "=", "20", ";", "double", "targetWrist", "=", "0", ";", "double", "heightIncrement", "=", "0", ";", "double", "lengthIncrement", "=", "0", ";", "double", "wristIncrement", "=", "0", ";", "int", "middlePeg", "=", "0", ";", "int", "numIncrements", "=", "1", ";", "int", "currentPreset", "=", "10", ";", "int", "presetStage", "=", "0", ";", "boolean", "boomHitTarget", "=", "false", ";", "boolean", "stickHitTarget", "=", "false", ";", "boolean", "wristHitTarget", "=", "false", ";", "int", "boomStillBuffer", "=", "0", ";", "int", "stickStillBuffer", "=", "0", ";", "int", "wristStillBuffer", "=", "0", ";", "boolean", "presetButton", "=", "false", ";", "double", "lastWristPot", "=", "1.61", ";", "int", "dT", "=", "1", ";", "double", "integral", "=", "0", ";", "double", "lastError", "=", "0", ";", "Servo", "deployServo", ";", "boolean", "deploy", "=", "false", ";", "DigitalInput", "leftLineSensor", ";", "DigitalInput", "middleLineSensor", ";", "DigitalInput", "rightLineSensor", ";", "int", "[", "]", "lastThreeLines", "=", "new", "int", "[", "3", "]", ";", "int", "lineLoops", "=", "0", ";", "boolean", "hitY", "=", "false", ";", "boolean", "hasStopped", "=", "false", ";", "int", "ignoreLines", "=", "0", ";", "boolean", "doAutoArmStuff", "=", "false", ";", "int", "yLoops", "=", "0", ";", "int", "dropLoops", "=", "0", ";", "boolean", "droppedTube", "=", "false", ";", "int", "backwardsLoops", "=", "0", ";", "int", "m_dsPacketsReceivedInCurrentSecond", ";", "Joystick", "m_joystick", ";", "static", "final", "int", "NUM_BUTTONS", "=", "10", ";", "int", "[", "]", "m_buttons", "=", "new", "int", "[", "NUM_BUTTONS", "]", ";", "int", "m_autoPeriodicLoops", ";", "int", "m_disabledPeriodicLoops", ";", "int", "m_telePeriodicLoops", ";", "public", "DefaultRobot", "(", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "ds", "=", "DriverStation", ".", "getInstance", "(", ")", ";", "try", "{", "frontLeftJag", "=", "new", "CANJaguar", "(", "4", ")", ";", "frontRightJag", "=", "new", "CANJaguar", "(", "5", ")", ";", "rearLeftJag", "=", "new", "CANJaguar", "(", "3", ")", ";", "rearRightJag", "=", "new", "CANJaguar", "(", "2", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "m_robotDrive", "=", "new", "RobotDrive", "(", "frontLeftJag", ",", "rearLeftJag", ",", "frontRightJag", ",", "rearRightJag", ")", ";", "m_robotDrive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kFrontLeft", ",", "true", ")", ";", "m_robotDrive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kRearLeft", ",", "true", ")", ";", "m_robotDrive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kFrontRight", ",", "true", ")", ";", "m_robotDrive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kRearRight", ",", "true", ")", ";", "try", "{", "boomRightJag", "=", "new", "CANJaguar", "(", "6", ",", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "boomLeftJag", "=", "new", "CANJaguar", "(", "9", ",", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "stickRightJag", "=", "new", "CANJaguar", "(", "7", ",", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "stickLeftJag", "=", "new", "CANJaguar", "(", "8", ",", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "wristJag", "=", "new", "CANJaguar", "(", "10", ",", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "for", "(", "int", "setThatMode", "=", "0", ";", "setThatMode", "<", "5", ";", "setThatMode", "++", ")", "{", "boomRightJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "boomLeftJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "stickRightJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "stickLeftJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "wristJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "Thread", ".", "sleep", "(", "100", ")", ";", "if", "(", "boomRightJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPosition", "&&", "boomLeftJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPosition", "&&", "stickLeftJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPosition", "&&", "stickRightJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPosition", "&&", "wristJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "break", ";", "}", "boomRightJag", ".", "setPositionReference", "(", "CANJaguar", ".", "PositionReference", ".", "kPotentiometer", ")", ";", "boomLeftJag", ".", "setPositionReference", "(", "CANJaguar", ".", "PositionReference", ".", "kPotentiometer", ")", ";", "stickRightJag", ".", "setPositionReference", "(", "CANJaguar", ".", "PositionReference", ".", "kPotentiometer", ")", ";", "stickLeftJag", ".", "setPositionReference", "(", "CANJaguar", ".", "PositionReference", ".", "kPotentiometer", ")", ";", "wristJag", ".", "setPositionReference", "(", "CANJaguar", ".", "PositionReference", ".", "kPotentiometer", ")", ";", "for", "(", "int", "setThatMode", "=", "0", ";", "setThatMode", "<", "5", ";", "setThatMode", "++", ")", "{", "boomRightJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", ")", ";", "boomLeftJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", ")", ";", "stickRightJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", ")", ";", "stickLeftJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", ")", ";", "wristJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", ")", ";", "Thread", ".", "sleep", "(", "100", ")", ";", "if", "(", "boomRightJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", "&&", "boomLeftJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", "&&", "stickLeftJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", "&&", "stickRightJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", "&&", "wristJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", ")", "break", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "gripperSolenoid", "=", "new", "Solenoid", "(", "1", ")", ";", "compressor", "=", "new", "Compressor", "(", "1", ",", "1", ")", ";", "compressor", ".", "start", "(", ")", ";", "topLeftRoller", "=", "new", "Servo", "(", "2", ")", ";", "topRightRoller", "=", "new", "Servo", "(", "3", ")", ";", "bottomLeftRoller", "=", "new", "Servo", "(", "4", ")", ";", "bottomRightRoller", "=", "new", "Servo", "(", "5", ")", ";", "gripperButton", "=", "new", "DigitalInput", "(", "2", ")", ";", "deployServo", "=", "new", "Servo", "(", "1", ")", ";", "leftLineSensor", "=", "new", "DigitalInput", "(", "14", ")", ";", "middleLineSensor", "=", "new", "DigitalInput", "(", "13", ")", ";", "rightLineSensor", "=", "new", "DigitalInput", "(", "12", ")", ";", "m_dsPacketsReceivedInCurrentSecond", "=", "0", ";", "m_joystick", "=", "new", "Joystick", "(", "1", ")", ";", "for", "(", "int", "buttonDex", "=", "0", ";", "buttonDex", "<", "NUM_BUTTONS", ";", "buttonDex", "++", ")", "{", "m_buttons", "[", "buttonDex", "]", "=", "(", "int", ")", "(", "m_joystick", ".", "getRawButton", "(", "buttonDex", "+", "1", ")", "?", "1", ":", "0", ")", ";", "}", "m_autoPeriodicLoops", "=", "0", ";", "m_disabledPeriodicLoops", "=", "0", ";", "m_telePeriodicLoops", "=", "0", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "public", "void", "robotInit", "(", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "public", "void", "disabledInit", "(", ")", "{", "m_disabledPeriodicLoops", "=", "0", ";", "startSec", "=", "(", "int", ")", "(", "Timer", ".", "getUsClock", "(", ")", "/", "1000000.0", ")", ";", "printSec", "=", "startSec", "+", "1", ";", "deploy", "=", "false", ";", "}", "public", "void", "autonomousInit", "(", ")", "{", "m_autoPeriodicLoops", "=", "0", ";", "try", "{", "double", "bLJP", "=", "boomLeftJag", ".", "getPosition", "(", ")", ";", "double", "sLJP", "=", "stickRightJag", ".", "getPosition", "(", ")", ";", "double", "wJP", "=", "wristJag", ".", "getPosition", "(", ")", ";", "boomAngle", "=", "(", "180", "-", "(", "bLJP", "*", "270", "-", "45", ")", ")", ";", "stickAngle", "=", "(", "180", "-", "(", "sLJP", "*", "270", "-", "45", ")", ")", ";", "wristAngle", "=", "(", "180", "-", "(", "wJP", "*", "270", "-", "45", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "double", "[", "]", "armCoords", "=", "getWristCoordinates", "(", "boomAngle", ",", "stickAngle", ")", ";", "currentHeight", "=", "armCoords", "[", "1", "]", ";", "currentLength", "=", "armCoords", "[", "0", "]", ";", "lineLoops", "=", "0", ";", "dropLoops", "=", "0", ";", "yLoops", "=", "0", ";", "hitY", "=", "false", ";", "hasStopped", "=", "false", ";", "droppedTube", "=", "false", ";", "backwardsLoops", "=", "0", ";", "ignoreLines", "=", "0", ";", "currentPreset", "=", "10", ";", "targetHeight", "=", "20", ";", "targetLength", "=", "18", ";", "lastTargetHeight", "=", "Math", ".", "max", "(", "currentHeight", ",", "20.0", ")", ";", "lastTargetLength", "=", "currentLength", ";", "lastTargetWrist", "=", "wristAngle", ";", "targetWrist", "=", "0", ";", "middlePeg", "=", "1", ";", "int", "yIncrements", "=", "(", "int", ")", "Math", ".", "abs", "(", "Math", ".", "floor", "(", "(", "targetHeight", "-", "lastTargetHeight", ")", "/", "3.0", ")", ")", "+", "1", ";", "int", "xIncrements", "=", "(", "int", ")", "Math", ".", "abs", "(", "Math", ".", "floor", "(", "(", "targetLength", "-", "lastTargetLength", ")", "/", "1.0", ")", ")", "+", "1", ";", "numIncrements", "=", "Math", ".", "max", "(", "xIncrements", ",", "yIncrements", ")", ";", "heightIncrement", "=", "(", "targetHeight", "-", "lastTargetHeight", ")", "/", "(", "double", ")", "numIncrements", ";", "lengthIncrement", "=", "(", "targetLength", "-", "lastTargetLength", ")", "/", "(", "double", ")", "numIncrements", ";", "wristIncrement", "=", "(", "targetWrist", "-", "lastTargetWrist", ")", "/", "(", "double", ")", "numIncrements", ";", "}", "public", "void", "teleopInit", "(", ")", "{", "m_telePeriodicLoops", "=", "0", ";", "m_dsPacketsReceivedInCurrentSecond", "=", "0", ";", "}", "static", "int", "printSec", ";", "static", "int", "startSec", ";", "public", "void", "disabledPeriodic", "(", ")", "{", "updateDashboard", "(", ")", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "=", "0", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "+=", "(", "leftLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "100", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "+=", "(", "middleLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "10", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "+=", "(", "rightLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "1", ";", "lineLoops", "++", ";", "Watchdog", ".", "getInstance", "(", ")", ".", "feed", "(", ")", ";", "m_disabledPeriodicLoops", "++", ";", "lineLoops", "=", "0", ";", "dropLoops", "=", "0", ";", "yLoops", "=", "0", ";", "hitY", "=", "false", ";", "hasStopped", "=", "false", ";", "droppedTube", "=", "false", ";", "backwardsLoops", "=", "0", ";", "ignoreLines", "=", "0", ";", "deploy", "=", "false", ";", "try", "{", "float", "bLJP", "=", "(", "float", ")", "boomLeftJag", ".", "getPosition", "(", ")", ";", "float", "sLJP", "=", "(", "float", ")", "stickRightJag", ".", "getPosition", "(", ")", ";", "float", "wJP", "=", "(", "float", ")", "wristJag", ".", "getPosition", "(", ")", ";", "boomAngle", "=", "(", "180", "-", "(", "bLJP", "*", "270", "-", "45", ")", ")", ";", "stickAngle", "=", "(", "180", "-", "(", "sLJP", "*", "270", "-", "45", ")", ")", ";", "wristAngle", "=", "(", "180", "-", "(", "wJP", "*", "270", "-", "45", ")", ")", ";", "double", "[", "]", "armCoords", "=", "getWristCoordinates", "(", "boomAngle", ",", "stickAngle", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "double", "bPot", "=", "0", ";", "double", "sPot", "=", "0", ";", "double", "wPot", "=", "0", ";", "try", "{", "bPot", "=", "ds", ".", "getEnhancedIO", "(", ")", ".", "getAnalogIn", "(", "2", ")", ";", "sPot", "=", "ds", ".", "getEnhancedIO", "(", ")", ".", "getAnalogIn", "(", "4", ")", ";", "wPot", "=", "ds", ".", "getEnhancedIO", "(", ")", ".", "getAnalogIn", "(", "6", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "public", "void", "autonomousPeriodic", "(", ")", "{", "updateDashboard", "(", ")", ";", "Watchdog", ".", "getInstance", "(", ")", ".", "feed", "(", ")", ";", "m_autoPeriodicLoops", "++", ";", "deployServo", ".", "setAngle", "(", "140", ")", ";", "boolean", "straightLine", "=", "true", ";", "boolean", "goLeft", "=", "false", ";", "boolean", "doAuto", "=", "false", ";", "try", "{", "double", "sPot", "=", "ds", ".", "getEnhancedIO", "(", ")", ".", "getAnalogIn", "(", "4", ")", ";", "double", "wPot", "=", "ds", ".", "getEnhancedIO", "(", ")", ".", "getAnalogIn", "(", "6", ")", ";", "if", "(", "wPot", ">", "0.5", "*", "3.3", ")", "doAuto", "=", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "if", "(", "doAuto", ")", "{", "if", "(", "!", "(", "hasStopped", "||", "hitY", ")", ")", "{", "int", "lineReading", "=", "0", ";", "lineReading", "+=", "(", "leftLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "100", ";", "lineReading", "+=", "(", "middleLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "10", ";", "lineReading", "+=", "(", "rightLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "1", ";", "double", "rightMotors", "=", "0", ";", "double", "leftMotors", "=", "0", ";", "switch", "(", "lineReading", ")", "{", "case", "0", ":", "rightMotors", "=", "0.7", "*", "(", "lastThreeLines", "[", "0", "]", "%", "10", "+", "lastThreeLines", "[", "1", "]", "%", "10", "+", "lastThreeLines", "[", "2", "]", "%", "10", ")", "/", "3.0", ";", "leftMotors", "=", "0.7", "*", "(", "Math", ".", "floor", "(", "lastThreeLines", "[", "0", "]", "/", "100", ")", "%", "10", "+", "Math", ".", "floor", "(", "lastThreeLines", "[", "1", "]", "/", "100", ")", "%", "10", "+", "Math", ".", "floor", "(", "lastThreeLines", "[", "2", "]", "/", "100", ")", "%", "10", ")", "/", "3.0", ";", "break", ";", "case", "1", ":", "leftMotors", "=", "0.55", ";", "rightMotors", "=", "0.7", ";", "break", ";", "case", "11", ":", "leftMotors", "=", "0.6", ";", "rightMotors", "=", "0.7", ";", "break", ";", "case", "10", ":", "leftMotors", "=", "0.8", ";", "rightMotors", "=", "0.8", ";", "break", ";", "case", "110", ":", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "0.6", ";", "break", ";", "case", "100", ":", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "0.55", ";", "break", ";", "case", "111", ":", "if", "(", "straightLine", ")", "{", "hasStopped", "=", "true", ";", "System", ".", "out", ".", "print", "(", "\"STOPPED!", "|", "\"", ")", ";", "dropLoops", "=", "m_autoPeriodicLoops", ";", "}", "else", "{", "if", "(", "!", "goLeft", ")", "{", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "-", "0.7", ";", "lineReading", "=", "100", ";", "}", "else", "{", "leftMotors", "=", "-", "0.7", ";", "rightMotors", "=", "0.7", ";", "lineReading", "=", "1", ";", "}", "hitY", "=", "true", ";", "System", ".", "out", ".", "print", "(", "\"HIT!", "|", "\"", ")", ";", "yLoops", "=", "m_autoPeriodicLoops", ";", "}", "break", ";", "case", "101", ":", "if", "(", "!", "straightLine", ")", "{", "if", "(", "!", "goLeft", ")", "{", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "-", "0.7", ";", "lineReading", "=", "100", ";", "}", "else", "{", "leftMotors", "=", "-", "0.7", ";", "rightMotors", "=", "0.7", ";", "lineReading", "=", "1", ";", "}", "hitY", "=", "true", ";", "System", ".", "out", ".", "print", "(", "\"HIT!", "|", "\"", ")", ";", "yLoops", "=", "m_autoPeriodicLoops", ";", "}", "break", ";", "default", ":", "break", ";", "}", "m_robotDrive", ".", "tankDrive", "(", "-", "leftMotors", "*", "0.87", ",", "-", "rightMotors", "*", "0.87", ")", ";", "if", "(", "lineReading", ">", "0", ")", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "=", "lineReading", ";", "lineLoops", "++", ";", "}", "else", "if", "(", "currentPreset", "==", "-", "1", "&&", "m_autoPeriodicLoops", "<", "dropLoops", "+", "10", ")", "{", "}", "else", "if", "(", "!", "droppedTube", ")", "{", "presetStage", "=", "0", ";", "lastTargetHeight", "=", "Math", ".", "max", "(", "currentHeight", ",", "20.0", ")", ";", "lastTargetLength", "=", "currentLength", ";", "lastTargetWrist", "=", "wristAngle", ";", "targetWrist", "=", "65", ";", "middlePeg", "=", "0", ";", "targetHeight", "=", "currentHeight", "-", "6", ";", "targetLength", "=", "currentLength", "-", "6", ";", "gripperSolenoid", ".", "set", "(", "true", ")", ";", "droppedTube", "=", "true", ";", "currentPreset", "=", "0", ";", "int", "yIncrements", "=", "(", "int", ")", "Math", ".", "abs", "(", "Math", ".", "floor", "(", "(", "targetHeight", "-", "lastTargetHeight", ")", "/", "3.0", ")", ")", "+", "1", ";", "int", "xIncrements", "=", "(", "int", ")", "Math", ".", "abs", "(", "Math", ".", "floor", "(", "(", "targetLength", "-", "lastTargetLength", ")", "/", "1.0", ")", ")", "+", "1", ";", "numIncrements", "=", "Math", ".", "max", "(", "xIncrements", ",", "yIncrements", ")", ";", "heightIncrement", "=", "(", "targetHeight", "-", "lastTargetHeight", ")", "/", "(", "double", ")", "numIncrements", ";", "lengthIncrement", "=", "(", "targetLength", "-", "lastTargetLength", ")", "/", "(", "double", ")", "numIncrements", ";", "wristIncrement", "=", "(", "targetWrist", "-", "lastTargetWrist", ")", "/", "(", "double", ")", "numIncrements", ";", "}", "else", "if", "(", "currentPreset", "==", "0", ")", "{", "System", ".", "out", ".", "println", "(", "\"DERP\"", ")", ";", "m_robotDrive", ".", "tankDrive", "(", "0.5", ",", "0.5", ")", ";", "backwardsLoops", "=", "m_autoPeriodicLoops", ";", "}", "else", "if", "(", "currentPreset", "==", "-", "1", ")", "{", "System", ".", "out", ".", "println", "(", "\"DERP\"", ")", ";", "m_robotDrive", ".", "tankDrive", "(", "0.5", ",", "0.5", ")", ";", "}", "try", "{", "double", "bLJP", "=", "boomLeftJag", ".", "getPosition", "(", ")", ";", "double", "sLJP", "=", "stickRightJag", ".", "getPosition", "(", ")", ";", "double", "wJP", "=", "wristJag", ".", "getPosition", "(", ")", ";", "boomAngle", "=", "(", "180", "-", "(", "bLJP", "*", "270", "-", "45", ")", ")", ";", "stickAngle", "=", "(", "180", "-", "(", "sLJP", "*", "270", "-", "45", ")", ")", ";", "wristAngle", "=", "(", "180", "-", "(", "wJP", "*", "270", "-", "45", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "double", "[", "]", "armCoords", "=", "getWristCoordinates", "(", "boomAngle", ",", "stickAngle", ")", ";", "currentHeight", "=", "armCoords", "[", "1", "]", ";", "currentLength", "=", "armCoords", "[", "0", "]", ";", "double", "[", "]", "targetAngles", "=", "{", "90", ",", "90", "}", ";", "double", "targetWristA", "=", "90", ";", "if", "(", "currentPreset", ">", "-", "1", ")", "{", "if", "(", "(", "presetStage", "+", "1", ")", "%", "numIncrements", "==", "0", ")", "{", "boolean", "defaultCase", "=", "false", ";", "switch", "(", "currentPreset", ")", "{", "case", "10", ":", "targetHeight", "=", "(", "92", "+", "8", "*", "middlePeg", ")", "/", "2.0", ";", "targetLength", "=", "18", ";", "currentPreset", "=", "101", ";", "targetWrist", "=", "45", ";", "break", ";", "case", "101", ":", "targetHeight", "=", "92", "+", "8", "*", "middlePeg", ";", "targetLength", "=", "17", ";", "currentPreset", "=", "102", ";", "targetWrist", "=", "110", ";", "break", ";", "case", "0", ":", "targetHeight", "=", "20", ";", "targetLength", "=", "18", ";", "targetWrist", "=", "45", ";", "currentPreset", "=", "3", ";", "break", ";", "case", "3", ":", "targetHeight", "=", "20", ";", "targetLength", "=", "18", ";", "targetWrist", "=", "0", ";", "gripperSolenoid", ".", "set", "(", "false", ")", ";", "currentPreset", "=", "31", ";", "break", ";", "default", ":", "currentPreset", "=", "-", "1", ";", "defaultCase", "=", "true", ";", "targetAngles", "=", "getArmAngles", "(", "targetLength", ",", "targetHeight", ")", ";", "targetWristA", "=", "targetWrist", ";", "break", ";", "}", "presetStage", "=", "0", ";", "if", "(", "!", "defaultCase", ")", "{", "lastTargetHeight", "=", "currentHeight", ";", "lastTargetLength", "=", "currentLength", ";", "lastTargetWrist", "=", "wristAngle", ";", "int", "yIncrements", "=", "(", "int", ")", "Math", ".", "abs", "(", "Math", ".", "floor", "(", "(", "targetHeight", "-", "lastTargetHeight", ")", "/", "3.0", ")", ")", "+", "1", ";", "int", "xIncrements", "=", "(", "int", ")", "Math", ".", "abs", "(", "Math", ".", "floor", "(", "(", "targetLength", "-", "lastTargetLength", ")", "/", "1.0", ")", ")", "+", "1", ";", "numIncrements", "=", "Math", ".", "max", "(", "xIncrements", ",", "yIncrements", ")", ";", "heightIncrement", "=", "(", "targetHeight", "-", "lastTargetHeight", ")", "/", "(", "double", ")", "numIncrements", ";", "lengthIncrement", "=", "(", "targetLength", "-", "lastTargetLength", ")", "/", "(", "double", ")", "numIncrements", ";", "wristIncrement", "=", "(", "targetWrist", "-", "lastTargetWrist", ")", "/", "(", "double", ")", "numIncrements", ";", "targetAngles", "[", "0", "]", "=", "boomAngle", ";", "targetAngles", "[", "1", "]", "=", "stickAngle", ";", "targetWristA", "=", "wristAngle", ";", "}", "}", "else", "{", "presetStage", "++", ";", "double", "tX", "=", "lastTargetLength", "+", "lengthIncrement", "*", "presetStage", ";", "double", "tY", "=", "lastTargetHeight", "+", "heightIncrement", "*", "presetStage", ";", "targetWristA", "=", "lastTargetWrist", "+", "wristIncrement", "*", "presetStage", ";", "targetAngles", "=", "getArmAngles", "(", "tX", ",", "tY", ")", ";", "if", "(", "(", "presetStage", "+", "1", ")", "%", "numIncrements", "==", "0", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "targetAngles", "[", "0", "]", "+", "\",", "\"", "+", "targetAngles", "[", "1", "]", "+", "\",", "\"", "+", "targetWristA", ")", ";", "double", "targetboom", "=", "1", "-", "(", "targetAngles", "[", "0", "]", "+", "45", ")", "/", "270.0", ";", "double", "targetstick", "=", "1", "-", "(", "targetAngles", "[", "1", "]", "+", "45", ")", "/", "270.0", ";", "double", "targetwrist", "=", "1", "-", "(", "targetWristA", "+", "45", ")", "/", "270.0", ";", "System", ".", "out", ".", "println", "(", "\"Pots:", "\"", "+", "(", "float", ")", "targetboom", "+", "\",", "\"", "+", "(", "float", ")", "targetstick", "+", "\",", "\"", "+", "(", "float", ")", "targetwrist", ")", ";", "float", "TboomAngle", "=", "(", "float", ")", "(", "180", "-", "(", "targetboom", "*", "270", "-", "45", ")", ")", ";", "float", "TstickAngle", "=", "(", "float", ")", "(", "180", "-", "(", "targetstick", "*", "270", "-", "45", ")", ")", ";", "float", "TwristAngle", "=", "(", "float", ")", "(", "180", "-", "(", "targetwrist", "*", "270", "-", "45", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "TboomAngle", "+", "\",", "\"", "+", "TstickAngle", "+", "\",", "\"", "+", "TwristAngle", "+", "\"\"", ")", ";", "}", "}", "}", "else", "{", "targetAngles", "=", "getArmAngles", "(", "targetLength", ",", "targetHeight", ")", ";", "targetWristA", "=", "targetWrist", ";", "}", "double", "boomV", "=", "0", ";", "double", "targetboom", "=", "1", "-", "(", "targetAngles", "[", "0", "]", "+", "45", ")", "/", "270.0", ";", "double", "boomDiff", "=", "0", ";", "try", "{", "if", "(", "boomLeftJag", ".", "getPosition", "(", ")", "!=", "0", ")", "boomDiff", "=", "targetboom", "-", "boomLeftJag", ".", "getPosition", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "double", "boomGain", "=", "60", ";", "if", "(", "boomDiff", ">", "0", ")", "boomGain", "=", "230", ";", "boomV", "=", "(", "-", "1", "*", "boomGain", "*", "boomDiff", ")", ";", "double", "boomMaxV", "=", "9", "*", "1", ";", "if", "(", "Math", ".", "abs", "(", "boomV", ")", ">", "boomMaxV", ")", "boomV", "=", "(", "boomV", "<", "boomMaxV", ")", "?", "-", "boomMaxV", ":", "boomMaxV", ";", "if", "(", "Math", ".", "abs", "(", "boomV", ")", ">", "1.5", ")", "{", "if", "(", "Math", ".", "abs", "(", "boomV", ")", "<", "3.25", ")", "boomV", "=", "(", "boomV", "<", "0", ")", "?", "-", "3.25", ":", "3.25", ";", "}", "else", "boomV", "=", "0", ";", "try", "{", "boomLeftJag", ".", "setX", "(", "boomV", "/", "12.0", ")", ";", "boomRightJag", ".", "setX", "(", "boomV", "/", "12.0", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "double", "stickV", "=", "0", ";", "double", "targetstick", "=", "1", "-", "(", "targetAngles", "[", "1", "]", "+", "45", ")", "/", "270.0", ";", "double", "stickDiff", "=", "0", ";", "try", "{", "if", "(", "stickRightJag", ".", "getPosition", "(", ")", "!=", "0", ")", "stickDiff", "=", "targetstick", "-", "stickRightJag", ".", "getPosition", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "stickV", "=", "1", "*", "(", "150", "*", "stickDiff", ")", ";", "if", "(", "Math", ".", "abs", "(", "stickV", ")", ">", "9", ")", "stickV", "=", "(", "stickV", "<", "0", ")", "?", "-", "9", ":", "9", ";", "if", "(", "Math", ".", "abs", "(", "stickV", ")", ">", "1.0", ")", "{", "if", "(", "Math", ".", "abs", "(", "stickV", ")", "<", "3.35", ")", "stickV", "=", "(", "stickV", "<", "0", ")", "?", "-", "3.35", ":", "3.35", ";", "}", "else", "stickV", "=", "0", ";", "try", "{", "stickLeftJag", ".", "setX", "(", "stickV", "/", "12.0", ")", ";", "stickRightJag", ".", "setX", "(", "stickV", "/", "12.0", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "double", "wristV", "=", "0", ";", "double", "targetwrist", "=", "1", "-", "(", "targetWristA", "+", "45", ")", "/", "270.0", ";", "double", "wristDiff", "=", "0", ";", "try", "{", "if", "(", "wristJag", ".", "getPosition", "(", ")", "!=", "0", ")", "wristDiff", "=", "targetwrist", "-", "wristJag", ".", "getPosition", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "wristV", "=", "-", "1", "*", "(", "35", "*", "wristDiff", ")", ";", "if", "(", "Math", ".", "abs", "(", "wristV", ")", ">", "12", ")", "wristV", "=", "(", "wristV", "<", "0", ")", "?", "-", "12", ":", "12", ";", "if", "(", "Math", ".", "abs", "(", "wristV", ")", ">", "0.2", ")", "{", "if", "(", "Math", ".", "abs", "(", "wristV", ")", "<", "1.0", ")", "wristV", "=", "(", "wristV", "<", "0", ")", "?", "-", "1.0", ":", "1.0", ";", "}", "else", "wristV", "=", "0", ";", "try", "{", "wristJag", ".", "setX", "(", "wristV", "/", "12.0", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "}", "public", "void", "teleopPeriodic", "(", ")", "{", "Watchdog", ".", "getInstance", "(", ")", ".", "feed", "(", ")", ";", "m_telePeriodicLoops", "++", ";", "m_dsPacketsReceivedInCurrentSecond", "++", ";", "updateDashboard", "(", ")", ";", "try", "{", "double", "bLJP", "=", "boomLeftJag", ".", "getPosition", "(", ")", ";", "double", "sLJP", "=", "stickRightJag", ".", "getPosition", "(", ")", ";", "double", "wJP", "=", "wristJag", ".", "getPosition", "(", ")", ";", "boomAngle", "=", "(", "180", "-", "(", "bLJP", "*", "270", "-", "45", ")", ")", ";", "stickAngle", "=", "(", "180", "-", "(", "sLJP", "*", "270", "-", "45", ")", ")", ";", "wristAngle", "=", "(", "180", "-", "(", "wJP", "*", "270", "-", "45", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "double", "[", "]", "armCoords", "=", "getWristCoordinates", "(", "boomAngle", ",", "stickAngle", ")", ";", "currentHeight", "=", "armCoords", "[", "1", "]", ";", "currentLength", "=", "armCoords", "[", "0", "]", ";", "lastOverButton", "=", "m_buttons", "[", "9", "]", ";", "lastArcadeButton", "=", "m_buttons", "[", "2", "]", ";", "lastStartingButton", "=", "m_buttons", "[", "3", "]", ";", "lastGripperButton", "=", "m_buttons", "[", "5", "]", ";", "for", "(", "int", "buttonDex", "=", "0", ";", "buttonDex", "<", "NUM_BUTTONS", ";", "buttonDex", "++", ")", "{", "m_buttons", "[", "buttonDex", "]", "=", "(", "int", ")", "(", "m_joystick", ".", "getRawButton", "(", "buttonDex", "+", "1", ")", "?", "1", ":", "0", ")", ";", "}", "if", "(", "m_buttons", "[", "2", "]", "==", "1", "&&", "lastArcadeButton", "==", "0", ")", "{", "arcadeDrive", "=", "!", "arcadeDrive", ";", "}", "if", "(", "m_buttons", "[", "9", "]", "==", "1", "&&", "lastOverButton", "==", "0", ")", "{", "override", "=", "!", "override", ";", "}", "if", "(", "m_buttons", "[", "5", "]", "==", "1", "&&", "lastGripperButton", "==", "0", ")", "{", "gripperSolenoid", ".", "set", "(", "!", "gripperSolenoid", ".", "get", "(", ")", ")", ";", "}", "double", "bPot", "=", "0.5", "*", "3.3", ";", "double", "sPot", "=", "0.5", "*", "3.3", ";", "double", "wPot", "=", "0.5", "*", "3.3", ";", "boolean", "rotateUp", "=", "false", ";", "boolean", "rotateDown", "=", "false", ";", "boolean", "deployment", "=", "false", ";", "try", "{", "ds", ".", "getEnhancedIO", "(", ")", ".", "setLED", "(", "1", ",", "arcadeDrive", ")", ";", "ds", ".", "getEnhancedIO", "(", ")", ".", "setLED", "(", "2", ",", "(", "m_buttons", "[", "6", "]", "==", "1", ")", ")", ";", "ds", ".", "getEnhancedIO", "(", ")", ".", "setLED", "(", "3", ",", "override", ")", ";", "for", "(", "int", "buttonDex", "=", "0", ";", "buttonDex", "<", "14", ";", "buttonDex", "++", ")", "{", "dsButtons", "[", "buttonDex", "]", "=", "!", "ds", ".", "getEnhancedIO", "(", ")", ".", "getDigital", "(", "buttonDex", "+", "1", ")", ";", "}", "rotateUp", "=", "dsButtons", "[", "9", "]", ";", "rotateDown", "=", "dsButtons", "[", "7", "]", ";", "deployment", "=", "dsButtons", "[", "11", "]", ";", "bPot", "=", "ds", ".", "getEnhancedIO", "(", ")", ".", "getAnalogIn", "(", "2", ")", ";", "sPot", "=", "ds", ".", "getEnhancedIO", "(", ")", ".", "getAnalogIn", "(", "4", ")", ";", "wPot", "=", "ds", ".", "getEnhancedIO", "(", ")", ".", "getAnalogIn", "(", "6", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "double", "halfArm", "=", "1.0", ";", "if", "(", "!", "override", ")", "{", "if", "(", "arcadeDrive", ")", "{", "m_robotDrive", ".", "arcadeDrive", "(", "(", "1", "-", "2", "*", "m_buttons", "[", "6", "]", ")", "*", "m_joystick", ".", "getRawAxis", "(", "2", ")", "*", "halfArm", ",", "m_joystick", ".", "getRawAxis", "(", "4", ")", "/", "(", "3", "+", "(", "m_buttons", "[", "7", "]", "*", "3", ")", ")", "*", "2", "*", "halfArm", ",", "false", ")", ";", "}", "else", "{", "if", "(", "m_buttons", "[", "6", "]", "==", "1", ")", "m_robotDrive", ".", "tankDrive", "(", "-", "m_joystick", ".", "getRawAxis", "(", "3", ")", ",", "-", "m_joystick", ".", "getRawAxis", "(", "2", ")", ")", ";", "else", "m_robotDrive", ".", "tankDrive", "(", "m_joystick", ".", "getRawAxis", "(", "2", ")", ",", "m_joystick", ".", "getRawAxis", "(", "3", ")", ")", ";", "}", "}", "if", "(", "m_buttons", "[", "4", "]", "==", "1", "||", "deployment", ")", "deploy", "=", "true", ";", "if", "(", "deploy", ")", "deployServo", ".", "setAngle", "(", "80", ")", ";", "else", "deployServo", ".", "setAngle", "(", "150", ")", ";", "if", "(", "!", "override", ")", "{", "if", "(", "gripperSolenoid", ".", "get", "(", ")", "!=", "dsButtons", "[", "0", "]", ")", "{", "gripperSolenoid", ".", "set", "(", "dsButtons", "[", "0", "]", ")", ";", "}", "if", "(", "rotateUp", "||", "rotateDown", ")", "{", "double", "rotateValue", "=", "0", ";", "rotateValue", "-=", "(", "rotateUp", ")", "?", "0.5", ":", "0", ";", "rotateValue", "+=", "(", "rotateDown", ")", "?", "0.5", ":", "0", ";", "topLeftRoller", ".", "set", "(", "(", "0.41452991452991456", ")", "+", "rotateValue", ")", ";", "topRightRoller", ".", "set", "(", "0.44017094017094016", "-", "rotateValue", ")", ";", "bottomRightRoller", ".", "set", "(", "0.44017094017094016", "-", "rotateValue", ")", ";", "bottomLeftRoller", ".", "set", "(", "(", "0.4230769230769231", ")", "+", "rotateValue", ")", ";", "}", "else", "if", "(", "gripperButton", ".", "get", "(", ")", "&&", "!", "dsButtons", "[", "0", "]", ")", "{", "topLeftRoller", ".", "set", "(", "(", "0.41452991452991456", ")", "+", "0.5", ")", ";", "topRightRoller", ".", "set", "(", "0.44017094017094016", "-", "0.5", ")", ";", "bottomLeftRoller", ".", "set", "(", "0.44017094017094016", "-", "0.5", ")", ";", "bottomRightRoller", ".", "set", "(", "(", "0.4230769230769231", ")", "+", "0.5", ")", ";", "}", "else", "{", "topLeftRoller", ".", "set", "(", "(", "0.41452991452991456", ")", ")", ";", "topRightRoller", ".", "set", "(", "0.44017094017094016", ")", ";", "bottomLeftRoller", ".", "set", "(", "0.44017094017094016", ")", ";", "bottomRightRoller", ".", "set", "(", "(", "0.4230769230769231", ")", ")", ";", "}", "}", "double", "boomV", "=", "0", ";", "if", "(", "!", "override", ")", "{", "double", "targetboom", "=", "(", "3.3", "-", "bPot", ")", "/", "3.71018053", "+", "0.06610589", ";", "double", "boomDiff", "=", "0", ";", "try", "{", "if", "(", "boomLeftJag", ".", "getPosition", "(", ")", "!=", "0", ")", "boomDiff", "=", "targetboom", "-", "boomLeftJag", ".", "getPosition", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "double", "boomGain", "=", "170", ";", "if", "(", "boomDiff", ">", "0", ")", "boomGain", "=", "80", ";", "boomV", "=", "(", "(", "boomGain", "*", "-", "1", ")", "*", "boomDiff", ")", ";", "double", "boomMaxV", "=", "9", "*", "1", ";", "if", "(", "Math", ".", "abs", "(", "boomV", ")", ">", "boomMaxV", ")", "boomV", "=", "(", "boomV", "<", "boomMaxV", ")", "?", "-", "boomMaxV", ":", "boomMaxV", ";", "if", "(", "Math", ".", "abs", "(", "boomV", ")", ">", "1.5", ")", "{", "if", "(", "Math", ".", "abs", "(", "boomV", ")", "<", "3.25", ")", "boomV", "=", "(", "boomV", "<", "0", ")", "?", "-", "3.25", ":", "3.25", ";", "}", "else", "boomV", "=", "0", ";", "}", "else", "{", "if", "(", "lastStartingButton", "==", "1", ")", "{", "double", "targetboom", "=", "0.41152954", ";", "double", "boomDiff", "=", "0", ";", "try", "{", "if", "(", "boomLeftJag", ".", "getPosition", "(", ")", "!=", "0", ")", "boomDiff", "=", "targetboom", "-", "boomLeftJag", ".", "getPosition", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "boomV", "=", "(", "-", "160", "*", "boomDiff", ")", ";", "if", "(", "Math", ".", "abs", "(", "boomV", ")", ">", "9", ")", "boomV", "=", "(", "boomV", "<", "0", ")", "?", "-", "9", ":", "9", ";", "if", "(", "Math", ".", "abs", "(", "boomV", ")", ">", "0.65", ")", "{", "if", "(", "Math", ".", "abs", "(", "boomV", ")", "<", "2.5", ")", "boomV", "=", "(", "boomV", "<", "0", ")", "?", "-", "3.25", ":", "3.25", ";", "}", "else", "boomV", "=", "0", ";", "}", "else", "boomV", "=", "12", "*", "-", "m_joystick", ".", "getRawAxis", "(", "4", ")", ";", "}", "try", "{", "boomLeftJag", ".", "setX", "(", "boomV", "/", "12.0", ")", ";", "boomRightJag", ".", "setX", "(", "boomV", "/", "12.0", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "double", "stickV", "=", "0", ";", "if", "(", "!", "override", ")", "{", "double", "targetstick", "=", "sPot", "/", "3.490056", "+", "0.01808", ";", "double", "stickDiff", "=", "0", ";", "try", "{", "if", "(", "stickRightJag", ".", "getPosition", "(", ")", "!=", "0", ")", "stickDiff", "=", "targetstick", "-", "stickRightJag", ".", "getPosition", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "stickV", "=", "(", "(", "150.0", "*", "1", ")", "*", "stickDiff", ")", ";", "double", "stickMaxV", "=", "9", "*", "1", ";", "if", "(", "Math", ".", "abs", "(", "stickV", ")", ">", "stickMaxV", ")", "stickV", "=", "(", "stickV", "<", "stickMaxV", ")", "?", "-", "stickMaxV", ":", "stickMaxV", ";", "if", "(", "Math", ".", "abs", "(", "stickV", ")", ">", "1.0", ")", "{", "if", "(", "Math", ".", "abs", "(", "stickV", ")", "<", "3.35", ")", "stickV", "=", "(", "stickV", "<", "0", ")", "?", "-", "3.35", ":", "3.35", ";", "}", "else", "stickV", "=", "0", ";", "}", "else", "{", "if", "(", "lastStartingButton", "==", "1", ")", "{", "double", "targetstick", "=", "0.7986296", ";", "double", "stickDiff", "=", "0", ";", "try", "{", "if", "(", "stickRightJag", ".", "getPosition", "(", ")", "!=", "0", ")", "stickDiff", "=", "targetstick", "-", "stickRightJag", ".", "getPosition", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "stickV", "=", "1", "*", "(", "150", "*", "stickDiff", ")", ";", "if", "(", "Math", ".", "abs", "(", "stickV", ")", ">", "12", ")", "stickV", "=", "(", "stickV", "<", "0", ")", "?", "-", "12", ":", "12", ";", "if", "(", "Math", ".", "abs", "(", "stickV", ")", ">", "0.85", ")", "{", "if", "(", "Math", ".", "abs", "(", "stickV", ")", "<", "3.35", ")", "stickV", "=", "(", "stickV", "<", "0", ")", "?", "-", "3.35", ":", "3.35", ";", "}", "else", "stickV", "=", "0", ";", "}", "else", "stickV", "=", "7", "*", "-", "m_joystick", ".", "getRawAxis", "(", "3", ")", ";", "}", "try", "{", "stickLeftJag", ".", "setX", "(", "stickV", "/", "12.0", ")", ";", "stickRightJag", ".", "setX", "(", "stickV", "/", "12.0", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "double", "wristV", "=", "0", ";", "if", "(", "!", "override", ")", "{", "double", "targetwrist", "=", "(", "1", "-", "wPot", "/", "3.51774071", ")", "-", "0.03755193", ";", "double", "wristDiff", "=", "0", ";", "try", "{", "if", "(", "wristJag", ".", "getPosition", "(", ")", "!=", "0", ")", "wristDiff", "=", "targetwrist", "-", "wristJag", ".", "getPosition", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "wristV", "=", "(", "(", "-", "35.0", "*", "1", ")", "*", "wristDiff", ")", ";", "double", "wristMaxV", "=", "9", "*", "1", ";", "if", "(", "Math", ".", "abs", "(", "wristV", ")", ">", "wristMaxV", ")", "wristV", "=", "(", "wristV", "<", "wristMaxV", ")", "?", "-", "wristMaxV", ":", "wristMaxV", ";", "if", "(", "Math", ".", "abs", "(", "wristV", ")", ">", "0.2", ")", "{", "if", "(", "Math", ".", "abs", "(", "wristV", ")", "<", "1.0", ")", "wristV", "=", "(", "wristV", "<", "0", ")", "?", "-", "1.0", ":", "1.0", ";", "}", "else", "wristV", "=", "0", ";", "}", "else", "{", "if", "(", "lastStartingButton", "==", "1", ")", "{", "double", "targetwrist", "=", "0.8758545", ";", "double", "wristDiff", "=", "0", ";", "try", "{", "if", "(", "wristJag", ".", "getPosition", "(", ")", "!=", "0", ")", "wristDiff", "=", "targetwrist", "-", "wristJag", ".", "getPosition", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "wristV", "=", "-", "1", "*", "(", "35", "*", "wristDiff", ")", ";", "if", "(", "Math", ".", "abs", "(", "wristV", ")", ">", "12", ")", "wristV", "=", "(", "wristV", "<", "0", ")", "?", "-", "12", ":", "12", ";", "if", "(", "Math", ".", "abs", "(", "wristV", ")", ">", "0.2", ")", "{", "if", "(", "Math", ".", "abs", "(", "wristV", ")", "<", "1.0", ")", "wristV", "=", "(", "wristV", "<", "0", ")", "?", "-", "1.0", ":", "1.0", ";", "}", "else", "wristV", "=", "0", ";", "}", "else", "wristV", "=", "4", "*", "-", "m_joystick", ".", "getRawAxis", "(", "2", ")", ";", "}", "try", "{", "wristJag", ".", "setX", "(", "wristV", "/", "12.0", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "double", "[", "]", "getArmAngles", "(", "double", "wristX", ",", "double", "wristY", ")", "{", "double", "hypotenuse", "=", "Math", ".", "sqrt", "(", "MathUtils", ".", "pow", "(", "wristX", ",", "2", ")", "+", "MathUtils", ".", "pow", "(", "wristY", "-", "23", ",", "2", ")", ")", ";", "double", "stickBoomAngle", "=", "MathUtils", ".", "acos", "(", "(", "36", "*", "36", "+", "44", "*", "44", "-", "hypotenuse", "*", "hypotenuse", ")", "/", "(", "2", "*", "36", "*", "44", ")", ")", ";", "double", "hypotenuseHorizontalAngle", "=", "MathUtils", ".", "atan2", "(", "(", "wristY", "-", "23", ")", ",", "wristX", ")", ";", "double", "hypotenuseBoomAngle", "=", "MathUtils", ".", "acos", "(", "(", "36", "*", "36", "+", "hypotenuse", "*", "hypotenuse", "-", "44", "*", "44", ")", "/", "(", "2", "*", "36", "*", "hypotenuse", ")", ")", ";", "double", "boomHorizontalAngle", "=", "(", "hypotenuseHorizontalAngle", "+", "hypotenuseBoomAngle", ")", ";", "double", "[", "]", "armAngles", "=", "{", "boomHorizontalAngle", "/", "Math", ".", "PI", "*", "180", ",", "stickBoomAngle", "/", "Math", ".", "PI", "*", "180", "}", ";", "return", "armAngles", ";", "}", "double", "[", "]", "getWristCoordinates", "(", "double", "boomAngle", ",", "double", "stickAngle", ")", "{", "double", "hypotenuse", "=", "Math", ".", "sqrt", "(", "36", "*", "36", "+", "44", "*", "44", "-", "2", "*", "36", "*", "44", "*", "Math", ".", "cos", "(", "stickAngle", "/", "180.0", "*", "Math", ".", "PI", ")", ")", ";", "double", "hypotenuseBoomAngle", "=", "MathUtils", ".", "acos", "(", "(", "36", "*", "36", "+", "hypotenuse", "*", "hypotenuse", "-", "44", "*", "44", ")", "/", "(", "2", "*", "36", "*", "hypotenuse", ")", ")", ";", "double", "hypotenuseHorizontalAngle", "=", "boomAngle", "/", "180.0", "*", "Math", ".", "PI", "-", "hypotenuseBoomAngle", ";", "double", "xCoord", "=", "hypotenuse", "*", "Math", ".", "cos", "(", "hypotenuseHorizontalAngle", ")", ";", "double", "yCoord", "=", "hypotenuse", "*", "Math", ".", "sin", "(", "hypotenuseHorizontalAngle", ")", "+", "23", ";", "double", "[", "]", "wristCoords", "=", "{", "xCoord", ",", "yCoord", "}", ";", "return", "wristCoords", ";", "}", "int", "GetLoopsPerSec", "(", ")", "{", "return", "20", ";", "}", "void", "updateDashboard", "(", ")", "{", "Dashboard", "lowDashData", "=", "ds", ".", "getDashboardPackerLow", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "8", ";", "i", "++", ")", "{", "lowDashData", ".", "addFloat", "(", "(", "float", ")", "AnalogModule", ".", "getInstance", "(", "1", ")", ".", "getAverageVoltage", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "8", ";", "i", "++", ")", "{", "lowDashData", ".", "addFloat", "(", "(", "float", ")", "AnalogModule", ".", "getInstance", "(", "2", ")", ".", "getAverageVoltage", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "int", "module", "=", "4", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getAllDIO", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getDIODirection", "(", ")", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "10", ";", "i", "++", ")", "{", "lowDashData", ".", "addByte", "(", "(", "byte", ")", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getPWM", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "int", "module", "=", "6", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getAllDIO", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getDIODirection", "(", ")", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "10", ";", "i", "++", ")", "{", "lowDashData", ".", "addByte", "(", "(", "byte", ")", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getPWM", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addByte", "(", "Solenoid", ".", "getAllFromDefaultModule", "(", ")", ")", ";", "lowDashData", ".", "commit", "(", ")", ";", "}", "}", "</s>" ]
7,511
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "defaultCode", ";", "import", "com", ".", "sun", ".", "squawk", ".", "util", ".", "MathUtils", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "AnalogChannel", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "AnalogModule", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "CANJaguar", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Dashboard", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DigitalInput", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DigitalModule", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DriverStation", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "IterativeRobot", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Joystick", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "RobotDrive", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Servo", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Solenoid", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Timer", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Watchdog", ";", "public", "class", "DefaultRobot1", "extends", "IterativeRobot", "{", "RobotDrive", "m_robotDrive", ";", "DriverStation", "ds", ";", "CANJaguar", "frontLeftJag", ";", "CANJaguar", "frontRightJag", ";", "CANJaguar", "rearLeftJag", ";", "CANJaguar", "rearRightJag", ";", "CANJaguar", "boomRightJag", ";", "CANJaguar", "boomLeftJag", ";", "CANJaguar", "stickRightJag", ";", "CANJaguar", "stickLeftJag", ";", "Servo", "wristServo", ";", "Solenoid", "gripperSolenoid", ";", "double", "boomAngle", "=", "0.5", ";", "double", "stickAngle", "=", "0.5", ";", "double", "lastTargetHeight", "=", "18", ";", "double", "currentHeight", "=", "18", ";", "double", "targetHeight", "=", "18", ";", "double", "heightIncrement", "=", "0", ";", "int", "currentPreset", "=", "-", "1", ";", "int", "presetStage", "=", "0", ";", "boolean", "doAutoArmStuff", "=", "false", ";", "Servo", "deployServo", ";", "boolean", "deployed", "=", "false", ";", "DigitalInput", "leftLineSensor", ";", "DigitalInput", "middleLineSensor", ";", "DigitalInput", "rightLineSensor", ";", "int", "[", "]", "lastThreeLines", "=", "new", "int", "[", "3", "]", ";", "int", "lineLoops", "=", "0", ";", "boolean", "hitY", "=", "false", ";", "boolean", "hasStopped", "=", "false", ";", "int", "ignoreLines", "=", "0", ";", "int", "m_dsPacketsReceivedInCurrentSecond", ";", "Joystick", "m_joystick", ";", "static", "final", "int", "NUM_BUTTONS", "=", "10", ";", "int", "[", "]", "m_buttons", "=", "new", "int", "[", "NUM_BUTTONS", "]", ";", "boolean", "slow_drive", "=", "false", ";", "int", "m_autoPeriodicLoops", ";", "int", "m_disabledPeriodicLoops", ";", "int", "m_telePeriodicLoops", ";", "public", "DefaultRobot1", "(", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "ds", "=", "DriverStation", ".", "getInstance", "(", ")", ";", "try", "{", "frontLeftJag", "=", "new", "CANJaguar", "(", "4", ")", ";", "frontRightJag", "=", "new", "CANJaguar", "(", "5", ")", ";", "rearLeftJag", "=", "new", "CANJaguar", "(", "3", ")", ";", "rearRightJag", "=", "new", "CANJaguar", "(", "2", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "m_robotDrive", "=", "new", "RobotDrive", "(", "frontLeftJag", ",", "rearLeftJag", ",", "frontRightJag", ",", "rearRightJag", ")", ";", "m_robotDrive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kFrontLeft", ",", "true", ")", ";", "m_robotDrive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kRearLeft", ",", "true", ")", ";", "m_robotDrive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kFrontRight", ",", "true", ")", ";", "m_robotDrive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kRearRight", ",", "true", ")", ";", "try", "{", "boomRightJag", "=", "new", "CANJaguar", "(", "6", ",", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "boomLeftJag", "=", "new", "CANJaguar", "(", "9", ",", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "stickRightJag", "=", "new", "CANJaguar", "(", "7", ",", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "stickLeftJag", "=", "new", "CANJaguar", "(", "8", ",", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "for", "(", "int", "setThatMode", "=", "0", ";", "setThatMode", "<", "5", ";", "setThatMode", "++", ")", "{", "boomRightJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "boomLeftJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "stickRightJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "stickLeftJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", ";", "Thread", ".", "sleep", "(", "100", ")", ";", "if", "(", "boomRightJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPosition", "&&", "boomLeftJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPosition", "&&", "stickLeftJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPosition", "&&", "stickRightJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPosition", ")", "break", ";", "}", "boomRightJag", ".", "setPositionReference", "(", "CANJaguar", ".", "PositionReference", ".", "kPotentiometer", ")", ";", "boomLeftJag", ".", "setPositionReference", "(", "CANJaguar", ".", "PositionReference", ".", "kPotentiometer", ")", ";", "stickRightJag", ".", "setPositionReference", "(", "CANJaguar", ".", "PositionReference", ".", "kPotentiometer", ")", ";", "stickLeftJag", ".", "setPositionReference", "(", "CANJaguar", ".", "PositionReference", ".", "kPotentiometer", ")", ";", "for", "(", "int", "setThatMode", "=", "0", ";", "setThatMode", "<", "5", ";", "setThatMode", "++", ")", "{", "boomRightJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", ")", ";", "boomLeftJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", ")", ";", "stickRightJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", ")", ";", "stickLeftJag", ".", "changeControlMode", "(", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", ")", ";", "Thread", ".", "sleep", "(", "100", ")", ";", "if", "(", "boomRightJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", "&&", "boomLeftJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", "&&", "stickLeftJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", "&&", "stickRightJag", ".", "getControlMode", "(", ")", "==", "CANJaguar", ".", "ControlMode", ".", "kPercentVbus", ")", "break", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "wristServo", "=", "new", "Servo", "(", "2", ")", ";", "gripperSolenoid", "=", "new", "Solenoid", "(", "1", ")", ";", "deployServo", "=", "new", "Servo", "(", "1", ")", ";", "leftLineSensor", "=", "new", "DigitalInput", "(", "14", ")", ";", "middleLineSensor", "=", "new", "DigitalInput", "(", "13", ")", ";", "rightLineSensor", "=", "new", "DigitalInput", "(", "12", ")", ";", "m_dsPacketsReceivedInCurrentSecond", "=", "0", ";", "m_joystick", "=", "new", "Joystick", "(", "1", ")", ";", "for", "(", "int", "buttonDex", "=", "0", ";", "buttonDex", "<", "NUM_BUTTONS", ";", "buttonDex", "++", ")", "{", "m_buttons", "[", "buttonDex", "]", "=", "(", "int", ")", "(", "m_joystick", ".", "getRawButton", "(", "buttonDex", "+", "1", ")", "?", "1", ":", "0", ")", ";", "}", "m_autoPeriodicLoops", "=", "0", ";", "m_disabledPeriodicLoops", "=", "0", ";", "m_telePeriodicLoops", "=", "0", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "public", "void", "robotInit", "(", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "public", "void", "disabledInit", "(", ")", "{", "m_disabledPeriodicLoops", "=", "0", ";", "startSec", "=", "(", "int", ")", "(", "Timer", ".", "getUsClock", "(", ")", "/", "1000000.0", ")", ";", "printSec", "=", "startSec", "+", "1", ";", "}", "public", "void", "autonomousInit", "(", ")", "{", "m_autoPeriodicLoops", "=", "0", ";", "try", "{", "boomAngle", "=", "(", "boomLeftJag", ".", "getPosition", "(", ")", "+", "boomRightJag", ".", "getPosition", "(", ")", ")", "/", "2.0", "*", "180", ";", "stickAngle", "=", "(", "stickLeftJag", ".", "getPosition", "(", ")", "+", "stickRightJag", ".", "getPosition", "(", ")", ")", "/", "2.0", "*", "180", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "if", "(", "boomAngle", "!=", "0", "&&", "stickAngle", "!=", "0", ")", "doAutoArmStuff", "=", "true", ";", "}", "public", "void", "teleopInit", "(", ")", "{", "m_telePeriodicLoops", "=", "0", ";", "m_dsPacketsReceivedInCurrentSecond", "=", "0", ";", "try", "{", "boomAngle", "=", "(", "boomLeftJag", ".", "getPosition", "(", ")", "+", "boomRightJag", ".", "getPosition", "(", ")", ")", "/", "2.0", "*", "180", ";", "stickAngle", "=", "(", "stickLeftJag", ".", "getPosition", "(", ")", "+", "stickRightJag", ".", "getPosition", "(", ")", ")", "/", "2.0", "*", "180", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "static", "int", "printSec", ";", "static", "int", "startSec", ";", "public", "void", "disabledPeriodic", "(", ")", "{", "updateDashboard", "(", ")", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "=", "0", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "+=", "(", "leftLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "100", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "+=", "(", "middleLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "10", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "+=", "(", "rightLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "1", ";", "lineLoops", "++", ";", "Watchdog", ".", "getInstance", "(", ")", ".", "feed", "(", ")", ";", "m_disabledPeriodicLoops", "++", ";", "lineLoops", "=", "0", ";", "hitY", "=", "false", ";", "hasStopped", "=", "false", ";", "ignoreLines", "=", "0", ";", "try", "{", "System", ".", "out", ".", "println", "(", "\"Boom:", "\"", "+", "boomLeftJag", ".", "getPosition", "(", ")", "+", "\"", "|", "\"", "+", "boomRightJag", ".", "getPosition", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"Stick:", "\"", "+", "stickLeftJag", ".", "getPosition", "(", ")", "+", "\"", "|", "\"", "+", "stickRightJag", ".", "getPosition", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "public", "void", "autonomousPeriodic", "(", ")", "{", "updateDashboard", "(", ")", ";", "Watchdog", ".", "getInstance", "(", ")", ".", "feed", "(", ")", ";", "m_autoPeriodicLoops", "++", ";", "deployServo", ".", "setAngle", "(", "140", ")", ";", "if", "(", "!", "hasStopped", ")", "{", "boolean", "straightLine", "=", "ds", ".", "getDigitalIn", "(", "1", ")", ";", "boolean", "goLeft", "=", "ds", ".", "getDigitalIn", "(", "2", ")", "&&", "!", "straightLine", ";", "int", "lineReading", "=", "0", ";", "lineReading", "+=", "(", "leftLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "100", ";", "lineReading", "+=", "(", "middleLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "10", ";", "lineReading", "+=", "(", "rightLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "1", ";", "System", ".", "out", ".", "print", "(", "\"\"", "+", "lineReading", "+", "\"", "|", "\"", ")", ";", "double", "rightMotors", "=", "0", ";", "double", "leftMotors", "=", "0", ";", "switch", "(", "lineReading", ")", "{", "case", "0", ":", "{", "rightMotors", "=", "1.2", "*", "(", "lastThreeLines", "[", "0", "]", "%", "10", "+", "lastThreeLines", "[", "1", "]", "%", "10", "+", "lastThreeLines", "[", "2", "]", "%", "10", ")", "/", "3.0", ";", "leftMotors", "=", "1.2", "*", "(", "Math", ".", "floor", "(", "lastThreeLines", "[", "0", "]", "/", "100", ")", "%", "10", "+", "Math", ".", "floor", "(", "lastThreeLines", "[", "1", "]", "/", "100", ")", "%", "10", "+", "Math", ".", "floor", "(", "lastThreeLines", "[", "2", "]", "/", "100", ")", "%", "10", ")", "/", "3.0", ";", "}", "break", ";", "case", "1", ":", "leftMotors", "=", "0.55", ";", "rightMotors", "=", "0.7", ";", "break", ";", "case", "11", ":", "leftMotors", "=", "0.6", ";", "rightMotors", "=", "0.7", ";", "break", ";", "case", "10", ":", "leftMotors", "=", "0.8", ";", "rightMotors", "=", "0.8", ";", "break", ";", "case", "110", ":", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "0.6", ";", "break", ";", "case", "100", ":", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "0.55", ";", "break", ";", "case", "111", ":", "if", "(", "straightLine", "||", "hitY", ")", "{", "hasStopped", "=", "true", ";", "System", ".", "out", ".", "print", "(", "\"STOPPED!", "|", "\"", ")", ";", "}", "else", "{", "if", "(", "goLeft", ")", "{", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "-", "0.7", ";", "lineReading", "=", "100", ";", "}", "else", "{", "leftMotors", "=", "-", "0.7", ";", "rightMotors", "=", "0.7", ";", "lineReading", "=", "1", ";", "}", "hitY", "=", "true", ";", "System", ".", "out", ".", "print", "(", "\"HIT!", "|", "\"", ")", ";", "}", "break", ";", "case", "101", ":", "if", "(", "!", "straightLine", ")", "{", "if", "(", "goLeft", ")", "{", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "-", "0.7", ";", "lineReading", "=", "100", ";", "}", "else", "{", "leftMotors", "=", "-", "0.7", ";", "rightMotors", "=", "0.7", ";", "lineReading", "=", "1", ";", "}", "hitY", "=", "true", ";", "System", ".", "out", ".", "print", "(", "\"HIT!", "|", "\"", ")", ";", "}", "break", ";", "default", ":", "break", ";", "}", "m_robotDrive", ".", "tankDrive", "(", "-", "leftMotors", ",", "-", "rightMotors", ")", ";", "System", ".", "out", ".", "println", "(", "\"Left:", "\"", "+", "leftMotors", "+", "\",", "Right:", "\"", "+", "rightMotors", ")", ";", "if", "(", "lineReading", ">", "0", ")", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "=", "lineReading", ";", "lineLoops", "++", ";", "}", "else", "if", "(", "ignoreLines", ">", "35", ")", "{", "int", "lineReading", "=", "0", ";", "lineReading", "+=", "(", "leftLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "100", ";", "lineReading", "+=", "(", "middleLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "10", ";", "lineReading", "+=", "(", "rightLineSensor", ".", "get", "(", ")", ")", "?", "0", ":", "1", ";", "System", ".", "out", ".", "print", "(", "\"\"", "+", "lineReading", "+", "\"", "|", "\"", ")", ";", "double", "rightMotors", "=", "0", ";", "double", "leftMotors", "=", "0", ";", "switch", "(", "lineReading", ")", "{", "case", "0", ":", "leftMotors", "=", "1", "*", "(", "lastThreeLines", "[", "0", "]", "%", "10", "+", "lastThreeLines", "[", "1", "]", "%", "10", "+", "lastThreeLines", "[", "2", "]", "%", "10", ")", "/", "3.0", ";", "rightMotors", "=", "1", "*", "(", "(", "lastThreeLines", "[", "0", "]", "/", "100", ")", "%", "10", "+", "(", "lastThreeLines", "[", "1", "]", "/", "100", ")", "%", "10", "+", "(", "lastThreeLines", "[", "2", "]", "/", "100", ")", "%", "10", ")", "/", "3.0", ";", "break", ";", "case", "1", ":", "leftMotors", "=", "0.4", ";", "rightMotors", "=", "0.8", ";", "break", ";", "case", "10", ":", "leftMotors", "=", "0.9", ";", "rightMotors", "=", "0.9", ";", "break", ";", "case", "11", ":", "leftMotors", "=", "0.7", ";", "rightMotors", "=", "0.9", ";", "break", ";", "case", "100", ":", "leftMotors", "=", "0.8", ";", "rightMotors", "=", "0.4", ";", "break", ";", "case", "110", ":", "leftMotors", "=", "0.9", ";", "rightMotors", "=", "0.7", ";", "break", ";", "case", "111", ":", "leftMotors", "=", "0.8", ";", "rightMotors", "=", "0.8", ";", "break", ";", "case", "101", ":", "leftMotors", "=", "0.8", ";", "rightMotors", "=", "0.8", ";", "break", ";", "default", ":", "break", ";", "}", "m_robotDrive", ".", "tankDrive", "(", "-", "leftMotors", ",", "-", "rightMotors", ")", ";", "System", ".", "out", ".", "println", "(", "\"Left:", "\"", "+", "leftMotors", "+", "\",", "Right:", "\"", "+", "rightMotors", ")", ";", "lastThreeLines", "[", "lineLoops", "%", "3", "]", "=", "lineReading", ";", "lineLoops", "++", ";", "}", "else", "{", "if", "(", "!", "doAutoArmStuff", ")", "{", "ignoreLines", "++", ";", "m_robotDrive", ".", "tankDrive", "(", "0.8", ",", "-", "0.8", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "}", "}", "public", "void", "teleopPeriodic", "(", ")", "{", "lineLoops", "=", "0", ";", "hitY", "=", "false", ";", "hasStopped", "=", "false", ";", "ignoreLines", "=", "0", ";", "Watchdog", ".", "getInstance", "(", ")", ".", "feed", "(", ")", ";", "m_telePeriodicLoops", "++", ";", "m_dsPacketsReceivedInCurrentSecond", "++", ";", "updateDashboard", "(", ")", ";", "for", "(", "int", "buttonDex", "=", "0", ";", "buttonDex", "<", "NUM_BUTTONS", ";", "buttonDex", "++", ")", "{", "m_buttons", "[", "buttonDex", "]", "=", "(", "int", ")", "(", "m_joystick", ".", "getRawButton", "(", "buttonDex", "+", "1", ")", "?", "1", ":", "0", ")", ";", "}", "m_robotDrive", ".", "arcadeDrive", "(", "(", "1", "+", "m_buttons", "[", "6", "]", "*", "-", "2", ")", "*", "m_joystick", ".", "getRawAxis", "(", "2", ")", ",", "m_joystick", ".", "getRawAxis", "(", "4", ")", "/", "3", "*", "2", ",", "false", ")", ";", "if", "(", "m_buttons", "[", "4", "]", "==", "1", ")", "deployed", "=", "true", ";", "if", "(", "deployed", ")", "deployServo", ".", "setAngle", "(", "0", ")", ";", "else", "deployServo", ".", "setAngle", "(", "140", ")", ";", "wristServo", ".", "setAngle", "(", "90", "+", "110", "*", "m_buttons", "[", "8", "]", ")", ";", "if", "(", "m_buttons", "[", "5", "]", "==", "1", ")", "{", "if", "(", "!", "gripperSolenoid", ".", "get", "(", ")", ")", "gripperSolenoid", ".", "set", "(", "true", ")", ";", "else", "gripperSolenoid", ".", "set", "(", "true", ")", ";", "}", "double", "targetboom", "=", "(", "m_joystick", ".", "getRawAxis", "(", "1", ")", "+", "1", ")", "*", "0.3", "+", "0.2", ";", "if", "(", "targetboom", "<", "0.2", ")", "targetboom", "=", "0.2", ";", "if", "(", "targetboom", ">", "0.8", ")", "targetboom", "=", "0.8", ";", "double", "boomDiff", "=", "0", ";", "try", "{", "if", "(", "boomLeftJag", ".", "getPosition", "(", ")", "!=", "0", ")", "boomDiff", "=", "targetboom", "-", "boomLeftJag", ".", "getPosition", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "if", "(", "Math", ".", "abs", "(", "boomDiff", ")", "<", "0.005", ")", "boomDiff", "=", "0", ";", "double", "boomV", "=", "boomDiff", "*", "25", ";", "if", "(", "boomV", "!=", "0", ")", "if", "(", "Math", ".", "abs", "(", "boomV", ")", "<", "2.5", ")", "boomV", "=", "(", "boomV", "<", "0", ")", "?", "-", "2.5", ":", "2.5", ";", "try", "{", "boomLeftJag", ".", "setX", "(", "boomV", "/", "12.0", ")", ";", "boomRightJag", ".", "setX", "(", "boomV", "/", "12.0", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "double", "targetstick", "=", "(", "-", "m_joystick", ".", "getRawAxis", "(", "3", ")", "+", "1", ")", "*", "0.3", "+", "0.2", ";", "if", "(", "targetstick", "<", "0.2", ")", "targetstick", "=", "0.2", ";", "if", "(", "targetstick", ">", "0.8", ")", "targetstick", "=", "0.8", ";", "double", "stickDiff", "=", "0", ";", "try", "{", "if", "(", "stickLeftJag", ".", "getPosition", "(", ")", "!=", "0", ")", "stickDiff", "=", "targetstick", "-", "stickLeftJag", ".", "getPosition", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "if", "(", "Math", ".", "abs", "(", "stickDiff", ")", "<", "0.005", ")", "stickDiff", "=", "0", ";", "double", "stickV", "=", "stickDiff", "*", "-", "35", ";", "if", "(", "stickV", "!=", "0", ")", "if", "(", "Math", ".", "abs", "(", "stickV", ")", "<", "2.5", ")", "stickV", "=", "(", "stickV", "<", "0", ")", "?", "-", "2.5", ":", "2.5", ";", "try", "{", "stickLeftJag", ".", "setX", "(", "stickV", "/", "12.0", ")", ";", "stickRightJag", ".", "setX", "(", "stickV", "/", "12.0", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "int", "GetLoopsPerSec", "(", ")", "{", "return", "20", ";", "}", "void", "updateDashboard", "(", ")", "{", "Dashboard", "lowDashData", "=", "ds", ".", "getDashboardPackerLow", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "8", ";", "i", "++", ")", "{", "lowDashData", ".", "addFloat", "(", "(", "float", ")", "AnalogModule", ".", "getInstance", "(", "1", ")", ".", "getAverageVoltage", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "8", ";", "i", "++", ")", "{", "lowDashData", ".", "addFloat", "(", "(", "float", ")", "AnalogModule", ".", "getInstance", "(", "2", ")", ".", "getAverageVoltage", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "int", "module", "=", "4", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getAllDIO", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getDIODirection", "(", ")", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "10", ";", "i", "++", ")", "{", "lowDashData", ".", "addByte", "(", "(", "byte", ")", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getPWM", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "int", "module", "=", "6", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getAllDIO", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getDIODirection", "(", ")", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "10", ";", "i", "++", ")", "{", "lowDashData", ".", "addByte", "(", "(", "byte", ")", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getPWM", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addByte", "(", "gripperSolenoid", ".", "getAll", "(", ")", ")", ";", "lowDashData", ".", "commit", "(", ")", ";", "}", "}", "</s>" ]
7,512
[ "<s>", "package", "robot", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Joystick", ";", "public", "class", "ButtonChange", "{", "Joystick", "joystick", ";", "int", "buttonNumber", ";", "boolean", "previousState", ";", "public", "ButtonChange", "(", "Joystick", "joystick", ",", "int", "buttonNumber", ")", "{", "this", ".", "joystick", "=", "joystick", ";", "this", ".", "buttonNumber", "=", "buttonNumber", ";", "}", "public", "void", "setPreviousState", "(", ")", "{", "previousState", "=", "joystick", ".", "getRawButton", "(", "buttonNumber", ")", ";", "}", "public", "boolean", "didButtonChange", "(", "boolean", "actOnRelease", ")", "{", "boolean", "currentState", "=", "joystick", ".", "getRawButton", "(", "buttonNumber", ")", ";", "if", "(", "actOnRelease", ")", "{", "if", "(", "currentState", "==", "false", ")", "{", "if", "(", "previousState", "==", "false", ")", "{", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}", "else", "{", "if", "(", "currentState", ")", "{", "if", "(", "previousState", "==", "false", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}", "}", "}", "</s>" ]
7,513
[ "<s>", "package", "robot", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Joystick", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Timer", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Victor", ";", "public", "class", "Intake", "{", "public", "static", "final", "int", "STOP", "=", "0", ";", "public", "static", "final", "int", "INTAKE", "=", "1", ";", "public", "static", "final", "int", "FIRE", "=", "2", ";", "public", "static", "final", "int", "REVERSE", "=", "-", "1", ";", "private", "Joystick", "joystick", ";", "private", "Victor", "beltMotorOne", ",", "beltMotorTwo", ",", "unobtaniumMotor", ";", "private", "ButtonChange", "intakeButton", ";", "private", "int", "intakeMode", ",", "previousMode", ";", "public", "Intake", "(", "Joystick", "joystick", ",", "Victor", "beltMotorOne", ",", "Victor", "beltMotorTwo", ",", "Victor", "unobtaniumMotor", ")", "{", "this", ".", "joystick", "=", "joystick", ";", "this", ".", "beltMotorOne", "=", "beltMotorOne", ";", "this", ".", "beltMotorTwo", "=", "beltMotorTwo", ";", "this", ".", "unobtaniumMotor", "=", "unobtaniumMotor", ";", "intakeMode", "=", "STOP", ";", "previousMode", "=", "STOP", ";", "intakeButton", "=", "new", "ButtonChange", "(", "joystick", ",", "3", ")", ";", "}", "public", "void", "doAction", "(", ")", "{", "if", "(", "intakeButton", ".", "didButtonChange", "(", "true", ")", ")", "{", "if", "(", "intakeMode", "==", "INTAKE", ")", "{", "intakeMode", "=", "STOP", ";", "}", "else", "{", "intakeMode", "=", "INTAKE", ";", "}", "}", "else", "{", "toggleModeFromJoystickButton", "(", "2", ",", "-", "1", ")", ";", "toggleModeFromJoystickButton", "(", "1", ",", "2", ")", ";", "}", "double", "beltSpeed", "=", "0", ";", "double", "unobtaniumSpeed", "=", "0", ";", "switch", "(", "intakeMode", ")", "{", "case", "REVERSE", ":", "beltSpeed", "=", "1", ";", "unobtaniumSpeed", "=", "0", ";", "break", ";", "case", "STOP", ":", "beltSpeed", "=", "0", ";", "unobtaniumSpeed", "=", "0", ";", "break", ";", "case", "INTAKE", ":", "beltSpeed", "=", "-", "1", ";", "unobtaniumSpeed", "=", "0.5", ";", "break", ";", "case", "FIRE", ":", "beltSpeed", "=", "-", "1", ";", "unobtaniumSpeed", "=", "-", "1", ";", "break", ";", "default", ":", "beltSpeed", "=", "0", ";", "unobtaniumSpeed", "=", "0", ";", "break", ";", "}", "setBeltSpeed", "(", "beltSpeed", ")", ";", "setUnobtaniumSpeed", "(", "unobtaniumSpeed", ")", ";", "intakeButton", ".", "setPreviousState", "(", ")", ";", "}", "public", "void", "toggleModeFromJoystickButton", "(", "int", "joystickButton", ",", "int", "desiredMode", ")", "{", "if", "(", "joystick", ".", "getRawButton", "(", "joystickButton", ")", ")", "{", "if", "(", "intakeMode", "!=", "desiredMode", ")", "{", "previousMode", "=", "intakeMode", ";", "}", "intakeMode", "=", "desiredMode", ";", "}", "else", "if", "(", "!", "joystick", ".", "getRawButton", "(", "joystickButton", ")", "&&", "intakeMode", "==", "desiredMode", ")", "{", "intakeMode", "=", "previousMode", ";", "previousMode", "=", "STOP", ";", "}", "}", "public", "void", "setBeltSpeed", "(", "double", "speed", ")", "{", "beltMotorOne", ".", "set", "(", "speed", ")", ";", "beltMotorTwo", ".", "set", "(", "speed", ")", ";", "}", "public", "void", "setUnobtaniumSpeed", "(", "double", "speed", ")", "{", "unobtaniumMotor", ".", "set", "(", "speed", ")", ";", "}", "}", "</s>" ]
7,514
[ "<s>", "package", "robot", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DigitalInput", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "IterativeRobot", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Jaguar", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Joystick", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "RobotDrive", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Timer", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Victor", ";", "public", "class", "LoganRover", "extends", "IterativeRobot", "{", "public", "static", "final", "double", "AUTO_CORNER_FORWARD_TIME", "=", "2", ";", "public", "static", "final", "double", "AUTO_MIDDLE_FORWARD_TIME", "=", "1", ";", "public", "static", "final", "double", "AUTO_FORWARD_SPEED", "=", "-", "0.5", ";", "public", "static", "final", "double", "AUTO_RIGHT_SPIN_SPEED", "=", "-", "1", ";", "public", "static", "final", "double", "AUTO_LEFT_SPIN_SPEED", "=", "1", ";", "private", "Joystick", "joystickOne", ";", "private", "DigitalInput", "leftAutoSwitch", ";", "private", "DigitalInput", "rightAutoSwitch", ";", "private", "Timer", "autoTimer", ";", "private", "RobotDrive", "drivetrain", ";", "private", "Intake", "intake", ";", "private", "Jaguar", "leftDrive", ",", "rightDrive", ";", "private", "Victor", "intakeMotorOne", ",", "intakeMotorTwo", ";", "private", "Victor", "unobtaniumMotor", ";", "public", "void", "robotInit", "(", ")", "{", "joystickOne", "=", "new", "Joystick", "(", "1", ")", ";", "leftAutoSwitch", "=", "new", "DigitalInput", "(", "1", ")", ";", "rightAutoSwitch", "=", "new", "DigitalInput", "(", "2", ")", ";", "autoTimer", "=", "new", "Timer", "(", ")", ";", "leftDrive", "=", "new", "Jaguar", "(", "3", ")", ";", "rightDrive", "=", "new", "Jaguar", "(", "1", ")", ";", "intakeMotorOne", "=", "new", "Victor", "(", "2", ")", ";", "intakeMotorTwo", "=", "new", "Victor", "(", "4", ")", ";", "unobtaniumMotor", "=", "new", "Victor", "(", "5", ")", ";", "drivetrain", "=", "new", "RobotDrive", "(", "leftDrive", ",", "rightDrive", ")", ";", "drivetrain", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kFrontLeft", ",", "true", ")", ";", "drivetrain", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kRearLeft", ",", "true", ")", ";", "drivetrain", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kFrontRight", ",", "true", ")", ";", "drivetrain", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kRearRight", ",", "true", ")", ";", "intake", "=", "new", "Intake", "(", "joystickOne", ",", "intakeMotorOne", ",", "intakeMotorTwo", ",", "unobtaniumMotor", ")", ";", "}", "public", "void", "autonomousInit", "(", ")", "{", "autoTimer", ".", "start", "(", ")", ";", "}", "public", "void", "autonomousPeriodic", "(", ")", "{", "getWatchdog", "(", ")", ".", "feed", "(", ")", ";", "double", "elapsedTime", "=", "autoTimer", ".", "get", "(", ")", ";", "if", "(", "leftAutoSwitch", ".", "get", "(", ")", "==", "true", "&&", "rightAutoSwitch", ".", "get", "(", ")", "==", "false", ")", "{", "if", "(", "elapsedTime", "<=", "AUTO_CORNER_FORWARD_TIME", ")", "{", "drivetrain", ".", "arcadeDrive", "(", "AUTO_FORWARD_SPEED", ",", "0", ")", ";", "}", "else", "{", "drivetrain", ".", "arcadeDrive", "(", "0", ",", "AUTO_LEFT_SPIN_SPEED", ")", ";", "}", "}", "else", "if", "(", "leftAutoSwitch", ".", "get", "(", ")", "==", "false", "&&", "rightAutoSwitch", ".", "get", "(", ")", "==", "true", ")", "{", "if", "(", "elapsedTime", "<=", "AUTO_CORNER_FORWARD_TIME", ")", "{", "drivetrain", ".", "arcadeDrive", "(", "AUTO_FORWARD_SPEED", ",", "0", ")", ";", "}", "else", "{", "drivetrain", ".", "arcadeDrive", "(", "0", ",", "AUTO_RIGHT_SPIN_SPEED", ")", ";", "}", "}", "else", "{", "if", "(", "elapsedTime", "<", "AUTO_MIDDLE_FORWARD_TIME", ")", "{", "drivetrain", ".", "arcadeDrive", "(", "AUTO_FORWARD_SPEED", ",", "0", ")", ";", "}", "else", "{", "drivetrain", ".", "arcadeDrive", "(", "0", ",", "AUTO_LEFT_SPIN_SPEED", ")", ";", "}", "}", "}", "public", "void", "teleopInit", "(", ")", "{", "autoTimer", ".", "stop", "(", ")", ";", "}", "public", "void", "teleopPeriodic", "(", ")", "{", "getWatchdog", "(", ")", ".", "feed", "(", ")", ";", "drivetrain", ".", "arcadeDrive", "(", "joystickOne", ")", ";", "intake", ".", "doAction", "(", ")", ";", "}", "}", "</s>" ]
7,515
[ "<s>", "package", "edu", ".", "missdaisy", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "*", ";", "import", "java", ".", "util", ".", "TimerTask", ";", "public", "class", "Daisy2009", "extends", "IterativeRobot", "{", "private", "class", "FastPeriodicTask", "extends", "TimerTask", "{", "private", "Daisy2009", "instance", ";", "private", "boolean", "run100HzTasks", "=", "true", ";", "java", ".", "util", ".", "Timer", "timer", ";", "public", "FastPeriodicTask", "(", "Daisy2009", "instance", ")", "{", "this", ".", "instance", "=", "instance", ";", "timer", "=", "new", "java", ".", "util", ".", "Timer", "(", ")", ";", "timer", ".", "schedule", "(", "this", ",", "0L", ",", "5L", ")", ";", "}", "private", "void", "run200Hz", "(", ")", "{", "if", "(", "instance", ".", "rightStick", ".", "getRawButton", "(", "11", ")", ")", "{", "if", "(", "turretPID", ".", "isEnabled", "(", ")", ")", "{", "turretPID", ".", "reset", "(", ")", ";", "turretPID", ".", "enable", "(", ")", ";", "}", "turretMotor", ".", "set", "(", "-", "1", ")", ";", "turretEncoder", ".", "reset", "(", ")", ";", "}", "else", "if", "(", "instance", ".", "rightStick", ".", "getRawButton", "(", "10", ")", ")", "{", "if", "(", "turretPID", ".", "isEnabled", "(", ")", ")", "{", "turretPID", ".", "reset", "(", ")", ";", "turretPID", ".", "enable", "(", ")", ";", "}", "turretMotor", ".", "set", "(", "1", ")", ";", "turretEncoder", ".", "reset", "(", ")", ";", "}", "else", "if", "(", "instance", ".", "turretPID", ".", "isEnabled", "(", ")", ")", "{", "if", "(", "instance", ".", "turretPID", ".", "onTarget", "(", "0.5", ")", ")", "{", "instance", ".", "turretMotor", ".", "set", "(", "0", ")", ";", "instance", ".", "turretPID", ".", "calculate", "(", "instance", ".", "turretEncoder", ".", "getDistance", "(", ")", ",", "0", ")", ";", "}", "else", "{", "instance", ".", "turretMotor", ".", "set", "(", "instance", ".", "turretPID", ".", "calculate", "(", "instance", ".", "turretEncoder", ".", "getDistance", "(", ")", ",", "0", ")", ")", ";", "}", "}", "if", "(", "instance", ".", "leftDrivePID", ".", "isEnabled", "(", ")", ")", "{", "instance", ".", "leftDrive", ".", "set", "(", "instance", ".", "leftDrivePID", ".", "calculate", "(", "instance", ".", "leftDriveEncoder", ".", "getRate", "(", ")", ",", "0", ")", ")", ";", "}", "if", "(", "instance", ".", "rightDrivePID", ".", "isEnabled", "(", ")", ")", "{", "instance", ".", "rightDrive", ".", "set", "(", "instance", ".", "rightDrivePID", ".", "calculate", "(", "instance", ".", "rightDriveEncoder", ".", "getRate", "(", ")", ",", "0", ")", ")", ";", "}", "}", "private", "void", "run100Hz", "(", ")", "{", "}", "public", "void", "run", "(", ")", "{", "run200Hz", "(", ")", ";", "if", "(", "run100HzTasks", ")", "{", "run100Hz", "(", ")", ";", "}", "run100HzTasks", "=", "!", "run100HzTasks", ";", "}", "}", "final", "double", "kMaxSpeedInPerSec", "=", "120.0", ";", "boolean", "isTwoStick", ";", "boolean", "turretShooting", ";", "int", "autoState", ";", "double", "secondsInAutonomous", ";", "Jaguar", "leftDrive", ";", "Jaguar", "rightDrive", ";", "Jaguar", "turretMotor", ";", "Victor", "conveyorMotor", ";", "Victor", "brushSpinner1", ";", "Victor", "brushSpinner2", ";", "Compressor", "compressor", ";", "Solenoid", "hoodSolenoid", ";", "Solenoid", "gateSolenoid", ";", "Joystick", "leftStick", ";", "Joystick", "rightStick", ";", "Joystick", "operatorStick", ";", "Encoder", "turretEncoder", ";", "Encoder", "rightDriveEncoder", ";", "Encoder", "leftDriveEncoder", ";", "Gyro", "gyro", ";", "SynchronousPID", "turretPID", ";", "DigitalFilter", "turretFilter", ";", "SynchronousPID", "leftDrivePID", ";", "DigitalFilter", "leftDriveFilter", ";", "SynchronousPID", "rightDrivePID", ";", "DigitalFilter", "rightDriveFilter", ";", "FastPeriodicTask", "fastTask", ";", "public", "Daisy2009", "(", ")", "{", "leftDrive", "=", "new", "Jaguar", "(", "2", ")", ";", "rightDrive", "=", "new", "Jaguar", "(", "1", ")", ";", "turretMotor", "=", "new", "Jaguar", "(", "3", ")", ";", "conveyorMotor", "=", "new", "Victor", "(", "4", ")", ";", "brushSpinner1", "=", "new", "Victor", "(", "5", ")", ";", "brushSpinner2", "=", "new", "Victor", "(", "6", ")", ";", "compressor", "=", "new", "Compressor", "(", "14", ",", "1", ")", ";", "hoodSolenoid", "=", "new", "Solenoid", "(", "1", ")", ";", "gateSolenoid", "=", "new", "Solenoid", "(", "4", ")", ";", "operatorStick", "=", "new", "Joystick", "(", "3", ")", ";", "leftStick", "=", "new", "Joystick", "(", "4", ")", ";", "rightStick", "=", "new", "Joystick", "(", "1", ")", ";", "turretEncoder", "=", "new", "Encoder", "(", "10", ",", "11", ",", "false", ",", "Encoder", ".", "EncodingType", ".", "k4X", ")", ";", "turretEncoder", ".", "setDistancePerPulse", "(", "-", "0.633431085043988", ")", ";", "rightDriveEncoder", "=", "new", "Encoder", "(", "3", ",", "4", ",", "false", ",", "Encoder", ".", "EncodingType", ".", "k1X", ")", ";", "rightDriveEncoder", ".", "setDistancePerPulse", "(", "0.0764035333", ")", ";", "rightDriveEncoder", ".", "setMinRate", "(", "1.0", ")", ";", "leftDriveEncoder", "=", "new", "Encoder", "(", "1", ",", "2", ",", "false", ",", "Encoder", ".", "EncodingType", ".", "k1X", ")", ";", "leftDriveEncoder", ".", "setDistancePerPulse", "(", "0.0764035333", ")", ";", "leftDriveEncoder", ".", "setMinRate", "(", "1.0", ")", ";", "gyro", "=", "new", "Gyro", "(", "1", ")", ";", "gyro", ".", "setSensitivity", "(", ".005", ")", ";", "turretPID", "=", "new", "SynchronousPID", "(", ".15", ",", ".003", ",", ".15", ")", ";", "turretFilter", "=", "DigitalFilter", ".", "SinglePoleIIRFilter", "(", ".2", ")", ";", "rightDrivePID", "=", "new", "SynchronousPID", "(", ".015", ",", ".0006", ",", "0", ")", ";", "rightDriveFilter", "=", "DigitalFilter", ".", "SinglePoleIIRFilter", "(", ".1", ")", ";", "leftDrivePID", "=", "new", "SynchronousPID", "(", ".015", ",", ".0006", ",", "0", ")", ";", "leftDriveFilter", "=", "DigitalFilter", ".", "SinglePoleIIRFilter", "(", ".1", ")", ";", "fastTask", "=", "new", "FastPeriodicTask", "(", "this", ")", ";", "getWatchdog", "(", ")", ".", "setEnabled", "(", "true", ")", ";", "getWatchdog", "(", ")", ".", "setExpiration", "(", "kDefaultPeriod", ")", ";", "}", "public", "void", "robotInit", "(", ")", "{", "isTwoStick", "=", "false", ";", "turretShooting", "=", "true", ";", "leftDriveEncoder", ".", "start", "(", ")", ";", "rightDriveEncoder", ".", "start", "(", ")", ";", "turretEncoder", ".", "start", "(", ")", ";", "compressor", ".", "start", "(", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "println", "(", "DriverStationLCD", ".", "Line", ".", "kMain6", ",", "1", ",", "\"\"", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "updateLCD", "(", ")", ";", "}", "public", "void", "disabledPeriodic", "(", ")", "{", "getWatchdog", "(", ")", ".", "feed", "(", ")", ";", "if", "(", "leftStick", ".", "getRawButton", "(", "4", ")", ")", "{", "isTwoStick", "=", "true", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "println", "(", "DriverStationLCD", ".", "Line", ".", "kMain6", ",", "1", ",", "\"\"", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "updateLCD", "(", ")", ";", "}", "else", "if", "(", "leftStick", ".", "getRawButton", "(", "5", ")", ")", "{", "isTwoStick", "=", "false", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "println", "(", "DriverStationLCD", ".", "Line", ".", "kMain6", ",", "1", ",", "\"\"", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "updateLCD", "(", ")", ";", "}", "}", "public", "void", "disabledInit", "(", ")", "{", "turretPID", ".", "reset", "(", ")", ";", "leftDrivePID", ".", "reset", "(", ")", ";", "rightDrivePID", ".", "reset", "(", ")", ";", "}", "public", "void", "autonomousInit", "(", ")", "{", "autoState", "=", "0", ";", "secondsInAutonomous", "=", "0.0", ";", "gyro", ".", "reset", "(", ")", ";", "}", "public", "void", "teleopInit", "(", ")", "{", "turretPID", ".", "enable", "(", ")", ";", "turretPID", ".", "setSetpoint", "(", "0", ")", ";", "leftDrivePID", ".", "enable", "(", ")", ";", "leftDrivePID", ".", "setSetpoint", "(", "0", ")", ";", "rightDrivePID", ".", "enable", "(", ")", ";", "rightDrivePID", ".", "setSetpoint", "(", "0", ")", ";", "}", "public", "void", "autonomousPeriodic", "(", ")", "{", "getWatchdog", "(", ")", ".", "feed", "(", ")", ";", "secondsInAutonomous", "+=", ".02", ";", "drive", "(", "1.0", "*", "kMaxSpeedInPerSec", ",", "1.0", "*", "kMaxSpeedInPerSec", ")", ";", "}", "public", "void", "teleopPeriodic", "(", ")", "{", "getWatchdog", "(", ")", ".", "feed", "(", ")", ";", "double", "leftSpeed", ";", "double", "rightSpeed", ";", "if", "(", "leftStick", ".", "getRawButton", "(", "4", ")", ")", "{", "isTwoStick", "=", "true", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "println", "(", "DriverStationLCD", ".", "Line", ".", "kMain6", ",", "1", ",", "\"\"", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "updateLCD", "(", ")", ";", "}", "else", "if", "(", "leftStick", ".", "getRawButton", "(", "5", ")", ")", "{", "isTwoStick", "=", "false", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "println", "(", "DriverStationLCD", ".", "Line", ".", "kMain6", ",", "1", ",", "\"\"", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "updateLCD", "(", ")", ";", "}", "if", "(", "isTwoStick", ")", "{", "leftSpeed", "=", "-", "leftStick", ".", "getY", "(", ")", ";", "rightSpeed", "=", "-", "rightStick", ".", "getY", "(", ")", ";", "}", "else", "{", "leftSpeed", "=", "-", "leftStick", ".", "getY", "(", ")", "+", "leftStick", ".", "getX", "(", ")", ";", "if", "(", "leftSpeed", ">", "1.0", ")", "{", "leftSpeed", "=", "1.0", ";", "}", "else", "if", "(", "leftSpeed", "<", "-", "1.0", ")", "{", "leftSpeed", "=", "-", "1.0", ";", "}", "rightSpeed", "=", "-", "leftStick", ".", "getY", "(", ")", "-", "leftStick", ".", "getX", "(", ")", ";", "if", "(", "rightSpeed", ">", "1.0", ")", "{", "rightSpeed", "=", "1.0", ";", "}", "else", "if", "(", "rightSpeed", "<", "-", "1.0", ")", "{", "rightSpeed", "=", "-", "1.0", ";", "}", "}", "drive", "(", "leftSpeed", "*", "kMaxSpeedInPerSec", ",", "rightSpeed", "*", "kMaxSpeedInPerSec", ")", ";", "if", "(", "operatorStick", ".", "getTrigger", "(", ")", ")", "{", "brushSpinner1", ".", "set", "(", "-", "1", ")", ";", "brushSpinner2", ".", "set", "(", "-", "1", ")", ";", "}", "else", "{", "brushSpinner1", ".", "set", "(", "(", "operatorStick", ".", "getThrottle", "(", ")", "-", "1.0", ")", "/", "2.0", ")", ";", "brushSpinner2", ".", "set", "(", "(", "operatorStick", ".", "getThrottle", "(", ")", "-", "1.0", ")", "/", "2.0", ")", ";", "}", "if", "(", "operatorStick", ".", "getRawButton", "(", "2", ")", ")", "{", "conveyorMotor", ".", "set", "(", "-", "1", ")", ";", "brushSpinner1", ".", "set", "(", "1", ")", ";", "brushSpinner2", ".", "set", "(", "1", ")", ";", "}", "else", "if", "(", "!", "turretShooting", "&&", "turretPID", ".", "onTarget", "(", "7.0", ")", ")", "{", "conveyorMotor", ".", "set", "(", ".9", ")", ";", "}", "else", "if", "(", "operatorStick", ".", "getTrigger", "(", ")", ")", "{", "conveyorMotor", ".", "set", "(", "1", ")", ";", "}", "else", "{", "conveyorMotor", ".", "set", "(", "0", ")", ";", "}", "if", "(", "operatorStick", ".", "getTrigger", "(", ")", ")", "{", "gateSolenoid", ".", "set", "(", "true", ")", ";", "}", "else", "{", "gateSolenoid", ".", "set", "(", "false", ")", ";", "}", "if", "(", "operatorStick", ".", "getRawButton", "(", "7", ")", ")", "{", "turretShooting", "=", "true", ";", "}", "else", "if", "(", "operatorStick", ".", "getRawButton", "(", "11", ")", ")", "{", "turretShooting", "=", "false", ";", "}", "if", "(", "turretShooting", ")", "{", "turretPID", ".", "setSetpoint", "(", "turretFilter", ".", "calculate", "(", "operatorStick", ".", "getX", "(", ")", "*", "32.0", ")", ")", ";", "}", "else", "{", "turretPID", ".", "setSetpoint", "(", "180", ")", ";", "}", "}", "private", "void", "drive", "(", "double", "leftDesiredSpeed", ",", "double", "rightDesiredSpeed", ")", "{", "leftDrivePID", ".", "setSetpoint", "(", "leftDriveFilter", ".", "calculate", "(", "leftDesiredSpeed", ")", ")", ";", "rightDrivePID", ".", "setSetpoint", "(", "rightDriveFilter", ".", "calculate", "(", "rightDesiredSpeed", ")", ")", ";", "}", "}", "</s>" ]
7,516
[ "<s>", "package", "edu", ".", "missdaisy", ";", "import", "java", ".", "util", ".", "Vector", ";", "public", "class", "DigitalFilter", "{", "private", "class", "CircularBuffer", "{", "private", "double", "[", "]", "data", ";", "private", "int", "front", ";", "public", "CircularBuffer", "(", "int", "size", ")", "{", "data", "=", "new", "double", "[", "size", "]", ";", "front", "=", "0", ";", "}", "public", "void", "increment", "(", ")", "{", "front", "++", ";", "if", "(", "front", ">=", "data", ".", "length", ")", "{", "front", "=", "0", ";", "}", "}", "public", "void", "reset", "(", ")", "{", "for", "(", "int", "d", "=", "0", ";", "d", "<", "data", ".", "length", ";", "d", "++", ")", "{", "data", "[", "d", "]", "=", "0", ";", "}", "}", "public", "int", "size", "(", ")", "{", "return", "data", ".", "length", ";", "}", "public", "double", "elementAt", "(", "int", "position", ")", "{", "return", "data", "[", "(", "position", "+", "front", ")", "%", "data", ".", "length", "]", ";", "}", "public", "void", "setElementAt", "(", "double", "value", ",", "int", "position", ")", "{", "data", "[", "(", "position", "+", "front", ")", "%", "data", ".", "length", "]", "=", "value", ";", "}", "}", "private", "CircularBuffer", "inputs", ";", "private", "CircularBuffer", "outputs", ";", "private", "Vector", "inputGains", ";", "private", "Vector", "outputGains", ";", "public", "DigitalFilter", "(", "Vector", "inputGains", ",", "Vector", "outputGains", ")", "{", "this", ".", "inputGains", "=", "inputGains", ";", "this", ".", "outputGains", "=", "outputGains", ";", "inputs", "=", "new", "CircularBuffer", "(", "inputGains", ".", "size", "(", ")", ")", ";", "outputs", "=", "new", "CircularBuffer", "(", "outputGains", ".", "size", "(", ")", ")", ";", "}", "public", "static", "DigitalFilter", "SinglePoleIIRFilter", "(", "double", "gain", ")", "{", "Vector", "inputGain", "=", "new", "Vector", "(", ")", ";", "Vector", "outputGain", "=", "new", "Vector", "(", ")", ";", "inputGain", ".", "addElement", "(", "new", "Double", "(", "gain", ")", ")", ";", "outputGain", ".", "addElement", "(", "new", "Double", "(", "1.0f", "-", "gain", ")", ")", ";", "return", "new", "DigitalFilter", "(", "inputGain", ",", "outputGain", ")", ";", "}", "public", "static", "DigitalFilter", "MovingAverageFilter", "(", "int", "taps", ")", "{", "if", "(", "taps", "<", "1", ")", "{", "taps", "=", "1", ";", "}", "Double", "gain", "=", "new", "Double", "(", "1.0", "/", "taps", ")", ";", "Vector", "gains", "=", "new", "Vector", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "taps", ";", "i", "++", ")", "{", "gains", ".", "addElement", "(", "gain", ")", ";", "}", "return", "new", "DigitalFilter", "(", "gains", ",", "new", "Vector", "(", ")", ")", ";", "}", "public", "void", "reset", "(", ")", "{", "inputs", ".", "reset", "(", ")", ";", "outputs", ".", "reset", "(", ")", ";", "}", "public", "double", "calculate", "(", "double", "value", ")", "{", "double", "retVal", "=", "0.0", ";", "if", "(", "inputs", ".", "size", "(", ")", ">", "0", ")", "{", "inputs", ".", "increment", "(", ")", ";", "inputs", ".", "setElementAt", "(", "value", ",", "0", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "inputs", ".", "size", "(", ")", ";", "i", "++", ")", "{", "retVal", "+=", "inputs", ".", "elementAt", "(", "i", ")", "*", "(", "(", "Double", ")", "inputGains", ".", "elementAt", "(", "i", ")", ")", ".", "doubleValue", "(", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "outputs", ".", "size", "(", ")", ";", "i", "++", ")", "{", "retVal", "+=", "outputs", ".", "elementAt", "(", "i", ")", "*", "(", "(", "Double", ")", "outputGains", ".", "elementAt", "(", "i", ")", ")", ".", "doubleValue", "(", ")", ";", "}", "if", "(", "outputs", ".", "size", "(", ")", ">", "0", ")", "{", "outputs", ".", "increment", "(", ")", ";", "outputs", ".", "setElementAt", "(", "retVal", ",", "0", ")", ";", "}", "return", "retVal", ";", "}", "}", "</s>" ]
7,517
[ "<s>", "package", "edu", ".", "missdaisy", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "util", ".", "BoundaryException", ";", "public", "class", "SynchronousPID", "{", "private", "double", "m_P", ";", "private", "double", "m_I", ";", "private", "double", "m_D", ";", "private", "double", "m_maximumOutput", "=", "1.0", ";", "private", "double", "m_minimumOutput", "=", "-", "1.0", ";", "private", "double", "m_maximumInput", "=", "0.0", ";", "private", "double", "m_minimumInput", "=", "0.0", ";", "private", "boolean", "m_continuous", "=", "false", ";", "private", "boolean", "m_enabled", "=", "false", ";", "private", "double", "m_prevError", "=", "0.0", ";", "private", "double", "m_totalError", "=", "0.0", ";", "private", "double", "m_setpoint", "=", "0.0", ";", "private", "double", "m_error", "=", "0.0", ";", "private", "double", "m_result", "=", "0.0", ";", "private", "double", "m_last_input", "=", "0.0", ";", "public", "SynchronousPID", "(", "double", "Kp", ",", "double", "Ki", ",", "double", "Kd", ")", "{", "m_P", "=", "Kp", ";", "m_I", "=", "Ki", ";", "m_D", "=", "Kd", ";", "}", "public", "synchronized", "double", "calculate", "(", "double", "input", ",", "double", "time", ")", "{", "m_last_input", "=", "input", ";", "if", "(", "m_enabled", ")", "{", "m_error", "=", "m_setpoint", "-", "input", ";", "if", "(", "m_continuous", ")", "{", "if", "(", "Math", ".", "abs", "(", "m_error", ")", ">", "(", "m_maximumInput", "-", "m_minimumInput", ")", "/", "2", ")", "{", "if", "(", "m_error", ">", "0", ")", "{", "m_error", "=", "m_error", "-", "m_maximumInput", "+", "m_minimumInput", ";", "}", "else", "{", "m_error", "=", "m_error", "+", "m_maximumInput", "-", "m_minimumInput", ";", "}", "}", "}", "if", "(", "(", "(", "m_totalError", "+", "m_error", ")", "*", "m_I", "<", "m_maximumOutput", ")", "&&", "(", "(", "m_totalError", "+", "m_error", ")", "*", "m_I", ">", "m_minimumOutput", ")", ")", "{", "m_totalError", "+=", "m_error", ";", "}", "m_result", "=", "(", "m_P", "*", "m_error", "+", "m_I", "*", "m_totalError", "+", "m_D", "*", "(", "m_error", "-", "m_prevError", ")", ")", ";", "m_prevError", "=", "m_error", ";", "if", "(", "m_result", ">", "m_maximumOutput", ")", "{", "m_result", "=", "m_maximumOutput", ";", "}", "else", "if", "(", "m_result", "<", "m_minimumOutput", ")", "{", "m_result", "=", "m_minimumOutput", ";", "}", "return", "m_result", ";", "}", "return", "0", ";", "}", "public", "synchronized", "void", "setPID", "(", "double", "p", ",", "double", "i", ",", "double", "d", ")", "{", "m_P", "=", "p", ";", "m_I", "=", "i", ";", "m_D", "=", "d", ";", "}", "public", "double", "getP", "(", ")", "{", "return", "m_P", ";", "}", "public", "double", "getI", "(", ")", "{", "return", "m_I", ";", "}", "public", "synchronized", "double", "getD", "(", ")", "{", "return", "m_D", ";", "}", "public", "synchronized", "double", "get", "(", ")", "{", "return", "m_result", ";", "}", "public", "synchronized", "void", "setContinuous", "(", "boolean", "continuous", ")", "{", "m_continuous", "=", "continuous", ";", "}", "public", "synchronized", "void", "setContinuous", "(", ")", "{", "this", ".", "setContinuous", "(", "true", ")", ";", "}", "public", "synchronized", "void", "setInputRange", "(", "double", "minimumInput", ",", "double", "maximumInput", ")", "{", "if", "(", "minimumInput", ">", "maximumInput", ")", "{", "throw", "new", "BoundaryException", "(", "\"\"", ")", ";", "}", "m_minimumInput", "=", "minimumInput", ";", "m_maximumInput", "=", "maximumInput", ";", "setSetpoint", "(", "m_setpoint", ")", ";", "}", "public", "synchronized", "void", "setOutputRange", "(", "double", "minimumOutput", ",", "double", "maximumOutput", ")", "{", "if", "(", "minimumOutput", ">", "maximumOutput", ")", "{", "throw", "new", "BoundaryException", "(", "\"\"", ")", ";", "}", "m_minimumOutput", "=", "minimumOutput", ";", "m_maximumOutput", "=", "maximumOutput", ";", "}", "public", "synchronized", "void", "setSetpoint", "(", "double", "setpoint", ")", "{", "if", "(", "m_maximumInput", ">", "m_minimumInput", ")", "{", "if", "(", "setpoint", ">", "m_maximumInput", ")", "{", "m_setpoint", "=", "m_maximumInput", ";", "}", "else", "if", "(", "setpoint", "<", "m_minimumInput", ")", "{", "m_setpoint", "=", "m_minimumInput", ";", "}", "else", "{", "m_setpoint", "=", "setpoint", ";", "}", "}", "else", "{", "m_setpoint", "=", "setpoint", ";", "}", "}", "public", "synchronized", "double", "getSetpoint", "(", ")", "{", "return", "m_setpoint", ";", "}", "public", "synchronized", "double", "getError", "(", ")", "{", "return", "m_error", ";", "}", "public", "synchronized", "boolean", "onTarget", "(", "double", "tolerance", ")", "{", "if", "(", "Math", ".", "abs", "(", "m_last_input", "-", "m_setpoint", ")", "<", "tolerance", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "public", "synchronized", "void", "enable", "(", ")", "{", "m_enabled", "=", "true", ";", "}", "public", "synchronized", "void", "disable", "(", ")", "{", "m_result", "=", "0", ";", "m_enabled", "=", "false", ";", "}", "public", "synchronized", "boolean", "isEnabled", "(", ")", "{", "return", "m_enabled", ";", "}", "public", "synchronized", "void", "reset", "(", ")", "{", "disable", "(", ")", ";", "m_last_input", "=", "0", ";", "m_prevError", "=", "0", ";", "m_totalError", "=", "0", ";", "m_result", "=", "0", ";", "m_setpoint", "=", "0", ";", "}", "}", "</s>" ]
7,518
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "templates", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "IterativeRobot", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Joystick", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "RobotDrive", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Jaguar", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Victor", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "BeachbotEncoder", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "PIDController", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Gyro", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DriverStationLCD", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Dashboard", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "AnalogModule", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DigitalModule", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DriverStation", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Solenoid", ";", "public", "class", "Beachbot2009", "extends", "IterativeRobot", "{", "private", "RobotDrive", "drivetrain", ";", "private", "Jaguar", "turntable", ";", "private", "Victor", "pickup", ";", "private", "Victor", "dumperA", ";", "private", "Victor", "dumperB", ";", "private", "Joystick", "steeringWheel", ";", "private", "Joystick", "driverJoystick", ";", "private", "Joystick", "operatorJoystick", ";", "private", "BeachbotEncoder", "turntableEncoder", ";", "private", "PIDController", "turntableController", ";", "private", "Gyro", "baseGyro", ";", "private", "PIDController", "baseGyroController", ";", "private", "DriverStationLCD", "driverStationLCD", ";", "private", "int", "autoMode", "=", "0", ";", "static", "final", "int", "numAutoModes", "=", "2", ";", "private", "boolean", "prevButton4", "=", "false", ";", "private", "boolean", "prevButton5", "=", "false", ";", "private", "double", "autoTimer", "=", "0", ";", "public", "void", "robotInit", "(", ")", "{", "final", "double", "TURNTABLEWHEEL", "=", "1.625", ";", "final", "int", "TURNTABLEWHEELGEARRATIO", "=", "22", ";", "final", "int", "TURNTABLEENCODERGEARRATIO", "=", "2", ";", "final", "double", "TURNTABLEFUDGEFACTOR", "=", "1.06", ";", "final", "int", "TURNTABLETICKSPERREVOLUTION", "=", "128", ";", "final", "int", "DEGREESPERREVOLUTION", "=", "360", ";", "drivetrain", "=", "new", "RobotDrive", "(", "1", ",", "3", ")", ";", "turntable", "=", "new", "Jaguar", "(", "7", ")", ";", "pickup", "=", "new", "Victor", "(", "8", ")", ";", "dumperA", "=", "new", "Victor", "(", "9", ")", ";", "dumperB", "=", "new", "Victor", "(", "10", ")", ";", "steeringWheel", "=", "new", "Joystick", "(", "1", ")", ";", "driverJoystick", "=", "new", "Joystick", "(", "2", ")", ";", "operatorJoystick", "=", "new", "Joystick", "(", "3", ")", ";", "turntableEncoder", "=", "new", "BeachbotEncoder", "(", "9", ",", "10", ",", "false", ",", "BeachbotEncoder", ".", "EncodingType", ".", "k4X", ")", ";", "turntableController", "=", "new", "PIDController", "(", "0.03", ",", "0", ",", "0", ",", "turntableEncoder", ",", "turntable", ",", "0.005", ")", ";", "baseGyro", "=", "new", "Gyro", "(", "1", ")", ";", "baseGyroController", "=", "new", "PIDController", "(", "0.03", ",", "0", ",", "0", ",", "baseGyro", ",", "turntable", ",", "0.005", ")", ";", "turntableEncoder", ".", "setDistancePerPulse", "(", "DEGREESPERREVOLUTION", "/", "(", "TURNTABLEWHEELGEARRATIO", "/", "TURNTABLEWHEEL", "*", "TURNTABLEFUDGEFACTOR", "*", "TURNTABLEENCODERGEARRATIO", "*", "TURNTABLETICKSPERREVOLUTION", ")", ")", ";", "turntableEncoder", ".", "start", "(", ")", ";", "turntableController", ".", "setSetpoint", "(", "0", ")", ";", "turntableController", ".", "setOutputRange", "(", "-", "0.8", ",", "0.8", ")", ";", "baseGyro", ".", "setSensitivity", "(", "0.006", ")", ";", "baseGyro", ".", "reset", "(", ")", ";", "baseGyroController", ".", "setSetpoint", "(", "0", ")", ";", "baseGyroController", ".", "setOutputRange", "(", "-", "0.8", ",", "0.8", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "println", "(", "DriverStationLCD", ".", "Line", ".", "kMain6", ",", "1", ",", "\"\"", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "println", "(", "DriverStationLCD", ".", "Line", ".", "kUser2", ",", "1", ",", "\"\"", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "println", "(", "DriverStationLCD", ".", "Line", ".", "kUser3", ",", "1", ",", "\"\"", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "println", "(", "DriverStationLCD", ".", "Line", ".", "kUser4", ",", "1", ",", "\"\"", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "println", "(", "DriverStationLCD", ".", "Line", ".", "kUser5", ",", "1", ",", "\"\"", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "updateLCD", "(", ")", ";", "}", "public", "void", "autonomousInit", "(", ")", "{", "turntableController", ".", "disable", "(", ")", ";", "baseGyroController", ".", "enable", "(", ")", ";", "drivetrain", ".", "arcadeDrive", "(", "0", ",", "0", ")", ";", "pickup", ".", "set", "(", "0", ")", ";", "dumperA", ".", "set", "(", "0", ")", ";", "dumperB", ".", "set", "(", "0", ")", ";", "autoTimer", "=", "0", ";", "}", "public", "void", "autonomousPeriodic", "(", ")", "{", "if", "(", "autoMode", "==", "1", ")", "{", "if", "(", "autoTimer", "<", "0.02", ")", "{", "baseGyroController", ".", "setSetpoint", "(", "50", ")", ";", "drivetrain", ".", "arcadeDrive", "(", "1", ",", "0", ")", ";", "}", "else", "if", "(", "autoTimer", ">=", "0.02", "&&", "autoTimer", "<=", "1.5", ")", "{", "}", "else", "if", "(", "autoTimer", ">=", "1.5", "&&", "autoTimer", "<=", "10.5", ")", "{", "drivetrain", ".", "arcadeDrive", "(", "0.5", ",", "0", ",", "false", ")", ";", "}", "else", "{", "baseGyroController", ".", "setSetpoint", "(", "0", ")", ";", "drivetrain", ".", "arcadeDrive", "(", "0", ",", "0", ")", ";", "}", "}", "autoTimer", "+=", "1", "/", "getLoopsPerSec", "(", ")", ";", "sendDashboardData", "(", ")", ";", "}", "public", "void", "disabledPeriodic", "(", ")", "{", "if", "(", "steeringWheel", ".", "getRawButton", "(", "4", ")", "&&", "prevButton4", ")", "autoMode", "++", ";", "if", "(", "steeringWheel", ".", "getRawButton", "(", "5", ")", "&&", "prevButton5", ")", "autoMode", "++", ";", "prevButton4", "=", "steeringWheel", ".", "getRawButton", "(", "4", ")", ";", "prevButton5", "=", "steeringWheel", ".", "getRawButton", "(", "5", ")", ";", "if", "(", "autoMode", "<", "0", ")", "autoMode", "=", "numAutoModes", "-", "1", ";", "if", "(", "autoMode", ">=", "numAutoModes", ")", "autoMode", "=", "0", ";", "if", "(", "autoMode", "==", "0", ")", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "println", "(", "DriverStationLCD", ".", "Line", ".", "kMain6", ",", "1", ",", "\"\"", ")", ";", "else", "if", "(", "autoMode", "==", "1", ")", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "println", "(", "DriverStationLCD", ".", "Line", ".", "kMain6", ",", "1", ",", "\"\"", ")", ";", "DriverStationLCD", ".", "getInstance", "(", ")", ".", "updateLCD", "(", ")", ";", "sendDashboardData", "(", ")", ";", "}", "public", "void", "teleopInit", "(", ")", "{", "baseGyroController", ".", "disable", "(", ")", ";", "turntableController", ".", "enable", "(", ")", ";", "drivetrain", ".", "arcadeDrive", "(", "0", ",", "0", ")", ";", "pickup", ".", "set", "(", "0", ")", ";", "dumperA", ".", "set", "(", "0", ")", ";", "dumperB", ".", "set", "(", "0", ")", ";", "}", "public", "void", "teleopPeriodic", "(", ")", "{", "drivetrain", ".", "arcadeDrive", "(", "driverJoystick", ",", "false", ")", ";", "turntableController", ".", "setSetpoint", "(", "steeringWheel", ".", "getX", "(", ")", "*", "135", ")", ";", "if", "(", "operatorJoystick", ".", "getRawButton", "(", "4", ")", "||", "driverJoystick", ".", "getRawButton", "(", "4", ")", ")", "{", "pickup", ".", "set", "(", "1.0", ")", ";", "}", "else", "if", "(", "operatorJoystick", ".", "getRawButton", "(", "5", ")", "||", "driverJoystick", ".", "getRawButton", "(", "5", ")", ")", "{", "pickup", ".", "set", "(", "-", "1.0", ")", ";", "}", "else", "{", "pickup", ".", "set", "(", "0", ")", ";", "}", "if", "(", "operatorJoystick", ".", "getRawButton", "(", "1", ")", "||", "driverJoystick", ".", "getRawButton", "(", "1", ")", ")", "{", "dumperA", ".", "set", "(", "1.0", ")", ";", "dumperB", ".", "set", "(", "1.0", ")", ";", "}", "else", "if", "(", "operatorJoystick", ".", "getRawButton", "(", "3", ")", "||", "driverJoystick", ".", "getRawButton", "(", "3", ")", ")", "{", "dumperA", ".", "set", "(", "-", "1.0", ")", ";", "dumperB", ".", "set", "(", "-", "1.0", ")", ";", "}", "else", "{", "dumperA", ".", "set", "(", "0", ")", ";", "dumperB", ".", "set", "(", "0", ")", ";", "}", "if", "(", "driverJoystick", ".", "getRawButton", "(", "2", ")", ")", "{", "turntableEncoder", ".", "reset", "(", ")", ";", "}", "sendDashboardData", "(", ")", ";", "}", "private", "void", "buildPIDDashboard", "(", "Dashboard", "dashboard", ",", "PIDController", "pid", ")", "{", "double", "setpoint", "=", "0", ";", "double", "output", "=", "0", ";", "boolean", "stable", "=", "false", ";", "double", "p", "=", "0", ";", "double", "i", "=", "0", ";", "double", "d", "=", "0", ";", "if", "(", "pid", "!=", "null", ")", "{", "setpoint", "=", "pid", ".", "getSetpoint", "(", ")", ";", "output", "=", "pid", ".", "get", "(", ")", ";", "stable", "=", "pid", ".", "onTarget", "(", ")", ";", "p", "=", "pid", ".", "getP", "(", ")", ";", "i", "=", "pid", ".", "getI", "(", ")", ";", "d", "=", "pid", ".", "getD", "(", ")", ";", "}", "dashboard", ".", "addCluster", "(", ")", ";", "{", "dashboard", ".", "addDouble", "(", "setpoint", ")", ";", "dashboard", ".", "addDouble", "(", "output", ")", ";", "dashboard", ".", "addBoolean", "(", "false", ")", ";", "dashboard", ".", "addDouble", "(", "10", ")", ";", "dashboard", ".", "addDouble", "(", "11", ")", ";", "dashboard", ".", "addDouble", "(", "12", ")", ";", "dashboard", ".", "addBoolean", "(", "stable", ")", ";", "dashboard", ".", "addCluster", "(", ")", ";", "{", "dashboard", ".", "addCluster", "(", ")", ";", "{", "dashboard", ".", "addDouble", "(", "p", ")", ";", "dashboard", ".", "addDouble", "(", "i", ")", ";", "dashboard", ".", "addDouble", "(", "d", ")", ";", "}", "dashboard", ".", "finalizeCluster", "(", ")", ";", "dashboard", ".", "addDouble", "(", "13", ")", ";", "dashboard", ".", "addDouble", "(", "14", ")", ";", "}", "dashboard", ".", "finalizeCluster", "(", ")", ";", "}", "dashboard", ".", "finalizeCluster", "(", ")", ";", "}", "private", "void", "buildCameraDashboard", "(", "Dashboard", "dashboard", ")", "{", "dashboard", ".", "addCluster", "(", ")", ";", "{", "dashboard", ".", "addCluster", "(", ")", ";", "{", "dashboard", ".", "addInt", "(", "1", ")", ";", "dashboard", ".", "addInt", "(", "2", ")", ";", "dashboard", ".", "addInt", "(", "3", ")", ";", "dashboard", ".", "addInt", "(", "4", ")", ";", "}", "dashboard", ".", "finalizeCluster", "(", ")", ";", "dashboard", ".", "addDouble", "(", "5", ")", ";", "dashboard", ".", "addArray", "(", ")", ";", "{", "dashboard", ".", "addDouble", "(", "6", ")", ";", "}", "dashboard", ".", "finalizeArray", "(", ")", ";", "dashboard", ".", "addShort", "(", "(", "short", ")", "0", ")", ";", "}", "dashboard", ".", "finalizeCluster", "(", ")", ";", "}", "public", "void", "sendDashboardData", "(", ")", "{", "Dashboard", "dash", "=", "DriverStation", ".", "getInstance", "(", ")", ".", "getDashboardPacker", "(", ")", ";", "dash", ".", "addCluster", "(", ")", ";", "{", "dash", ".", "addCluster", "(", ")", ";", "{", "dash", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "8", ";", "i", "++", ")", "{", "dash", ".", "addFloat", "(", "(", "float", ")", "AnalogModule", ".", "getInstance", "(", "1", ")", ".", "getAverageVoltage", "(", "i", ")", ")", ";", "}", "}", "dash", ".", "finalizeCluster", "(", ")", ";", "dash", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "8", ";", "i", "++", ")", "{", "dash", ".", "addFloat", "(", "(", "float", ")", "AnalogModule", ".", "getInstance", "(", "2", ")", ".", "getAverageVoltage", "(", "i", ")", ")", ";", "}", "}", "dash", ".", "finalizeCluster", "(", ")", ";", "}", "dash", ".", "finalizeCluster", "(", ")", ";", "dash", ".", "addCluster", "(", ")", ";", "{", "dash", ".", "addCluster", "(", ")", ";", "{", "dash", ".", "addCluster", "(", ")", ";", "{", "int", "module", "=", "4", ";", "dash", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "dash", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "dash", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getAllDIO", "(", ")", ")", ";", "dash", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getDIODirection", "(", ")", ")", ";", "dash", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "10", ";", "i", "++", ")", "{", "dash", ".", "addByte", "(", "(", "byte", ")", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getPWM", "(", "i", ")", ")", ";", "}", "}", "dash", ".", "finalizeCluster", "(", ")", ";", "}", "dash", ".", "finalizeCluster", "(", ")", ";", "}", "dash", ".", "finalizeCluster", "(", ")", ";", "dash", ".", "addCluster", "(", ")", ";", "{", "dash", ".", "addCluster", "(", ")", ";", "{", "int", "module", "=", "6", ";", "dash", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "dash", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayReverse", "(", ")", ")", ";", "dash", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getAllDIO", "(", ")", ")", ";", "dash", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getDIODirection", "(", ")", ")", ";", "dash", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "10", ";", "i", "++", ")", "{", "dash", ".", "addByte", "(", "(", "byte", ")", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getPWM", "(", "i", ")", ")", ";", "}", "}", "dash", ".", "finalizeCluster", "(", ")", ";", "}", "dash", ".", "finalizeCluster", "(", ")", ";", "}", "dash", ".", "finalizeCluster", "(", ")", ";", "}", "dash", ".", "finalizeCluster", "(", ")", ";", "dash", ".", "addByte", "(", "Solenoid", ".", "getAll", "(", ")", ")", ";", "}", "dash", ".", "finalizeCluster", "(", ")", ";", "buildPIDDashboard", "(", "dash", ",", "null", ")", ";", "buildPIDDashboard", "(", "dash", ",", "null", ")", ";", "buildPIDDashboard", "(", "dash", ",", "turntableController", ")", ";", "buildPIDDashboard", "(", "dash", ",", "null", ")", ";", "buildPIDDashboard", "(", "dash", ",", "null", ")", ";", "buildCameraDashboard", "(", "dash", ")", ";", "dash", ".", "commit", "(", ")", ";", "}", "}", "</s>" ]
7,519
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ";", "public", "class", "BeachbotEncoder", "extends", "Encoder", "implements", "PIDSource", "{", "public", "BeachbotEncoder", "(", "final", "int", "aSlot", ",", "final", "int", "aChannel", ",", "final", "int", "bSlot", ",", "final", "int", "bChannel", ",", "boolean", "reverseDirection", ")", "{", "super", "(", "aSlot", ",", "aChannel", ",", "bSlot", ",", "bChannel", ",", "reverseDirection", ")", ";", "}", "public", "BeachbotEncoder", "(", "final", "int", "aSlot", ",", "final", "int", "aChannel", ",", "final", "int", "bSlot", ",", "final", "int", "bChannel", ")", "{", "this", "(", "aSlot", ",", "aChannel", ",", "bSlot", ",", "bChannel", ",", "false", ")", ";", "}", "public", "BeachbotEncoder", "(", "final", "int", "aSlot", ",", "final", "int", "aChannel", ",", "final", "int", "bSlot", ",", "final", "int", "bChannel", ",", "boolean", "reverseDirection", ",", "final", "EncodingType", "encodingType", ")", "{", "super", "(", "aSlot", ",", "aChannel", ",", "bSlot", ",", "bChannel", ",", "reverseDirection", ",", "encodingType", ")", ";", "}", "public", "BeachbotEncoder", "(", "final", "int", "aSlot", ",", "final", "int", "aChannel", ",", "final", "int", "bSlot", ",", "final", "int", "bChannel", ",", "final", "int", "indexSlot", ",", "final", "int", "indexChannel", ",", "boolean", "reverseDirection", ")", "{", "super", "(", "aSlot", ",", "aChannel", ",", "bSlot", ",", "bChannel", ",", "indexSlot", ",", "indexChannel", ",", "reverseDirection", ")", ";", "}", "public", "BeachbotEncoder", "(", "final", "int", "aSlot", ",", "final", "int", "aChannel", ",", "final", "int", "bSlot", ",", "final", "int", "bChannel", ",", "final", "int", "indexSlot", ",", "final", "int", "indexChannel", ")", "{", "this", "(", "aSlot", ",", "aChannel", ",", "bSlot", ",", "bChannel", ",", "indexSlot", ",", "indexChannel", ",", "false", ")", ";", "}", "public", "BeachbotEncoder", "(", "final", "int", "aChannel", ",", "final", "int", "bChannel", ",", "boolean", "reverseDirection", ")", "{", "super", "(", "aChannel", ",", "bChannel", ",", "reverseDirection", ")", ";", "}", "public", "BeachbotEncoder", "(", "final", "int", "aChannel", ",", "final", "int", "bChannel", ")", "{", "this", "(", "aChannel", ",", "bChannel", ",", "false", ")", ";", "}", "public", "BeachbotEncoder", "(", "final", "int", "aChannel", ",", "final", "int", "bChannel", ",", "boolean", "reverseDirection", ",", "final", "EncodingType", "encodingType", ")", "{", "super", "(", "aChannel", ",", "bChannel", ",", "reverseDirection", ",", "encodingType", ")", ";", "}", "public", "BeachbotEncoder", "(", "final", "int", "aChannel", ",", "final", "int", "bChannel", ",", "final", "int", "indexChannel", ",", "boolean", "reverseDirection", ")", "{", "super", "(", "aChannel", ",", "bChannel", ",", "indexChannel", ",", "reverseDirection", ")", ";", "}", "public", "BeachbotEncoder", "(", "final", "int", "aChannel", ",", "final", "int", "bChannel", ",", "final", "int", "indexChannel", ")", "{", "this", "(", "aChannel", ",", "bChannel", ",", "indexChannel", ",", "false", ")", ";", "}", "public", "BeachbotEncoder", "(", "DigitalSource", "aSource", ",", "DigitalSource", "bSource", ",", "boolean", "reverseDirection", ")", "{", "super", "(", "aSource", ",", "bSource", ",", "reverseDirection", ")", ";", "}", "public", "BeachbotEncoder", "(", "DigitalSource", "aSource", ",", "DigitalSource", "bSource", ")", "{", "this", "(", "aSource", ",", "bSource", ",", "false", ")", ";", "}", "public", "BeachbotEncoder", "(", "DigitalSource", "aSource", ",", "DigitalSource", "bSource", ",", "boolean", "reverseDirection", ",", "final", "EncodingType", "encodingType", ")", "{", "super", "(", "aSource", ",", "bSource", ",", "reverseDirection", ",", "encodingType", ")", ";", "}", "public", "BeachbotEncoder", "(", "DigitalSource", "aSource", ",", "DigitalSource", "bSource", ",", "DigitalSource", "indexSource", ",", "boolean", "reverseDirection", ")", "{", "super", "(", "aSource", ",", "bSource", ",", "indexSource", ",", "reverseDirection", ")", ";", "}", "public", "BeachbotEncoder", "(", "DigitalSource", "aSource", ",", "DigitalSource", "bSource", ",", "DigitalSource", "indexSource", ")", "{", "this", "(", "aSource", ",", "bSource", ",", "indexSource", ",", "false", ")", ";", "}", "public", "double", "pidGet", "(", ")", "{", "return", "getDistance", "(", ")", ";", "}", "}", "</s>" ]
7,520
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "samples", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Gyro", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "IterativeRobot", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Joystick", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "PIDController", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "PIDOutput", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "RobotDrive", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Timer", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Watchdog", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "camera", ".", "AxisCamera", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "camera", ".", "AxisCameraException", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "ColorImage", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "NIVisionException", ";", "public", "class", "CircleTrackerDemo", "extends", "IterativeRobot", "{", "double", "kScoreThreshold", "=", ".01", ";", "AxisCamera", "cam", ";", "Gyro", "gyro", "=", "new", "Gyro", "(", "1", ")", ";", "RobotDrive", "drive", "=", "new", "RobotDrive", "(", "1", ",", "2", ")", ";", "{", "drive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kRearLeft", ",", "true", ")", ";", "drive", ".", "setInvertedMotor", "(", "RobotDrive", ".", "MotorType", ".", "kRearRight", ",", "true", ")", ";", "}", "Joystick", "js", "=", "new", "Joystick", "(", "1", ")", ";", "PIDController", "turnController", "=", "new", "PIDController", "(", ".08", ",", "0.0", ",", "0.5", ",", "gyro", ",", "new", "PIDOutput", "(", ")", "{", "public", "void", "pidWrite", "(", "double", "output", ")", "{", "drive", ".", "arcadeDrive", "(", "0", ",", "output", ")", ";", "}", "}", ",", ".005", ")", ";", "TrackerDashboard", "trackerDashboard", "=", "new", "TrackerDashboard", "(", ")", ";", "public", "void", "robotInit", "(", ")", "{", "Timer", ".", "delay", "(", "10.0", ")", ";", "getWatchdog", "(", ")", ".", "setExpiration", "(", ".75", ")", ";", "cam", "=", "AxisCamera", ".", "getInstance", "(", ")", ";", "cam", ".", "writeResolution", "(", "AxisCamera", ".", "ResolutionT", ".", "k320x240", ")", ";", "cam", ".", "writeBrightness", "(", "0", ")", ";", "gyro", ".", "setSensitivity", "(", ".007", ")", ";", "turnController", ".", "setInputRange", "(", "-", "360.0", ",", "360.0", ")", ";", "turnController", ".", "setTolerance", "(", "1", "/", "90.", "*", "100", ")", ";", "turnController", ".", "disable", "(", ")", ";", "}", "public", "void", "autonomousPeriodic", "(", ")", "{", "}", "public", "void", "disabledPeriodic", "(", ")", "{", "}", "public", "void", "teleopInit", "(", ")", "{", "}", "boolean", "lastTrigger", "=", "false", ";", "public", "void", "teleopPeriodic", "(", ")", "{", "long", "startTime", "=", "Timer", ".", "getUsClock", "(", ")", ";", "if", "(", "!", "js", ".", "getTrigger", "(", ")", ")", "{", "if", "(", "lastTrigger", ")", "{", "turnController", ".", "disable", "(", ")", ";", "}", "lastTrigger", "=", "false", ";", "drive", ".", "arcadeDrive", "(", "js", ")", ";", "}", "else", "{", "if", "(", "!", "lastTrigger", ")", "{", "turnController", ".", "enable", "(", ")", ";", "turnController", ".", "setSetpoint", "(", "gyro", ".", "pidGet", "(", ")", ")", ";", "}", "lastTrigger", "=", "true", ";", "ColorImage", "image", "=", "null", ";", "try", "{", "if", "(", "cam", ".", "freshImage", "(", ")", ")", "{", "double", "gyroAngle", "=", "gyro", ".", "pidGet", "(", ")", ";", "image", "=", "cam", ".", "getImage", "(", ")", ";", "Thread", ".", "yield", "(", ")", ";", "Target", "[", "]", "targets", "=", "Target", ".", "findCircularTargets", "(", "image", ")", ";", "Thread", ".", "yield", "(", ")", ";", "if", "(", "targets", ".", "length", "==", "0", "||", "targets", "[", "0", "]", ".", "m_score", "<", "kScoreThreshold", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "Target", "[", "]", "newTargets", "=", "new", "Target", "[", "targets", ".", "length", "+", "1", "]", ";", "newTargets", "[", "0", "]", "=", "new", "Target", "(", ")", ";", "newTargets", "[", "0", "]", ".", "m_majorRadius", "=", "0", ";", "newTargets", "[", "0", "]", ".", "m_minorRadius", "=", "0", ";", "newTargets", "[", "0", "]", ".", "m_score", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "targets", ".", "length", ";", "i", "++", ")", "{", "newTargets", "[", "i", "+", "1", "]", "=", "targets", "[", "i", "]", ";", "}", "trackerDashboard", ".", "updateVisionDashboard", "(", "0.0", ",", "gyro", ".", "getAngle", "(", ")", ",", "0.0", ",", "0.0", ",", "newTargets", ")", ";", "}", "else", "{", "System", ".", "out", ".", "println", "(", "targets", "[", "0", "]", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "targets", "[", "0", "]", ".", "getHorizontalAngle", "(", ")", ")", ";", "turnController", ".", "setSetpoint", "(", "gyroAngle", "+", "targets", "[", "0", "]", ".", "getHorizontalAngle", "(", ")", ")", ";", "trackerDashboard", ".", "updateVisionDashboard", "(", "0.0", ",", "gyro", ".", "getAngle", "(", ")", ",", "0.0", ",", "targets", "[", "0", "]", ".", "m_xPos", "/", "targets", "[", "0", "]", ".", "m_xMax", ",", "targets", ")", ";", "}", "}", "}", "catch", "(", "NIVisionException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "AxisCameraException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "try", "{", "if", "(", "image", "!=", "null", ")", "{", "image", ".", "free", "(", ")", ";", "}", "}", "catch", "(", "NIVisionException", "ex", ")", "{", "}", "}", "System", ".", "out", ".", "println", "(", "\"Time", ":", "\"", "+", "(", "Timer", ".", "getUsClock", "(", ")", "-", "startTime", ")", "/", "1000000.0", ")", ";", "System", ".", "out", ".", "println", "(", "\"Gyro", "Angle:", "\"", "+", "gyro", ".", "getAngle", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
7,521
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "samples", ";", "import", "com", ".", "sun", ".", "squawk", ".", "platform", ".", "posix", ".", "natives", ".", "Time", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "AnalogModule", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Dashboard", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DigitalModule", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DriverStation", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Solenoid", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "Timer", ";", "import", "java", ".", "util", ".", "TimerTask", ";", "public", "class", "TrackerDashboard", "{", "public", "TrackerDashboard", "(", ")", "{", "Timer", "dashTimer", "=", "new", "Timer", "(", ")", ";", "dashTimer", ".", "schedule", "(", "new", "TimerTask", "(", ")", "{", "public", "void", "run", "(", ")", "{", "updateDefaultDashboard", "(", ")", ";", "}", "}", ",", "0", ",", "100", ")", ";", "}", "void", "updateDefaultDashboard", "(", ")", "{", "Dashboard", "lowDashData", "=", "DriverStation", ".", "getInstance", "(", ")", ".", "getDashboardPackerLow", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "8", ";", "i", "++", ")", "{", "lowDashData", ".", "addFloat", "(", "(", "float", ")", "AnalogModule", ".", "getInstance", "(", "1", ")", ".", "getAverageVoltage", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "8", ";", "i", "++", ")", "{", "lowDashData", ".", "addFloat", "(", "(", "float", ")", "AnalogModule", ".", "getInstance", "(", "2", ")", ".", "getAverageVoltage", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "int", "module", "=", "4", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getAllDIO", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getDIODirection", "(", ")", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "10", ";", "i", "++", ")", "{", "lowDashData", ".", "addByte", "(", "(", "byte", ")", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getPWM", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "int", "module", "=", "6", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayReverse", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getAllDIO", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getDIODirection", "(", ")", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "10", ";", "i", "++", ")", "{", "lowDashData", ".", "addByte", "(", "(", "byte", ")", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getPWM", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addByte", "(", "Solenoid", ".", "getAll", "(", ")", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "commit", "(", ")", ";", "}", "Date", "time", "=", "new", "Date", "(", ")", ";", "public", "void", "updateVisionDashboard", "(", "double", "joyStickX", ",", "double", "gyroAngle", ",", "double", "gyroRate", ",", "double", "targetX", ",", "Target", "[", "]", "targets", ")", "{", "Dashboard", "highDashData", "=", "DriverStation", ".", "getInstance", "(", ")", ".", "getDashboardPackerHigh", "(", ")", ";", "highDashData", ".", "addCluster", "(", ")", ";", "{", "highDashData", ".", "addCluster", "(", ")", ";", "{", "highDashData", ".", "addDouble", "(", "joyStickX", ")", ";", "highDashData", ".", "addDouble", "(", "(", "(", "gyroAngle", "+", "360.0", "+", "180.0", ")", "%", "360.0", ")", "-", "180.0", ")", ";", "highDashData", ".", "addDouble", "(", "gyroRate", ")", ";", "highDashData", ".", "addDouble", "(", "targetX", ")", ";", "}", "highDashData", ".", "finalizeCluster", "(", ")", ";", "highDashData", ".", "addCluster", "(", ")", ";", "{", "highDashData", ".", "addArray", "(", ")", ";", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "targets", ".", "length", ";", "i", "++", ")", "{", "highDashData", ".", "addCluster", "(", ")", ";", "{", "highDashData", ".", "addDouble", "(", "targets", "[", "i", "]", ".", "m_score", ")", ";", "highDashData", ".", "addCluster", "(", ")", ";", "{", "highDashData", ".", "addCluster", "(", ")", ";", "{", "highDashData", ".", "addFloat", "(", "(", "float", ")", "(", "targets", "[", "i", "]", ".", "m_xPos", "/", "targets", "[", "i", "]", ".", "m_xMax", ")", ")", ";", "highDashData", ".", "addFloat", "(", "(", "float", ")", "targets", "[", "i", "]", ".", "m_yPos", ")", ";", "}", "highDashData", ".", "finalizeCluster", "(", ")", ";", "highDashData", ".", "addDouble", "(", "targets", "[", "i", "]", ".", "m_rotation", ")", ";", "highDashData", ".", "addDouble", "(", "targets", "[", "i", "]", ".", "m_majorRadius", ")", ";", "highDashData", ".", "addDouble", "(", "targets", "[", "i", "]", ".", "m_minorRadius", ")", ";", "highDashData", ".", "addDouble", "(", "targets", "[", "i", "]", ".", "m_rawScore", ")", ";", "}", "highDashData", ".", "finalizeCluster", "(", ")", ";", "}", "highDashData", ".", "finalizeCluster", "(", ")", ";", "}", "}", "highDashData", ".", "finalizeArray", "(", ")", ";", "highDashData", ".", "addInt", "(", "(", "int", ")", "time", ".", "getTime", "(", ")", ")", ";", "}", "highDashData", ".", "finalizeCluster", "(", ")", ";", "}", "highDashData", ".", "finalizeCluster", "(", ")", ";", "highDashData", ".", "commit", "(", ")", ";", "}", "}", "</s>" ]
7,522
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "samples", ";", "import", "com", ".", "sun", ".", "squawk", ".", "util", ".", "MathUtils", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "ColorImage", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "CurveOptions", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "EllipseDescriptor", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "EllipseMatch", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "MonoImage", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "NIVisionException", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "ShapeDetectionOptions", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "util", ".", "SortedVector", ";", "public", "class", "Target", "{", "public", "double", "m_majorRadius", ";", "public", "double", "m_minorRadius", ";", "public", "double", "m_xPos", ";", "public", "double", "m_yPos", ";", "public", "double", "m_score", ";", "public", "double", "m_rawScore", ";", "public", "double", "m_rotation", ";", "public", "boolean", "m_bothFound", ";", "public", "double", "m_xMax", ";", "Target", "(", ")", "{", "}", "public", "double", "getHorizontalAngle", "(", ")", "{", "double", "x", "=", "m_xPos", ";", "x", "=", "(", "x", "*", "9.0", "/", "m_xMax", ")", ";", "x", "=", "MathUtils", ".", "atan2", "(", "x", ",", "20.0", ")", ";", "x", "=", "x", "*", "180.0", "/", "Math", ".", "PI", ";", "return", "x", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "\"", "Pos", "x:", "\"", "+", "m_xPos", "+", "\"", "y:", "\"", "+", "m_yPos", "+", "\"n\"", "+", "\"\"", "+", "m_majorRadius", "+", "\"", "minor:", "\"", "+", "m_minorRadius", "+", "\"n\"", "+", "\"", "Rotation:", "\"", "+", "m_rotation", "+", "\"", "Score:", "\"", "+", "m_score", "+", "\"\"", "+", "m_bothFound", "+", "\"n\"", ";", "}", "static", "EllipseDescriptor", "ellipseDescriptor", "=", "new", "EllipseDescriptor", "(", "3", ",", "200", ",", "3", ",", "100", ")", ";", "static", "CurveOptions", "curveOptions", "=", "new", "CurveOptions", "(", "0", ",", "40", ",", "1", ",", "25", ",", "15", ",", "15", ",", "10", ",", "1", ",", "0", ")", ";", "static", "ShapeDetectionOptions", "shapeOptions", "=", "new", "ShapeDetectionOptions", "(", "ShapeDetectionOptions", ".", "IMAQ_GEOMETRIC_MATCH_SHIFT_INVARIANT", ",", "0", ",", "0", ",", "75", ",", "125", ",", "500", ")", ";", "public", "static", "Target", "[", "]", "findCircularTargets", "(", "ColorImage", "image", ")", "throws", "NIVisionException", "{", "int", "width", "=", "image", ".", "getWidth", "(", ")", ";", "int", "height", "=", "image", ".", "getHeight", "(", ")", ";", "MonoImage", "lumPlane", "=", "image", ".", "getLuminancePlane", "(", ")", ";", "EllipseMatch", "[", "]", "results", "=", "lumPlane", ".", "detectEllipses", "(", "ellipseDescriptor", ",", "curveOptions", ",", "shapeOptions", ",", "null", ")", ";", "lumPlane", ".", "free", "(", ")", ";", "SortedVector", ".", "Comparator", "targetComparator", "=", "new", "SortedVector", ".", "Comparator", "(", ")", "{", "public", "int", "compare", "(", "Object", "target1", ",", "Object", "target2", ")", "{", "if", "(", "(", "(", "Target", ")", "target1", ")", ".", "m_score", ">", "(", "(", "Target", ")", "target2", ")", ".", "m_score", ")", "{", "return", "1", ";", "}", "if", "(", "(", "(", "Target", ")", "target1", ")", ".", "m_score", "<", "(", "(", "Target", ")", "target2", ")", ".", "m_score", ")", "{", "return", "-", "1", ";", "}", "return", "0", ";", "}", "}", ";", "SortedVector", "sortedTargetList", "=", "new", "SortedVector", "(", "targetComparator", ")", ";", "SortedVector", "combinedTargetList", "=", "new", "SortedVector", "(", "targetComparator", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "results", ".", "length", ";", "i", "++", ")", "{", "Target", "target", "=", "new", "Target", "(", ")", ";", "target", ".", "m_rawScore", "=", "results", "[", "i", "]", ".", "m_score", ";", "target", ".", "m_score", "=", "(", "results", "[", "i", "]", ".", "m_majorRadius", "*", "results", "[", "i", "]", ".", "m_minorRadius", ")", "/", "(", "1001", "-", "results", "[", "i", "]", ".", "m_score", ")", "/", "(", "height", "*", "width", ")", "*", "100", ";", "target", ".", "m_majorRadius", "=", "results", "[", "i", "]", ".", "m_majorRadius", "/", "height", ";", "target", ".", "m_minorRadius", "=", "results", "[", "i", "]", ".", "m_minorRadius", "/", "height", ";", "target", ".", "m_xPos", "=", "(", "2.0", "*", "results", "[", "i", "]", ".", "m_xPos", "-", "width", ")", "/", "height", ";", "target", ".", "m_yPos", "=", "(", "2.0", "*", "results", "[", "i", "]", ".", "m_yPos", "-", "height", ")", "/", "height", ";", "target", ".", "m_rotation", "=", "results", "[", "i", "]", ".", "m_rotation", ";", "target", ".", "m_bothFound", "=", "false", ";", "target", ".", "m_xMax", "=", "(", "double", ")", "width", "/", "height", ";", "sortedTargetList", ".", "addElement", "(", "target", ")", ";", "}", "while", "(", "!", "sortedTargetList", ".", "isEmpty", "(", ")", ")", "{", "Target", "firstTarget", "=", "(", "Target", ")", "sortedTargetList", ".", "elementAt", "(", "0", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "sortedTargetList", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Target", "otherTarget", "=", "(", "Target", ")", "sortedTargetList", ".", "elementAt", "(", "i", ")", ";", "if", "(", "(", "Math", ".", "abs", "(", "firstTarget", ".", "m_xPos", "-", "otherTarget", ".", "m_xPos", ")", "<", "Math", ".", "min", "(", "firstTarget", ".", "m_minorRadius", ",", "otherTarget", ".", "m_minorRadius", ")", ")", "&&", "(", "Math", ".", "abs", "(", "firstTarget", ".", "m_yPos", "-", "otherTarget", ".", "m_yPos", ")", "<", "Math", ".", "min", "(", "firstTarget", ".", "m_majorRadius", ",", "otherTarget", ".", "m_majorRadius", ")", ")", ")", "{", "firstTarget", ".", "m_xPos", "=", "(", "firstTarget", ".", "m_xPos", "+", "otherTarget", ".", "m_xPos", ")", "/", "2", ";", "firstTarget", ".", "m_yPos", "=", "(", "firstTarget", ".", "m_yPos", "+", "otherTarget", ".", "m_yPos", ")", "/", "2", ";", "firstTarget", ".", "m_rawScore", "+=", "otherTarget", ".", "m_rawScore", ";", "firstTarget", ".", "m_score", "+=", "otherTarget", ".", "m_score", ";", "firstTarget", ".", "m_majorRadius", "=", "Math", ".", "max", "(", "firstTarget", ".", "m_majorRadius", ",", "otherTarget", ".", "m_majorRadius", ")", ";", "firstTarget", ".", "m_minorRadius", "=", "Math", ".", "max", "(", "firstTarget", ".", "m_minorRadius", ",", "otherTarget", ".", "m_minorRadius", ")", ";", "firstTarget", ".", "m_bothFound", "=", "true", ";", "sortedTargetList", ".", "removeElementAt", "(", "i", ")", ";", "break", ";", "}", "}", "sortedTargetList", ".", "removeElementAt", "(", "0", ")", ";", "combinedTargetList", ".", "addElement", "(", "firstTarget", ")", ";", "}", "Target", "[", "]", "toReturn", "=", "new", "Target", "[", "combinedTargetList", ".", "size", "(", ")", "]", ";", "combinedTargetList", ".", "copyInto", "(", "toReturn", ")", ";", "return", "toReturn", ";", "}", "}", "</s>" ]
7,523
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "trackerdemo", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "SimpleRobot", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Timer", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "camera", ".", "AxisCamera", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "camera", ".", "AxisCameraException", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "BinaryImage", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "ColorImage", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "NIVisionException", ";", "public", "class", "TrackerDemo", "extends", "SimpleRobot", "{", "public", "void", "autonomous", "(", ")", "{", "}", "public", "void", "operatorControl", "(", ")", "{", "Tracker", "tracker", "=", "Tracker", ".", "getInstance", "(", ")", ";", "AxisCamera", ".", "getInstance", "(", ")", ".", "writeCompression", "(", "0", ")", ";", "AxisCamera", ".", "getInstance", "(", ")", ".", "writeBrightness", "(", "10", ")", ";", "AxisCamera", ".", "getInstance", "(", ")", ".", "writeResolution", "(", "AxisCamera", ".", "ResolutionT", ".", "k160x120", ")", ";", "Timer", ".", "delay", "(", "5.0", ")", ";", "Timer", "timer", "=", "new", "Timer", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "timer", ".", "start", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "100", ";", "i", "++", ")", "{", "try", "{", "AxisCamera", ".", "getInstance", "(", ")", ".", "freshImage", "(", ")", ";", "AxisCamera", ".", "getInstance", "(", ")", ".", "getImage", "(", ")", ".", "free", "(", ")", ";", "Timer", ".", "delay", "(", ".001", ")", ";", "}", "catch", "(", "NIVisionException", "e", ")", "{", "}", "catch", "(", "AxisCameraException", "e", ")", "{", "}", "}", "System", ".", "out", ".", "println", "(", "\"Took", "\"", "+", "timer", ".", "get", "(", ")", "+", "\"\"", ")", ";", "timer", ".", "reset", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "timer", ".", "start", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "100", ";", "i", "++", ")", "{", "while", "(", "!", "AxisCamera", ".", "getInstance", "(", ")", ".", "freshImage", "(", ")", ")", "{", "Timer", ".", "delay", "(", ".001", ")", ";", "}", "try", "{", "AxisCamera", ".", "getInstance", "(", ")", ".", "getImage", "(", ")", ".", "free", "(", ")", ";", "}", "catch", "(", "AxisCameraException", "e", ")", "{", "}", "catch", "(", "NIVisionException", "e", ")", "{", "}", "Timer", ".", "delay", "(", ".001", ")", ";", "}", "System", ".", "out", ".", "println", "(", "\"Took", "\"", "+", "timer", ".", "get", "(", ")", "+", "\"\"", ")", ";", "timer", ".", "reset", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "timer", ".", "start", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "100", ";", "i", "++", ")", "{", "try", "{", "AxisCamera", ".", "getInstance", "(", ")", ".", "freshImage", "(", ")", ";", "ColorImage", "image", "=", "AxisCamera", ".", "getInstance", "(", ")", ".", "getImage", "(", ")", ";", "image", ".", "thresholdHSL", "(", "10", ",", "20", ",", "30", ",", "40", ",", "50", ",", "60", ")", ".", "free", "(", ")", ";", "image", ".", "thresholdHSL", "(", "50", ",", "60", ",", "30", ",", "40", ",", "10", ",", "20", ")", ".", "free", "(", ")", ";", "image", ".", "free", "(", ")", ";", "Timer", ".", "delay", "(", ".001", ")", ";", "}", "catch", "(", "AxisCameraException", "e", ")", "{", "}", "catch", "(", "NIVisionException", "e", ")", "{", "}", "}", "System", ".", "out", ".", "println", "(", "\"Took", "\"", "+", "timer", ".", "get", "(", ")", "+", "\"\"", ")", ";", "timer", ".", "reset", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "timer", ".", "start", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "100", ";", "i", "++", ")", "{", "AxisCamera", ".", "getInstance", "(", ")", ".", "freshImage", "(", ")", ";", "try", "{", "tracker", ".", "getTarget", "(", ")", ";", "}", "catch", "(", "AxisCameraException", "e", ")", "{", "}", "catch", "(", "NIVisionException", "e", ")", "{", "}", "Timer", ".", "delay", "(", ".001", ")", ";", "}", "System", ".", "out", ".", "println", "(", "\"Took", "\"", "+", "timer", ".", "get", "(", ")", "+", "\"\"", ")", ";", "timer", ".", "reset", "(", ")", ";", "while", "(", "true", ")", "{", "if", "(", "AxisCamera", ".", "getInstance", "(", ")", ".", "freshImage", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"Fresh", "image\"", ")", ";", "}", "Target", "target", "=", "null", ";", "try", "{", "target", "=", "tracker", ".", "getTarget", "(", ")", ";", "}", "catch", "(", "AxisCameraException", "e", ")", "{", "}", "catch", "(", "NIVisionException", "e", ")", "{", "}", "if", "(", "target", "!=", "null", ")", "{", "System", ".", "out", ".", "println", "(", "target", "+", "\"", "in", "\"", "+", "timer", ".", "get", "(", ")", "+", "\"", "seconds\"", ")", ";", "}", "else", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "timer", ".", "get", "(", ")", "+", "\"", "seconds\"", ")", ";", "}", "timer", ".", "reset", "(", ")", ";", "Timer", ".", "delay", "(", ".001", ")", ";", "}", "}", "}", "</s>" ]
7,524
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "trackerdemo", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "BinaryImage", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "ColorImage", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "NIVisionException", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "ParticleAnalysisReport", ";", "public", "class", "Target", "{", "private", "static", "final", "double", "FRC_PARTICLE_TO_IMAGE_PERCENT", "=", ".0001", ";", "private", "static", "final", "double", "FRC_SIZE_FACTOR", "=", "3.0", ";", "private", "static", "final", "double", "FRC_MAX_IMAGE_SEPARATION", "=", "20.0", ";", "private", "static", "final", "double", "FRC_ALIGNMENT_SCALE", "=", "3.0", ";", "final", "ParticleAnalysisReport", "firstParticle", ";", "final", "ParticleAnalysisReport", "secondParticle", ";", "Target", "(", "ParticleAnalysisReport", "firstParticle", ",", "ParticleAnalysisReport", "secondParticle", ")", "{", "this", ".", "firstParticle", "=", "firstParticle", ";", "this", ".", "secondParticle", "=", "secondParticle", ";", "}", "public", "static", "class", "Position", "{", "public", "final", "int", "value", ";", "protected", "static", "final", "int", "above_val", "=", "0", ";", "protected", "static", "final", "int", "below_val", "=", "1", ";", "protected", "static", "final", "int", "right_val", "=", "2", ";", "protected", "static", "final", "int", "left_val", "=", "3", ";", "public", "static", "final", "Position", "above", "=", "new", "Position", "(", "above_val", ")", ";", "public", "static", "final", "Position", "bellow", "=", "new", "Position", "(", "below_val", ")", ";", "public", "static", "final", "Position", "right", "=", "new", "Position", "(", "right_val", ")", ";", "public", "static", "final", "Position", "left", "=", "new", "Position", "(", "left_val", ")", ";", "private", "Position", "(", "int", "value", ")", "{", "this", ".", "value", "=", "value", ";", "}", "}", "public", "static", "class", "Threshold", "{", "int", "plane1Low", ";", "int", "plane1High", ";", "int", "plane2Low", ";", "int", "plane2High", ";", "int", "plane3Low", ";", "int", "plane3High", ";", "public", "Threshold", "(", "int", "plane1Low", ",", "int", "plane1High", ",", "int", "plane2Low", ",", "int", "plane2High", ",", "int", "plane3Low", ",", "int", "plane3High", ")", "{", "this", ".", "plane1Low", "=", "plane1Low", ";", "this", ".", "plane1High", "=", "plane1High", ";", "this", ".", "plane2Low", "=", "plane2Low", ";", "this", ".", "plane2High", "=", "plane2High", ";", "this", ".", "plane3Low", "=", "plane3Low", ";", "this", ".", "plane3High", "=", "plane3High", ";", "}", "}", "private", "static", "boolean", "aligned", "(", "int", "center1", ",", "int", "center2", ",", "int", "dimension1", ",", "int", "dimension2", ")", "{", "double", "averageWidth", "=", "(", "dimension1", "+", "dimension2", ")", "/", "2.0", ";", "averageWidth", "*=", "FRC_ALIGNMENT_SCALE", ";", "int", "centerDiff", "=", "Math", ".", "abs", "(", "center1", "-", "center2", ")", ";", "if", "(", "centerDiff", "<", "averageWidth", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "private", "static", "boolean", "adjacent", "(", "int", "value1", ",", "int", "value2", ")", "{", "if", "(", "Math", ".", "abs", "(", "value1", "-", "value2", ")", "<=", "FRC_MAX_IMAGE_SEPARATION", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "private", "static", "boolean", "sizesRelative", "(", "double", "area1", ",", "double", "area2", ")", "{", "if", "(", "(", "area2", "<", "(", "area1", "*", "FRC_SIZE_FACTOR", ")", ")", "&&", "(", "area1", "<", "(", "area2", "*", "FRC_SIZE_FACTOR", ")", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "public", "static", "Target", "getTarget", "(", "ColorImage", "image", ",", "Position", "position", ",", "Threshold", "firstThreshold", ",", "Threshold", "secondThreshold", ")", "throws", "NIVisionException", "{", "BinaryImage", "firstColor", "=", "image", ".", "thresholdHSL", "(", "firstThreshold", ".", "plane1Low", ",", "firstThreshold", ".", "plane1High", ",", "firstThreshold", ".", "plane2Low", ",", "firstThreshold", ".", "plane2High", ",", "firstThreshold", ".", "plane3Low", ",", "firstThreshold", ".", "plane3High", ")", ";", "BinaryImage", "secondColor", "=", "image", ".", "thresholdHSL", "(", "secondThreshold", ".", "plane1Low", ",", "secondThreshold", ".", "plane1High", ",", "secondThreshold", ".", "plane2Low", ",", "secondThreshold", ".", "plane2High", ",", "secondThreshold", ".", "plane3Low", ",", "secondThreshold", ".", "plane3High", ")", ";", "ParticleAnalysisReport", "[", "]", "firstColorHits", "=", "firstColor", ".", "getOrderedParticleAnalysisReports", "(", "3", ")", ";", "ParticleAnalysisReport", "[", "]", "secondColorHits", "=", "secondColor", ".", "getOrderedParticleAnalysisReports", "(", "3", ")", ";", "firstColor", ".", "free", "(", ")", ";", "secondColor", ".", "free", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "firstColorHits", ".", "length", ";", "i", "++", ")", "{", "ParticleAnalysisReport", "firstTrackReport", "=", "firstColorHits", "[", "i", "]", ";", "if", "(", "firstTrackReport", ".", "particleToImagePercent", "<", "FRC_PARTICLE_TO_IMAGE_PERCENT", ")", "{", "break", ";", "}", "for", "(", "int", "j", "=", "0", ";", "j", "<", "secondColorHits", ".", "length", ";", "j", "++", ")", "{", "ParticleAnalysisReport", "secondTrackReport", "=", "secondColorHits", "[", "j", "]", ";", "if", "(", "secondTrackReport", ".", "particleToImagePercent", "<", "FRC_PARTICLE_TO_IMAGE_PERCENT", ")", "{", "break", ";", "}", "switch", "(", "position", ".", "value", ")", "{", "case", "Position", ".", "above_val", ":", "if", "(", "secondTrackReport", ".", "center_mass_y", "<", "firstTrackReport", ".", "center_mass_y", ")", "{", "if", "(", "aligned", "(", "firstTrackReport", ".", "center_mass_x", ",", "secondTrackReport", ".", "center_mass_x", ",", "firstTrackReport", ".", "boundingRectWidth", ",", "secondTrackReport", ".", "boundingRectWidth", ")", "&&", "adjacent", "(", "firstTrackReport", ".", "boundingRectTop", ",", "(", "secondTrackReport", ".", "boundingRectTop", "+", "secondTrackReport", ".", "boundingRectHeight", ")", ")", "&&", "sizesRelative", "(", "firstTrackReport", ".", "particleArea", ",", "secondTrackReport", ".", "particleArea", ")", ")", "{", "return", "new", "Target", "(", "firstTrackReport", ",", "secondTrackReport", ")", ";", "}", "}", "break", ";", "case", "Position", ".", "below_val", ":", "if", "(", "secondTrackReport", ".", "center_mass_y", ">", "firstTrackReport", ".", "center_mass_y", ")", "{", "if", "(", "aligned", "(", "firstTrackReport", ".", "center_mass_x", ",", "secondTrackReport", ".", "center_mass_x", ",", "firstTrackReport", ".", "boundingRectWidth", ",", "secondTrackReport", ".", "boundingRectWidth", ")", "&&", "adjacent", "(", "(", "firstTrackReport", ".", "boundingRectTop", "+", "firstTrackReport", ".", "boundingRectHeight", ")", ",", "secondTrackReport", ".", "boundingRectTop", ")", ")", "{", "return", "new", "Target", "(", "firstTrackReport", ",", "secondTrackReport", ")", ";", "}", "}", "break", ";", "case", "Position", ".", "left_val", ":", "if", "(", "secondTrackReport", ".", "center_mass_x", "<", "firstTrackReport", ".", "center_mass_x", ")", "{", "if", "(", "aligned", "(", "firstTrackReport", ".", "center_mass_y", ",", "secondTrackReport", ".", "center_mass_y", ",", "firstTrackReport", ".", "boundingRectWidth", ",", "secondTrackReport", ".", "boundingRectWidth", ")", "&&", "adjacent", "(", "firstTrackReport", ".", "boundingRectLeft", ",", "(", "secondTrackReport", ".", "boundingRectLeft", "+", "secondTrackReport", ".", "boundingRectWidth", ")", ")", ")", "{", "return", "new", "Target", "(", "firstTrackReport", ",", "secondTrackReport", ")", ";", "}", "}", "break", ";", "case", "Position", ".", "right_val", ":", "if", "(", "secondTrackReport", ".", "center_mass_x", ">", "firstTrackReport", ".", "center_mass_x", ")", "{", "if", "(", "aligned", "(", "firstTrackReport", ".", "center_mass_y", ",", "secondTrackReport", ".", "center_mass_y", ",", "firstTrackReport", ".", "boundingRectWidth", ",", "secondTrackReport", ".", "boundingRectWidth", ")", "&&", "adjacent", "(", "(", "firstTrackReport", ".", "boundingRectLeft", "+", "secondTrackReport", ".", "boundingRectWidth", ")", ",", "secondTrackReport", ".", "boundingRectLeft", ")", ")", "{", "return", "new", "Target", "(", "firstTrackReport", ",", "secondTrackReport", ")", ";", "}", "}", "break", ";", "}", "}", "}", "return", "null", ";", "}", "public", "double", "getXPosition", "(", ")", "{", "return", "(", "firstParticle", ".", "center_mass_x_normalized", "*", "firstParticle", ".", "particleToImagePercent", "+", "secondParticle", ".", "center_mass_x_normalized", "*", "secondParticle", ".", "particleToImagePercent", ")", "/", "getSize", "(", ")", ";", "}", "public", "double", "getYPosition", "(", ")", "{", "return", "(", "firstParticle", ".", "center_mass_y_normalized", "*", "firstParticle", ".", "particleToImagePercent", "+", "secondParticle", ".", "center_mass_y_normalized", "*", "secondParticle", ".", "particleToImagePercent", ")", "/", "getSize", "(", ")", ";", "}", "public", "double", "getSize", "(", ")", "{", "return", "firstParticle", ".", "particleToImagePercent", "+", "secondParticle", ".", "particleToImagePercent", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "\"Target", "at", "(", "\"", "+", "getXPosition", "(", ")", "+", "\"", ",", "\"", "+", "getYPosition", "(", ")", "+", "\"", ")", "of", "size", "\"", "+", "getSize", "(", ")", ";", "}", "}", "</s>" ]
7,525
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "trackerdemo", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Timer", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "camera", ".", "AxisCamera", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "camera", ".", "AxisCameraException", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "ColorImage", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "image", ".", "NIVisionException", ";", "public", "class", "Tracker", "{", "static", "Tracker", "instance", "=", "null", ";", "Target", ".", "Threshold", "firstColor", "=", "new", "Target", ".", "Threshold", "(", "215", ",", "245", ",", "42", ",", "255", ",", "7", ",", "255", ")", ";", "Target", ".", "Threshold", "secondColor", "=", "new", "Target", ".", "Threshold", "(", "88", ",", "128", ",", "42", ",", "255", ",", "7", ",", "255", ")", ";", "Target", ".", "Position", "position", "=", "Target", ".", "Position", ".", "above", ";", "AxisCamera", "camera", "=", "AxisCamera", ".", "getInstance", "(", ")", ";", "public", "static", "Tracker", "getInstance", "(", ")", "{", "if", "(", "instance", "==", "null", ")", "{", "instance", "=", "new", "Tracker", "(", ")", ";", "}", "return", "instance", ";", "}", "public", "void", "setFirstColorThresholds", "(", "int", "lowerHue", ",", "int", "upperHue", ",", "int", "lowerSaturation", ",", "int", "upperSaturation", ",", "int", "lowerLuminance", ",", "int", "upperLuminance", ")", "{", "firstColor", "=", "new", "Target", ".", "Threshold", "(", "lowerHue", ",", "upperHue", ",", "lowerSaturation", ",", "upperSaturation", ",", "lowerLuminance", ",", "upperLuminance", ")", ";", "}", "public", "void", "setSecondColorThresholds", "(", "int", "lowerHue", ",", "int", "upperHue", ",", "int", "lowerSaturation", ",", "int", "upperSaturation", ",", "int", "lowerLuminance", ",", "int", "upperLuminance", ")", "{", "secondColor", "=", "new", "Target", ".", "Threshold", "(", "lowerHue", ",", "upperHue", ",", "lowerSaturation", ",", "upperSaturation", ",", "lowerLuminance", ",", "upperLuminance", ")", ";", "}", "public", "Target", "getTarget", "(", ")", "throws", "NIVisionException", ",", "AxisCameraException", "{", "while", "(", "true", ")", "{", "ColorImage", "image", "=", "camera", ".", "getImage", "(", ")", ";", "try", "{", "return", "Target", ".", "getTarget", "(", "image", ",", "position", ",", "firstColor", ",", "secondColor", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "if", "(", "image", "!=", "null", ")", "{", "image", ".", "free", "(", ")", ";", "}", "image", "=", "null", ";", "}", "Timer", ".", "delay", "(", ".001", ")", ";", "}", "}", "}", "</s>" ]
7,526
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "samples", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DriverStation", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DriverStationEnhancedIO", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "IterativeRobot", ";", "import", "java", ".", "util", ".", "Timer", ";", "import", "java", ".", "util", ".", "TimerTask", ";", "public", "class", "EnhancedIOSample", "extends", "IterativeRobot", "{", "public", "void", "robotInit", "(", ")", "{", "}", "DriverStationEnhancedIO", "enhancedIO", "=", "DriverStation", ".", "getInstance", "(", ")", ".", "getEnhancedIO", "(", ")", ";", "public", "void", "disabledPeriodic", "(", ")", "{", "}", "public", "void", "autonomousPeriodic", "(", ")", "{", "}", "byte", "ledCounter", "=", "0", ";", "Timer", "timer", ";", "public", "void", "teleopInit", "(", ")", "{", "timer", "=", "new", "Timer", "(", ")", ";", "timer", ".", "schedule", "(", "new", "TimerTask", "(", ")", "{", "public", "void", "run", "(", ")", "{", "printData", "(", ")", ";", "}", "}", ",", "0", ",", "500", ")", ";", "}", "public", "void", "autonomousInit", "(", ")", "{", "if", "(", "timer", "!=", "null", ")", "{", "timer", ".", "cancel", "(", ")", ";", "}", "}", "public", "void", "disabledInit", "(", ")", "{", "if", "(", "timer", "!=", "null", ")", "{", "timer", ".", "cancel", "(", ")", ";", "}", "}", "boolean", "ledAccelerometer", "=", "false", ";", "public", "synchronized", "void", "teleopPeriodic", "(", ")", "{", "try", "{", "double", "touchSlider", "=", "enhancedIO", ".", "getTouchSlider", "(", ")", ";", "if", "(", "Math", ".", "abs", "(", "enhancedIO", ".", "getAcceleration", "(", "DriverStationEnhancedIO", ".", "tAccelChannel", ".", "kAccelX", ")", ")", ">", "2.0", "||", "Math", ".", "abs", "(", "enhancedIO", ".", "getAcceleration", "(", "DriverStationEnhancedIO", ".", "tAccelChannel", ".", "kAccelY", ")", ")", ">", "2.0", ")", "{", "ledCounter", "=", "0", ";", "}", "if", "(", "Math", ".", "abs", "(", "enhancedIO", ".", "getAcceleration", "(", "DriverStationEnhancedIO", ".", "tAccelChannel", ".", "kAccelZ", ")", ")", ">", "2.0", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "ledAccelerometer", "=", "!", "ledAccelerometer", ";", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Timer", ".", "delay", "(", "1.0", ")", ";", "}", "if", "(", "touchSlider", "==", "-", "1.0", ")", "{", "if", "(", "ledAccelerometer", ")", "{", "double", "accel", "=", "-", "enhancedIO", ".", "getAcceleration", "(", "DriverStationEnhancedIO", ".", "tAccelChannel", ".", "kAccelX", ")", ";", "if", "(", "accel", ">", "1.0", ")", "{", "accel", "=", "1.0", ";", "}", "if", "(", "accel", "<", "-", "1.0", ")", "{", "accel", "=", "-", "1.0", ";", "}", "enhancedIO", ".", "setLEDs", "(", "(", "byte", ")", "(", "0x01", "<<", "(", "int", ")", "(", "(", "accel", "+", "1.0", ")", "*", "3.99", ")", ")", ")", ";", "}", "else", "{", "enhancedIO", ".", "setLEDs", "(", "ledCounter", ")", ";", "}", "}", "else", "{", "enhancedIO", ".", "setLEDs", "(", "(", "byte", ")", "(", "0x01", "<<", "(", "int", ")", "(", "touchSlider", "*", "7.99", ")", ")", ")", ";", "}", "}", "catch", "(", "DriverStationEnhancedIO", ".", "EnhancedIOException", "ex", ")", "{", "System", ".", "out", ".", "println", "(", "ex", ".", "getMessage", "(", ")", ")", ";", "}", "}", "public", "synchronized", "void", "printData", "(", ")", "{", "try", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "enhancedIO", ".", "getAcceleration", "(", "DriverStationEnhancedIO", ".", "tAccelChannel", ".", "kAccelX", ")", "+", "\"", "\"", "+", "enhancedIO", ".", "getAcceleration", "(", "DriverStationEnhancedIO", ".", "tAccelChannel", ".", "kAccelY", ")", "+", "\"", "\"", "+", "enhancedIO", ".", "getAcceleration", "(", "DriverStationEnhancedIO", ".", "tAccelChannel", ".", "kAccelZ", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "enhancedIO", ".", "getTouchSlider", "(", ")", ")", ";", "ledCounter", "++", ";", "}", "catch", "(", "DriverStationEnhancedIO", ".", "EnhancedIOException", "ex", ")", "{", "System", ".", "out", ".", "println", "(", "ex", ".", "getMessage", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
7,527
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "defaultCode", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DriverStation", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "IterativeRobot", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Joystick", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "RobotDrive", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Solenoid", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Timer", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Watchdog", ";", "public", "class", "DefaultRobot", "extends", "IterativeRobot", "{", "RobotDrive", "m_robotDrive", ";", "DriverStation", "m_ds", ";", "int", "m_priorPacketNumber", ";", "int", "m_dsPacketsReceivedInCurrentSecond", ";", "Joystick", "m_rightStick", ";", "Joystick", "m_leftStick", ";", "static", "final", "int", "NUM_JOYSTICK_BUTTONS", "=", "16", ";", "boolean", "[", "]", "m_rightStickButtonState", "=", "new", "boolean", "[", "(", "NUM_JOYSTICK_BUTTONS", "+", "1", ")", "]", ";", "boolean", "[", "]", "m_leftStickButtonState", "=", "new", "boolean", "[", "(", "NUM_JOYSTICK_BUTTONS", "+", "1", ")", "]", ";", "static", "final", "int", "NUM_SOLENOIDS", "=", "8", ";", "Solenoid", "[", "]", "m_solenoids", "=", "new", "Solenoid", "[", "NUM_SOLENOIDS", "]", ";", "static", "final", "int", "UNINITIALIZED_DRIVE", "=", "0", ";", "static", "final", "int", "ARCADE_DRIVE", "=", "1", ";", "static", "final", "int", "TANK_DRIVE", "=", "2", ";", "int", "m_driveMode", ";", "int", "m_autoPeriodicLoops", ";", "int", "m_disabledPeriodicLoops", ";", "int", "m_telePeriodicLoops", ";", "public", "DefaultRobot", "(", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "m_robotDrive", "=", "new", "RobotDrive", "(", "1", ",", "3", ",", "2", ",", "4", ")", ";", "m_ds", "=", "DriverStation", ".", "getInstance", "(", ")", ";", "m_priorPacketNumber", "=", "0", ";", "m_dsPacketsReceivedInCurrentSecond", "=", "0", ";", "m_rightStick", "=", "new", "Joystick", "(", "1", ")", ";", "m_leftStick", "=", "new", "Joystick", "(", "2", ")", ";", "int", "buttonNum", "=", "1", ";", "for", "(", "buttonNum", "=", "1", ";", "buttonNum", "<=", "NUM_JOYSTICK_BUTTONS", ";", "buttonNum", "++", ")", "{", "m_rightStickButtonState", "[", "buttonNum", "]", "=", "false", ";", "m_leftStickButtonState", "[", "buttonNum", "]", "=", "false", ";", "}", "int", "solenoidNum", "=", "1", ";", "for", "(", "solenoidNum", "=", "0", ";", "solenoidNum", "<", "NUM_SOLENOIDS", ";", "solenoidNum", "++", ")", "{", "m_solenoids", "[", "solenoidNum", "]", "=", "new", "Solenoid", "(", "solenoidNum", "+", "1", ")", ";", "}", "m_driveMode", "=", "UNINITIALIZED_DRIVE", ";", "m_autoPeriodicLoops", "=", "0", ";", "m_disabledPeriodicLoops", "=", "0", ";", "m_telePeriodicLoops", "=", "0", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "public", "void", "robotInit", "(", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "public", "void", "disabledInit", "(", ")", "{", "m_disabledPeriodicLoops", "=", "0", ";", "ClearSolenoidLEDsKITT", "(", ")", ";", "}", "public", "void", "autonomousInit", "(", ")", "{", "m_autoPeriodicLoops", "=", "0", ";", "ClearSolenoidLEDsKITT", "(", ")", ";", "}", "public", "void", "teleopInit", "(", ")", "{", "m_telePeriodicLoops", "=", "0", ";", "m_dsPacketsReceivedInCurrentSecond", "=", "0", ";", "m_driveMode", "=", "UNINITIALIZED_DRIVE", ";", "ClearSolenoidLEDsKITT", "(", ")", ";", "}", "static", "int", "printSec", "=", "(", "int", ")", "(", "(", "Timer", ".", "getUsClock", "(", ")", "/", "1000000.0", ")", "+", "1.0", ")", ";", "static", "final", "int", "startSec", "=", "(", "int", ")", "(", "Timer", ".", "getUsClock", "(", ")", "/", "1000000.0", ")", ";", "public", "void", "disabledPeriodic", "(", ")", "{", "Watchdog", ".", "getInstance", "(", ")", ".", "feed", "(", ")", ";", "m_disabledPeriodicLoops", "++", ";", "if", "(", "(", "Timer", ".", "getUsClock", "(", ")", "/", "1000000.0", ")", ">", "printSec", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", "+", "(", "printSec", "-", "startSec", ")", "+", "\"rn\"", ")", ";", "printSec", "++", ";", "}", "}", "public", "void", "autonomousPeriodic", "(", ")", "{", "Watchdog", ".", "getInstance", "(", ")", ".", "feed", "(", ")", ";", "m_autoPeriodicLoops", "++", ";", "SolenoidLEDsKITT", "(", "m_autoPeriodicLoops", ")", ";", "}", "public", "void", "teleopPeriodic", "(", ")", "{", "Watchdog", ".", "getInstance", "(", ")", ".", "feed", "(", ")", ";", "m_telePeriodicLoops", "++", ";", "m_dsPacketsReceivedInCurrentSecond", "++", ";", "Solenoid", "[", "]", "firstGroup", "=", "new", "Solenoid", "[", "4", "]", ";", "Solenoid", "[", "]", "secondGroup", "=", "new", "Solenoid", "[", "4", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "firstGroup", "[", "i", "]", "=", "m_solenoids", "[", "i", "]", ";", "secondGroup", "[", "i", "]", "=", "m_solenoids", "[", "i", "+", "4", "]", ";", "}", "DemonstrateJoystickButtons", "(", "m_rightStick", ",", "m_rightStickButtonState", ",", "\"Right", "Stick\"", ",", "firstGroup", ")", ";", "DemonstrateJoystickButtons", "(", "m_leftStick", ",", "m_leftStickButtonState", ",", "\"Left", "Stick", "\"", ",", "secondGroup", ")", ";", "if", "(", "m_rightStick", ".", "getZ", "(", ")", "<=", "0", ")", "{", "m_robotDrive", ".", "arcadeDrive", "(", "m_rightStick", ",", "false", ")", ";", "if", "(", "m_driveMode", "!=", "ARCADE_DRIVE", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "m_driveMode", "=", "ARCADE_DRIVE", ";", "}", "}", "else", "{", "m_robotDrive", ".", "tankDrive", "(", "m_leftStick", ",", "m_rightStick", ")", ";", "if", "(", "m_driveMode", "!=", "TANK_DRIVE", ")", "{", "System", ".", "out", ".", "println", "(", "\"Tank", "Driven\"", ")", ";", "m_driveMode", "=", "TANK_DRIVE", ";", "}", "}", "}", "public", "void", "ClearSolenoidLEDsKITT", "(", ")", "{", "int", "solenoidNum", "=", "1", ";", "for", "(", "solenoidNum", "=", "0", ";", "solenoidNum", "<", "NUM_SOLENOIDS", ";", "solenoidNum", "++", ")", "{", "m_solenoids", "[", "solenoidNum", "]", ".", "set", "(", "false", ")", ";", "}", "}", "public", "void", "SolenoidLEDsKITT", "(", "int", "numloops", ")", "{", "final", "int", "NUM_KITT_POSITIONS", "=", "6", ";", "int", "numloop_within_second", "=", "numloops", "%", "GetLoopsPerSec", "(", ")", ";", "if", "(", "numloop_within_second", "==", "0", ")", "{", "m_solenoids", "[", "1", "]", ".", "set", "(", "true", ")", ";", "m_solenoids", "[", "8", "]", ".", "set", "(", "true", ")", ";", "m_solenoids", "[", "2", "]", ".", "set", "(", "false", ")", ";", "m_solenoids", "[", "7", "]", ".", "set", "(", "false", ")", ";", "}", "else", "if", "(", "numloop_within_second", "==", "(", "GetLoopsPerSec", "(", ")", "/", "NUM_KITT_POSITIONS", ")", ")", "{", "m_solenoids", "[", "2", "]", ".", "set", "(", "true", ")", ";", "m_solenoids", "[", "7", "]", ".", "set", "(", "true", ")", ";", "m_solenoids", "[", "1", "]", ".", "set", "(", "false", ")", ";", "m_solenoids", "[", "8", "]", ".", "set", "(", "false", ")", ";", "}", "else", "if", "(", "numloop_within_second", "==", "(", "GetLoopsPerSec", "(", ")", "*", "2", "/", "NUM_KITT_POSITIONS", ")", ")", "{", "m_solenoids", "[", "3", "]", ".", "set", "(", "true", ")", ";", "m_solenoids", "[", "6", "]", ".", "set", "(", "true", ")", ";", "m_solenoids", "[", "2", "]", ".", "set", "(", "false", ")", ";", "m_solenoids", "[", "7", "]", ".", "set", "(", "false", ")", ";", "}", "else", "if", "(", "numloop_within_second", "==", "(", "GetLoopsPerSec", "(", ")", "*", "3", "/", "NUM_KITT_POSITIONS", ")", ")", "{", "m_solenoids", "[", "4", "]", ".", "set", "(", "true", ")", ";", "m_solenoids", "[", "5", "]", ".", "set", "(", "true", ")", ";", "m_solenoids", "[", "3", "]", ".", "set", "(", "false", ")", ";", "m_solenoids", "[", "6", "]", ".", "set", "(", "false", ")", ";", "}", "else", "if", "(", "numloop_within_second", "==", "(", "GetLoopsPerSec", "(", ")", "*", "4", "/", "NUM_KITT_POSITIONS", ")", ")", "{", "m_solenoids", "[", "3", "]", ".", "set", "(", "true", ")", ";", "m_solenoids", "[", "6", "]", ".", "set", "(", "true", ")", ";", "m_solenoids", "[", "4", "]", ".", "set", "(", "false", ")", ";", "m_solenoids", "[", "5", "]", ".", "set", "(", "false", ")", ";", "}", "else", "if", "(", "numloop_within_second", "==", "(", "GetLoopsPerSec", "(", ")", "*", "5", "/", "NUM_KITT_POSITIONS", ")", ")", "{", "m_solenoids", "[", "2", "]", ".", "set", "(", "true", ")", ";", "m_solenoids", "[", "7", "]", ".", "set", "(", "true", ")", ";", "m_solenoids", "[", "3", "]", ".", "set", "(", "false", ")", ";", "m_solenoids", "[", "6", "]", ".", "set", "(", "false", ")", ";", "}", "}", "int", "GetLoopsPerSec", "(", ")", "{", "return", "10000", ";", "}", "public", "void", "DemonstrateJoystickButtons", "(", "Joystick", "currStick", ",", "boolean", "[", "]", "buttonPreviouslyPressed", ",", "String", "stickString", ",", "Solenoid", "solenoids", "[", "]", ")", "{", "int", "buttonNum", "=", "1", ";", "boolean", "outputGenerated", "=", "false", ";", "int", "numOfButtonPressed", "=", "0", ";", "for", "(", "buttonNum", "=", "1", ";", "buttonNum", "<=", "NUM_JOYSTICK_BUTTONS", ";", "buttonNum", "++", ")", "{", "if", "(", "currStick", ".", "getRawButton", "(", "buttonNum", ")", ")", "{", "if", "(", "!", "buttonPreviouslyPressed", "[", "buttonNum", "]", ")", "{", "if", "(", "!", "outputGenerated", ")", "{", "outputGenerated", "=", "true", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "stickString", ")", ";", "}", "System", ".", "out", ".", "println", "(", "\"", "\"", "+", "buttonNum", ")", ";", "}", "buttonPreviouslyPressed", "[", "buttonNum", "]", "=", "true", ";", "if", "(", "numOfButtonPressed", "==", "0", ")", "{", "numOfButtonPressed", "=", "buttonNum", ";", "}", "else", "{", "numOfButtonPressed", "=", "-", "1", ";", "}", "}", "else", "{", "buttonPreviouslyPressed", "[", "buttonNum", "]", "=", "false", ";", "}", "}", "if", "(", "outputGenerated", ")", "{", "System", ".", "out", ".", "println", "(", "\"n\"", ")", ";", "}", "if", "(", "numOfButtonPressed", "==", "-", "1", ")", "{", "DisplayBinaryNumberOnSolenoidLEDs", "(", "15", ",", "solenoids", ")", ";", "}", "else", "{", "DisplayBinaryNumberOnSolenoidLEDs", "(", "numOfButtonPressed", ",", "solenoids", ")", ";", "}", "}", "void", "DisplayBinaryNumberOnSolenoidLEDs", "(", "int", "displayNumber", ",", "Solenoid", "[", "]", "solenoids", ")", "{", "if", "(", "displayNumber", ">", "15", ")", "{", "displayNumber", "=", "0", ";", "}", "solenoids", "[", "3", "]", ".", "set", "(", "(", "displayNumber", "&", "1", ")", "!=", "0", ")", ";", "solenoids", "[", "2", "]", ".", "set", "(", "(", "displayNumber", "&", "2", ")", "!=", "0", ")", ";", "solenoids", "[", "1", "]", ".", "set", "(", "(", "displayNumber", "&", "4", ")", "!=", "0", ")", ";", "solenoids", "[", "0", "]", ".", "set", "(", "(", "displayNumber", "&", "8", ")", "!=", "0", ")", ";", "}", "}", "</s>" ]
7,528
[ "<s>", "package", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "samples", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "AnalogModule", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Dashboard", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DigitalModule", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "DriverStation", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "IterativeRobot", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Jaguar", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Solenoid", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Timer", ";", "import", "edu", ".", "wpi", ".", "first", ".", "wpilibj", ".", "Watchdog", ";", "public", "class", "DashBoardExample", "extends", "IterativeRobot", "{", "public", "void", "robotInit", "(", ")", "{", "Watchdog", ".", "getInstance", "(", ")", ".", "setEnabled", "(", "false", ")", ";", "}", "public", "void", "autonomousPeriodic", "(", ")", "{", "}", "Jaguar", "jag", "=", "new", "Jaguar", "(", "1", ")", ";", "double", "speed", "=", "-", "1.0", ";", "public", "void", "teleopPeriodic", "(", ")", "{", "updateDashboard", "(", ")", ";", "}", "void", "updateDashboard", "(", ")", "{", "Dashboard", "lowDashData", "=", "DriverStation", ".", "getInstance", "(", ")", ".", "getDashboardPackerLow", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "8", ";", "i", "++", ")", "{", "lowDashData", ".", "addFloat", "(", "(", "float", ")", "AnalogModule", ".", "getInstance", "(", "1", ")", ".", "getAverageVoltage", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "8", ";", "i", "++", ")", "{", "lowDashData", ".", "addFloat", "(", "(", "float", ")", "AnalogModule", ".", "getInstance", "(", "2", ")", ".", "getAverageVoltage", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "int", "module", "=", "4", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getAllDIO", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getDIODirection", "(", ")", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "10", ";", "i", "++", ")", "{", "lowDashData", ".", "addByte", "(", "(", "byte", ")", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getPWM", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "int", "module", "=", "6", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayForward", "(", ")", ")", ";", "lowDashData", ".", "addByte", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getRelayReverse", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getAllDIO", "(", ")", ")", ";", "lowDashData", ".", "addShort", "(", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getDIODirection", "(", ")", ")", ";", "lowDashData", ".", "addCluster", "(", ")", ";", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "10", ";", "i", "++", ")", "{", "lowDashData", ".", "addByte", "(", "(", "byte", ")", "DigitalModule", ".", "getInstance", "(", "module", ")", ".", "getPWM", "(", "i", ")", ")", ";", "}", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "addByte", "(", "Solenoid", ".", "getAll", "(", ")", ")", ";", "}", "lowDashData", ".", "finalizeCluster", "(", ")", ";", "lowDashData", ".", "commit", "(", ")", ";", "}", "}", "</s>" ]
7,529
[ "<s>", "public", "class", "Main", "{", "}", "</s>" ]
7,530
[ "<s>", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "com", ".", "google", ".", "gdata", ".", "util", ".", "ServiceException", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "server", ".", "*", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "*", ";", "public", "class", "TestRetrieval", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "IOException", ",", "ServiceException", "{", "ArrayList", "<", "Tree", ">", "treeList", "=", "new", "ArrayList", "<", "Tree", ">", "(", ")", ";", "ArrayList", "<", "Brick", ">", "brickList", "=", "new", "ArrayList", "<", "Brick", ">", "(", ")", ";", "ArrayList", "<", "Bench", ">", "benchList", "=", "new", "ArrayList", "<", "Bench", ">", "(", ")", ";", "SpreadsheetRetrieval", "sheets", "=", "new", "SpreadsheetRetrieval", "(", ")", ";", "sheets", ".", "updateMasterLists", "(", ")", ";", "treeList", "=", "sheets", ".", "getTreeMasterList", "(", ")", ";", "brickList", "=", "sheets", ".", "getBrickMasterList", "(", ")", ";", "benchList", "=", "sheets", ".", "getBenchMasterList", "(", ")", ";", "for", "(", "Brick", "brick", ":", "brickList", ")", "{", "System", ".", "out", ".", "print", "(", "brick", ".", "getSize", "(", ")", "+", "\"", "\"", "+", "brick", ".", "getDonatedFor", "(", ")", "+", "\"", "\"", "+", "brick", ".", "getYearDonated", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", ")", ";", "}", "for", "(", "Bench", "bench", ":", "benchList", ")", "{", "System", ".", "out", ".", "print", "(", "bench", ".", "getBenchType", "(", ")", "+", "\"", "\"", "+", "bench", ".", "getDonatedFor", "(", ")", "+", "\"", "\"", "+", "bench", ".", "getYearDonated", "(", ")", "+", "\"", "\"", "+", "bench", ".", "getLongitude", "(", ")", "+", "\"", "\"", "+", "bench", ".", "getLatitude", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", ")", ";", "}", "for", "(", "Tree", "tree", ":", "treeList", ")", "{", "System", ".", "out", ".", "print", "(", "tree", ".", "getCommonName", "(", ")", "+", "\"", "\"", "+", "tree", ".", "getScientificName", "(", ")", "+", "\"", "\"", "+", "tree", ".", "getYearPlanted", "(", ")", "+", "\"", "\"", "+", "tree", ".", "getLongitude", "(", ")", "+", "\"", "\"", "+", "tree", ".", "getLatitude", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", ")", ";", "}", "}", "}", "</s>" ]
7,531
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ";", "public", "class", "FieldVerifier", "{", "public", "static", "boolean", "isValidName", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", ")", "{", "return", "false", ";", "}", "return", "name", ".", "length", "(", ")", ">", "3", ";", "}", "}", "</s>" ]
7,532
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "rpc", ".", "AsyncCallback", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Bench", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Brick", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Tree", ";", "public", "interface", "MasterListRetrievalAsync", "{", "void", "getBenchMasterList", "(", "AsyncCallback", "<", "ArrayList", "<", "Bench", ">", ">", "callback", ")", ";", "void", "getBrickMasterList", "(", "AsyncCallback", "<", "ArrayList", "<", "Brick", ">", ">", "callback", ")", ";", "void", "getTreeMasterList", "(", "AsyncCallback", "<", "ArrayList", "<", "Tree", ">", ">", "callback", ")", ";", "}", "</s>" ]
7,533
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ".", "SearchParameter", ".", "Quadrant", ";", "public", "class", "Bench", "extends", "DonatedObject", "implements", "Serializable", "{", "private", "static", "final", "long", "serialVersionUID", "=", "3L", ";", "private", "String", "type", ";", "private", "double", "longitude", ";", "private", "double", "latitude", ";", "private", "Quadrant", "quadrant", ";", "public", "Bench", "(", ")", "{", "}", "public", "String", "getBenchType", "(", ")", "{", "return", "type", ";", "}", "public", "void", "setType", "(", "String", "type", ")", "{", "this", ".", "type", "=", "type", ";", "}", "public", "double", "getLongitude", "(", ")", "{", "return", "longitude", ";", "}", "public", "void", "setLongitude", "(", "double", "longitude", ")", "{", "this", ".", "longitude", "=", "longitude", ";", "}", "public", "double", "getLatitude", "(", ")", "{", "return", "latitude", ";", "}", "public", "void", "setLatitude", "(", "double", "d", ")", "{", "this", ".", "latitude", "=", "d", ";", "}", "public", "void", "setQuadrant", "(", ")", "{", "double", "latitude", "=", "this", ".", "getLatitude", "(", ")", ";", "double", "longitude", "=", "this", ".", "getLongitude", "(", ")", ";", "if", "(", "latitude", "<", "44.323368", "&&", "longitude", "<", "-", "93.976750", ")", "{", "this", ".", "quadrant", "=", "Quadrant", ".", "B", ";", "}", "else", "if", "(", "latitude", "<", "44.323368", "&&", "longitude", "<", "-", "93.973827", ")", "{", "this", ".", "quadrant", "=", "Quadrant", ".", "A", ";", "}", "else", "if", "(", "latitude", "<", "44.323368", "&&", "longitude", ">=", "-", "93.973827", ")", "{", "this", ".", "quadrant", "=", "Quadrant", ".", "D", ";", "}", "else", "if", "(", "latitude", ">=", "44.323368", "&&", "longitude", "<", "-", "93.973827", ")", "{", "this", ".", "quadrant", "=", "Quadrant", ".", "C", ";", "}", "else", "this", ".", "quadrant", "=", "Quadrant", ".", "E", ";", "}", "public", "Quadrant", "getQuadrant", "(", ")", "{", "return", "quadrant", ";", "}", "}", "</s>" ]
7,534
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ".", "SearchParameter", ".", "Quadrant", ";", "public", "class", "Tree", "extends", "DonatedObject", "implements", "Serializable", "{", "private", "static", "final", "long", "serialVersionUID", "=", "1L", ";", "private", "String", "commonName", ";", "private", "String", "scientificName", ";", "private", "String", "yearPlanted", ";", "private", "String", "health", ";", "private", "double", "longitude", ";", "private", "double", "latitude", ";", "private", "String", "diameter", ";", "private", "String", "donatedFor", ";", "private", "Quadrant", "quadrant", ";", "public", "Tree", "(", ")", "{", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "}", "public", "String", "getCommonName", "(", ")", "{", "return", "commonName", ";", "}", "public", "void", "setCommonName", "(", "String", "commonName", ")", "{", "this", ".", "commonName", "=", "commonName", ";", "}", "public", "String", "getScientificName", "(", ")", "{", "return", "scientificName", ";", "}", "public", "void", "setScientificName", "(", "String", "scientificName", ")", "{", "this", ".", "scientificName", "=", "scientificName", ";", "}", "public", "String", "getYearPlanted", "(", ")", "{", "return", "yearPlanted", ";", "}", "public", "void", "setYearPlanted", "(", "String", "yearPlanted", ")", "{", "this", ".", "yearPlanted", "=", "yearPlanted", ";", "}", "public", "void", "setYearDonated", "(", "String", "yearDonated", ")", "{", "this", ".", "yearDonated", "=", "yearDonated", ";", "}", "public", "String", "getHealth", "(", ")", "{", "return", "health", ";", "}", "public", "void", "setHealth", "(", "String", "health", ")", "{", "this", ".", "health", "=", "health", ";", "}", "public", "double", "getLongitude", "(", ")", "{", "return", "longitude", ";", "}", "public", "void", "setLongitude", "(", "double", "longitude", ")", "{", "this", ".", "longitude", "=", "longitude", ";", "}", "public", "double", "getLatitude", "(", ")", "{", "return", "latitude", ";", "}", "public", "void", "setLatitude", "(", "double", "latitude", ")", "{", "this", ".", "latitude", "=", "latitude", ";", "}", "public", "String", "getDiameter", "(", ")", "{", "return", "diameter", ";", "}", "public", "void", "setDiameter", "(", "String", "diameter", ")", "{", "this", ".", "diameter", "=", "diameter", ";", "}", "public", "String", "getDonatedFor", "(", ")", "{", "return", "donatedFor", ";", "}", "public", "void", "setDonatedFor", "(", "String", "donatedFor", ")", "{", "this", ".", "donatedFor", "=", "donatedFor", ";", "}", "public", "void", "setQuadrant", "(", ")", "{", "double", "latitude", "=", "this", ".", "getLatitude", "(", ")", ";", "double", "longitude", "=", "this", ".", "getLongitude", "(", ")", ";", "if", "(", "latitude", "<", "44.323368", "&&", "longitude", "<", "-", "93.976750", ")", "{", "this", ".", "quadrant", "=", "Quadrant", ".", "B", ";", "}", "else", "if", "(", "latitude", "<", "44.323368", "&&", "longitude", "<", "-", "93.973827", ")", "{", "this", ".", "quadrant", "=", "Quadrant", ".", "A", ";", "}", "else", "if", "(", "latitude", "<", "44.323368", "&&", "longitude", ">=", "-", "93.973827", ")", "{", "this", ".", "quadrant", "=", "Quadrant", ".", "D", ";", "}", "else", "if", "(", "latitude", ">=", "44.323368", "&&", "longitude", "<", "-", "93.973827", ")", "{", "this", ".", "quadrant", "=", "Quadrant", ".", "C", ";", "}", "else", "this", ".", "quadrant", "=", "Quadrant", ".", "E", ";", "}", "public", "Quadrant", "getQuadrant", "(", ")", "{", "return", "quadrant", ";", "}", "}", "</s>" ]
7,535
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ";", "import", "java", ".", "io", ".", "Serializable", ";", "public", "class", "Brick", "extends", "DonatedObject", "implements", "Serializable", "{", "private", "static", "final", "long", "serialVersionUID", "=", "2L", ";", "private", "String", "size", ";", "private", "String", "distance", ";", "public", "Brick", "(", ")", "{", "}", "public", "String", "getSize", "(", ")", "{", "return", "size", ";", "}", "public", "void", "setSize", "(", "String", "size", ")", "{", "this", ".", "size", "=", "size", ";", "}", "public", "String", "getDistance", "(", ")", "{", "return", "distance", ";", "}", "public", "void", "setDistance", "(", "String", "distance", ")", "{", "this", ".", "distance", "=", "distance", ";", "}", "}", "</s>" ]
7,536
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ".", "SearchParameter", ".", "Quadrant", ";", "public", "class", "DonatedObject", "{", "public", "String", "yearDonated", ";", "public", "String", "donatedFor", ";", "public", "String", "getYearDonated", "(", ")", "{", "return", "yearDonated", ";", "}", "public", "void", "setYearDonated", "(", "String", "yearDonated", ")", "{", "this", ".", "yearDonated", "=", "yearDonated", ";", "}", "public", "String", "getDonatedFor", "(", ")", "{", "return", "donatedFor", ";", "}", "public", "void", "setDonatedFor", "(", "String", "donatedFor", ")", "{", "this", ".", "donatedFor", "=", "donatedFor", ";", "}", "public", "Quadrant", "getQuadrant", "(", ")", "{", "return", "Quadrant", ".", "E", ";", "}", "}", "</s>" ]
7,537
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "*", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "*", ";", "import", "com", ".", "google", ".", "gdata", ".", "util", ".", "ServiceException", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "rpc", ".", "RemoteService", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "rpc", ".", "RemoteServiceRelativePath", ";", "@", "RemoteServiceRelativePath", "(", "\"\"", ")", "public", "interface", "MasterListRetrieval", "extends", "RemoteService", "{", "ArrayList", "<", "Tree", ">", "getTreeMasterList", "(", ")", ";", "ArrayList", "<", "Brick", ">", "getBrickMasterList", "(", ")", ";", "ArrayList", "<", "Bench", ">", "getBenchMasterList", "(", ")", ";", "}", "</s>" ]
7,538
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "server", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "net", ".", "MalformedURLException", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "com", ".", "google", ".", "gdata", ".", "client", ".", "spreadsheet", ".", "SpreadsheetService", ";", "import", "com", ".", "google", ".", "gdata", ".", "data", ".", "spreadsheet", ".", "ListEntry", ";", "import", "com", ".", "google", ".", "gdata", ".", "data", ".", "spreadsheet", ".", "ListFeed", ";", "import", "com", ".", "google", ".", "gdata", ".", "data", ".", "spreadsheet", ".", "WorksheetEntry", ";", "import", "com", ".", "google", ".", "gdata", ".", "data", ".", "spreadsheet", ".", "WorksheetFeed", ";", "import", "com", ".", "google", ".", "gdata", ".", "util", ".", "ServiceException", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "Timer", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "server", ".", "rpc", ".", "RemoteServiceServlet", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "MasterListRetrieval", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "*", ";", "public", "class", "SpreadsheetRetrieval", "extends", "RemoteServiceServlet", "implements", "MasterListRetrieval", "{", "private", "static", "final", "long", "serialVersionUID", "=", "-", "5367523128487203951L", ";", "private", "ArrayList", "<", "Tree", ">", "treeMasterList", ";", "private", "ArrayList", "<", "Brick", ">", "brickMasterList", ";", "private", "ArrayList", "<", "Bench", ">", "benchMasterList", ";", "private", "URL", "treeURL", ";", "public", "void", "updateMasterLists", "(", ")", "throws", "IOException", ",", "ServiceException", "{", "SpreadsheetService", "treeSpreadsheetService", "=", "new", "SpreadsheetService", "(", "\"\"", ")", ";", "WorksheetFeed", "feed", "=", "treeSpreadsheetService", ".", "getFeed", "(", "treeURL", ",", "WorksheetFeed", ".", "class", ")", ";", "List", "<", "WorksheetEntry", ">", "worksheets", "=", "feed", ".", "getEntries", "(", ")", ";", "if", "(", "worksheets", ".", "size", "(", ")", "==", "0", ")", "{", "}", "WorksheetEntry", "treeWorksheet", "=", "new", "WorksheetEntry", "(", ")", ";", "for", "(", "WorksheetEntry", "worksheet", ":", "worksheets", ")", "{", "if", "(", "\"Trees\"", ".", "equals", "(", "worksheet", ".", "getTitle", "(", ")", ".", "getPlainText", "(", ")", ")", ")", "{", "treeWorksheet", "=", "worksheet", ";", "}", "}", "URL", "listFeedUrl", "=", "treeWorksheet", ".", "getListFeedUrl", "(", ")", ";", "ListFeed", "listFeed", "=", "treeSpreadsheetService", ".", "getFeed", "(", "listFeedUrl", ",", "ListFeed", ".", "class", ")", ";", "this", ".", "setTreeMasterList", "(", "new", "ArrayList", "<", "Tree", ">", "(", ")", ")", ";", "for", "(", "ListEntry", "entry", ":", "listFeed", ".", "getEntries", "(", ")", ")", "{", "Tree", "tree", "=", "new", "Tree", "(", ")", ";", "for", "(", "String", "tag", ":", "entry", ".", "getCustomElements", "(", ")", ".", "getTags", "(", ")", ")", "{", "if", "(", "\"commonname\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "commonName", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "tree", ".", "setCommonName", "(", "commonName", ")", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "scientificName", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "tree", ".", "setScientificName", "(", "scientificName", ")", ";", "}", "else", "if", "(", "\"yearplanted\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "yearPlanted", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "tree", ".", "setYearPlanted", "(", "yearPlanted", ")", ";", "}", "else", "if", "(", "\"health\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "health", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "tree", ".", "setHealth", "(", "health", ")", ";", "}", "else", "if", "(", "\"longitude\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "stringLongitude", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "if", "(", "stringLongitude", "==", "null", ")", "{", "tree", ".", "setLongitude", "(", "0", ")", ";", "}", "else", "{", "try", "{", "Double", "longitude", "=", "new", "Double", "(", "stringLongitude", ")", ";", "tree", ".", "setLongitude", "(", "longitude", ".", "doubleValue", "(", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "}", "}", "}", "else", "if", "(", "\"latitude\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "stringLatitude", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "if", "(", "stringLatitude", "==", "null", ")", "{", "tree", ".", "setLatitude", "(", "0", ")", ";", "}", "else", "{", "try", "{", "Double", "latitude", "=", "new", "Double", "(", "stringLatitude", ")", ";", "tree", ".", "setLatitude", "(", "latitude", ".", "doubleValue", "(", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "}", "}", "}", "else", "if", "(", "\"diameter\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "diameter", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "tree", ".", "setDiameter", "(", "diameter", ")", ";", "}", "else", "if", "(", "\"yeardonated\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "yearDonated", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "tree", ".", "setYearDonated", "(", "yearDonated", ")", ";", "}", "else", "if", "(", "\"donatedfor\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "donatedFor", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "tree", ".", "setDonatedFor", "(", "donatedFor", ")", ";", "}", "}", "tree", ".", "setQuadrant", "(", ")", ";", "this", ".", "treeMasterList", ".", "add", "(", "tree", ")", ";", "}", "this", ".", "setBenchMasterList", "(", "new", "ArrayList", "<", "Bench", ">", "(", ")", ")", ";", "if", "(", "worksheets", ".", "size", "(", ")", "==", "0", ")", "{", "}", "WorksheetEntry", "benchWorksheet", "=", "new", "WorksheetEntry", "(", ")", ";", "for", "(", "WorksheetEntry", "worksheet", ":", "worksheets", ")", "{", "if", "(", "\"Benches\"", ".", "equals", "(", "worksheet", ".", "getTitle", "(", ")", ".", "getPlainText", "(", ")", ")", ")", "{", "benchWorksheet", "=", "worksheet", ";", "}", "}", "listFeedUrl", "=", "benchWorksheet", ".", "getListFeedUrl", "(", ")", ";", "listFeed", "=", "treeSpreadsheetService", ".", "getFeed", "(", "listFeedUrl", ",", "ListFeed", ".", "class", ")", ";", "for", "(", "ListEntry", "entry", ":", "listFeed", ".", "getEntries", "(", ")", ")", "{", "Bench", "bench", "=", "new", "Bench", "(", ")", ";", "for", "(", "String", "tag", ":", "entry", ".", "getCustomElements", "(", ")", ".", "getTags", "(", ")", ")", "{", "if", "(", "\"benchtype\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "benchType", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "bench", ".", "setType", "(", "benchType", ")", ";", "}", "else", "if", "(", "\"yeardonated\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "yearDonated", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "bench", ".", "setYearDonated", "(", "yearDonated", ")", ";", "}", "else", "if", "(", "\"longitude\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "stringLongitude", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "if", "(", "stringLongitude", "==", "null", ")", "{", "bench", ".", "setLongitude", "(", "0", ")", ";", "}", "else", "{", "try", "{", "Double", "longitude", "=", "new", "Double", "(", "stringLongitude", ")", ";", "bench", ".", "setLongitude", "(", "longitude", ".", "doubleValue", "(", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "}", "}", "}", "else", "if", "(", "\"latitude\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "stringLatitude", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "if", "(", "stringLatitude", "==", "null", ")", "{", "bench", ".", "setLatitude", "(", "0", ")", ";", "}", "else", "{", "try", "{", "Double", "latitude", "=", "new", "Double", "(", "stringLatitude", ")", ";", "bench", ".", "setLatitude", "(", "latitude", ".", "doubleValue", "(", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "}", "}", "}", "else", "if", "(", "\"donatedfor\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "donatedFor", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "bench", ".", "setDonatedFor", "(", "donatedFor", ")", ";", "}", "}", "bench", ".", "setQuadrant", "(", ")", ";", "this", ".", "benchMasterList", ".", "add", "(", "bench", ")", ";", "}", "this", ".", "setBrickMasterList", "(", "new", "ArrayList", "<", "Brick", ">", "(", ")", ")", ";", "WorksheetEntry", "brickWorksheet", "=", "new", "WorksheetEntry", "(", ")", ";", "for", "(", "WorksheetEntry", "worksheet", ":", "worksheets", ")", "{", "if", "(", "\"Bricks\"", ".", "equals", "(", "worksheet", ".", "getTitle", "(", ")", ".", "getPlainText", "(", ")", ")", ")", "{", "brickWorksheet", "=", "worksheet", ";", "}", "}", "listFeedUrl", "=", "brickWorksheet", ".", "getListFeedUrl", "(", ")", ";", "listFeed", "=", "treeSpreadsheetService", ".", "getFeed", "(", "listFeedUrl", ",", "ListFeed", ".", "class", ")", ";", "for", "(", "ListEntry", "entry", ":", "listFeed", ".", "getEntries", "(", ")", ")", "{", "Brick", "brick", "=", "new", "Brick", "(", ")", ";", "for", "(", "String", "tag", ":", "entry", ".", "getCustomElements", "(", ")", ".", "getTags", "(", ")", ")", "{", "if", "(", "\"size\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "brickSize", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "brick", ".", "setSize", "(", "brickSize", ")", ";", "}", "else", "if", "(", "\"yeardonated\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "yearDonated", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "brick", ".", "setYearDonated", "(", "yearDonated", ")", ";", "}", "else", "if", "(", "\"donatedfor\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "donatedFor", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "brick", ".", "setDonatedFor", "(", "donatedFor", ")", ";", "}", "else", "if", "(", "\"distance\"", ".", "equals", "(", "tag", ")", ")", "{", "String", "distance", "=", "entry", ".", "getCustomElements", "(", ")", ".", "getValue", "(", "tag", ")", ";", "brick", ".", "setDistance", "(", "distance", ")", ";", "}", "}", "this", ".", "brickMasterList", ".", "add", "(", "brick", ")", ";", "}", "}", "public", "SpreadsheetRetrieval", "(", ")", "throws", "MalformedURLException", "{", "this", ".", "treeURL", "=", "new", "URL", "(", "\"\"", ")", ";", "try", "{", "this", ".", "updateMasterLists", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "ServiceException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "public", "ArrayList", "<", "Tree", ">", "getTreeMasterList", "(", ")", "{", "return", "treeMasterList", ";", "}", "public", "void", "setTreeMasterList", "(", "ArrayList", "<", "Tree", ">", "treeMasterList", ")", "{", "this", ".", "treeMasterList", "=", "treeMasterList", ";", "}", "public", "ArrayList", "<", "Brick", ">", "getBrickMasterList", "(", ")", "{", "return", "brickMasterList", ";", "}", "public", "void", "setBrickMasterList", "(", "ArrayList", "<", "Brick", ">", "brickMasterList", ")", "{", "this", ".", "brickMasterList", "=", "brickMasterList", ";", "}", "public", "ArrayList", "<", "Bench", ">", "getBenchMasterList", "(", ")", "{", "return", "benchMasterList", ";", "}", "public", "void", "setBenchMasterList", "(", "ArrayList", "<", "Bench", ">", "benchMasterList", ")", "{", "this", ".", "benchMasterList", "=", "benchMasterList", ";", "}", "public", "URL", "getTreeURL", "(", ")", "{", "return", "treeURL", ";", "}", "public", "void", "setTreeURL", "(", "URL", "treeURL", ")", "{", "this", ".", "treeURL", "=", "treeURL", ";", "}", "}", "</s>" ]
7,539
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ";", "import", "com", ".", "google", ".", "gwt", ".", "core", ".", "client", ".", "EntryPoint", ";", "import", "com", ".", "google", ".", "gwt", ".", "event", ".", "dom", ".", "client", ".", "ClickEvent", ";", "import", "com", ".", "google", ".", "gwt", ".", "event", ".", "dom", ".", "client", ".", "ClickHandler", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "RootPanel", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Label", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Image", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Bench", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Button", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "AbsolutePanel", ";", "public", "class", "BenchPage", "implements", "EntryPoint", "{", "Bench", "bench", ";", "final", "RootPanel", "rootPanel", "=", "RootPanel", ".", "get", "(", ")", ";", "Button", "buttonRoadMap", "=", "new", "Button", "(", "\"Road", "Map\"", ")", ";", "Button", "buttonHybridMap", "=", "new", "Button", "(", "\"Hybrid", "Map\"", ")", ";", "Button", "buttonSatelliteMap", "=", "new", "Button", "(", "\"\"", ")", ";", "Button", "buttonHomePage", "=", "new", "Button", "(", "\"Home", "Page\"", ")", ";", "Button", "buttonBack", "=", "new", "Button", "(", "\"Back\"", ")", ";", "Label", "labelYourBench", "=", "new", "Label", "(", "\"Your", "Bench\"", ")", ";", "Label", "labelDonatedFor", "=", "new", "Label", "(", "\"Donated", "For\"", ")", ";", "Label", "labelYearDonated", "=", "new", "Label", "(", "\"Year", "Donated\"", ")", ";", "Label", "labelBenchDonor", "=", "new", "Label", "(", "\"\"", ")", ";", "Label", "labelBenchGetYearDonated", "=", "new", "Label", "(", "\"\"", ")", ";", "String", "zoom", ";", "String", "mapType", "=", "\"road\"", ";", "String", "url", "=", "new", "String", "(", "\"nothing\"", ")", ";", "Image", "image", "=", "new", "Image", "(", "(", "String", ")", "url", ")", ";", "Float", "benchLatitude", ";", "Float", "benchLongitude", ";", "private", "final", "AbsolutePanel", "absolutePanel", "=", "new", "AbsolutePanel", "(", ")", ";", "@", "Override", "public", "void", "onModuleLoad", "(", ")", "{", "show", "(", "bench", ",", "new", "SearchParameter", "(", ")", ")", ";", "}", "public", "BenchPage", "(", ")", "{", "rootPanel", ".", "setSize", "(", "\"1600\"", ",", "\"900\"", ")", ";", "absolutePanel", ".", "setSize", "(", "\"861px\"", ",", "\"770px\"", ")", ";", "absolutePanel", ".", "add", "(", "image", ")", ";", "image", ".", "setSize", "(", "\"479px\"", ",", "\"409px\"", ")", ";", "absolutePanel", ".", "add", "(", "labelYourBench", ",", "499", ",", "0", ")", ";", "labelYourBench", ".", "setSize", "(", "\"66px\"", ",", "\"18px\"", ")", ";", "absolutePanel", ".", "add", "(", "labelDonatedFor", ",", "499", ",", "47", ")", ";", "absolutePanel", ".", "add", "(", "labelYearDonated", ",", "499", ",", "71", ")", ";", "absolutePanel", ".", "add", "(", "labelBenchDonor", ",", "499", ",", "113", ")", ";", "absolutePanel", ".", "add", "(", "labelBenchGetYearDonated", ",", "499", ",", "157", ")", ";", "absolutePanel", ".", "add", "(", "buttonHomePage", ",", "687", ",", "120", ")", ";", "buttonHomePage", ".", "setSize", "(", "\"115px\"", ",", "\"55px\"", ")", ";", "absolutePanel", ".", "add", "(", "buttonBack", ",", "686", ",", "26", ")", ";", "buttonBack", ".", "setSize", "(", "\"112px\"", ",", "\"55px\"", ")", ";", "absolutePanel", ".", "add", "(", "buttonRoadMap", ",", "10", ",", "454", ")", ";", "buttonRoadMap", ".", "setSize", "(", "\"115px\"", ",", "\"55px\"", ")", ";", "absolutePanel", ".", "add", "(", "buttonHybridMap", ",", "188", ",", "454", ")", ";", "buttonHybridMap", ".", "setSize", "(", "\"115px\"", ",", "\"55px\"", ")", ";", "absolutePanel", ".", "add", "(", "buttonSatelliteMap", ",", "364", ",", "454", ")", ";", "buttonSatelliteMap", ".", "setSize", "(", "\"115px\"", ",", "\"55px\"", ")", ";", "buttonSatelliteMap", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "createMap", "(", "bench", ",", "zoom", ",", "\"satellite\"", ")", ";", "}", "}", ")", ";", "buttonHybridMap", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "createMap", "(", "bench", ",", "zoom", ",", "\"hybrid\"", ")", ";", "}", "}", ")", ";", "buttonRoadMap", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "createMap", "(", "bench", ",", "zoom", ",", "\"road\"", ")", ";", "}", "}", ")", ";", "buttonHomePage", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "rootPanel", ".", "clear", "(", ")", ";", "PageController", ".", "sharedPageController", "(", ")", ".", "showMainPage", "(", ")", ";", "}", "}", ")", ";", "}", "public", "void", "show", "(", "Bench", "bench", ",", "final", "SearchParameter", "sp", ")", "{", "rootPanel", ".", "add", "(", "absolutePanel", ",", "0", ",", "0", ")", ";", "benchLatitude", "=", "(", "float", ")", "Double", ".", "valueOf", "(", "bench", ".", "getLatitude", "(", ")", ")", ".", "doubleValue", "(", ")", ";", "benchLongitude", "=", "(", "float", ")", "Double", ".", "valueOf", "(", "bench", ".", "getLongitude", "(", ")", ")", ".", "doubleValue", "(", ")", ";", "zoom", "=", "checkSize", "(", "benchLatitude", ",", "benchLongitude", ")", ";", "createMap", "(", "bench", ",", "zoom", ",", "mapType", ")", ";", "labelBenchDonor", ".", "setText", "(", "bench", ".", "getDonatedFor", "(", ")", ")", ";", "labelBenchGetYearDonated", ".", "setText", "(", "String", ".", "valueOf", "(", "bench", ".", "getYearDonated", "(", ")", ")", ")", ";", "buttonBack", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "rootPanel", ".", "clear", "(", ")", ";", "PageController", ".", "sharedPageController", "(", ")", ".", "showSearchResultsPage", "(", "sp", ")", ";", "}", "}", ")", ";", "}", "private", "String", "checkSize", "(", "Float", "treeLatitude", ",", "Float", "treeLongitude", ")", "{", "if", "(", "treeLatitude", ">", "44.32252", "||", "treeLongitude", ">", "-", "93.974755", ")", "{", "return", "\"16\"", ";", "}", "return", "\"17\"", ";", "}", "private", "void", "createMap", "(", "final", "Bench", "Bench", ",", "String", "zoom", ",", "String", "mapType", ")", "{", "String", "url", "=", "new", "String", "(", "\"\"", "+", "zoom", "+", "\"\"", "+", "mapType", "+", "\"\"", "+", "Bench", ".", "getLatitude", "(", ")", "+", "\",\"", "+", "Bench", ".", "getLongitude", "(", ")", "+", "\"\"", ")", ";", "image", ".", "setUrl", "(", "url", ")", ";", "}", "}", "</s>" ]
7,540
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ";", "import", "com", ".", "google", ".", "gwt", ".", "core", ".", "client", ".", "EntryPoint", ";", "import", "com", ".", "google", ".", "gwt", ".", "dom", ".", "client", ".", "Style", ".", "Position", ";", "import", "com", ".", "google", ".", "gwt", ".", "event", ".", "dom", ".", "client", ".", "ClickEvent", ";", "import", "com", ".", "google", ".", "gwt", ".", "event", ".", "dom", ".", "client", ".", "ClickHandler", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "RootPanel", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Label", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Image", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Tree", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Button", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "AbsolutePanel", ";", "public", "class", "TreePage", "implements", "EntryPoint", "{", "private", "Tree", "tree", ";", "final", "RootPanel", "rootPanel", "=", "RootPanel", ".", "get", "(", ")", ";", "AbsolutePanel", "absolutePanel", "=", "new", "AbsolutePanel", "(", ")", ";", "Button", "buttonSatelliteMap", "=", "new", "Button", "(", "\"\"", ")", ";", "Button", "buttonRoadMap", "=", "new", "Button", "(", "\"Road", "Map\"", ")", ";", "Button", "buttonHybridMap", "=", "new", "Button", "(", "\"Hybrid", "Map\"", ")", ";", "Button", "buttonHomePage", "=", "new", "Button", "(", "\"Home", "Page\"", ")", ";", "Button", "buttonBack", "=", "new", "Button", "(", "\"Back\"", ")", ";", "Float", "treeLatitude", ";", "Float", "treeLongitude", ";", "String", "zoom", "=", "\"16\"", ";", "String", "mapType", "=", "\"road\"", ";", "String", "url", "=", "null", ";", "Image", "image", "=", "new", "Image", "(", "\"nothing\"", ")", ";", "Label", "labelYourTree", "=", "new", "Label", "(", "\"Your", "Tree\"", ")", ";", "Label", "labelCommonName", "=", "new", "Label", "(", "\"Common", "Name\"", ")", ";", "Label", "labelGetCommonName", "=", "new", "Label", "(", "\"\"", ")", ";", "Label", "labelScientificName", "=", "new", "Label", "(", "\"\"", ")", ";", "Label", "labelGetScientificName", "=", "new", "Label", "(", "\"\"", ")", ";", "Label", "labelYearPlanted", "=", "new", "Label", "(", "\"Year", "Planted\"", ")", ";", "Label", "labelGetYearPlanted", "=", "new", "Label", "(", "\"\"", ")", ";", "Label", "labelYearDonated", "=", "new", "Label", "(", "\"Year", "Donated\"", ")", ";", "Label", "labelGetYearDonated", "=", "new", "Label", "(", "\"\"", ")", ";", "Label", "labelDonatedFor", "=", "new", "Label", "(", "\"Donated", "For\"", ")", ";", "Label", "labelGetDonatedFor", "=", "new", "Label", "(", "\"\"", ")", ";", "@", "Override", "public", "void", "onModuleLoad", "(", ")", "{", "show", "(", "tree", ",", "new", "SearchParameter", "(", ")", ")", ";", "}", "public", "void", "show", "(", "Tree", "tree", ",", "final", "SearchParameter", "sp", ")", "{", "treeLatitude", "=", "(", "float", ")", "Double", ".", "valueOf", "(", "tree", ".", "getLatitude", "(", ")", ")", ".", "doubleValue", "(", ")", ";", "treeLongitude", "=", "(", "float", ")", "Double", ".", "valueOf", "(", "tree", ".", "getLongitude", "(", ")", ")", ".", "doubleValue", "(", ")", ";", "zoom", "=", "checkSize", "(", "treeLatitude", ",", "treeLongitude", ")", ";", "createMap", "(", "tree", ",", "zoom", ")", ";", "rootPanel", ".", "add", "(", "absolutePanel", ",", "10", ",", "10", ")", ";", "labelGetCommonName", ".", "setText", "(", "tree", ".", "getCommonName", "(", ")", ")", ";", "labelGetScientificName", ".", "setText", "(", "tree", ".", "getScientificName", "(", ")", ")", ";", "labelGetYearPlanted", ".", "setText", "(", "tree", ".", "getYearPlanted", "(", ")", ")", ";", "labelGetYearDonated", ".", "setText", "(", "tree", ".", "getYearDonated", "(", ")", ")", ";", "labelGetDonatedFor", ".", "setText", "(", "tree", ".", "getDonatedFor", "(", ")", ")", ";", "buttonBack", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "rootPanel", ".", "clear", "(", ")", ";", "PageController", ".", "sharedPageController", "(", ")", ".", "showSearchResultsPage", "(", "sp", ")", ";", "}", "}", ")", ";", "}", "public", "TreePage", "(", ")", "{", "rootPanel", ".", "setSize", "(", "\"1600\"", ",", "\"900\"", ")", ";", "rootPanel", ".", "getElement", "(", ")", ".", "getStyle", "(", ")", ".", "setPosition", "(", "Position", ".", "RELATIVE", ")", ";", "absolutePanel", ".", "setSize", "(", "\"1004px\"", ",", "\"822px\"", ")", ";", "absolutePanel", ".", "add", "(", "labelYourTree", ",", "480", ",", "0", ")", ";", "absolutePanel", ".", "add", "(", "image", ")", ";", "image", ".", "setSize", "(", "\"479px\"", ",", "\"409px\"", ")", ";", "absolutePanel", ".", "add", "(", "buttonSatelliteMap", ",", "364", ",", "453", ")", ";", "buttonSatelliteMap", ".", "setSize", "(", "\"115px\"", ",", "\"55px\"", ")", ";", "absolutePanel", ".", "add", "(", "buttonHomePage", ",", "889", ",", "50", ")", ";", "buttonHomePage", ".", "setSize", "(", "\"115px\"", ",", "\"55px\"", ")", ";", "absolutePanel", ".", "add", "(", "buttonBack", ",", "889", ",", "152", ")", ";", "buttonBack", ".", "setSize", "(", "\"112px\"", ",", "\"55px\"", ")", ";", "absolutePanel", ".", "add", "(", "buttonRoadMap", ",", "10", ",", "453", ")", ";", "buttonRoadMap", ".", "setSize", "(", "\"115px\"", ",", "\"55px\"", ")", ";", "absolutePanel", ".", "add", "(", "buttonHybridMap", ",", "180", ",", "453", ")", ";", "buttonHybridMap", ".", "setSize", "(", "\"115px\"", ",", "\"55px\"", ")", ";", "absolutePanel", ".", "add", "(", "labelCommonName", ",", "560", ",", "50", ")", ";", "labelCommonName", ".", "setSize", "(", "\"92px\"", ",", "\"18px\"", ")", ";", "absolutePanel", ".", "add", "(", "labelGetCommonName", ",", "560", ",", "68", ")", ";", "absolutePanel", ".", "add", "(", "labelScientificName", ",", "560", ",", "118", ")", ";", "absolutePanel", ".", "add", "(", "labelGetScientificName", ",", "560", ",", "136", ")", ";", "absolutePanel", ".", "add", "(", "labelYearPlanted", ",", "560", ",", "171", ")", ";", "absolutePanel", ".", "add", "(", "labelGetYearPlanted", ",", "560", ",", "189", ")", ";", "absolutePanel", ".", "add", "(", "labelYearDonated", ",", "560", ",", "230", ")", ";", "absolutePanel", ".", "add", "(", "labelGetYearDonated", ",", "560", ",", "248", ")", ";", "absolutePanel", ".", "add", "(", "labelDonatedFor", ",", "560", ",", "297", ")", ";", "absolutePanel", ".", "add", "(", "labelGetDonatedFor", ",", "560", ",", "315", ")", ";", "buttonHybridMap", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "mapType", "=", "\"hybrid\"", ";", "createMap", "(", "tree", ",", "zoom", ")", ";", "}", "}", ")", ";", "buttonRoadMap", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "mapType", "=", "\"road\"", ";", "createMap", "(", "tree", ",", "zoom", ")", ";", "}", "}", ")", ";", "buttonHomePage", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "rootPanel", ".", "clear", "(", ")", ";", "PageController", ".", "sharedPageController", "(", ")", ".", "showMainPage", "(", ")", ";", "}", "}", ")", ";", "buttonSatelliteMap", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "mapType", "=", "\"satellite\"", ";", "createMap", "(", "tree", ",", "zoom", ")", ";", "}", "}", ")", ";", "}", "private", "String", "checkSize", "(", "Float", "treeLatitude", ",", "Float", "treeLongitude", ")", "{", "if", "(", "treeLatitude", ">", "44.32252", "||", "treeLongitude", ">", "-", "93.974755", ")", "{", "return", "\"16\"", ";", "}", "return", "\"17\"", ";", "}", "private", "void", "createMap", "(", "final", "Tree", "tree", ",", "String", "zoom", ")", "{", "String", "url", "=", "new", "String", "(", "\"\"", "+", "zoom", "+", "\"\"", "+", "mapType", "+", "\"\"", "+", "tree", ".", "getLatitude", "(", ")", "+", "\",\"", "+", "tree", ".", "getLongitude", "(", ")", "+", "\"\"", ")", ";", "image", ".", "setUrl", "(", "url", ")", ";", "}", "}", "</s>" ]
7,541
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "public", "class", "SearchParameter", "{", "public", "enum", "SearchType", "{", "commonName", "(", "\"Common", "Name\"", ")", ",", "scientificName", "(", "\"\"", ")", ",", "donatedFor", "(", "\"Donated", "For\"", ")", ";", "private", "final", "String", "name", ";", "SearchType", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "name", ";", "}", "}", "enum", "SearchFor", "{", "trees", "(", "\"Trees\"", ")", ",", "benches", "(", "\"Benches\"", ")", ",", "bricks", "(", "\"Bricks\"", ")", ";", "private", "final", "String", "name", ";", "SearchFor", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "name", ";", "}", "}", "public", "enum", "Quadrant", "{", "A", ",", "B", ",", "C", ",", "D", ",", "E", "}", "String", "keywordQuery", ";", "private", "SearchFor", "searchFor", ";", "private", "SearchType", "searchType", ";", "private", "ArrayList", "<", "Quadrant", ">", "quadrants", ";", "private", "boolean", "undonatedBoxChecked", ";", "public", "SearchParameter", "(", ")", "{", "ArrayList", "<", "Quadrant", ">", "quadrants", "=", "new", "ArrayList", "<", "Quadrant", ">", "(", ")", ";", "quadrants", ".", "add", "(", "Quadrant", ".", "E", ")", ";", "this", ".", "keywordQuery", "=", "\"Grandpa", "Jo\"", ";", "this", ".", "searchFor", "=", "SearchFor", ".", "trees", ";", "this", ".", "searchType", "=", "SearchType", ".", "commonName", ";", "this", ".", "quadrants", "=", "quadrants", ";", "this", ".", "undonatedBoxChecked", "=", "false", ";", "}", "public", "SearchParameter", "(", "String", "keywordQuery", ",", "SearchFor", "searchFor", ",", "SearchType", "searchType", ",", "ArrayList", "<", "Quadrant", ">", "quadrants", ",", "boolean", "unDonatedBoxChecked", ")", "{", "this", ".", "keywordQuery", "=", "keywordQuery", ";", "this", ".", "searchType", "=", "searchType", ";", "this", ".", "searchFor", "=", "searchFor", ";", "this", ".", "quadrants", "=", "quadrants", ";", "this", ".", "undonatedBoxChecked", "=", "unDonatedBoxChecked", ";", "}", "public", "boolean", "isUndonatedBoxChecked", "(", ")", "{", "return", "undonatedBoxChecked", ";", "}", "public", "String", "getKeywordQuery", "(", ")", "{", "return", "keywordQuery", ";", "}", "public", "String", "getSearchTypeAsString", "(", ")", "{", "return", "searchType", ".", "toString", "(", ")", ";", "}", "public", "ArrayList", "<", "Quadrant", ">", "getQuadrants", "(", ")", "{", "return", "quadrants", ";", "}", "public", "SearchType", "getSearchType", "(", ")", "{", "return", "searchType", ";", "}", "public", "SearchFor", "getSearchFor", "(", ")", "{", "return", "searchFor", ";", "}", "}", "</s>" ]
7,542
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ";", "import", "java", ".", "util", ".", "*", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "MasterListRetrieval", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "MasterListRetrievalAsync", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Bench", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Brick", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Tree", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ".", "SearchParameter", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ".", "SearchParameter", ".", "Quadrant", ";", "import", "com", ".", "google", ".", "gwt", ".", "core", ".", "client", ".", "*", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "rpc", ".", "AsyncCallback", ";", "public", "class", "Searcher", "{", "private", "ArrayList", "<", "Bench", ">", "updatedBenchList", ";", "private", "ArrayList", "<", "Brick", ">", "updatedBrickList", ";", "private", "ArrayList", "<", "Tree", ">", "updatedTreeList", ";", "private", "final", "MasterListRetrievalAsync", "masterListRetrieval", "=", "GWT", ".", "create", "(", "MasterListRetrieval", ".", "class", ")", ";", "private", "AsyncCallback", "<", "ArrayList", "<", "Tree", ">", ">", "treeUpdater", "=", "new", "AsyncCallback", "<", "ArrayList", "<", "Tree", ">", ">", "(", ")", "{", "@", "Override", "public", "void", "onFailure", "(", "Throwable", "caught", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "onSuccess", "(", "ArrayList", "<", "Tree", ">", "result", ")", "{", "updatedTreeList", "=", "result", ";", "}", "}", ";", "private", "AsyncCallback", "<", "ArrayList", "<", "Bench", ">", ">", "benchUpdater", "=", "new", "AsyncCallback", "<", "ArrayList", "<", "Bench", ">", ">", "(", ")", "{", "@", "Override", "public", "void", "onFailure", "(", "Throwable", "caught", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "onSuccess", "(", "ArrayList", "<", "Bench", ">", "result", ")", "{", "updatedBenchList", "=", "result", ";", "}", "}", ";", "private", "AsyncCallback", "<", "ArrayList", "<", "Brick", ">", ">", "brickUpdater", "=", "new", "AsyncCallback", "<", "ArrayList", "<", "Brick", ">", ">", "(", ")", "{", "@", "Override", "public", "void", "onFailure", "(", "Throwable", "caught", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "onSuccess", "(", "ArrayList", "<", "Brick", ">", "result", ")", "{", "updatedBrickList", "=", "result", ";", "}", "}", ";", "public", "void", "updateLocalMasterLists", "(", ")", "{", "masterListRetrieval", ".", "getTreeMasterList", "(", "treeUpdater", ")", ";", "masterListRetrieval", ".", "getBenchMasterList", "(", "benchUpdater", ")", ";", "masterListRetrieval", ".", "getBrickMasterList", "(", "brickUpdater", ")", ";", "}", "public", "ArrayList", "<", "Tree", ">", "searchResultsForTreeSearch", "(", "SearchParameter", "sp", ")", "{", "ArrayList", "<", "Tree", ">", "accumulatorList", "=", "new", "ArrayList", "<", "Tree", ">", "(", ")", ";", "if", "(", "sp", ".", "getSearchTypeAsString", "(", ")", "==", "null", ")", "{", "return", "updatedTreeList", ";", "}", "else", "if", "(", "updatedTreeList", "==", "null", ")", "{", "return", "accumulatorList", ";", "}", "else", "if", "(", "sp", ".", "getSearchTypeAsString", "(", ")", "==", "\"Common", "Name\"", ")", "{", "for", "(", "Tree", "loopTree", ":", "updatedTreeList", ")", "{", "if", "(", "(", "loopTree", ")", ".", "getCommonName", "(", ")", ".", "toLowerCase", "(", ")", ".", "contains", "(", "sp", ".", "getKeywordQuery", "(", ")", ".", "toLowerCase", "(", ")", ")", ")", "{", "accumulatorList", ".", "add", "(", "loopTree", ")", ";", "}", "}", "}", "else", "if", "(", "sp", ".", "getSearchTypeAsString", "(", ")", "==", "\"\"", ")", "{", "for", "(", "Tree", "loopTree", ":", "updatedTreeList", ")", "{", "if", "(", "(", "loopTree", ")", ".", "getScientificName", "(", ")", ".", "toLowerCase", "(", ")", ".", "contains", "(", "sp", ".", "getKeywordQuery", "(", ")", ".", "toLowerCase", "(", ")", ")", ")", "{", "accumulatorList", ".", "add", "(", "loopTree", ")", ";", "}", "}", "}", "else", "if", "(", "sp", ".", "getSearchTypeAsString", "(", ")", "==", "\"Donated", "For\"", ")", "{", "for", "(", "Tree", "loopTree", ":", "updatedTreeList", ")", "{", "if", "(", "(", "loopTree", ")", ".", "getDonatedFor", "(", ")", ".", "toLowerCase", "(", ")", ".", "contains", "(", "sp", ".", "getKeywordQuery", "(", ")", ".", "toLowerCase", "(", ")", ")", ")", "{", "accumulatorList", ".", "add", "(", "loopTree", ")", ";", "}", "}", "}", "ArrayList", "<", "Tree", ">", "newAccumList", "=", "new", "ArrayList", "<", "Tree", ">", "(", ")", ";", "for", "(", "Tree", "loopTree", ":", "accumulatorList", ")", "{", "if", "(", "sp", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "A", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"Check\"", ")", ";", "if", "(", "loopTree", ".", "getQuadrant", "(", ")", "==", "Quadrant", ".", "A", ")", "{", "System", ".", "out", ".", "println", "(", "\"Check1\"", ")", ";", "newAccumList", ".", "add", "(", "loopTree", ")", ";", "}", "}", "if", "(", "sp", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "B", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"Check\"", ")", ";", "if", "(", "loopTree", ".", "getQuadrant", "(", ")", "==", "Quadrant", ".", "B", ")", "{", "System", ".", "out", ".", "println", "(", "\"Check1\"", ")", ";", "newAccumList", ".", "add", "(", "loopTree", ")", ";", "}", "}", "if", "(", "sp", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "C", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"Check\"", ")", ";", "if", "(", "loopTree", ".", "getQuadrant", "(", ")", "==", "Quadrant", ".", "C", ")", "{", "System", ".", "out", ".", "println", "(", "\"Check1\"", ")", ";", "newAccumList", ".", "add", "(", "loopTree", ")", ";", "}", "}", "if", "(", "sp", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "D", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"Check\"", ")", ";", "if", "(", "loopTree", ".", "getQuadrant", "(", ")", "==", "Quadrant", ".", "D", ")", "{", "System", ".", "out", ".", "println", "(", "\"Check1\"", ")", ";", "newAccumList", ".", "add", "(", "loopTree", ")", ";", "}", "}", "if", "(", "sp", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "E", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"Check\"", ")", ";", "if", "(", "loopTree", ".", "getQuadrant", "(", ")", "==", "Quadrant", ".", "E", ")", "{", "System", ".", "out", ".", "println", "(", "\"Check1\"", ")", ";", "newAccumList", ".", "add", "(", "loopTree", ")", ";", "}", "}", "}", "accumulatorList", "=", "newAccumList", ";", "if", "(", "sp", ".", "isUndonatedBoxChecked", "(", ")", ")", "{", "ArrayList", "<", "Tree", ">", "newAccumList1", "=", "new", "ArrayList", "<", "Tree", ">", "(", ")", ";", "for", "(", "Tree", "loopTree", ":", "accumulatorList", ")", "{", "if", "(", "loopTree", ".", "getDonatedFor", "(", ")", "==", "null", ")", "{", "newAccumList1", ".", "add", "(", "loopTree", ")", ";", "}", "}", "accumulatorList", "=", "newAccumList1", ";", "}", "return", "accumulatorList", ";", "}", "public", "ArrayList", "<", "Bench", ">", "searchResultsForBenchSearch", "(", "SearchParameter", "sp", ")", "{", "ArrayList", "<", "Bench", ">", "accumulatorList", "=", "new", "ArrayList", "<", "Bench", ">", "(", ")", ";", "if", "(", "sp", ".", "getSearchTypeAsString", "(", ")", "==", "null", ")", "{", "return", "updatedBenchList", ";", "}", "else", "if", "(", "updatedBenchList", "==", "null", ")", "{", "return", "accumulatorList", ";", "}", "else", "if", "(", "sp", ".", "getSearchTypeAsString", "(", ")", "==", "\"Donated", "For\"", ")", "{", "for", "(", "Bench", "loopBench", ":", "updatedBenchList", ")", "{", "if", "(", "loopBench", ".", "getDonatedFor", "(", ")", ".", "toLowerCase", "(", ")", ".", "contains", "(", "sp", ".", "getKeywordQuery", "(", ")", ".", "toLowerCase", "(", ")", ")", ")", "{", "accumulatorList", ".", "add", "(", "loopBench", ")", ";", "}", "}", "}", "ArrayList", "<", "Bench", ">", "newAccumList", "=", "new", "ArrayList", "<", "Bench", ">", "(", ")", ";", "for", "(", "Bench", "loopBench", ":", "accumulatorList", ")", "{", "if", "(", "sp", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "A", ")", ")", "{", "if", "(", "loopBench", ".", "getQuadrant", "(", ")", "==", "Quadrant", ".", "A", ")", "{", "newAccumList", ".", "add", "(", "loopBench", ")", ";", "}", "}", "if", "(", "sp", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "B", ")", ")", "{", "if", "(", "loopBench", ".", "getQuadrant", "(", ")", "==", "Quadrant", ".", "B", ")", "{", "newAccumList", ".", "add", "(", "loopBench", ")", ";", "}", "}", "if", "(", "sp", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "C", ")", ")", "{", "if", "(", "loopBench", ".", "getQuadrant", "(", ")", "==", "Quadrant", ".", "C", ")", "{", "newAccumList", ".", "add", "(", "loopBench", ")", ";", "}", "}", "if", "(", "sp", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "D", ")", ")", "{", "if", "(", "loopBench", ".", "getQuadrant", "(", ")", "==", "Quadrant", ".", "D", ")", "{", "newAccumList", ".", "add", "(", "loopBench", ")", ";", "}", "}", "if", "(", "sp", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "E", ")", ")", "{", "if", "(", "loopBench", ".", "getQuadrant", "(", ")", "==", "Quadrant", ".", "E", ")", "{", "newAccumList", ".", "add", "(", "loopBench", ")", ";", "}", "}", "}", "accumulatorList", "=", "newAccumList", ";", "if", "(", "sp", ".", "isUndonatedBoxChecked", "(", ")", ")", "{", "ArrayList", "<", "Bench", ">", "newAccumList1", "=", "new", "ArrayList", "<", "Bench", ">", "(", ")", ";", "for", "(", "Bench", "loopBench", ":", "accumulatorList", ")", "{", "if", "(", "loopBench", ".", "getDonatedFor", "(", ")", "==", "null", ")", "{", "newAccumList1", ".", "add", "(", "loopBench", ")", ";", "}", "}", "accumulatorList", "=", "newAccumList1", ";", "}", "return", "accumulatorList", ";", "}", "public", "ArrayList", "<", "Brick", ">", "searchResultsForBrickSearch", "(", "SearchParameter", "sp", ")", "{", "ArrayList", "<", "Brick", ">", "accumulatorList", "=", "new", "ArrayList", "<", "Brick", ">", "(", ")", ";", "if", "(", "sp", ".", "getSearchTypeAsString", "(", ")", "==", "null", ")", "{", "return", "updatedBrickList", ";", "}", "else", "if", "(", "updatedBrickList", "==", "null", ")", "{", "return", "accumulatorList", ";", "}", "else", "if", "(", "sp", ".", "getSearchTypeAsString", "(", ")", "==", "\"Donated", "For\"", ")", "{", "for", "(", "Brick", "loopBrick", ":", "updatedBrickList", ")", "{", "if", "(", "(", "loopBrick", ")", ".", "getDonatedFor", "(", ")", ".", "toLowerCase", "(", ")", ".", "contains", "(", "sp", ".", "getKeywordQuery", "(", ")", ".", "toLowerCase", "(", ")", ")", ")", "{", "accumulatorList", ".", "add", "(", "loopBrick", ")", ";", "}", "}", "}", "if", "(", "sp", ".", "isUndonatedBoxChecked", "(", ")", ")", "{", "ArrayList", "<", "Brick", ">", "newAccumList", "=", "new", "ArrayList", "<", "Brick", ">", "(", ")", ";", "for", "(", "Brick", "loopBrick", ":", "accumulatorList", ")", "{", "if", "(", "loopBrick", ".", "getDonatedFor", "(", ")", "==", "null", ")", "{", "newAccumList", ".", "add", "(", "loopBrick", ")", ";", "}", "}", "accumulatorList", "=", "newAccumList", ";", "}", "return", "accumulatorList", ";", "}", "}", "</s>" ]
7,543
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ".", "SearchParameter", ".", "Quadrant", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ".", "SearchParameter", ".", "SearchFor", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ".", "SearchParameter", ".", "SearchType", ";", "import", "com", ".", "google", ".", "gwt", ".", "core", ".", "client", ".", "EntryPoint", ";", "import", "com", ".", "google", ".", "gwt", ".", "dom", ".", "client", ".", "Style", ".", "Position", ";", "import", "com", ".", "google", ".", "gwt", ".", "event", ".", "dom", ".", "client", ".", "ClickEvent", ";", "import", "com", ".", "google", ".", "gwt", ".", "event", ".", "dom", ".", "client", ".", "ClickHandler", ";", "import", "com", ".", "google", ".", "gwt", ".", "event", ".", "dom", ".", "client", ".", "KeyUpEvent", ";", "import", "com", ".", "google", ".", "gwt", ".", "event", ".", "dom", ".", "client", ".", "KeyUpHandler", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "Window", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Button", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "CheckBox", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "HasHorizontalAlignment", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "InlineLabel", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Label", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "RadioButton", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "RootPanel", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "TextBox", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "AbsolutePanel", ";", "public", "class", "MainPage", "implements", "EntryPoint", ",", "ClickHandler", "{", "RootPanel", "rootPanel", "=", "RootPanel", ".", "get", "(", ")", ";", "AbsolutePanel", "absolutePanel", "=", "new", "AbsolutePanel", "(", ")", ";", "final", "String", "INCONSISTENT_SEARCH_CRITERIA", "=", "\"\"", ";", "final", "RadioButton", "commonNameSearchTypeRadioButton", "=", "new", "RadioButton", "(", "\"Search", "Type\"", ",", "\"Common", "Name\"", ")", ";", "final", "RadioButton", "donatedForSearchTypeRadioButton", "=", "new", "RadioButton", "(", "\"Search", "Type\"", ",", "\"Donated", "For\"", ")", ";", "final", "RadioButton", "scientificNameSearchTypeRadioButton", "=", "new", "RadioButton", "(", "\"Search", "Type\"", ",", "\"\"", ")", ";", "final", "RadioButton", "benchesRadioButton", "=", "new", "RadioButton", "(", "\"Search", "For\"", ",", "\"Benches\"", ")", ";", "final", "RadioButton", "treesRadioButton", "=", "new", "RadioButton", "(", "\"Search", "For\"", ",", "\"Trees\"", ")", ";", "final", "RadioButton", "bricksRadioButton", "=", "new", "RadioButton", "(", "\"Search", "For\"", ",", "\"Bricks\"", ")", ";", "private", "final", "CheckBox", "checkBoxNotYetDonated", "=", "new", "CheckBox", "(", "\"Bricks\"", ")", ";", "CheckBox", "checkBoxQuadrantA", "=", "new", "CheckBox", "(", "\"A\"", ")", ";", "CheckBox", "checkBoxQuadrantB", "=", "new", "CheckBox", "(", "\"B\"", ")", ";", "CheckBox", "checkBoxQuadrantC", "=", "new", "CheckBox", "(", "\"C\"", ")", ";", "CheckBox", "checkBoxQuadrantD", "=", "new", "CheckBox", "(", "\"D\"", ")", ";", "CheckBox", "checkBoxQuadrantE", "=", "new", "CheckBox", "(", "\"E\"", ")", ";", "final", "TextBox", "searchField", "=", "new", "TextBox", "(", ")", ";", "Label", "labelIn", "=", "new", "InlineLabel", "(", "\"Search", "For:\"", ")", ";", "Label", "labelBy", "=", "new", "InlineLabel", "(", "\"Search", "By:\"", ")", ";", "Label", "labelQuery", "=", "new", "InlineLabel", "(", "\"Keyword:\"", ")", ";", "Label", "labelHeader", "=", "new", "InlineLabel", "(", "\"\"", ")", ";", "Label", "labelLocatedInQuadrant", "=", "new", "Label", "(", "\"\"", ")", ";", "Button", "searchButton", "=", "new", "Button", "(", "\"Search\"", ")", ";", "public", "void", "onModuleLoad", "(", ")", "{", "this", ".", "show", "(", ")", ";", "}", "@", "Override", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "}", "public", "void", "show", "(", ")", "{", "rootPanel", ".", "setSize", "(", "\"1600\"", ",", "\"900\"", ")", ";", "rootPanel", ".", "getElement", "(", ")", ".", "getStyle", "(", ")", ".", "setPosition", "(", "Position", ".", "RELATIVE", ")", ";", "rootPanel", ".", "add", "(", "absolutePanel", ",", "0", ",", "0", ")", ";", "absolutePanel", ".", "setSize", "(", "\"962px\"", ",", "\"636px\"", ")", ";", "searchField", ".", "setText", "(", "\"search\"", ")", ";", "absolutePanel", ".", "add", "(", "checkBoxQuadrantA", ",", "663", ",", "192", ")", ";", "absolutePanel", ".", "add", "(", "checkBoxQuadrantB", ",", "663", ",", "218", ")", ";", "absolutePanel", ".", "add", "(", "checkBoxQuadrantC", ",", "663", ",", "244", ")", ";", "absolutePanel", ".", "add", "(", "checkBoxQuadrantD", ",", "732", ",", "192", ")", ";", "absolutePanel", ".", "add", "(", "checkBoxQuadrantE", ",", "732", ",", "218", ")", ";", "checkBoxQuadrantA", ".", "setValue", "(", "true", ")", ";", "checkBoxQuadrantB", ".", "setValue", "(", "true", ")", ";", "checkBoxQuadrantC", ".", "setValue", "(", "true", ")", ";", "checkBoxQuadrantD", ".", "setValue", "(", "true", ")", ";", "checkBoxQuadrantE", ".", "setValue", "(", "true", ")", ";", "checkBoxNotYetDonated", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "if", "(", "checkBoxNotYetDonated", ".", "getValue", "(", ")", ")", "{", "donatedForSearchTypeRadioButton", ".", "setEnabled", "(", "false", ")", ";", "if", "(", "donatedForSearchTypeRadioButton", ".", "getValue", "(", ")", ")", "donatedForSearchTypeRadioButton", ".", "setValue", "(", "false", ")", ";", "}", "if", "(", "!", "checkBoxNotYetDonated", ".", "getValue", "(", ")", ")", "donatedForSearchTypeRadioButton", ".", "setEnabled", "(", "true", ")", ";", "}", "}", ")", ";", "checkBoxNotYetDonated", ".", "setHTML", "(", "\"\"", ")", ";", "absolutePanel", ".", "add", "(", "checkBoxNotYetDonated", ",", "492", ",", "270", ")", ";", "checkBoxNotYetDonated", ".", "setSize", "(", "\"136px\"", ",", "\"20px\"", ")", ";", "absolutePanel", ".", "add", "(", "labelIn", ",", "337", ",", "158", ")", ";", "labelIn", ".", "setStyleName", "(", "\"sendButton\"", ")", ";", "absolutePanel", ".", "add", "(", "labelBy", ",", "492", ",", "158", ")", ";", "labelBy", ".", "setStyleName", "(", "\"sendButton\"", ")", ";", "absolutePanel", ".", "add", "(", "labelQuery", ",", "80", ",", "158", ")", ";", "labelQuery", ".", "setStyleName", "(", "\"sendButton\"", ")", ";", "labelLocatedInQuadrant", ".", "setStyleName", "(", "\"sendButton\"", ")", ";", "absolutePanel", ".", "add", "(", "labelLocatedInQuadrant", ",", "663", ",", "158", ")", ";", "absolutePanel", ".", "add", "(", "labelHeader", ",", "222", ",", "10", ")", ";", "labelHeader", ".", "setHorizontalAlignment", "(", "HasHorizontalAlignment", ".", "ALIGN_CENTER", ")", ";", "labelHeader", ".", "setStyleName", "(", "\"sendButton\"", ")", ";", "labelHeader", ".", "setSize", "(", "\"532px\"", ",", "\"50px\"", ")", ";", "class", "MySearchForRadioButtonHandler", "implements", "ClickHandler", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "checkCurrentSearchConfiguration", "(", ")", ";", "}", "private", "void", "checkCurrentSearchConfiguration", "(", ")", "{", "if", "(", "!", "bricksRadioButton", ".", "getValue", "(", ")", "&&", "!", "benchesRadioButton", ".", "getValue", "(", ")", ")", "{", "commonNameSearchTypeRadioButton", ".", "setEnabled", "(", "true", ")", ";", "scientificNameSearchTypeRadioButton", ".", "setEnabled", "(", "true", ")", ";", "}", "else", "{", "commonNameSearchTypeRadioButton", ".", "setEnabled", "(", "false", ")", ";", "scientificNameSearchTypeRadioButton", ".", "setEnabled", "(", "false", ")", ";", "if", "(", "commonNameSearchTypeRadioButton", ".", "getValue", "(", ")", ")", "commonNameSearchTypeRadioButton", ".", "setValue", "(", "false", ")", ";", "if", "(", "scientificNameSearchTypeRadioButton", ".", "getValue", "(", ")", ")", "scientificNameSearchTypeRadioButton", ".", "setValue", "(", "false", ")", ";", "}", "}", "}", "absolutePanel", ".", "add", "(", "commonNameSearchTypeRadioButton", ",", "492", ",", "218", ")", ";", "absolutePanel", ".", "add", "(", "donatedForSearchTypeRadioButton", ",", "492", ",", "192", ")", ";", "absolutePanel", ".", "add", "(", "scientificNameSearchTypeRadioButton", ",", "492", ",", "244", ")", ";", "treesRadioButton", ".", "setHTML", "(", "\"Trees\"", ")", ";", "treesRadioButton", ".", "setStyleName", "(", "\"h1\"", ")", ";", "absolutePanel", ".", "add", "(", "treesRadioButton", ",", "337", ",", "192", ")", ";", "bricksRadioButton", ".", "setHTML", "(", "\"Bricks\"", ")", ";", "absolutePanel", ".", "add", "(", "bricksRadioButton", ",", "337", ",", "244", ")", ";", "bricksRadioButton", ".", "setSize", "(", "\"71px\"", ",", "\"20px\"", ")", ";", "benchesRadioButton", ".", "setHTML", "(", "\"Benches\"", ")", ";", "absolutePanel", ".", "add", "(", "benchesRadioButton", ",", "337", ",", "218", ")", ";", "treesRadioButton", ".", "addClickHandler", "(", "new", "MySearchForRadioButtonHandler", "(", ")", ")", ";", "benchesRadioButton", ".", "addClickHandler", "(", "new", "MySearchForRadioButtonHandler", "(", ")", ")", ";", "bricksRadioButton", ".", "addClickHandler", "(", "new", "MySearchForRadioButtonHandler", "(", ")", ")", ";", "class", "MySendButtonHandler", "implements", "ClickHandler", ",", "KeyUpHandler", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "if", "(", "checkCurrentSearchConfigurationForConsistency", "(", ")", ")", "{", "SearchType", "searchBy", "=", "SearchType", ".", "commonName", ";", "if", "(", "commonNameSearchTypeRadioButton", ".", "getValue", "(", ")", ")", "searchBy", "=", "SearchType", ".", "commonName", ";", "if", "(", "scientificNameSearchTypeRadioButton", ".", "getValue", "(", ")", ")", "searchBy", "=", "SearchType", ".", "scientificName", ";", "if", "(", "donatedForSearchTypeRadioButton", ".", "getValue", "(", ")", ")", "searchBy", "=", "SearchType", ".", "donatedFor", ";", "SearchFor", "searchFor", "=", "SearchFor", ".", "trees", ";", "if", "(", "treesRadioButton", ".", "getValue", "(", ")", ")", "searchFor", "=", "SearchFor", ".", "trees", ";", "if", "(", "benchesRadioButton", ".", "getValue", "(", ")", ")", "searchFor", "=", "SearchFor", ".", "benches", ";", "if", "(", "bricksRadioButton", ".", "getValue", "(", ")", ")", "searchFor", "=", "SearchFor", ".", "bricks", ";", "ArrayList", "<", "Quadrant", ">", "quadrants", "=", "new", "ArrayList", "<", "Quadrant", ">", "(", ")", ";", "if", "(", "checkBoxQuadrantA", ".", "getValue", "(", ")", ")", "quadrants", ".", "add", "(", "Quadrant", ".", "A", ")", ";", "if", "(", "checkBoxQuadrantB", ".", "getValue", "(", ")", ")", "quadrants", ".", "add", "(", "Quadrant", ".", "B", ")", ";", "if", "(", "checkBoxQuadrantC", ".", "getValue", "(", ")", ")", "quadrants", ".", "add", "(", "Quadrant", ".", "C", ")", ";", "if", "(", "checkBoxQuadrantD", ".", "getValue", "(", ")", ")", "quadrants", ".", "add", "(", "Quadrant", ".", "D", ")", ";", "if", "(", "checkBoxQuadrantE", ".", "getValue", "(", ")", ")", "quadrants", ".", "add", "(", "Quadrant", ".", "E", ")", ";", "SearchParameter", "searchParameter", "=", "new", "SearchParameter", "(", "searchField", ".", "getText", "(", ")", ",", "searchFor", ",", "searchBy", ",", "quadrants", ",", "checkBoxNotYetDonated", ".", "getValue", "(", ")", ")", ";", "rootPanel", ".", "clear", "(", ")", ";", "PageController", ".", "sharedPageController", "(", ")", ".", "showSearchResultsPage", "(", "searchParameter", ")", ";", "}", "}", "private", "boolean", "checkCurrentSearchConfigurationForConsistency", "(", ")", "{", "System", ".", "out", ".", "println", "(", "checkBoxQuadrantA", ".", "getValue", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "checkBoxQuadrantB", ".", "getValue", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "checkBoxQuadrantC", ".", "getValue", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "checkBoxQuadrantD", ".", "getValue", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "checkBoxQuadrantE", ".", "getValue", "(", ")", ")", ";", "if", "(", "!", "checkBoxQuadrantA", ".", "getValue", "(", ")", "&&", "!", "checkBoxQuadrantB", ".", "getValue", "(", ")", "&&", "!", "checkBoxQuadrantC", ".", "getValue", "(", ")", "&&", "!", "checkBoxQuadrantD", ".", "getValue", "(", ")", "&&", "!", "checkBoxQuadrantE", ".", "getValue", "(", ")", ")", "{", "Window", ".", "alert", "(", "\"\"", ")", ";", "return", "false", ";", "}", "if", "(", "!", "benchesRadioButton", ".", "getValue", "(", ")", "&&", "!", "bricksRadioButton", ".", "getValue", "(", ")", "&&", "!", "treesRadioButton", ".", "getValue", "(", ")", ")", "{", "Window", ".", "alert", "(", "\"\"", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", "@", "Override", "public", "void", "onKeyUp", "(", "KeyUpEvent", "event", ")", "{", "}", "}", "absolutePanel", ".", "add", "(", "searchButton", ",", "663", ",", "442", ")", ";", "searchButton", ".", "setStyleName", "(", "\"h1\"", ")", ";", "searchButton", ".", "addStyleName", "(", "\"searchButton\"", ")", ";", "searchButton", ".", "setSize", "(", "\"134px\"", ",", "\"56px\"", ")", ";", "searchField", ".", "setFocus", "(", "true", ")", ";", "MySendButtonHandler", "handler", "=", "new", "MySendButtonHandler", "(", ")", ";", "searchField", ".", "addKeyUpHandler", "(", "handler", ")", ";", "searchButton", ".", "addClickHandler", "(", "handler", ")", ";", "absolutePanel", ".", "add", "(", "searchField", ",", "80", ",", "204", ")", ";", "}", "}", "</s>" ]
7,544
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ";", "import", "com", ".", "google", ".", "gwt", ".", "core", ".", "client", ".", "EntryPoint", ";", "import", "com", ".", "google", ".", "gwt", ".", "dom", ".", "client", ".", "Style", ".", "Position", ";", "import", "com", ".", "google", ".", "gwt", ".", "event", ".", "dom", ".", "client", ".", "ClickEvent", ";", "import", "com", ".", "google", ".", "gwt", ".", "event", ".", "dom", ".", "client", ".", "ClickHandler", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "RootPanel", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Label", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Brick", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Button", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "AbsolutePanel", ";", "public", "class", "BrickPage", "implements", "EntryPoint", "{", "Brick", "brick", "=", "new", "Brick", "(", ")", ";", "final", "RootPanel", "rootPanel", "=", "RootPanel", ".", "get", "(", ")", ";", "private", "final", "AbsolutePanel", "absolutePanel", "=", "new", "AbsolutePanel", "(", ")", ";", "private", "final", "Label", "labelYourBrick", "=", "new", "Label", "(", "\"Your", "Brick\"", ")", ";", "private", "final", "Label", "labelDonatedFor", "=", "new", "Label", "(", "\"Donated", "For\"", ")", ";", "private", "final", "Label", "labelYearDonated", "=", "new", "Label", "(", "\"Year", "Donated\"", ")", ";", "private", "final", "Label", "labelBrickSize", "=", "new", "Label", "(", "\"Brick", "Size\"", ")", ";", "private", "final", "Label", "labelDistance", "=", "new", "Label", "(", "\"\"", ")", ";", "private", "final", "Label", "labelGetDonatedFor", "=", "new", "Label", "(", "\"\"", ")", ";", "private", "final", "Label", "labelGetYearDonated", "=", "new", "Label", "(", "\"\"", ")", ";", "private", "final", "Label", "labelGetSize", "=", "new", "Label", "(", "\"\"", ")", ";", "private", "final", "Label", "labelGetDistance", "=", "new", "Label", "(", "\"\"", ")", ";", "private", "final", "Button", "buttonHomePage", "=", "new", "Button", "(", "\"Home", "Page\"", ")", ";", "private", "final", "Button", "buttonBack", "=", "new", "Button", "(", "\"Back\"", ")", ";", "@", "Override", "public", "void", "onModuleLoad", "(", ")", "{", "show", "(", "brick", ",", "new", "SearchParameter", "(", ")", ")", ";", "}", "public", "BrickPage", "(", ")", "{", "rootPanel", ".", "setSize", "(", "\"1600\"", ",", "\"900\"", ")", ";", "rootPanel", ".", "getElement", "(", ")", ".", "getStyle", "(", ")", ".", "setPosition", "(", "Position", ".", "RELATIVE", ")", ";", "absolutePanel", ".", "setSize", "(", "\"1344px\"", ",", "\"605px\"", ")", ";", "absolutePanel", ".", "add", "(", "labelYourBrick", ",", "427", ",", "10", ")", ";", "labelYourBrick", ".", "setSize", "(", "\"66px\"", ",", "\"18px\"", ")", ";", "absolutePanel", ".", "add", "(", "labelDonatedFor", ",", "372", ",", "58", ")", ";", "absolutePanel", ".", "add", "(", "labelYearDonated", ",", "372", ",", "104", ")", ";", "absolutePanel", ".", "add", "(", "labelBrickSize", ",", "372", ",", "145", ")", ";", "absolutePanel", ".", "add", "(", "labelDistance", ",", "372", ",", "187", ")", ";", "labelDistance", ".", "setSize", "(", "\"109px\"", ",", "\"18px\"", ")", ";", "absolutePanel", ".", "add", "(", "labelGetDonatedFor", ",", "497", ",", "58", ")", ";", "absolutePanel", ".", "add", "(", "labelGetYearDonated", ",", "497", ",", "104", ")", ";", "absolutePanel", ".", "add", "(", "labelGetSize", ",", "497", ",", "145", ")", ";", "absolutePanel", ".", "add", "(", "labelGetDistance", ",", "497", ",", "187", ")", ";", "absolutePanel", ".", "add", "(", "buttonHomePage", ",", "712", ",", "120", ")", ";", "buttonHomePage", ".", "setSize", "(", "\"115px\"", ",", "\"55px\"", ")", ";", "buttonHomePage", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "PageController", ".", "sharedPageController", "(", ")", ".", "showMainPage", "(", ")", ";", "}", "}", ")", ";", "absolutePanel", ".", "add", "(", "buttonBack", ",", "712", ",", "33", ")", ";", "buttonBack", ".", "setSize", "(", "\"112px\"", ",", "\"55px\"", ")", ";", "}", "public", "void", "show", "(", "Brick", "brick2", ",", "final", "SearchParameter", "sp", ")", "{", "rootPanel", ".", "add", "(", "absolutePanel", ",", "0", ",", "0", ")", ";", "labelGetSize", ".", "setText", "(", "brick", ".", "getSize", "(", ")", ")", ";", "labelGetYearDonated", ".", "setText", "(", "brick", ".", "getYearDonated", "(", ")", ")", ";", "labelGetDonatedFor", ".", "setText", "(", "brick", ".", "getDonatedFor", "(", ")", ")", ";", "labelGetDistance", ".", "setText", "(", "brick", ".", "getDistance", "(", ")", ")", ";", "buttonBack", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "PageController", ".", "sharedPageController", "(", ")", ".", "showSearchResultsPage", "(", "sp", ")", ";", "}", "}", ")", ";", "}", "}", "</s>" ]
7,545
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "com", ".", "google", ".", "gwt", ".", "cell", ".", "client", ".", "TextCell", ";", "import", "com", ".", "google", ".", "gwt", ".", "core", ".", "client", ".", "EntryPoint", ";", "import", "com", ".", "google", ".", "gwt", ".", "core", ".", "client", ".", "GWT", ";", "import", "com", ".", "google", ".", "gwt", ".", "event", ".", "dom", ".", "client", ".", "ClickEvent", ";", "import", "com", ".", "google", ".", "gwt", ".", "event", ".", "dom", ".", "client", ".", "ClickHandler", ";", "import", "com", ".", "google", ".", "gwt", ".", "uibinder", ".", "client", ".", "UiField", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "cellview", ".", "client", ".", "Column", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "cellview", ".", "client", ".", "DataGrid", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "cellview", ".", "client", ".", "SimplePager", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "cellview", ".", "client", ".", "SimplePager", ".", "TextLocation", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "Window", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Label", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "ListBox", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "RootPanel", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "TextBox", ";", "import", "com", ".", "google", ".", "gwt", ".", "view", ".", "client", ".", "SelectionChangeEvent", ";", "import", "com", ".", "google", ".", "gwt", ".", "view", ".", "client", ".", "SingleSelectionModel", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ".", "SearchParameter", ".", "Quadrant", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ".", "SearchParameter", ".", "SearchFor", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ".", "SearchParameter", ".", "SearchType", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Bench", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Brick", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "DonatedObject", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Tree", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Button", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "CheckBox", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "AbsolutePanel", ";", "import", "com", ".", "google", ".", "gwt", ".", "user", ".", "client", ".", "ui", ".", "Image", ";", "public", "class", "SearchResultsPage", "implements", "EntryPoint", "{", "@", "UiField", "(", "provided", "=", "true", ")", "DataGrid", "<", "DonatedObject", ">", "dataGrid", "=", "new", "DataGrid", "<", "DonatedObject", ">", "(", ")", ";", "@", "UiField", "(", "provided", "=", "true", ")", "SimplePager", "pager", ";", "private", "RootPanel", "rootPanel", "=", "RootPanel", ".", "get", "(", ")", ";", "private", "AbsolutePanel", "absolutePanel", "=", "new", "AbsolutePanel", "(", ")", ";", "Image", "image", ";", "Searcher", "searcher", "=", "new", "Searcher", "(", ")", ";", "ArrayList", "<", "DonatedObject", ">", "sampleTreeList", "=", "new", "ArrayList", "<", "DonatedObject", ">", "(", ")", ";", "ArrayList", "<", "DonatedObject", ">", "sampleBenchList", "=", "new", "ArrayList", "<", "DonatedObject", ">", "(", ")", ";", "ArrayList", "<", "DonatedObject", ">", "sampleBrickList", "=", "new", "ArrayList", "<", "DonatedObject", ">", "(", ")", ";", "CheckBox", "checkBoxQuadrantA", "=", "new", "CheckBox", "(", "\"A\"", ")", ";", "CheckBox", "checkBoxQuadrantB", "=", "new", "CheckBox", "(", "\"B\"", ")", ";", "CheckBox", "checkBoxQuadrantC", "=", "new", "CheckBox", "(", "\"C\"", ")", ";", "CheckBox", "checkBoxQuadrantD", "=", "new", "CheckBox", "(", "\"D\"", ")", ";", "CheckBox", "checkBoxQuadrantE", "=", "new", "CheckBox", "(", "\"E\"", ")", ";", "Column", "<", "DonatedObject", ",", "String", ">", "donatedForColumn", ";", "Column", "<", "DonatedObject", ",", "String", ">", "yearDonatedColumn", ";", "Column", "<", "DonatedObject", ",", "String", ">", "quadrantColumn", ";", "Column", "<", "DonatedObject", ",", "String", ">", "commonNameColumn", ";", "Column", "<", "DonatedObject", ",", "String", ">", "scientificNameColumn", ";", "Column", "<", "DonatedObject", ",", "String", ">", "benchTypeColumn", ";", "Column", "<", "DonatedObject", ",", "String", ">", "brickLocationColumn", ";", "Column", "<", "DonatedObject", ",", "String", ">", "brickSizeColumn", ";", "ListBox", "byListBox", "=", "new", "ListBox", "(", ")", ";", "ListBox", "inListBox", "=", "new", "ListBox", "(", ")", ";", "Label", "searchResultsLabel", "=", "new", "Label", "(", "\"\"", ")", ";", "Label", "inLabel", "=", "new", "Label", "(", "\"In:\"", ")", ";", "Label", "byLabel", "=", "new", "Label", "(", "\"By:\"", ")", ";", "Label", "locatedInQuadrantLabel", "=", "new", "Label", "(", "\"\"", ")", ";", "TextBox", "searchKeywordsTextBox", "=", "new", "TextBox", "(", ")", ";", "Button", "updateSearchButton", "=", "new", "Button", "(", "\"\"", ")", ";", "Button", "backButton", "=", "new", "Button", "(", "\"BACK\"", ")", ";", "@", "Override", "public", "void", "onModuleLoad", "(", ")", "{", "this", ".", "show", "(", "new", "SearchParameter", "(", ")", ")", ";", "}", "public", "SearchResultsPage", "(", ")", "{", "rootPanel", ".", "setSize", "(", "\"1200\"", ",", "\"900\"", ")", ";", "absolutePanel", ".", "setSize", "(", "\"1062px\"", ",", "\"1001px\"", ")", ";", "absolutePanel", ".", "add", "(", "dataGrid", ",", "0", ",", "133", ")", ";", "dataGrid", ".", "setSize", "(", "\"1040px\"", ",", "\"308px\"", ")", ";", "searcher", ".", "updateLocalMasterLists", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "100", ";", "i", "++", ")", "{", "sampleBenchList", ".", "add", "(", "new", "Bench", "(", ")", ")", ";", "sampleBrickList", ".", "add", "(", "new", "Brick", "(", ")", ")", ";", "sampleTreeList", ".", "add", "(", "new", "Tree", "(", ")", ")", ";", "}", "commonNameColumn", "=", "new", "Column", "<", "DonatedObject", ",", "String", ">", "(", "new", "TextCell", "(", ")", ")", "{", "@", "Override", "public", "String", "getValue", "(", "DonatedObject", "tree", ")", "{", "if", "(", "tree", "instanceof", "Tree", ")", "return", "(", "(", "Tree", ")", "tree", ")", ".", "getCommonName", "(", ")", ";", "else", "return", "null", ";", "}", "}", ";", "scientificNameColumn", "=", "new", "Column", "<", "DonatedObject", ",", "String", ">", "(", "new", "TextCell", "(", ")", ")", "{", "@", "Override", "public", "String", "getValue", "(", "DonatedObject", "tree", ")", "{", "if", "(", "tree", "instanceof", "Tree", ")", "return", "(", "(", "Tree", ")", "tree", ")", ".", "getScientificName", "(", ")", ";", "else", "return", "null", ";", "}", "}", ";", "donatedForColumn", "=", "new", "Column", "<", "DonatedObject", ",", "String", ">", "(", "new", "TextCell", "(", ")", ")", "{", "@", "Override", "public", "String", "getValue", "(", "DonatedObject", "o", ")", "{", "return", "o", ".", "getDonatedFor", "(", ")", ";", "}", "}", ";", "yearDonatedColumn", "=", "new", "Column", "<", "DonatedObject", ",", "String", ">", "(", "new", "TextCell", "(", ")", ")", "{", "@", "Override", "public", "String", "getValue", "(", "DonatedObject", "o", ")", "{", "return", "o", ".", "getYearDonated", "(", ")", ";", "}", "}", ";", "quadrantColumn", "=", "new", "Column", "<", "DonatedObject", ",", "String", ">", "(", "new", "TextCell", "(", ")", ")", "{", "@", "Override", "public", "String", "getValue", "(", "DonatedObject", "o", ")", "{", "return", "o", ".", "getQuadrant", "(", ")", ".", "toString", "(", ")", ";", "}", "}", ";", "benchTypeColumn", "=", "new", "Column", "<", "DonatedObject", ",", "String", ">", "(", "new", "TextCell", "(", ")", ")", "{", "@", "Override", "public", "String", "getValue", "(", "DonatedObject", "o", ")", "{", "if", "(", "o", "instanceof", "Bench", ")", "return", "(", "(", "Bench", ")", "o", ")", ".", "getBenchType", "(", ")", ";", "else", "return", "null", ";", "}", "}", ";", "brickLocationColumn", "=", "new", "Column", "<", "DonatedObject", ",", "String", ">", "(", "new", "TextCell", "(", ")", ")", "{", "@", "Override", "public", "String", "getValue", "(", "DonatedObject", "brick", ")", "{", "if", "(", "brick", "instanceof", "Brick", ")", "return", "(", "(", "Brick", ")", "brick", ")", ".", "getDistance", "(", ")", ";", "else", "return", "null", ";", "}", "}", ";", "brickSizeColumn", "=", "new", "Column", "<", "DonatedObject", ",", "String", ">", "(", "new", "TextCell", "(", ")", ")", "{", "@", "Override", "public", "String", "getValue", "(", "DonatedObject", "brick", ")", "{", "if", "(", "brick", "instanceof", "Brick", ")", "return", "(", "(", "Brick", ")", "brick", ")", ".", "getSize", "(", ")", ";", "else", "return", "null", ";", "}", "}", ";", "dataGrid", ".", "addColumn", "(", "commonNameColumn", ",", "\"Common", "Name\"", ")", ";", "dataGrid", ".", "addColumn", "(", "scientificNameColumn", ",", "\"\"", ")", ";", "dataGrid", ".", "addColumn", "(", "donatedForColumn", ",", "\"Donated", "For\"", ")", ";", "dataGrid", ".", "addColumn", "(", "yearDonatedColumn", ",", "\"Year", "Donated\"", ")", ";", "dataGrid", ".", "addColumn", "(", "quadrantColumn", ",", "\"\"", ")", ";", "dataGrid", ".", "setTitle", "(", "\"\"", ")", ";", "byListBox", ".", "addItem", "(", "\"Donated", "For\"", ")", ";", "byListBox", ".", "addItem", "(", "\"Common", "Name\"", ")", ";", "byListBox", ".", "addItem", "(", "\"\"", ")", ";", "byListBox", ".", "setSize", "(", "\"192px\"", ",", "\"74px\"", ")", ";", "byListBox", ".", "setVisibleItemCount", "(", "1", ")", ";", "inListBox", ".", "addItem", "(", "\"Trees\"", ")", ";", "inListBox", ".", "addItem", "(", "\"Benches\"", ")", ";", "inListBox", ".", "addItem", "(", "\"Bricks\"", ")", ";", "inListBox", ".", "setSize", "(", "\"117px\"", ",", "\"22px\"", ")", ";", "inListBox", ".", "setVisibleItemCount", "(", "1", ")", ";", "absolutePanel", ".", "add", "(", "byListBox", ",", "427", ",", "52", ")", ";", "absolutePanel", ".", "add", "(", "inListBox", ",", "44", ",", "52", ")", ";", "absolutePanel", ".", "add", "(", "checkBoxQuadrantA", ",", "528", ",", "10", ")", ";", "checkBoxQuadrantA", ".", "setSize", "(", "\"36px\"", ",", "\"20px\"", ")", ";", "absolutePanel", ".", "add", "(", "checkBoxQuadrantB", ",", "570", ",", "10", ")", ";", "checkBoxQuadrantB", ".", "setSize", "(", "\"36px\"", ",", "\"20px\"", ")", ";", "absolutePanel", ".", "add", "(", "checkBoxQuadrantC", ",", "611", ",", "10", ")", ";", "checkBoxQuadrantC", ".", "setSize", "(", "\"36px\"", ",", "\"20px\"", ")", ";", "absolutePanel", ".", "add", "(", "checkBoxQuadrantD", ",", "653", ",", "10", ")", ";", "checkBoxQuadrantD", ".", "setSize", "(", "\"36px\"", ",", "\"20px\"", ")", ";", "absolutePanel", ".", "add", "(", "checkBoxQuadrantE", ",", "695", ",", "10", ")", ";", "absolutePanel", ".", "add", "(", "searchResultsLabel", ",", "24", ",", "10", ")", ";", "absolutePanel", ".", "add", "(", "inLabel", ",", "24", ",", "52", ")", ";", "inLabel", ".", "setSize", "(", "\"14px\"", ",", "\"24px\"", ")", ";", "absolutePanel", ".", "add", "(", "byLabel", ",", "401", ",", "53", ")", ";", "byLabel", ".", "setSize", "(", "\"20px\"", ",", "\"24px\"", ")", ";", "absolutePanel", ".", "add", "(", "locatedInQuadrantLabel", ",", "401", ",", "10", ")", ";", "locatedInQuadrantLabel", ".", "setSize", "(", "\"121px\"", ",", "\"24px\"", ")", ";", "absolutePanel", ".", "add", "(", "searchKeywordsTextBox", ",", "149", ",", "10", ")", ";", "searchKeywordsTextBox", ".", "setSize", "(", "\"222px\"", ",", "\"12px\"", ")", ";", "absolutePanel", ".", "add", "(", "updateSearchButton", ",", "839", ",", "24", ")", ";", "updateSearchButton", ".", "setSize", "(", "\"173px\"", ",", "\"81px\"", ")", ";", "updateSearchButton", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "if", "(", "currentConfigurationIsAcceptable", "(", ")", ")", "{", "SearchParameter", "newParam", "=", "extractSearchParameterFromConfiguration", "(", ")", ";", "configureColumnsBasedOnSearchParameter", "(", "newParam", ")", ";", "}", "}", "}", ")", ";", "absolutePanel", ".", "add", "(", "backButton", ",", "839", ",", "494", ")", ";", "backButton", ".", "setSize", "(", "\"173px\"", ",", "\"81px\"", ")", ";", "backButton", ".", "addClickHandler", "(", "new", "ClickHandler", "(", ")", "{", "public", "void", "onClick", "(", "ClickEvent", "event", ")", "{", "rootPanel", ".", "clear", "(", ")", ";", "PageController", ".", "sharedPageController", "(", ")", ".", "showMainPage", "(", ")", ";", "}", "}", ")", ";", "final", "SingleSelectionModel", "<", "DonatedObject", ">", "selectionModel", "=", "new", "SingleSelectionModel", "<", "DonatedObject", ">", "(", ")", ";", "dataGrid", ".", "setSelectionModel", "(", "selectionModel", ")", ";", "selectionModel", ".", "addSelectionChangeHandler", "(", "new", "SelectionChangeEvent", ".", "Handler", "(", ")", "{", "public", "void", "onSelectionChange", "(", "SelectionChangeEvent", "event", ")", "{", "DonatedObject", "selectedObject", "=", "selectionModel", ".", "getSelectedObject", "(", ")", ";", "if", "(", "selectedObject", "!=", "null", ")", "{", "rootPanel", ".", "clear", "(", ")", ";", "SearchParameter", "searchParameter", "=", "extractSearchParameterFromConfiguration", "(", ")", ";", "if", "(", "selectedObject", "instanceof", "Tree", ")", "{", "PageController", ".", "sharedPageController", "(", ")", ".", "showTreePage", "(", "(", "Tree", ")", "selectedObject", ",", "searchParameter", ")", ";", "}", "if", "(", "selectedObject", "instanceof", "Bench", ")", "{", "PageController", ".", "sharedPageController", "(", ")", ".", "showBenchPage", "(", "(", "Bench", ")", "selectedObject", ",", "searchParameter", ")", ";", "}", "if", "(", "selectedObject", "instanceof", "Brick", ")", "{", "PageController", ".", "sharedPageController", "(", ")", ".", "showBrickPage", "(", "(", "Brick", ")", "selectedObject", ",", "searchParameter", ")", ";", "}", "}", "}", "}", ")", ";", "}", "public", "void", "show", "(", "final", "SearchParameter", "searchParameter", ")", "{", "rootPanel", ".", "add", "(", "absolutePanel", ",", "0", ",", "0", ")", ";", "rootPanel", ".", "add", "(", "image", ",", "54", ",", "44", ")", ";", "image", ".", "setSize", "(", "\"100px\"", ",", "\"100px\"", ")", ";", "configureColumnsBasedOnSearchParameter", "(", "searchParameter", ")", ";", "searchKeywordsTextBox", ".", "setText", "(", "searchParameter", ".", "getKeywordQuery", "(", ")", ")", ";", "if", "(", "searchParameter", ".", "getSearchType", "(", ")", "==", "SearchType", ".", "donatedFor", ")", "byListBox", ".", "setItemSelected", "(", "0", ",", "true", ")", ";", "if", "(", "searchParameter", ".", "getSearchType", "(", ")", "==", "SearchType", ".", "commonName", ")", "byListBox", ".", "setItemSelected", "(", "1", ",", "true", ")", ";", "if", "(", "searchParameter", ".", "getSearchType", "(", ")", "==", "SearchType", ".", "scientificName", ")", "byListBox", ".", "setItemSelected", "(", "2", ",", "true", ")", ";", "if", "(", "searchParameter", ".", "getSearchFor", "(", ")", "==", "SearchFor", ".", "trees", ")", "inListBox", ".", "setItemSelected", "(", "0", ",", "true", ")", ";", "if", "(", "searchParameter", ".", "getSearchFor", "(", ")", "==", "SearchFor", ".", "benches", ")", "inListBox", ".", "setItemSelected", "(", "1", ",", "true", ")", ";", "if", "(", "searchParameter", ".", "getSearchFor", "(", ")", "==", "SearchFor", ".", "bricks", ")", "inListBox", ".", "setItemSelected", "(", "2", ",", "true", ")", ";", "if", "(", "searchParameter", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "A", ")", ")", "checkBoxQuadrantA", ".", "setValue", "(", "true", ")", ";", "if", "(", "searchParameter", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "B", ")", ")", "checkBoxQuadrantB", ".", "setValue", "(", "true", ")", ";", "if", "(", "searchParameter", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "C", ")", ")", "checkBoxQuadrantC", ".", "setValue", "(", "true", ")", ";", "if", "(", "searchParameter", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "D", ")", ")", "checkBoxQuadrantD", ".", "setValue", "(", "true", ")", ";", "if", "(", "searchParameter", ".", "getQuadrants", "(", ")", ".", "contains", "(", "Quadrant", ".", "E", ")", ")", "checkBoxQuadrantE", ".", "setValue", "(", "true", ")", ";", "dataGrid", ".", "setPageSize", "(", "50", ")", ";", "SimplePager", ".", "Resources", "pagerResources", "=", "GWT", ".", "create", "(", "SimplePager", ".", "Resources", ".", "class", ")", ";", "pager", "=", "new", "SimplePager", "(", "TextLocation", ".", "CENTER", ",", "pagerResources", ",", "false", ",", "0", ",", "true", ")", ";", "pager", ".", "setVisible", "(", "true", ")", ";", "}", "private", "void", "configureColumnsBasedOnSearchParameter", "(", "SearchParameter", "searchParameter", ")", "{", "if", "(", "searchParameter", ".", "getSearchFor", "(", ")", "==", "SearchFor", ".", "trees", ")", "{", "ArrayList", "<", "Tree", ">", "trees", "=", "searcher", ".", "searchResultsForTreeSearch", "(", "searchParameter", ")", ";", "dataGrid", ".", "setRowData", "(", "trees", ")", ";", "if", "(", "dataGrid", ".", "getColumnIndex", "(", "scientificNameColumn", ")", "==", "-", "1", ")", "{", "dataGrid", ".", "insertColumn", "(", "0", ",", "scientificNameColumn", ",", "\"\"", ")", ";", "}", "if", "(", "dataGrid", ".", "getColumnIndex", "(", "commonNameColumn", ")", "==", "-", "1", ")", "{", "dataGrid", ".", "insertColumn", "(", "0", ",", "commonNameColumn", ",", "\"Common", "Name\"", ")", ";", "}", "if", "(", "!", "(", "dataGrid", ".", "getColumnIndex", "(", "benchTypeColumn", ")", "==", "-", "1", ")", ")", "{", "dataGrid", ".", "removeColumn", "(", "benchTypeColumn", ")", ";", "}", "if", "(", "!", "(", "dataGrid", ".", "getColumnIndex", "(", "brickLocationColumn", ")", "==", "-", "1", ")", ")", "{", "dataGrid", ".", "removeColumn", "(", "brickLocationColumn", ")", ";", "}", "if", "(", "!", "(", "dataGrid", ".", "getColumnIndex", "(", "brickSizeColumn", ")", "==", "-", "1", ")", ")", "{", "dataGrid", ".", "removeColumn", "(", "brickSizeColumn", ")", ";", "}", "setupMapForTrees", "(", "trees", ")", ";", "}", "if", "(", "searchParameter", ".", "getSearchFor", "(", ")", "==", "SearchFor", ".", "benches", ")", "{", "ArrayList", "<", "Bench", ">", "benches", "=", "searcher", ".", "searchResultsForBenchSearch", "(", "searchParameter", ")", ";", "dataGrid", ".", "setRowData", "(", "sampleBenchList", ")", ";", "if", "(", "!", "(", "dataGrid", ".", "getColumnIndex", "(", "commonNameColumn", ")", "==", "-", "1", ")", ")", "{", "dataGrid", ".", "removeColumn", "(", "commonNameColumn", ")", ";", "}", "if", "(", "!", "(", "dataGrid", ".", "getColumnIndex", "(", "scientificNameColumn", ")", "==", "-", "1", ")", ")", "{", "dataGrid", ".", "removeColumn", "(", "scientificNameColumn", ")", ";", "}", "if", "(", "dataGrid", ".", "getColumnIndex", "(", "benchTypeColumn", ")", "==", "-", "1", ")", "{", "dataGrid", ".", "addColumn", "(", "benchTypeColumn", ",", "\"Bench", "Type\"", ")", ";", "}", "if", "(", "!", "(", "dataGrid", ".", "getColumnIndex", "(", "brickLocationColumn", ")", "==", "-", "1", ")", ")", "{", "dataGrid", ".", "removeColumn", "(", "brickLocationColumn", ")", ";", "}", "if", "(", "!", "(", "dataGrid", ".", "getColumnIndex", "(", "brickSizeColumn", ")", "==", "-", "1", ")", ")", "{", "dataGrid", ".", "removeColumn", "(", "brickSizeColumn", ")", ";", "}", "setupMapForBenches", "(", "benches", ")", ";", "}", "if", "(", "searchParameter", ".", "getSearchFor", "(", ")", "==", "SearchFor", ".", "bricks", ")", "{", "dataGrid", ".", "setRowData", "(", "sampleBrickList", ")", ";", "if", "(", "!", "(", "dataGrid", ".", "getColumnIndex", "(", "commonNameColumn", ")", "==", "-", "1", ")", ")", "{", "dataGrid", ".", "removeColumn", "(", "commonNameColumn", ")", ";", "}", "if", "(", "!", "(", "dataGrid", ".", "getColumnIndex", "(", "scientificNameColumn", ")", "==", "-", "1", ")", ")", "{", "dataGrid", ".", "removeColumn", "(", "scientificNameColumn", ")", ";", "}", "if", "(", "!", "(", "dataGrid", ".", "getColumnIndex", "(", "benchTypeColumn", ")", "==", "-", "1", ")", ")", "{", "dataGrid", ".", "removeColumn", "(", "benchTypeColumn", ")", ";", "}", "if", "(", "dataGrid", ".", "getColumnIndex", "(", "brickLocationColumn", ")", "==", "-", "1", ")", "{", "dataGrid", ".", "addColumn", "(", "brickLocationColumn", ",", "\"\"", ")", ";", "}", "if", "(", "dataGrid", ".", "getColumnIndex", "(", "brickSizeColumn", ")", "==", "-", "1", ")", "{", "dataGrid", ".", "addColumn", "(", "brickSizeColumn", ",", "\"Brick", "Size\"", ")", ";", "}", "}", "dataGrid", ".", "redraw", "(", ")", ";", "}", "private", "void", "setupMapForTrees", "(", "ArrayList", "<", "Tree", ">", "sampleTreeList2", ")", "{", "String", "baseString", "=", "\"\"", "+", "\"\"", ";", "for", "(", "Tree", "tree", ":", "sampleTreeList2", ")", "{", "String", "appendingString", "=", "\"\"", "+", "tree", ".", "getLatitude", "(", ")", "+", "\",", "\"", "+", "tree", ".", "getLongitude", "(", ")", ";", "baseString", "+=", "appendingString", ";", "}", "baseString", "+=", "\"\"", ";", "image", ".", "setUrl", "(", "baseString", ")", ";", "}", "private", "void", "setupMapForBenches", "(", "ArrayList", "<", "Bench", ">", "benches", ")", "{", "String", "baseString", "=", "\"\"", "+", "\"\"", ";", "for", "(", "Bench", "bench", ":", "benches", ")", "{", "String", "appendingString", "=", "\"\"", "+", "bench", ".", "getLatitude", "(", ")", "+", "\",", "\"", "+", "bench", ".", "getLongitude", "(", ")", ";", "baseString", "+=", "appendingString", ";", "}", "baseString", "+=", "\"\"", ";", "image", ".", "setUrl", "(", "baseString", ")", ";", "}", "private", "boolean", "currentConfigurationIsAcceptable", "(", ")", "{", "if", "(", "!", "checkBoxQuadrantA", ".", "getValue", "(", ")", "&&", "!", "checkBoxQuadrantB", ".", "getValue", "(", ")", "&&", "!", "checkBoxQuadrantC", ".", "getValue", "(", ")", "&&", "!", "checkBoxQuadrantD", ".", "getValue", "(", ")", "&&", "!", "checkBoxQuadrantE", ".", "getValue", "(", ")", ")", "{", "Window", ".", "alert", "(", "\"\"", ")", ";", "return", "false", ";", "}", "if", "(", "inListBox", ".", "getSelectedIndex", "(", ")", "==", "-", "1", ")", "{", "Window", ".", "alert", "(", "\"\"", ")", ";", "return", "false", ";", "}", "String", "searchInSelectedText", "=", "inListBox", ".", "getItemText", "(", "inListBox", ".", "getSelectedIndex", "(", ")", ")", ";", "String", "searchForSelectedText", "=", "byListBox", ".", "getItemText", "(", "byListBox", ".", "getSelectedIndex", "(", ")", ")", ";", "if", "(", "(", "searchInSelectedText", ".", "equals", "(", "\"Benches\"", ")", "||", "searchInSelectedText", ".", "equals", "(", "\"Bricks\"", ")", ")", "&&", "searchForSelectedText", ".", "equals", "(", "\"Common", "Name\"", ")", "||", "searchForSelectedText", ".", "equals", "(", "\"\"", ")", ")", "{", "Window", ".", "alert", "(", "\"\"", "+", "\"\"", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", "private", "SearchParameter", "extractSearchParameterFromConfiguration", "(", ")", "{", "SearchFor", "searchFor", "=", "SearchFor", ".", "trees", ";", "if", "(", "inListBox", ".", "getItemText", "(", "inListBox", ".", "getSelectedIndex", "(", ")", ")", ".", "equals", "(", "\"Trees\"", ")", ")", "searchFor", "=", "SearchFor", ".", "trees", ";", "if", "(", "inListBox", ".", "getItemText", "(", "inListBox", ".", "getSelectedIndex", "(", ")", ")", ".", "equals", "(", "\"Benches\"", ")", ")", "searchFor", "=", "SearchFor", ".", "benches", ";", "if", "(", "inListBox", ".", "getItemText", "(", "inListBox", ".", "getSelectedIndex", "(", ")", ")", ".", "equals", "(", "\"Bricks\"", ")", ")", "searchFor", "=", "SearchFor", ".", "bricks", ";", "SearchType", "searchType", "=", "SearchType", ".", "commonName", ";", "if", "(", "byListBox", ".", "getItemText", "(", "byListBox", ".", "getSelectedIndex", "(", ")", ")", ".", "equals", "(", "\"Donated", "For\"", ")", ")", "searchType", "=", "SearchType", ".", "donatedFor", ";", "if", "(", "byListBox", ".", "getItemText", "(", "byListBox", ".", "getSelectedIndex", "(", ")", ")", ".", "equals", "(", "\"Common", "Name\"", ")", ")", "searchType", "=", "SearchType", ".", "commonName", ";", "if", "(", "byListBox", ".", "getItemText", "(", "byListBox", ".", "getSelectedIndex", "(", ")", ")", ".", "equals", "(", "\"\"", ")", ")", "searchType", "=", "SearchType", ".", "scientificName", ";", "ArrayList", "<", "Quadrant", ">", "quadrants", "=", "new", "ArrayList", "<", "Quadrant", ">", "(", ")", ";", "if", "(", "checkBoxQuadrantA", ".", "getValue", "(", ")", ")", "quadrants", ".", "add", "(", "Quadrant", ".", "A", ")", ";", "if", "(", "checkBoxQuadrantB", ".", "getValue", "(", ")", ")", "quadrants", ".", "add", "(", "Quadrant", ".", "B", ")", ";", "if", "(", "checkBoxQuadrantC", ".", "getValue", "(", ")", ")", "quadrants", ".", "add", "(", "Quadrant", ".", "C", ")", ";", "if", "(", "checkBoxQuadrantD", ".", "getValue", "(", ")", ")", "quadrants", ".", "add", "(", "Quadrant", ".", "D", ")", ";", "if", "(", "checkBoxQuadrantE", ".", "getValue", "(", ")", ")", "quadrants", ".", "add", "(", "Quadrant", ".", "E", ")", ";", "SearchParameter", "newParam", "=", "new", "SearchParameter", "(", "searchKeywordsTextBox", ".", "getText", "(", ")", ",", "searchFor", ",", "searchType", ",", "quadrants", ",", "false", ")", ";", "return", "newParam", ";", "}", "}", "</s>" ]
7,546
[ "<s>", "package", "edu", ".", "gac", ".", "arboretumweb", ".", "client", ";", "import", "com", ".", "google", ".", "gwt", ".", "core", ".", "client", ".", "EntryPoint", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Bench", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Brick", ";", "import", "edu", ".", "gac", ".", "arboretumweb", ".", "shared", ".", "domain", ".", "Tree", ";", "public", "class", "PageController", "implements", "EntryPoint", "{", "private", "static", "PageController", "instance", "=", "null", ";", "private", "final", "MainPage", "mainPage", "=", "new", "MainPage", "(", ")", ";", "private", "final", "SearchResultsPage", "searchResultsPage", "=", "new", "SearchResultsPage", "(", ")", ";", "private", "final", "TreePage", "treePage", "=", "new", "TreePage", "(", ")", ";", "private", "final", "BenchPage", "benchPage", "=", "new", "BenchPage", "(", ")", ";", "private", "final", "BrickPage", "brickPage", "=", "new", "BrickPage", "(", ")", ";", "protected", "PageController", "(", ")", "{", "}", "public", "static", "PageController", "sharedPageController", "(", ")", "{", "if", "(", "instance", "==", "null", ")", "{", "instance", "=", "new", "PageController", "(", ")", ";", "}", "return", "instance", ";", "}", "public", "void", "showMainPage", "(", ")", "{", "mainPage", ".", "show", "(", ")", ";", "}", "public", "void", "showSearchResultsPage", "(", "SearchParameter", "p", ")", "{", "searchResultsPage", ".", "show", "(", "p", ")", ";", "}", "public", "void", "showTreePage", "(", "Tree", "tree", ",", "SearchParameter", "sp", ")", "{", "treePage", ".", "show", "(", "tree", ",", "sp", ")", ";", "}", "public", "void", "showBenchPage", "(", "Bench", "bench", ",", "SearchParameter", "sp", ")", "{", "benchPage", ".", "show", "(", "bench", ",", "sp", ")", ";", "}", "public", "void", "showBrickPage", "(", "Brick", "brick", ",", "SearchParameter", "sp", ")", "{", "brickPage", ".", "show", "(", "brick", ",", "sp", ")", ";", "}", "@", "Override", "public", "void", "onModuleLoad", "(", ")", "{", "showMainPage", "(", ")", ";", "}", "}", "</s>" ]
7,547
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ";", "import", "java", ".", "io", ".", "Reader", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "filters", ".", "BaseParamFilterReader", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "filters", ".", "ChainableReader", ";", "public", "class", "MarkdownFilter", "extends", "BaseParamFilterReader", "implements", "ChainableReader", "{", "char", "[", "]", "chars", "=", "null", ";", "int", "pos", "=", "0", ";", "int", "len", "=", "0", ";", "public", "MarkdownFilter", "(", ")", "{", "super", "(", ")", ";", "}", "public", "MarkdownFilter", "(", "Reader", "reader", ")", "{", "super", "(", "reader", ")", ";", "}", "public", "Reader", "chain", "(", "Reader", "reader", ")", "{", "MarkdownFilter", "result", "=", "new", "MarkdownFilter", "(", "reader", ")", ";", "result", ".", "setParameters", "(", "this", ".", "getParameters", "(", ")", ")", ";", "return", "(", "result", ")", ";", "}", "@", "Override", "public", "final", "int", "read", "(", ")", "throws", "java", ".", "io", ".", "IOException", "{", "if", "(", "chars", "==", "null", ")", "{", "char", "[", "]", "cbuf", "=", "new", "char", "[", "1024", "]", ";", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "int", "charsRead", "=", "in", ".", "read", "(", "cbuf", ")", ";", "while", "(", "charsRead", ">=", "0", ")", "{", "buf", ".", "append", "(", "cbuf", ",", "0", ",", "charsRead", ")", ";", "charsRead", "=", "in", ".", "read", "(", "cbuf", ")", ";", "}", "MarkdownProcessor", "markdown", "=", "new", "MarkdownProcessor", "(", ")", ";", "chars", "=", "markdown", ".", "markdown", "(", "buf", ".", "toString", "(", ")", ")", ".", "toCharArray", "(", ")", ";", "len", "=", "chars", ".", "length", ";", "}", "return", "(", "pos", ">=", "len", "?", "-", "1", ":", "chars", "[", "pos", "++", "]", ")", ";", "}", "}", "</s>" ]
7,548
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ".", "test", ";", "import", "com", ".", "petebevin", ".", "markdown", ".", "TextEditor", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "TestTextEditor", "{", "@", "Test", "public", "void", "testDetabify", "(", ")", "{", "assertEquals", "(", "\"", "\"", ",", "new", "TextEditor", "(", "\"t\"", ")", ".", "detabify", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "\"", "\"", ",", "new", "TextEditor", "(", "\"", "t\"", ")", ".", "detabify", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "\"", "\"", ",", "new", "TextEditor", "(", "\"", "t\"", ")", ".", "detabify", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "\"", "\"", ",", "new", "TextEditor", "(", "\"", "t\"", ")", ".", "detabify", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "\"", "\"", ",", "new", "TextEditor", "(", "\"", "t\"", ")", ".", "detabify", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "\"", "\"", ",", "new", "TextEditor", "(", "\"t", "\"", ")", ".", "detabify", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "\"", "\"", ",", "new", "TextEditor", "(", "\"t", "t\"", ")", ".", "detabify", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "}", "</s>" ]
7,549
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ".", "test", ";", "import", "com", ".", "petebevin", ".", "markdown", ".", "MarkdownProcessor", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "LineConventions", "{", "private", "static", "final", "String", "EXPECTED", "=", "\"\"", ";", "private", "MarkdownProcessor", "m", ";", "@", "Before", "public", "void", "createProcessor", "(", ")", "{", "m", "=", "new", "MarkdownProcessor", "(", ")", ";", "}", "@", "Test", "public", "void", "testUnixLineConventions", "(", ")", "{", "assertEquals", "(", "EXPECTED", ",", "m", ".", "markdown", "(", "\"anbncn\"", ")", ")", ";", "}", "@", "Test", "public", "void", "testWindowsLineConventions", "(", ")", "{", "MarkdownProcessor", "markup", "=", "new", "MarkdownProcessor", "(", ")", ";", "assertEquals", "(", "EXPECTED", ",", "markup", ".", "markdown", "(", "\"arnbrncrn\"", ")", ")", ";", "}", "@", "Test", "public", "void", "testMacLineConventions", "(", ")", "{", "MarkdownProcessor", "markup", "=", "new", "MarkdownProcessor", "(", ")", ";", "assertEquals", "(", "EXPECTED", ",", "markup", ".", "markdown", "(", "\"arbrcr\"", ")", ")", ";", "}", "}", "</s>" ]
7,550
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ".", "test", ";", "import", "com", ".", "petebevin", ".", "markdown", ".", "MarkdownProcessor", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "EdgeCases", "{", "private", "MarkdownProcessor", "m", ";", "@", "Before", "public", "void", "createProcessor", "(", ")", "{", "m", "=", "new", "MarkdownProcessor", "(", ")", ";", "}", "@", "Test", "public", "void", "testEmptyString", "(", ")", "{", "assertEquals", "(", "\"n\"", ",", "m", ".", "markdown", "(", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "testSpaces", "(", ")", "{", "assertEquals", "(", "\"n\"", ",", "m", ".", "markdown", "(", "\"", "\"", ")", ")", ";", "}", "@", "Test", "public", "void", "testNull", "(", ")", "{", "assertEquals", "(", "\"n\"", ",", "m", ".", "markdown", "(", "null", ")", ")", ";", "}", "@", "Test", "public", "void", "testSplitAssumption", "(", ")", "{", "Pattern", "x", "=", "Pattern", ".", "compile", "(", "\"x\"", ")", ";", "String", "[", "]", "xs", "=", "x", ".", "split", "(", "\"\"", ")", ";", "assertEquals", "(", "1", ",", "xs", ".", "length", ")", ";", "assertEquals", "(", "\"\"", ",", "xs", "[", "0", "]", ")", ";", "}", "}", "</s>" ]
7,551
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ".", "test", ";", "import", "com", ".", "petebevin", ".", "markdown", ".", "HTMLDecoder", ";", "import", "com", ".", "petebevin", ".", "markdown", ".", "MarkdownProcessor", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "EmailAddresses", "{", "MarkdownProcessor", "m", ";", "@", "Before", "public", "void", "createProcessor", "(", ")", "{", "m", "=", "new", "MarkdownProcessor", "(", ")", ";", "}", "@", "Test", "public", "void", "testDecoder", "(", ")", "{", "String", "encoded", "=", "\"\"", ";", "String", "billg", "=", "\"\"", ";", "assertEquals", "(", "billg", ",", "HTMLDecoder", ".", "decode", "(", "encoded", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "HTMLDecoder", ".", "decode", "(", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "testEmail", "(", ")", "{", "String", "html", "=", "m", ".", "markdown", "(", "\"\"", ")", ";", "String", "plain", "=", "HTMLDecoder", ".", "decode", "(", "html", ")", ";", "assertEquals", "(", "\"\"", ",", "plain", ")", ";", "assertFalse", "(", "\"\"", ",", "plain", ".", "equals", "(", "html", ")", ")", ";", "}", "}", "</s>" ]
7,552
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ".", "test", ";", "import", "com", ".", "petebevin", ".", "markdown", ".", "MarkdownProcessor", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "EscapeSpecialCharsWithinTagAttributes", "{", "MarkdownProcessor", "m", ";", "@", "Before", "public", "void", "createProcessor", "(", ")", "{", "m", "=", "new", "MarkdownProcessor", "(", ")", ";", "}", "@", "Test", "public", "void", "testImages", "(", ")", "{", "String", "url", "=", "\"\"", ";", "String", "processed", "=", "m", ".", "markdown", "(", "url", ")", ";", "String", "output", "=", "\"\"", ";", "assertEquals", "(", "output", ",", "processed", ")", ";", "}", "@", "Test", "public", "void", "testAutoLinks", "(", ")", "{", "String", "url", "=", "\"\"", ";", "String", "processed", "=", "m", ".", "markdown", "(", "url", ")", ";", "String", "output", "=", "\"\"", ";", "assertEquals", "(", "output", ",", "processed", ")", ";", "}", "}", "</s>" ]
7,553
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ".", "test", ";", "public", "class", "TestResultPair", "{", "private", "String", "name", ";", "private", "String", "test", ";", "private", "String", "result", ";", "public", "TestResultPair", "(", "String", "name", ",", "String", "test", ",", "String", "result", ")", "{", "this", ".", "name", "=", "name", ";", "this", ".", "test", "=", "test", ";", "this", ".", "result", "=", "result", ";", "}", "public", "String", "getTest", "(", ")", "{", "return", "test", ";", "}", "public", "String", "getResult", "(", ")", "{", "return", "result", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "name", ";", "}", "}", "</s>" ]
7,554
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ".", "test", ";", "import", "com", ".", "petebevin", ".", "markdown", ".", "MarkdownProcessor", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "net", ".", "URLDecoder", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "junit", ".", "runners", ".", "Parameterized", ";", "import", "org", ".", "junit", ".", "runners", ".", "Parameterized", ".", "Parameters", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "@", "RunWith", "(", "value", "=", "Parameterized", ".", "class", ")", "public", "class", "MarkdownTestTester", "{", "private", "final", "static", "String", "MARKDOWN_TEST_DIR", "=", "\"\"", ";", "String", "test", ";", "String", "dir", ";", "@", "Parameters", "public", "static", "Collection", "<", "Object", "[", "]", ">", "markdownTests", "(", ")", "{", "List", "list", "=", "new", "ArrayList", "<", "Object", "[", "]", ">", "(", ")", ";", "URL", "fileUrl", "=", "MarkdownTestTester", ".", "class", ".", "getResource", "(", "MARKDOWN_TEST_DIR", ")", ";", "File", "dir", "=", "new", "File", "(", "fileUrl", ".", "getFile", "(", ")", ")", ";", "File", "[", "]", "dirEntries", "=", "dir", ".", "listFiles", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dirEntries", ".", "length", ";", "i", "++", ")", "{", "File", "dirEntry", "=", "dirEntries", "[", "i", "]", ";", "String", "fileName", "=", "dirEntry", ".", "getName", "(", ")", ";", "if", "(", "fileName", ".", "endsWith", "(", "\".text\"", ")", ")", "{", "String", "testName", "=", "fileName", ".", "substring", "(", "0", ",", "fileName", ".", "lastIndexOf", "(", "'.'", ")", ")", ";", "list", ".", "add", "(", "new", "Object", "[", "]", "{", "MARKDOWN_TEST_DIR", ",", "testName", "}", ")", ";", "}", "}", "return", "list", ";", "}", "public", "MarkdownTestTester", "(", "String", "dir", ",", "String", "test", ")", "{", "this", ".", "test", "=", "test", ";", "this", ".", "dir", "=", "dir", ";", "}", "@", "Test", "public", "void", "runTest", "(", ")", "throws", "IOException", "{", "String", "testText", "=", "slurp", "(", "dir", "+", "File", ".", "separator", "+", "test", "+", "\".text\"", ")", ";", "String", "htmlText", "=", "slurp", "(", "dir", "+", "File", ".", "separator", "+", "test", "+", "\".html\"", ")", ";", "MarkdownProcessor", "markup", "=", "new", "MarkdownProcessor", "(", ")", ";", "String", "markdownText", "=", "markup", ".", "markdown", "(", "testText", ")", ";", "assertEquals", "(", "test", ",", "htmlText", ".", "trim", "(", ")", ",", "markdownText", ".", "trim", "(", ")", ")", ";", "}", "private", "String", "slurp", "(", "String", "fileName", ")", "throws", "IOException", "{", "URL", "fileUrl", "=", "this", ".", "getClass", "(", ")", ".", "getResource", "(", "fileName", ")", ";", "File", "file", "=", "new", "File", "(", "URLDecoder", ".", "decode", "(", "fileUrl", ".", "getFile", "(", ")", ",", "\"UTF-8\"", ")", ")", ";", "FileReader", "in", "=", "new", "FileReader", "(", "file", ")", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "int", "ch", ";", "while", "(", "(", "ch", "=", "in", ".", "read", "(", ")", ")", "!=", "-", "1", ")", "{", "sb", ".", "append", "(", "(", "char", ")", "ch", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
7,555
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ".", "test", ";", "import", "com", ".", "petebevin", ".", "markdown", ".", "MarkdownProcessor", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "FileReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "junit", ".", "runners", ".", "Parameterized", ";", "import", "org", ".", "junit", ".", "runners", ".", "Parameterized", ".", "Parameters", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "@", "RunWith", "(", "value", "=", "Parameterized", ".", "class", ")", "public", "class", "MarkupFileTester", "{", "private", "final", "static", "String", "[", "]", "TEST_FILENAMES", "=", "new", "String", "[", "]", "{", "\"/dingus.txt\"", ",", "\"\"", ",", "\"\"", ",", "\"/lists.txt\"", "}", ";", "TestResultPair", "pair", ";", "@", "Parameters", "public", "static", "Collection", "<", "Object", "[", "]", ">", "testResultPairs", "(", ")", "throws", "IOException", "{", "List", "<", "TestResultPair", ">", "fullResultPairList", "=", "new", "ArrayList", "<", "TestResultPair", ">", "(", ")", ";", "for", "(", "String", "filename", ":", "TEST_FILENAMES", ")", "{", "fullResultPairList", ".", "addAll", "(", "newTestResultPairList", "(", "filename", ")", ")", ";", "}", "Collection", "<", "Object", "[", "]", ">", "testResultPairs", "=", "new", "ArrayList", "<", "Object", "[", "]", ">", "(", ")", ";", "for", "(", "TestResultPair", "p", ":", "fullResultPairList", ")", "{", "testResultPairs", ".", "add", "(", "new", "Object", "[", "]", "{", "p", "}", ")", ";", "}", "return", "testResultPairs", ";", "}", "public", "MarkupFileTester", "(", "TestResultPair", "pair", ")", "{", "this", ".", "pair", "=", "pair", ";", "}", "public", "static", "List", "<", "TestResultPair", ">", "newTestResultPairList", "(", "String", "filename", ")", "throws", "IOException", "{", "List", "<", "TestResultPair", ">", "list", "=", "new", "ArrayList", "<", "TestResultPair", ">", "(", ")", ";", "URL", "fileUrl", "=", "MarkupFileTester", ".", "class", ".", "getResource", "(", "filename", ")", ";", "FileReader", "file", "=", "new", "FileReader", "(", "fileUrl", ".", "getFile", "(", ")", ")", ";", "BufferedReader", "in", "=", "new", "BufferedReader", "(", "file", ")", ";", "StringBuffer", "test", "=", "null", ";", "StringBuffer", "result", "=", "null", ";", "Pattern", "pTest", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "Pattern", "pResult", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "String", "line", ";", "int", "lineNumber", "=", "0", ";", "String", "testNumber", "=", "null", ";", "String", "testName", "=", "null", ";", "StringBuffer", "curbuf", "=", "null", ";", "while", "(", "(", "line", "=", "in", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "lineNumber", "++", ";", "Matcher", "mTest", "=", "pTest", ".", "matcher", "(", "line", ")", ";", "Matcher", "mResult", "=", "pResult", ".", "matcher", "(", "line", ")", ";", "if", "(", "mTest", ".", "matches", "(", ")", ")", "{", "addTestResultPair", "(", "list", ",", "test", ",", "result", ",", "testNumber", ",", "testName", ")", ";", "testNumber", "=", "mTest", ".", "group", "(", "1", ")", ";", "testName", "=", "mTest", ".", "group", "(", "2", ")", ";", "test", "=", "new", "StringBuffer", "(", ")", ";", "result", "=", "new", "StringBuffer", "(", ")", ";", "curbuf", "=", "test", ";", "}", "else", "if", "(", "mResult", ".", "matches", "(", ")", ")", "{", "if", "(", "testNumber", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", "+", "lineNumber", "+", "\")\"", ")", ";", "}", "String", "resultNumber", "=", "mResult", ".", "group", "(", "1", ")", ";", "if", "(", "!", "testNumber", ".", "equals", "(", "resultNumber", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Result", "\"", "+", "resultNumber", "+", "\"", "test", "\"", "+", "testNumber", "+", "\"", "(line", "\"", "+", "lineNumber", "+", "\")\"", ")", ";", "}", "curbuf", "=", "result", ";", "}", "else", "{", "curbuf", ".", "append", "(", "line", ")", ";", "curbuf", ".", "append", "(", "\"n\"", ")", ";", "}", "}", "addTestResultPair", "(", "list", ",", "test", ",", "result", ",", "testNumber", ",", "testName", ")", ";", "return", "list", ";", "}", "private", "static", "void", "addTestResultPair", "(", "List", "list", ",", "StringBuffer", "testbuf", ",", "StringBuffer", "resultbuf", ",", "String", "testNumber", ",", "String", "testName", ")", "{", "if", "(", "testbuf", "==", "null", "||", "resultbuf", "==", "null", ")", "{", "return", ";", "}", "String", "test", "=", "chomp", "(", "testbuf", ".", "toString", "(", ")", ")", ";", "String", "result", "=", "chomp", "(", "resultbuf", ".", "toString", "(", ")", ")", ";", "String", "id", "=", "testNumber", "+", "\"(\"", "+", "testName", "+", "\")\"", ";", "list", ".", "add", "(", "new", "TestResultPair", "(", "id", ",", "test", ",", "result", ")", ")", ";", "}", "private", "static", "String", "chomp", "(", "String", "s", ")", "{", "int", "lastPos", "=", "s", ".", "length", "(", ")", "-", "1", ";", "while", "(", "s", ".", "charAt", "(", "lastPos", ")", "==", "'\\n'", "||", "s", ".", "charAt", "(", "lastPos", ")", "==", "'\\r'", ")", "{", "lastPos", "--", ";", "}", "return", "s", ".", "substring", "(", "0", ",", "lastPos", "+", "1", ")", ";", "}", "@", "Test", "public", "void", "runTest", "(", ")", "{", "MarkdownProcessor", "markup", "=", "new", "MarkdownProcessor", "(", ")", ";", "assertEquals", "(", "pair", ".", "toString", "(", ")", ",", "pair", ".", "getResult", "(", ")", ".", "trim", "(", ")", ",", "markup", ".", "markdown", "(", "pair", ".", "getTest", "(", ")", ")", ".", "trim", "(", ")", ")", ";", "}", "}", "</s>" ]
7,556
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "public", "class", "TextEditor", "{", "private", "StringBuffer", "text", ";", "public", "TextEditor", "(", "CharSequence", "text", ")", "{", "this", ".", "text", "=", "new", "StringBuffer", "(", "text", ".", "toString", "(", ")", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "text", ".", "toString", "(", ")", ";", "}", "public", "TextEditor", "replaceAll", "(", "String", "regex", ",", "String", "replacement", ")", "{", "if", "(", "text", ".", "length", "(", ")", ">", "0", ")", "{", "final", "String", "r", "=", "replacement", ";", "Pattern", "p", "=", "Pattern", ".", "compile", "(", "regex", ",", "Pattern", ".", "MULTILINE", ")", ";", "Matcher", "m", "=", "p", ".", "matcher", "(", "text", ")", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "while", "(", "m", ".", "find", "(", ")", ")", "{", "m", ".", "appendReplacement", "(", "sb", ",", "r", ")", ";", "}", "m", ".", "appendTail", "(", "sb", ")", ";", "text", "=", "sb", ";", "}", "return", "this", ";", "}", "public", "TextEditor", "replaceAllLiteral", "(", "String", "regex", ",", "final", "String", "replacement", ")", "{", "return", "replaceAll", "(", "Pattern", ".", "compile", "(", "regex", ",", "Pattern", ".", "MULTILINE", ")", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "return", "replacement", ";", "}", "}", ")", ";", "}", "public", "TextEditor", "replaceAll", "(", "Pattern", "pattern", ",", "Replacement", "replacement", ")", "{", "Matcher", "m", "=", "pattern", ".", "matcher", "(", "text", ")", ";", "int", "lastIndex", "=", "0", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "while", "(", "m", ".", "find", "(", ")", ")", "{", "sb", ".", "append", "(", "text", ".", "subSequence", "(", "lastIndex", ",", "m", ".", "start", "(", ")", ")", ")", ";", "sb", ".", "append", "(", "replacement", ".", "replacement", "(", "m", ")", ")", ";", "lastIndex", "=", "m", ".", "end", "(", ")", ";", "}", "sb", ".", "append", "(", "text", ".", "subSequence", "(", "lastIndex", ",", "text", ".", "length", "(", ")", ")", ")", ";", "text", "=", "sb", ";", "return", "this", ";", "}", "public", "TextEditor", "deleteAll", "(", "String", "pattern", ")", "{", "return", "replaceAll", "(", "pattern", ",", "\"\"", ")", ";", "}", "public", "TextEditor", "detabify", "(", ")", "{", "return", "detabify", "(", "4", ")", ";", "}", "public", "TextEditor", "detabify", "(", "final", "int", "tabWidth", ")", "{", "replaceAll", "(", "Pattern", ".", "compile", "(", "\"(.*?)\\\\t\"", ")", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "lineSoFar", "=", "m", ".", "group", "(", "1", ")", ";", "int", "width", "=", "lineSoFar", ".", "length", "(", ")", ";", "StringBuffer", "replacement", "=", "new", "StringBuffer", "(", "lineSoFar", ")", ";", "do", "{", "replacement", ".", "append", "(", "'", "'", ")", ";", "++", "width", ";", "}", "while", "(", "width", "%", "tabWidth", "!=", "0", ")", ";", "return", "replacement", ".", "toString", "(", ")", ";", "}", "}", ")", ";", "return", "this", ";", "}", "public", "TextEditor", "outdent", "(", "int", "spaces", ")", "{", "return", "deleteAll", "(", "\"^(\\\\t|[", "]{1,\"", "+", "spaces", "+", "\"})\"", ")", ";", "}", "public", "TextEditor", "outdent", "(", ")", "{", "return", "outdent", "(", "4", ")", ";", "}", "public", "TextEditor", "trim", "(", ")", "{", "text", "=", "new", "StringBuffer", "(", "text", ".", "toString", "(", ")", ".", "trim", "(", ")", ")", ";", "return", "this", ";", "}", "public", "TextEditor", "indent", "(", "int", "spaces", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", "spaces", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "spaces", ";", "i", "++", ")", "{", "sb", ".", "append", "(", "'", "'", ")", ";", "}", "return", "replaceAll", "(", "\"^\"", ",", "sb", ".", "toString", "(", ")", ")", ";", "}", "public", "void", "append", "(", "CharSequence", "s", ")", "{", "text", ".", "append", "(", "s", ")", ";", "}", "public", "Collection", "<", "HTMLToken", ">", "tokenizeHTML", "(", ")", "{", "List", "<", "HTMLToken", ">", "tokens", "=", "new", "ArrayList", "<", "HTMLToken", ">", "(", ")", ";", "String", "nestedTags", "=", "nestedTagsRegex", "(", "6", ")", ";", "Pattern", "p", "=", "Pattern", ".", "compile", "(", "\"\"", "+", "\"\"", "+", "\"|\"", "+", "\"\"", "+", "\"|\"", "+", "nestedTags", "+", "\"\"", ",", "Pattern", ".", "CASE_INSENSITIVE", ")", ";", "Matcher", "m", "=", "p", ".", "matcher", "(", "text", ")", ";", "int", "lastPos", "=", "0", ";", "while", "(", "m", ".", "find", "(", ")", ")", "{", "if", "(", "lastPos", "<", "m", ".", "start", "(", ")", ")", "{", "tokens", ".", "add", "(", "HTMLToken", ".", "text", "(", "text", ".", "substring", "(", "lastPos", ",", "m", ".", "start", "(", ")", ")", ")", ")", ";", "}", "tokens", ".", "add", "(", "HTMLToken", ".", "tag", "(", "text", ".", "substring", "(", "m", ".", "start", "(", ")", ",", "m", ".", "end", "(", ")", ")", ")", ")", ";", "lastPos", "=", "m", ".", "end", "(", ")", ";", "}", "if", "(", "lastPos", "<", "text", ".", "length", "(", ")", ")", "{", "tokens", ".", "add", "(", "HTMLToken", ".", "text", "(", "text", ".", "substring", "(", "lastPos", ",", "text", ".", "length", "(", ")", ")", ")", ")", ";", "}", "return", "tokens", ";", "}", "private", "String", "nestedTagsRegex", "(", "int", "depth", ")", "{", "if", "(", "depth", "==", "0", ")", "{", "return", "\"\"", ";", "}", "else", "{", "return", "\"\"", "+", "nestedTagsRegex", "(", "depth", "-", "1", ")", "+", "\")*>)\"", ";", "}", "}", "public", "void", "prepend", "(", "CharSequence", "s", ")", "{", "StringBuffer", "newText", "=", "new", "StringBuffer", "(", ")", ";", "newText", ".", "append", "(", "s", ")", ";", "newText", ".", "append", "(", "text", ")", ";", "text", "=", "newText", ";", "}", "public", "boolean", "isEmpty", "(", ")", "{", "return", "text", ".", "length", "(", ")", "==", "0", ";", "}", "}", "</s>" ]
7,557
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ";", "public", "class", "LinkDefinition", "{", "private", "String", "url", ";", "private", "String", "title", ";", "public", "LinkDefinition", "(", "String", "url", ",", "String", "title", ")", "{", "this", ".", "url", "=", "url", ";", "this", ".", "title", "=", "title", ";", "}", "public", "String", "getUrl", "(", ")", "{", "return", "url", ";", "}", "public", "String", "getTitle", "(", ")", "{", "return", "title", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "url", "+", "\"", "(\"", "+", "title", "+", "\")\"", ";", "}", "}", "</s>" ]
7,558
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Random", ";", "import", "java", ".", "util", ".", "TreeMap", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "public", "class", "MarkdownProcessor", "{", "private", "Random", "rnd", "=", "new", "Random", "(", ")", ";", "private", "Map", "<", "String", ",", "LinkDefinition", ">", "linkDefinitions", "=", "new", "TreeMap", "<", "String", ",", "LinkDefinition", ">", "(", ")", ";", "private", "static", "final", "CharacterProtector", "HTML_PROTECTOR", "=", "new", "CharacterProtector", "(", ")", ";", "private", "static", "final", "CharacterProtector", "CHAR_PROTECTOR", "=", "new", "CharacterProtector", "(", ")", ";", "private", "int", "listLevel", ";", "private", "String", "emptyElementSuffix", "=", "\"", "/>\"", ";", "private", "int", "tabWidth", "=", "4", ";", "public", "MarkdownProcessor", "(", ")", "{", "listLevel", "=", "0", ";", "}", "public", "String", "markdown", "(", "String", "txt", ")", "{", "if", "(", "txt", "==", "null", ")", "{", "txt", "=", "\"\"", ";", "}", "TextEditor", "text", "=", "new", "TextEditor", "(", "txt", ")", ";", "text", ".", "replaceAll", "(", "\"\\\\r\\\\n\"", ",", "\"n\"", ")", ";", "text", ".", "replaceAll", "(", "\"\\\\r\"", ",", "\"n\"", ")", ";", "text", ".", "replaceAll", "(", "\"^[", "\\\\t]+$\"", ",", "\"\"", ")", ";", "text", ".", "append", "(", "\"nn\"", ")", ";", "text", ".", "detabify", "(", ")", ";", "text", ".", "deleteAll", "(", "\"^[", "]+$\"", ")", ";", "hashHTMLBlocks", "(", "text", ")", ";", "stripLinkDefinitions", "(", "text", ")", ";", "text", "=", "runBlockGamut", "(", "text", ")", ";", "unEscapeSpecialChars", "(", "text", ")", ";", "text", ".", "append", "(", "\"n\"", ")", ";", "return", "text", ".", "toString", "(", ")", ";", "}", "private", "TextEditor", "encodeBackslashEscapes", "(", "TextEditor", "text", ")", "{", "char", "[", "]", "normalChars", "=", "\"`_>!\"", ".", "toCharArray", "(", ")", ";", "char", "[", "]", "escapedChars", "=", "\"*{}[]()#+-.\"", ".", "toCharArray", "(", ")", ";", "text", ".", "replaceAllLiteral", "(", "\"\\\\\\\\\\\\\\\\\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"\\\\\"", ")", ")", ";", "encodeEscapes", "(", "text", ",", "normalChars", ",", "\"\\\\\\\\\"", ")", ";", "encodeEscapes", "(", "text", ",", "escapedChars", ",", "\"\\\\\\\\\\\\\"", ")", ";", "return", "text", ";", "}", "private", "TextEditor", "encodeEscapes", "(", "TextEditor", "text", ",", "char", "[", "]", "chars", ",", "String", "slashes", ")", "{", "for", "(", "char", "ch", ":", "chars", ")", "{", "String", "regex", "=", "slashes", "+", "ch", ";", "text", ".", "replaceAllLiteral", "(", "regex", ",", "CHAR_PROTECTOR", ".", "encode", "(", "String", ".", "valueOf", "(", "ch", ")", ")", ")", ";", "}", "return", "text", ";", "}", "private", "void", "stripLinkDefinitions", "(", "TextEditor", "text", ")", "{", "Pattern", "p", "=", "Pattern", ".", "compile", "(", "\"\"", "+", "\"\"", "+", "\"<?(\\\\S+?)>?\"", "+", "\"\"", "+", "\"\"", "+", "\"(?:\\\\n+|\\\\Z)\"", ",", "Pattern", ".", "MULTILINE", ")", ";", "text", ".", "replaceAll", "(", "p", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "id", "=", "m", ".", "group", "(", "1", ")", ".", "toLowerCase", "(", ")", ";", "String", "url", "=", "encodeAmpsAndAngles", "(", "new", "TextEditor", "(", "m", ".", "group", "(", "2", ")", ")", ")", ".", "toString", "(", ")", ";", "String", "title", "=", "m", ".", "group", "(", "3", ")", ";", "if", "(", "title", "==", "null", ")", "{", "title", "=", "\"\"", ";", "}", "title", "=", "replaceAll", "(", "title", ",", "\"\\\"\"", ",", "\"&quot;\"", ")", ";", "linkDefinitions", ".", "put", "(", "id", ",", "new", "LinkDefinition", "(", "url", ",", "title", ")", ")", ";", "return", "\"\"", ";", "}", "}", ")", ";", "}", "public", "TextEditor", "runBlockGamut", "(", "TextEditor", "text", ")", "{", "doHeaders", "(", "text", ")", ";", "doHorizontalRules", "(", "text", ")", ";", "doLists", "(", "text", ")", ";", "doCodeBlocks", "(", "text", ")", ";", "doBlockQuotes", "(", "text", ")", ";", "hashHTMLBlocks", "(", "text", ")", ";", "return", "formParagraphs", "(", "text", ")", ";", "}", "private", "void", "doHorizontalRules", "(", "TextEditor", "text", ")", "{", "String", "[", "]", "hrDelimiters", "=", "{", "\"\\\\*\"", ",", "\"-\"", ",", "\"_\"", "}", ";", "for", "(", "String", "hrDelimiter", ":", "hrDelimiters", ")", "{", "text", ".", "replaceAll", "(", "\"\"", "+", "hrDelimiter", "+", "\"\"", ",", "\"<hr", "/>\"", ")", ";", "}", "}", "private", "void", "hashHTMLBlocks", "(", "TextEditor", "text", ")", "{", "String", "[", "]", "tagsA", "=", "{", "\"p\"", ",", "\"div\"", ",", "\"h1\"", ",", "\"h2\"", ",", "\"h3\"", ",", "\"h4\"", ",", "\"h5\"", ",", "\"h6\"", ",", "\"blockquote\"", ",", "\"pre\"", ",", "\"table\"", ",", "\"dl\"", ",", "\"ol\"", ",", "\"ul\"", ",", "\"script\"", ",", "\"noscript\"", ",", "\"form\"", ",", "\"fieldset\"", ",", "\"iframe\"", ",", "\"math\"", "}", ";", "String", "[", "]", "tagsB", "=", "{", "\"ins\"", ",", "\"del\"", "}", ";", "String", "alternationA", "=", "join", "(", "\"|\"", ",", "tagsA", ")", ";", "String", "alternationB", "=", "alternationA", "+", "\"|\"", "+", "join", "(", "\"|\"", ",", "tagsB", ")", ";", "int", "less_than_tab", "=", "tabWidth", "-", "1", ";", "Pattern", "p1", "=", "Pattern", ".", "compile", "(", "\"(\"", "+", "\"^<(\"", "+", "alternationA", "+", "\")\"", "+", "\"\\\\b\"", "+", "\"(.*\\\\n)*?\"", "+", "\"</\\\\2>\"", "+", "\"[", "]*\"", "+", "\"(?=\\\\n+|\\\\Z))\"", ",", "Pattern", ".", "MULTILINE", ")", ";", "Replacement", "protectHTML", "=", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "literal", "=", "m", ".", "group", "(", ")", ";", "return", "\"nn\"", "+", "HTML_PROTECTOR", ".", "encode", "(", "literal", ")", "+", "\"nn\"", ";", "}", "}", ";", "text", ".", "replaceAll", "(", "p1", ",", "protectHTML", ")", ";", "Pattern", "p2", "=", "Pattern", ".", "compile", "(", "\"(\"", "+", "\"^\"", "+", "\"<(\"", "+", "alternationB", "+", "\")\"", "+", "\"\\\\b\"", "+", "\"(.*\\\\n)*?\"", "+", "\".*</\\\\2>\"", "+", "\"[", "]*\"", "+", "\"(?=\\\\n+|\\\\Z))\"", ",", "Pattern", ".", "MULTILINE", ")", ";", "text", ".", "replaceAll", "(", "p2", ",", "protectHTML", ")", ";", "Pattern", "p3", "=", "Pattern", ".", "compile", "(", "\"(?:\"", "+", "\"(?<=\\\\n\\\\n)\"", "+", "\"|\"", "+", "\"\\\\A\\\\n?\"", "+", "\")\"", "+", "\"(\"", "+", "\"[", "]{0,\"", "+", "less_than_tab", "+", "\"}\"", "+", "\"<(hr)\"", "+", "\"\\\\b\"", "+", "\"([^<>])*?\"", "+", "\"/?>\"", "+", "\"[", "]*\"", "+", "\"\"", ")", ";", "text", ".", "replaceAll", "(", "p3", ",", "protectHTML", ")", ";", "Pattern", "p4", "=", "Pattern", ".", "compile", "(", "\"(?:\"", "+", "\"(?<=\\\\n\\\\n)\"", "+", "\"|\"", "+", "\"\\\\A\\\\n?\"", "+", "\")\"", "+", "\"(\"", "+", "\"[", "]{0,\"", "+", "less_than_tab", "+", "\"}\"", "+", "\"(?s:\"", "+", "\"<!\"", "+", "\"\"", "+", "\">\"", "+", "\")\"", "+", "\"[", "]*\"", "+", "\"\"", "+", "\")\"", ")", ";", "text", ".", "replaceAll", "(", "p4", ",", "protectHTML", ")", ";", "}", "private", "TextEditor", "formParagraphs", "(", "TextEditor", "markup", ")", "{", "markup", ".", "deleteAll", "(", "\"\\\\A\\\\n+\"", ")", ";", "markup", ".", "deleteAll", "(", "\"\\\\n+\\\\z\"", ")", ";", "String", "[", "]", "paragraphs", ";", "if", "(", "markup", ".", "isEmpty", "(", ")", ")", "{", "paragraphs", "=", "new", "String", "[", "0", "]", ";", "}", "else", "{", "paragraphs", "=", "Pattern", ".", "compile", "(", "\"\\\\n{2,}\"", ")", ".", "split", "(", "markup", ".", "toString", "(", ")", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "paragraphs", ".", "length", ";", "i", "++", ")", "{", "String", "paragraph", "=", "paragraphs", "[", "i", "]", ";", "String", "decoded", "=", "HTML_PROTECTOR", ".", "decode", "(", "paragraph", ")", ";", "if", "(", "decoded", "!=", "null", ")", "{", "paragraphs", "[", "i", "]", "=", "decoded", ";", "}", "else", "{", "paragraph", "=", "runSpanGamut", "(", "new", "TextEditor", "(", "paragraph", ")", ")", ".", "toString", "(", ")", ";", "paragraphs", "[", "i", "]", "=", "\"<p>\"", "+", "paragraph", "+", "\"</p>\"", ";", "}", "}", "return", "new", "TextEditor", "(", "join", "(", "\"nn\"", ",", "paragraphs", ")", ")", ";", "}", "private", "TextEditor", "doAutoLinks", "(", "TextEditor", "markup", ")", "{", "markup", ".", "replaceAll", "(", "\"\"", ",", "\"\"", ")", ";", "Pattern", "email", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "markup", ".", "replaceAll", "(", "email", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "address", "=", "m", ".", "group", "(", "1", ")", ";", "TextEditor", "ed", "=", "new", "TextEditor", "(", "address", ")", ";", "unEscapeSpecialChars", "(", "ed", ")", ";", "String", "addr", "=", "encodeEmail", "(", "ed", ".", "toString", "(", ")", ")", ";", "String", "url", "=", "encodeEmail", "(", "\"mailto:\"", "+", "ed", ".", "toString", "(", ")", ")", ";", "return", "\"<a", "href=\\\"\"", "+", "url", "+", "\"\\\">\"", "+", "addr", "+", "\"</a>\"", ";", "}", "}", ")", ";", "return", "markup", ";", "}", "private", "void", "unEscapeSpecialChars", "(", "TextEditor", "ed", ")", "{", "for", "(", "String", "hash", ":", "CHAR_PROTECTOR", ".", "getAllEncodedTokens", "(", ")", ")", "{", "String", "plaintext", "=", "CHAR_PROTECTOR", ".", "decode", "(", "hash", ")", ";", "ed", ".", "replaceAllLiteral", "(", "hash", ",", "plaintext", ")", ";", "}", "}", "private", "String", "encodeEmail", "(", "String", "s", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "char", "[", "]", "email", "=", "s", ".", "toCharArray", "(", ")", ";", "for", "(", "char", "ch", ":", "email", ")", "{", "double", "r", "=", "rnd", ".", "nextDouble", "(", ")", ";", "if", "(", "r", "<", "0.45", ")", "{", "sb", ".", "append", "(", "\"&#\"", ")", ";", "sb", ".", "append", "(", "(", "int", ")", "ch", ")", ";", "sb", ".", "append", "(", "';'", ")", ";", "}", "else", "if", "(", "r", "<", "0.9", ")", "{", "sb", ".", "append", "(", "\"&#x\"", ")", ";", "sb", ".", "append", "(", "Integer", ".", "toString", "(", "(", "int", ")", "ch", ",", "16", ")", ")", ";", "sb", ".", "append", "(", "';'", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "ch", ")", ";", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "private", "TextEditor", "doBlockQuotes", "(", "TextEditor", "markup", ")", "{", "Pattern", "p", "=", "Pattern", ".", "compile", "(", "\"(\"", "+", "\"(\"", "+", "\"^[", "t]*>[", "t]?\"", "+", "\".+\\\\n\"", "+", "\"(.+\\\\n)*\"", "+", "\"\\\\n*\"", "+", "\")+\"", "+", "\")\"", ",", "Pattern", ".", "MULTILINE", ")", ";", "return", "markup", ".", "replaceAll", "(", "p", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "TextEditor", "blockQuote", "=", "new", "TextEditor", "(", "m", ".", "group", "(", "1", ")", ")", ";", "blockQuote", ".", "deleteAll", "(", "\"^[", "t]*>[", "t]?\"", ")", ";", "blockQuote", ".", "deleteAll", "(", "\"^[", "t]+$\"", ")", ";", "blockQuote", "=", "runBlockGamut", "(", "blockQuote", ")", ";", "blockQuote", ".", "replaceAll", "(", "\"^\"", ",", "\"", "\"", ")", ";", "Pattern", "p1", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "DOTALL", ")", ";", "blockQuote", "=", "blockQuote", ".", "replaceAll", "(", "p1", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m1", ")", "{", "String", "pre", "=", "m1", ".", "group", "(", "1", ")", ";", "return", "deleteAll", "(", "pre", ",", "\"^", "\"", ")", ";", "}", "}", ")", ";", "return", "\"\"", "+", "blockQuote", "+", "\"\"", ";", "}", "}", ")", ";", "}", "private", "TextEditor", "doCodeBlocks", "(", "TextEditor", "markup", ")", "{", "Pattern", "p", "=", "Pattern", ".", "compile", "(", "\"\"", "+", "\"(?:\\\\n\\\\n|\\\\A)\"", "+", "\"((?:\"", "+", "\"(?:[", "]{4})\"", "+", "\".*\\\\n+\"", "+", "\")+\"", "+", "\")\"", "+", "\"\"", ",", "Pattern", ".", "MULTILINE", ")", ";", "return", "markup", ".", "replaceAll", "(", "p", ",", "new", "Replacement", "(", ")", "{", "private", "static", "final", "String", "LANG_IDENTIFIER", "=", "\"lang:\"", ";", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "codeBlock", "=", "m", ".", "group", "(", "1", ")", ";", "TextEditor", "ed", "=", "new", "TextEditor", "(", "codeBlock", ")", ";", "ed", ".", "outdent", "(", ")", ";", "encodeCode", "(", "ed", ")", ";", "ed", ".", "detabify", "(", ")", ".", "deleteAll", "(", "\"\\\\A\\\\n+\"", ")", ".", "deleteAll", "(", "\"\\\\s+\\\\z\"", ")", ";", "String", "text", "=", "ed", ".", "toString", "(", ")", ";", "String", "out", "=", "\"\"", ";", "String", "firstLine", "=", "firstLine", "(", "text", ")", ";", "if", "(", "isLanguageIdentifier", "(", "firstLine", ")", ")", "{", "out", "=", "languageBlock", "(", "firstLine", ",", "text", ")", ";", "}", "else", "{", "out", "=", "genericCodeBlock", "(", "text", ")", ";", "}", "return", "out", ";", "}", "public", "String", "firstLine", "(", "String", "text", ")", "{", "if", "(", "text", "==", "null", ")", "return", "\"\"", ";", "String", "[", "]", "splitted", "=", "text", ".", "split", "(", "\"\\\\n\"", ")", ";", "return", "splitted", "[", "0", "]", ";", "}", "public", "boolean", "isLanguageIdentifier", "(", "String", "line", ")", "{", "if", "(", "line", "==", "null", ")", "return", "false", ";", "String", "lang", "=", "\"\"", ";", "if", "(", "line", ".", "startsWith", "(", "LANG_IDENTIFIER", ")", ")", "{", "lang", "=", "line", ".", "replaceFirst", "(", "LANG_IDENTIFIER", ",", "\"\"", ")", ".", "trim", "(", ")", ";", "}", "return", "lang", ".", "length", "(", ")", ">", "0", ";", "}", "public", "String", "languageBlock", "(", "String", "firstLine", ",", "String", "text", ")", "{", "String", "codeBlockTemplate", "=", "\"\"", ";", "String", "lang", "=", "firstLine", ".", "replaceFirst", "(", "LANG_IDENTIFIER", ",", "\"\"", ")", ".", "trim", "(", ")", ";", "String", "block", "=", "text", ".", "replaceFirst", "(", "firstLine", "+", "\"n\"", ",", "\"\"", ")", ";", "return", "String", ".", "format", "(", "codeBlockTemplate", ",", "lang", ",", "block", ")", ";", "}", "public", "String", "genericCodeBlock", "(", "String", "text", ")", "{", "String", "codeBlockTemplate", "=", "\"\"", ";", "return", "String", ".", "format", "(", "codeBlockTemplate", ",", "text", ")", ";", "}", "}", ")", ";", "}", "private", "void", "encodeCode", "(", "TextEditor", "ed", ")", "{", "ed", ".", "replaceAll", "(", "\"&\"", ",", "\"&amp;\"", ")", ";", "ed", ".", "replaceAll", "(", "\"<\"", ",", "\"&lt;\"", ")", ";", "ed", ".", "replaceAll", "(", "\">\"", ",", "\"&gt;\"", ")", ";", "ed", ".", "replaceAll", "(", "\"\\\\*\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"*\"", ")", ")", ";", "ed", ".", "replaceAll", "(", "\"_\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"_\"", ")", ")", ";", "ed", ".", "replaceAll", "(", "\"\\\\{\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"{\"", ")", ")", ";", "ed", ".", "replaceAll", "(", "\"\\\\}\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"}\"", ")", ")", ";", "ed", ".", "replaceAll", "(", "\"\\\\[\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"[\"", ")", ")", ";", "ed", ".", "replaceAll", "(", "\"\\\\]\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"]\"", ")", ")", ";", "ed", ".", "replaceAll", "(", "\"\\\\\\\\\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"\\\\\"", ")", ")", ";", "}", "private", "TextEditor", "doLists", "(", "TextEditor", "text", ")", "{", "int", "lessThanTab", "=", "tabWidth", "-", "1", ";", "String", "wholeList", "=", "\"(\"", "+", "\"(\"", "+", "\"[", "]{0,\"", "+", "lessThanTab", "+", "\"}\"", "+", "\"\"", "+", "\"[", "]+\"", "+", "\")\"", "+", "\"(?s:.+?)\"", "+", "\"(\"", "+", "\"\\\\z\"", "+", "\"|\"", "+", "\"\\\\n{2,}\"", "+", "\"(?=\\\\S)\"", "+", "\"(?![", "]*\"", "+", "\"\"", "+", "\"[", "]+\"", "+", "\")\"", "+", "\")\"", "+", "\")\"", ";", "if", "(", "listLevel", ">", "0", ")", "{", "Replacement", "replacer", "=", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "list", "=", "m", ".", "group", "(", "1", ")", ";", "String", "listStart", "=", "m", ".", "group", "(", "3", ")", ";", "String", "listType", "=", "\"\"", ";", "if", "(", "listStart", ".", "matches", "(", "\"[*+-]\"", ")", ")", "{", "listType", "=", "\"ul\"", ";", "}", "else", "{", "listType", "=", "\"ol\"", ";", "}", "list", "=", "replaceAll", "(", "list", ",", "\"\\\\n{2,}\"", ",", "\"nnn\"", ")", ";", "String", "result", "=", "processListItems", "(", "list", ")", ";", "result", "=", "result", ".", "replaceAll", "(", "\"\\\\s+$\"", ",", "\"\"", ")", ";", "String", "html", ";", "if", "(", "\"ul\"", ".", "equals", "(", "listType", ")", ")", "{", "html", "=", "\"<ul>\"", "+", "result", "+", "\"</ul>n\"", ";", "}", "else", "{", "html", "=", "\"<ol>\"", "+", "result", "+", "\"</ol>n\"", ";", "}", "return", "html", ";", "}", "}", ";", "Pattern", "matchStartOfLine", "=", "Pattern", ".", "compile", "(", "\"^\"", "+", "wholeList", ",", "Pattern", ".", "MULTILINE", ")", ";", "text", ".", "replaceAll", "(", "matchStartOfLine", ",", "replacer", ")", ";", "}", "else", "{", "Replacement", "replacer", "=", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "list", "=", "m", ".", "group", "(", "1", ")", ";", "String", "listStart", "=", "m", ".", "group", "(", "3", ")", ";", "String", "listType", "=", "\"\"", ";", "if", "(", "listStart", ".", "matches", "(", "\"[*+-]\"", ")", ")", "{", "listType", "=", "\"ul\"", ";", "}", "else", "{", "listType", "=", "\"ol\"", ";", "}", "list", "=", "replaceAll", "(", "list", ",", "\"n{2,}\"", ",", "\"nnn\"", ")", ";", "String", "result", "=", "processListItems", "(", "list", ")", ";", "String", "html", ";", "if", "(", "listStart", ".", "matches", "(", "\"[*+-]\"", ")", ")", "{", "html", "=", "\"<ul>n\"", "+", "result", "+", "\"</ul>n\"", ";", "}", "else", "{", "html", "=", "\"<ol>n\"", "+", "result", "+", "\"</ol>n\"", ";", "}", "return", "html", ";", "}", "}", ";", "Pattern", "matchStartOfLine", "=", "Pattern", ".", "compile", "(", "\"\"", "+", "wholeList", ",", "Pattern", ".", "MULTILINE", ")", ";", "text", ".", "replaceAll", "(", "matchStartOfLine", ",", "replacer", ")", ";", "}", "return", "text", ";", "}", "private", "String", "processListItems", "(", "String", "list", ")", "{", "listLevel", "++", ";", "list", "=", "replaceAll", "(", "list", ",", "\"\\\\n{2,}\\\\z\"", ",", "\"n\"", ")", ";", "Pattern", "p", "=", "Pattern", ".", "compile", "(", "\"(\\\\n)?\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ",", "Pattern", ".", "MULTILINE", ")", ";", "list", "=", "replaceAll", "(", "list", ",", "p", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "text", "=", "m", ".", "group", "(", "4", ")", ";", "TextEditor", "item", "=", "new", "TextEditor", "(", "text", ")", ";", "String", "leadingLine", "=", "m", ".", "group", "(", "1", ")", ";", "if", "(", "!", "isEmptyString", "(", "leadingLine", ")", "||", "hasParagraphBreak", "(", "item", ")", ")", "{", "item", "=", "runBlockGamut", "(", "item", ".", "outdent", "(", ")", ")", ";", "}", "else", "{", "item", "=", "doLists", "(", "item", ".", "outdent", "(", ")", ")", ";", "item", "=", "runSpanGamut", "(", "item", ")", ";", "}", "return", "\"<li>\"", "+", "item", ".", "trim", "(", ")", ".", "toString", "(", ")", "+", "\"</li>n\"", ";", "}", "}", ")", ";", "listLevel", "--", ";", "return", "list", ";", "}", "private", "boolean", "hasParagraphBreak", "(", "TextEditor", "item", ")", "{", "return", "item", ".", "toString", "(", ")", ".", "indexOf", "(", "\"nn\"", ")", "!=", "-", "1", ";", "}", "private", "boolean", "isEmptyString", "(", "String", "leadingLine", ")", "{", "return", "leadingLine", "==", "null", "||", "leadingLine", ".", "equals", "(", "\"\"", ")", ";", "}", "private", "TextEditor", "doHeaders", "(", "TextEditor", "markup", ")", "{", "markup", ".", "replaceAll", "(", "\"^(.*)n====+$\"", ",", "\"<h1>$1</h1>\"", ")", ";", "markup", ".", "replaceAll", "(", "\"^(.*)n----+$\"", ",", "\"<h2>$1</h2>\"", ")", ";", "Pattern", "p", "=", "Pattern", ".", "compile", "(", "\"\"", ",", "Pattern", ".", "MULTILINE", ")", ";", "markup", ".", "replaceAll", "(", "p", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "marker", "=", "m", ".", "group", "(", "1", ")", ";", "String", "heading", "=", "m", ".", "group", "(", "2", ")", ";", "int", "level", "=", "marker", ".", "length", "(", ")", ";", "String", "tag", "=", "\"h\"", "+", "level", ";", "return", "\"<\"", "+", "tag", "+", "\">\"", "+", "heading", "+", "\"</\"", "+", "tag", "+", "\">n\"", ";", "}", "}", ")", ";", "return", "markup", ";", "}", "private", "String", "join", "(", "String", "separator", ",", "String", "[", "]", "strings", ")", "{", "int", "length", "=", "strings", ".", "length", ";", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "if", "(", "length", ">", "0", ")", "{", "buf", ".", "append", "(", "strings", "[", "0", "]", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "length", ";", "i", "++", ")", "{", "buf", ".", "append", "(", "separator", ")", ".", "append", "(", "strings", "[", "i", "]", ")", ";", "}", "}", "return", "buf", ".", "toString", "(", ")", ";", "}", "public", "TextEditor", "runSpanGamut", "(", "TextEditor", "text", ")", "{", "text", "=", "escapeSpecialCharsWithinTagAttributes", "(", "text", ")", ";", "text", "=", "doCodeSpans", "(", "text", ")", ";", "text", "=", "encodeBackslashEscapes", "(", "text", ")", ";", "doImages", "(", "text", ")", ";", "doAnchors", "(", "text", ")", ";", "doAutoLinks", "(", "text", ")", ";", "text", "=", "escapeSpecialCharsWithinTagAttributes", "(", "text", ")", ";", "encodeAmpsAndAngles", "(", "text", ")", ";", "doItalicsAndBold", "(", "text", ")", ";", "text", ".", "replaceAll", "(", "\"", "{2,}n\"", ",", "\"", "<br", "/>n\"", ")", ";", "return", "text", ";", "}", "private", "TextEditor", "escapeSpecialCharsWithinTagAttributes", "(", "TextEditor", "text", ")", "{", "Collection", "<", "HTMLToken", ">", "tokens", "=", "text", ".", "tokenizeHTML", "(", ")", ";", "TextEditor", "newText", "=", "new", "TextEditor", "(", "\"\"", ")", ";", "for", "(", "HTMLToken", "token", ":", "tokens", ")", "{", "String", "value", "=", "\"\"", ";", "value", "=", "token", ".", "getText", "(", ")", ";", "if", "(", "token", ".", "isTag", "(", ")", ")", "{", "value", "=", "value", ".", "replaceAll", "(", "\"\\\\\\\\\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"\\\\\"", ")", ")", ";", "value", "=", "value", ".", "replaceAll", "(", "\"`\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"`\"", ")", ")", ";", "value", "=", "value", ".", "replaceAll", "(", "\"\\\\*\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"*\"", ")", ")", ";", "value", "=", "value", ".", "replaceAll", "(", "\"_\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"_\"", ")", ")", ";", "}", "newText", ".", "append", "(", "value", ")", ";", "}", "return", "newText", ";", "}", "private", "void", "doImages", "(", "TextEditor", "text", ")", "{", "text", ".", "replaceAll", "(", "\"\"", ",", "\"\"", ")", ";", "text", ".", "replaceAll", "(", "\"\"", ",", "\"\"", ")", ";", "}", "private", "TextEditor", "doAnchors", "(", "TextEditor", "markup", ")", "{", "Pattern", "internalLink", "=", "Pattern", ".", "compile", "(", "\"(\"", "+", "\"\\\\[(.*?)\\\\]\"", "+", "\"\"", "+", "\"\\\\[(.*?)\\\\]\"", "+", "\")\"", ")", ";", "markup", ".", "replaceAll", "(", "internalLink", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "replacementText", ";", "String", "wholeMatch", "=", "m", ".", "group", "(", "1", ")", ";", "String", "linkText", "=", "m", ".", "group", "(", "2", ")", ";", "String", "id", "=", "m", ".", "group", "(", "3", ")", ".", "toLowerCase", "(", ")", ";", "if", "(", "id", "==", "null", "||", "\"\"", ".", "equals", "(", "id", ")", ")", "{", "id", "=", "linkText", ".", "toLowerCase", "(", ")", ";", "}", "LinkDefinition", "defn", "=", "linkDefinitions", ".", "get", "(", "id", ")", ";", "if", "(", "defn", "!=", "null", ")", "{", "String", "url", "=", "defn", ".", "getUrl", "(", ")", ";", "url", "=", "url", ".", "replaceAll", "(", "\"\\\\*\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"*\"", ")", ")", ";", "url", "=", "url", ".", "replaceAll", "(", "\"_\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"_\"", ")", ")", ";", "String", "title", "=", "defn", ".", "getTitle", "(", ")", ";", "String", "titleTag", "=", "\"\"", ";", "if", "(", "title", "!=", "null", "&&", "!", "title", ".", "equals", "(", "\"\"", ")", ")", "{", "title", "=", "title", ".", "replaceAll", "(", "\"\\\\*\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"*\"", ")", ")", ";", "title", "=", "title", ".", "replaceAll", "(", "\"_\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"_\"", ")", ")", ";", "titleTag", "=", "\"", "title=\\\"\"", "+", "title", "+", "\"\\\"\"", ";", "}", "replacementText", "=", "\"<a", "href=\\\"\"", "+", "url", "+", "\"\\\"\"", "+", "titleTag", "+", "\">\"", "+", "linkText", "+", "\"</a>\"", ";", "}", "else", "{", "replacementText", "=", "wholeMatch", ";", "}", "return", "replacementText", ";", "}", "}", ")", ";", "Pattern", "inlineLink", "=", "Pattern", ".", "compile", "(", "\"(\"", "+", "\"\\\\[(.*?)\\\\]\"", "+", "\"\\\\(\"", "+", "\"[", "\\\\t]*\"", "+", "\"<?(.*?)>?\"", "+", "\"[", "\\\\t]*\"", "+", "\"(\"", "+", "\"(['\\\"])\"", "+", "\"(.*?)\"", "+", "\"\\\\5\"", "+", "\")?\"", "+", "\"\\\\)\"", "+", "\")\"", ",", "Pattern", ".", "DOTALL", ")", ";", "markup", ".", "replaceAll", "(", "inlineLink", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "linkText", "=", "m", ".", "group", "(", "2", ")", ";", "String", "url", "=", "m", ".", "group", "(", "3", ")", ";", "String", "title", "=", "m", ".", "group", "(", "6", ")", ";", "url", "=", "url", ".", "replaceAll", "(", "\"\\\\*\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"*\"", ")", ")", ";", "url", "=", "url", ".", "replaceAll", "(", "\"_\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"_\"", ")", ")", ";", "StringBuffer", "result", "=", "new", "StringBuffer", "(", ")", ";", "result", ".", "append", "(", "\"<a", "href=\\\"\"", ")", ".", "append", "(", "url", ")", ".", "append", "(", "\"\\\"\"", ")", ";", "if", "(", "title", "!=", "null", ")", "{", "title", "=", "title", ".", "replaceAll", "(", "\"\\\\*\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"*\"", ")", ")", ";", "title", "=", "title", ".", "replaceAll", "(", "\"_\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"_\"", ")", ")", ";", "title", "=", "replaceAll", "(", "title", ",", "\"\\\"\"", ",", "\"&quot;\"", ")", ";", "result", ".", "append", "(", "\"", "title=\\\"\"", ")", ";", "result", ".", "append", "(", "title", ")", ";", "result", ".", "append", "(", "\"\\\"\"", ")", ";", "}", "result", ".", "append", "(", "\">\"", ")", ".", "append", "(", "linkText", ")", ";", "result", ".", "append", "(", "\"</a>\"", ")", ";", "return", "result", ".", "toString", "(", ")", ";", "}", "}", ")", ";", "Pattern", "referenceShortcut", "=", "Pattern", ".", "compile", "(", "\"(\"", "+", "\"\\\\[\"", "+", "\"([^\\\\[\\\\]]+)\"", "+", "\"\\\\]\"", "+", "\")\"", ",", "Pattern", ".", "DOTALL", ")", ";", "markup", ".", "replaceAll", "(", "referenceShortcut", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "replacementText", ";", "String", "wholeMatch", "=", "m", ".", "group", "(", "1", ")", ";", "String", "linkText", "=", "m", ".", "group", "(", "2", ")", ";", "String", "id", "=", "m", ".", "group", "(", "2", ")", ".", "toLowerCase", "(", ")", ";", "id", "=", "id", ".", "replaceAll", "(", "\"[", "]?\\\\n\"", ",", "\"", "\"", ")", ";", "LinkDefinition", "defn", "=", "linkDefinitions", ".", "get", "(", "id", ".", "toLowerCase", "(", ")", ")", ";", "if", "(", "defn", "!=", "null", ")", "{", "String", "url", "=", "defn", ".", "getUrl", "(", ")", ";", "url", "=", "url", ".", "replaceAll", "(", "\"\\\\*\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"*\"", ")", ")", ";", "url", "=", "url", ".", "replaceAll", "(", "\"_\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"_\"", ")", ")", ";", "String", "title", "=", "defn", ".", "getTitle", "(", ")", ";", "String", "titleTag", "=", "\"\"", ";", "if", "(", "title", "!=", "null", "&&", "!", "title", ".", "equals", "(", "\"\"", ")", ")", "{", "title", "=", "title", ".", "replaceAll", "(", "\"\\\\*\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"*\"", ")", ")", ";", "title", "=", "title", ".", "replaceAll", "(", "\"_\"", ",", "CHAR_PROTECTOR", ".", "encode", "(", "\"_\"", ")", ")", ";", "titleTag", "=", "\"", "title=\\\"\"", "+", "title", "+", "\"\\\"\"", ";", "}", "replacementText", "=", "\"<a", "href=\\\"\"", "+", "url", "+", "\"\\\"\"", "+", "titleTag", "+", "\">\"", "+", "linkText", "+", "\"</a>\"", ";", "}", "else", "{", "replacementText", "=", "wholeMatch", ";", "}", "return", "replacementText", ";", "}", "}", ")", ";", "return", "markup", ";", "}", "private", "TextEditor", "doItalicsAndBold", "(", "TextEditor", "markup", ")", "{", "markup", ".", "replaceAll", "(", "\"\"", ",", "\"\"", ")", ";", "markup", ".", "replaceAll", "(", "\"\"", ",", "\"<em>$2</em>\"", ")", ";", "return", "markup", ";", "}", "private", "TextEditor", "encodeAmpsAndAngles", "(", "TextEditor", "markup", ")", "{", "markup", ".", "replaceAll", "(", "\"\"", ",", "\"&amp;\"", ")", ";", "markup", ".", "replaceAll", "(", "\"\"", ",", "\"&lt;\"", ")", ";", "return", "markup", ";", "}", "private", "TextEditor", "doCodeSpans", "(", "TextEditor", "markup", ")", "{", "return", "markup", ".", "replaceAll", "(", "Pattern", ".", "compile", "(", "\"\"", ")", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "code", "=", "m", ".", "group", "(", "2", ")", ";", "TextEditor", "subEditor", "=", "new", "TextEditor", "(", "code", ")", ";", "subEditor", ".", "deleteAll", "(", "\"^[", "\\\\t]+\"", ")", ".", "deleteAll", "(", "\"[", "\\\\t]+$\"", ")", ";", "encodeCode", "(", "subEditor", ")", ";", "return", "\"<code>\"", "+", "subEditor", ".", "toString", "(", ")", "+", "\"</code>\"", ";", "}", "}", ")", ";", "}", "private", "String", "deleteAll", "(", "String", "text", ",", "String", "regex", ")", "{", "return", "replaceAll", "(", "text", ",", "regex", ",", "\"\"", ")", ";", "}", "private", "String", "replaceAll", "(", "String", "text", ",", "String", "regex", ",", "String", "replacement", ")", "{", "TextEditor", "ed", "=", "new", "TextEditor", "(", "text", ")", ";", "ed", ".", "replaceAll", "(", "regex", ",", "replacement", ")", ";", "return", "ed", ".", "toString", "(", ")", ";", "}", "private", "String", "replaceAll", "(", "String", "markup", ",", "Pattern", "pattern", ",", "Replacement", "replacement", ")", "{", "TextEditor", "ed", "=", "new", "TextEditor", "(", "markup", ")", ";", "ed", ".", "replaceAll", "(", "pattern", ",", "replacement", ")", ";", "return", "ed", ".", "toString", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", ";", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "char", "[", "]", "cbuf", "=", "new", "char", "[", "1024", "]", ";", "java", ".", "io", ".", "Reader", "in", "=", "new", "java", ".", "io", ".", "InputStreamReader", "(", "System", ".", "in", ")", ";", "try", "{", "int", "charsRead", "=", "in", ".", "read", "(", "cbuf", ")", ";", "while", "(", "charsRead", ">=", "0", ")", "{", "buf", ".", "append", "(", "cbuf", ",", "0", ",", "charsRead", ")", ";", "charsRead", "=", "in", ".", "read", "(", "cbuf", ")", ";", "}", "System", ".", "out", ".", "println", "(", "new", "MarkdownProcessor", "(", ")", ".", "markdown", "(", "buf", ".", "toString", "(", ")", ")", ")", ";", "}", "catch", "(", "java", ".", "io", ".", "IOException", "e", ")", "{", "System", ".", "err", ".", "println", "(", "\"\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "System", ".", "exit", "(", "1", ")", ";", "}", "}", "}", "</s>" ]
7,559
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Random", ";", "class", "CharacterProtector", "{", "private", "Map", "<", "String", ",", "String", ">", "protectMap", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "private", "Map", "<", "String", ",", "String", ">", "unprotectMap", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "private", "static", "final", "String", "GOOD_CHARS", "=", "\"\"", ";", "private", "Random", "rnd", "=", "new", "Random", "(", ")", ";", "public", "String", "encode", "(", "String", "literal", ")", "{", "if", "(", "!", "protectMap", ".", "containsKey", "(", "literal", ")", ")", "{", "addToken", "(", "literal", ")", ";", "}", "return", "protectMap", ".", "get", "(", "literal", ")", ";", "}", "public", "String", "decode", "(", "String", "coded", ")", "{", "return", "unprotectMap", ".", "get", "(", "coded", ")", ";", "}", "public", "Collection", "<", "String", ">", "getAllEncodedTokens", "(", ")", "{", "return", "unprotectMap", ".", "keySet", "(", ")", ";", "}", "private", "void", "addToken", "(", "String", "literal", ")", "{", "String", "encoded", "=", "longRandomString", "(", ")", ";", "protectMap", ".", "put", "(", "literal", ",", "encoded", ")", ";", "unprotectMap", ".", "put", "(", "encoded", ",", "literal", ")", ";", "}", "private", "String", "longRandomString", "(", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "final", "int", "CHAR_MAX", "=", "GOOD_CHARS", ".", "length", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "20", ";", "i", "++", ")", "{", "sb", ".", "append", "(", "GOOD_CHARS", ".", "charAt", "(", "rnd", ".", "nextInt", "(", "CHAR_MAX", ")", ")", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "protectMap", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
7,560
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "public", "interface", "Replacement", "{", "String", "replacement", "(", "Matcher", "m", ")", ";", "}", "</s>" ]
7,561
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ";", "public", "class", "HTMLToken", "{", "private", "boolean", "isTag", ";", "private", "String", "text", ";", "private", "HTMLToken", "(", "boolean", "tag", ",", "String", "value", ")", "{", "isTag", "=", "tag", ";", "text", "=", "value", ";", "}", "public", "static", "HTMLToken", "tag", "(", "String", "text", ")", "{", "return", "new", "HTMLToken", "(", "true", ",", "text", ")", ";", "}", "public", "static", "HTMLToken", "text", "(", "String", "text", ")", "{", "return", "new", "HTMLToken", "(", "false", ",", "text", ")", ";", "}", "public", "boolean", "isTag", "(", ")", "{", "return", "isTag", ";", "}", "public", "String", "getText", "(", ")", "{", "return", "text", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "String", "type", ";", "if", "(", "isTag", "(", ")", ")", "{", "type", "=", "\"tag\"", ";", "}", "else", "{", "type", "=", "\"text\"", ";", "}", "return", "type", "+", "\":", "\"", "+", "getText", "(", ")", ";", "}", "}", "</s>" ]
7,562
[ "<s>", "package", "com", ".", "petebevin", ".", "markdown", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "public", "class", "HTMLDecoder", "{", "public", "static", "String", "decode", "(", "String", "html", ")", "{", "TextEditor", "ed", "=", "new", "TextEditor", "(", "html", ")", ";", "Pattern", "p1", "=", "Pattern", ".", "compile", "(", "\"&#(\\\\d+);\"", ")", ";", "ed", ".", "replaceAll", "(", "p1", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "charDecimal", "=", "m", ".", "group", "(", "1", ")", ";", "char", "ch", "=", "(", "char", ")", "Integer", ".", "parseInt", "(", "charDecimal", ")", ";", "return", "Character", ".", "toString", "(", "ch", ")", ";", "}", "}", ")", ";", "Pattern", "p2", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "ed", ".", "replaceAll", "(", "p2", ",", "new", "Replacement", "(", ")", "{", "public", "String", "replacement", "(", "Matcher", "m", ")", "{", "String", "charHex", "=", "m", ".", "group", "(", "1", ")", ";", "char", "ch", "=", "(", "char", ")", "Integer", ".", "parseInt", "(", "charHex", ",", "16", ")", ";", "return", "Character", ".", "toString", "(", "ch", ")", ";", "}", "}", ")", ";", "return", "ed", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
7,563
[ "<s>", "package", "com", ".", "cookbook", ".", "domain", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "javax", ".", "persistence", ".", "Entity", ";", "import", "javax", ".", "persistence", ".", "GeneratedValue", ";", "import", "javax", ".", "persistence", ".", "GenerationType", ";", "import", "javax", ".", "persistence", ".", "Id", ";", "import", "javax", ".", "persistence", ".", "TableGenerator", ";", "@", "Entity", "public", "class", "User", "implements", "DomainObject", ",", "Serializable", "{", "private", "static", "final", "long", "serialVersionUID", "=", "-", "7310625405953952315L", ";", "public", "User", "(", ")", "{", "super", "(", ")", ";", "}", "public", "User", "(", "long", "id", ",", "String", "name", ")", "{", "super", "(", ")", ";", "this", ".", "id", "=", "id", ";", "this", ".", "firstName", "=", "name", ";", "}", "@", "TableGenerator", "(", "name", "=", "\"userGen\"", ",", "table", "=", "\"ID_GEN\"", ",", "pkColumnName", "=", "\"GEN_KEY\"", ",", "valueColumnName", "=", "\"GEN_VALUE\"", ",", "pkColumnValue", "=", "\"USER_ID\"", ",", "allocationSize", "=", "1", ")", "@", "Id", "@", "GeneratedValue", "(", "strategy", "=", "GenerationType", ".", "TABLE", ",", "generator", "=", "\"userGen\"", ")", "private", "long", "id", ";", "private", "String", "firstName", ";", "private", "String", "lastName", ";", "private", "String", "empId", ";", "private", "String", "status", ";", "public", "long", "getId", "(", ")", "{", "return", "id", ";", "}", "public", "void", "setId", "(", "long", "id", ")", "{", "this", ".", "id", "=", "id", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "final", "int", "prime", "=", "31", ";", "int", "result", "=", "1", ";", "result", "=", "prime", "*", "result", "+", "(", "int", ")", "(", "id", "^", "(", "id", ">>>", "32", ")", ")", ";", "return", "result", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "boolean", "flag", "=", "false", ";", "if", "(", "this", "==", "obj", ")", "{", "return", "true", ";", "}", "if", "(", "obj", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "obj", "instanceof", "User", ")", "{", "User", "other", "=", "(", "User", ")", "obj", ";", "if", "(", "id", "==", "other", ".", "id", ")", "{", "flag", "=", "true", ";", "}", "}", "return", "flag", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"User", "[id=\"", "+", "id", "+", "\",", "name=\"", "+", "firstName", "+", "\"]\"", ";", "}", "public", "String", "getFirstName", "(", ")", "{", "return", "firstName", ";", "}", "public", "void", "setFirstName", "(", "String", "firstName", ")", "{", "this", ".", "firstName", "=", "firstName", ";", "}", "public", "String", "getLastName", "(", ")", "{", "return", "lastName", ";", "}", "public", "void", "setLastName", "(", "String", "lastName", ")", "{", "this", ".", "lastName", "=", "lastName", ";", "}", "public", "String", "getEmpId", "(", ")", "{", "return", "empId", ";", "}", "public", "void", "setEmpId", "(", "String", "empId", ")", "{", "this", ".", "empId", "=", "empId", ";", "}", "public", "String", "getStatus", "(", ")", "{", "return", "status", ";", "}", "public", "void", "setStatus", "(", "String", "status", ")", "{", "this", ".", "status", "=", "status", ";", "}", "}", "</s>" ]
7,564
[ "<s>", "package", "com", ".", "cookbook", ".", "domain", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "javax", ".", "persistence", ".", "CascadeType", ";", "import", "javax", ".", "persistence", ".", "Entity", ";", "import", "javax", ".", "persistence", ".", "GeneratedValue", ";", "import", "javax", ".", "persistence", ".", "GenerationType", ";", "import", "javax", ".", "persistence", ".", "Id", ";", "import", "javax", ".", "persistence", ".", "OneToMany", ";", "import", "javax", ".", "persistence", ".", "TableGenerator", ";", "import", "javax", ".", "persistence", ".", "Version", ";", "@", "Entity", "public", "class", "Recipe", "implements", "DomainObject", ",", "Serializable", "{", "private", "static", "final", "long", "serialVersionUID", "=", "-", "8333501449975018182L", ";", "public", "Recipe", "(", "long", "id", ",", "String", "title", ",", "String", "contents", ")", "{", "super", "(", ")", ";", "this", ".", "id", "=", "id", ";", "this", ".", "title", "=", "title", ";", "this", ".", "contents", "=", "contents", ";", "}", "public", "Recipe", "(", ")", "{", "super", "(", ")", ";", "}", "@", "TableGenerator", "(", "name", "=", "\"recipeGen\"", ",", "table", "=", "\"ID_GEN\"", ",", "pkColumnName", "=", "\"GEN_KEY\"", ",", "valueColumnName", "=", "\"GEN_VALUE\"", ",", "pkColumnValue", "=", "\"RECIPE_ID\"", ",", "allocationSize", "=", "1", ")", "@", "Id", "@", "GeneratedValue", "(", "strategy", "=", "GenerationType", ".", "TABLE", ",", "generator", "=", "\"recipeGen\"", ")", "private", "long", "id", ";", "private", "String", "title", ";", "private", "String", "contents", ";", "@", "OneToMany", "(", "mappedBy", "=", "\"recipe\"", ",", "cascade", "=", "CascadeType", ".", "ALL", ")", "private", "List", "<", "Author", ">", "authors", ";", "@", "Version", "private", "int", "version", ";", "public", "long", "getId", "(", ")", "{", "return", "id", ";", "}", "public", "void", "setId", "(", "long", "id", ")", "{", "this", ".", "id", "=", "id", ";", "}", "public", "String", "getTitle", "(", ")", "{", "return", "title", ";", "}", "public", "void", "setTitle", "(", "String", "title", ")", "{", "this", ".", "title", "=", "title", ";", "}", "public", "String", "getContents", "(", ")", "{", "return", "contents", ";", "}", "public", "void", "setContents", "(", "String", "contents", ")", "{", "this", ".", "contents", "=", "contents", ";", "}", "public", "List", "<", "Author", ">", "getAuthors", "(", ")", "{", "if", "(", "authors", "==", "null", ")", "authors", "=", "new", "ArrayList", "<", "Author", ">", "(", ")", ";", "return", "authors", ";", "}", "public", "boolean", "addAuthorToRecipe", "(", "Author", "author", ")", "{", "boolean", "flag", "=", "false", ";", "if", "(", "author", "!=", "null", ")", "{", "author", ".", "setRecipe", "(", "this", ")", ";", "if", "(", "authors", "!=", "null", ")", "{", "flag", "=", "this", ".", "authors", ".", "add", "(", "author", ")", ";", "}", "else", "{", "authors", "=", "new", "ArrayList", "<", "Author", ">", "(", ")", ";", "flag", "=", "this", ".", "authors", ".", "add", "(", "author", ")", ";", "}", "}", "return", "flag", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "final", "int", "prime", "=", "31", ";", "int", "result", "=", "1", ";", "result", "=", "prime", "*", "result", "+", "(", "int", ")", "(", "id", "^", "(", "id", ">>>", "32", ")", ")", ";", "return", "result", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "boolean", "flag", "=", "false", ";", "if", "(", "this", "==", "obj", ")", "{", "return", "true", ";", "}", "if", "(", "obj", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "obj", "instanceof", "Recipe", ")", "{", "Recipe", "other", "=", "(", "Recipe", ")", "obj", ";", "if", "(", "id", "==", "other", ".", "id", ")", "{", "flag", "=", "true", ";", "}", "}", "return", "flag", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"Recipe", "[id=\"", "+", "id", "+", "\",", "title=\"", "+", "title", "+", "\",", "contents=\"", "+", "contents", "+", "\",", "authors=\"", "+", "authors", "+", "\",", "version=\"", "+", "version", "+", "\"]\"", ";", "}", "}", "</s>" ]
7,565
[ "<s>", "package", "com", ".", "cookbook", ".", "domain", ";", "public", "interface", "DomainObject", "{", "}", "</s>" ]
7,566
[ "<s>", "package", "com", ".", "cookbook", ".", "domain", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "javax", ".", "persistence", ".", "Entity", ";", "import", "javax", ".", "persistence", ".", "GeneratedValue", ";", "import", "javax", ".", "persistence", ".", "GenerationType", ";", "import", "javax", ".", "persistence", ".", "Id", ";", "import", "javax", ".", "persistence", ".", "ManyToOne", ";", "import", "javax", ".", "persistence", ".", "TableGenerator", ";", "import", "javax", ".", "persistence", ".", "Temporal", ";", "import", "javax", ".", "persistence", ".", "TemporalType", ";", "@", "Entity", "public", "class", "Author", "implements", "DomainObject", ",", "Serializable", "{", "private", "static", "final", "long", "serialVersionUID", "=", "-", "7310625405953952315L", ";", "public", "Author", "(", ")", "{", "super", "(", ")", ";", "}", "public", "Author", "(", "long", "id", ",", "String", "name", ")", "{", "super", "(", ")", ";", "this", ".", "id", "=", "id", ";", "this", ".", "name", "=", "name", ";", "}", "@", "TableGenerator", "(", "name", "=", "\"authorGen\"", ",", "table", "=", "\"ID_GEN\"", ",", "pkColumnName", "=", "\"GEN_KEY\"", ",", "valueColumnName", "=", "\"GEN_VALUE\"", ",", "pkColumnValue", "=", "\"AUTHOR_ID\"", ",", "allocationSize", "=", "1", ")", "@", "Id", "@", "GeneratedValue", "(", "strategy", "=", "GenerationType", ".", "TABLE", ",", "generator", "=", "\"authorGen\"", ")", "private", "long", "id", ";", "private", "String", "name", ";", "@", "Temporal", "(", "TemporalType", ".", "TIMESTAMP", ")", "private", "Date", "createdDate", ";", "@", "ManyToOne", "private", "Recipe", "recipe", ";", "public", "long", "getId", "(", ")", "{", "return", "id", ";", "}", "public", "void", "setId", "(", "long", "id", ")", "{", "this", ".", "id", "=", "id", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "public", "void", "setName", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ".", "trim", "(", ")", ";", "}", "public", "Recipe", "getRecipe", "(", ")", "{", "return", "recipe", ";", "}", "public", "void", "setRecipe", "(", "Recipe", "recipe", ")", "{", "this", ".", "recipe", "=", "recipe", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "final", "int", "prime", "=", "31", ";", "int", "result", "=", "1", ";", "result", "=", "prime", "*", "result", "+", "(", "int", ")", "(", "id", "^", "(", "id", ">>>", "32", ")", ")", ";", "return", "result", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "(", "obj", "==", "null", ")", "||", "(", "obj", ".", "getClass", "(", ")", "!=", "this", ".", "getClass", "(", ")", ")", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "return", "false", ";", "}", "if", "(", "obj", "instanceof", "Author", ")", "{", "Author", "other", "=", "(", "Author", ")", "obj", ";", "if", "(", "id", "==", "other", ".", "id", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "return", "true", ";", "}", "}", "if", "(", "this", "==", "obj", ")", "{", "return", "false", ";", "}", "return", "false", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "builder", ".", "append", "(", "\"Author", "[id=\"", ")", ";", "builder", ".", "append", "(", "id", ")", ";", "builder", ".", "append", "(", "\",", "name=\"", ")", ";", "builder", ".", "append", "(", "name", ")", ";", "builder", ".", "append", "(", "\"\"", ")", ";", "builder", ".", "append", "(", "createdDate", ")", ";", "builder", ".", "append", "(", "\",", "recipe=\"", ")", ";", "if", "(", "recipe", "!=", "null", ")", "builder", ".", "append", "(", "recipe", ".", "getId", "(", ")", ")", ";", "builder", ".", "append", "(", "\"]\"", ")", ";", "return", "builder", ".", "toString", "(", ")", ";", "}", "public", "Date", "getCreatedDate", "(", ")", "{", "return", "createdDate", ";", "}", "public", "void", "setCreatedDate", "(", "Date", "createdDate", ")", "{", "this", ".", "createdDate", "=", "createdDate", ";", "}", "}", "</s>" ]
7,567
[ "<s>", "package", "com", ".", "akkineni", ".", "domain", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "com", ".", "cookbook", ".", "domain", ".", "Author", ";", "import", "com", ".", "cookbook", ".", "domain", ".", "Recipe", ";", "public", "class", "AuthorTest", "{", "@", "Test", "public", "void", "testEqualMethod", "(", ")", "{", "Author", "author", "=", "new", "Author", "(", "1", ",", "\"\"", ")", ";", "Author", "author1", "=", "new", "Author", "(", "1", ",", "\"\"", ")", ";", "System", ".", "out", ".", "println", "(", "author", ".", "hashCode", "(", ")", "+", "\":\"", "+", "author1", ".", "hashCode", "(", ")", "+", "\"", "\"", "+", "author", ".", "equals", "(", "author1", ")", ")", ";", "Assert", ".", "assertEquals", "(", "true", ",", "author", ".", "equals", "(", "author1", ")", ")", ";", "Assert", ".", "assertEquals", "(", "false", ",", "author", ".", "equals", "(", "null", ")", ")", ";", "Assert", ".", "assertEquals", "(", "false", ",", "author", ".", "equals", "(", "new", "Object", "(", ")", ")", ")", ";", "Assert", ".", "assertEquals", "(", "false", ",", "author", ".", "equals", "(", "new", "ArrayList", "<", "Object", ">", "(", ")", ")", ")", ";", "author", "=", "new", "Author", "(", "101", ",", "\"\"", ")", ";", "Object", "obj", "=", "new", "Author", "(", "102", ",", "\"\"", ")", ";", "Assert", ".", "assertEquals", "(", "false", ",", "author", ".", "equals", "(", "obj", ")", ")", ";", "Assert", ".", "assertEquals", "(", "true", ",", "author", ".", "equals", "(", "author", ")", ")", ";", "author", ".", "setId", "(", "10001", ")", ";", "author1", ".", "setId", "(", "10001", ")", ";", "boolean", "flag", "=", "author", ".", "equals", "(", "author1", ")", ";", "Assert", ".", "assertEquals", "(", "true", ",", "flag", ")", ";", "}", "@", "Test", "public", "void", "testGettersAndSetters", "(", ")", "{", "Author", "author", "=", "new", "Author", "(", ")", ";", "author", ".", "setId", "(", "1", ")", ";", "author", ".", "setName", "(", "\"\"", ")", ";", "Recipe", "recipe", "=", "new", "Recipe", "(", "1", ",", "\"My", "Recipe\"", ",", "\"\"", ")", ";", "author", ".", "setRecipe", "(", "recipe", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "author", ".", "getId", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"\"", ",", "author", ".", "getName", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "recipe", ",", "author", ".", "getRecipe", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testConstructors", "(", ")", "{", "Author", "author", "=", "new", "Author", "(", ")", ";", "Assert", ".", "assertNotNull", "(", "author", ")", ";", "Author", "author1", "=", "new", "Author", "(", "101", ",", "\"\"", ")", ";", "Assert", ".", "assertNotNull", "(", "author1", ")", ";", "Assert", ".", "assertEquals", "(", "101", ",", "author1", ".", "getId", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"\"", ",", "author", ".", "toString", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testHashCode", "(", ")", "{", "Author", "author1", "=", "new", "Author", "(", "1", ",", "\"\"", ")", ";", "Assert", ".", "assertEquals", "(", "32", ",", "author1", ".", "hashCode", "(", ")", ")", ";", "Author", "author2", "=", "new", "Author", "(", "100", ",", "\"\"", ")", ";", "Assert", ".", "assertEquals", "(", "131", ",", "author2", ".", "hashCode", "(", ")", ")", ";", "}", "}", "</s>" ]
7,568
[ "<s>", "package", "com", ".", "akkineni", ".", "domain", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "junit", ".", "BeforeClass", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "com", ".", "cookbook", ".", "domain", ".", "Author", ";", "import", "com", ".", "cookbook", ".", "domain", ".", "Recipe", ";", "public", "class", "RecipeTest", "{", "private", "static", "Recipe", "recipe", ";", "@", "BeforeClass", "public", "static", "void", "initialize", "(", ")", "{", "recipe", "=", "new", "Recipe", "(", ")", ";", "}", "@", "Test", "public", "void", "testEqualMethod", "(", ")", "{", "Recipe", "recipe2", "=", "new", "Recipe", "(", "10", ",", "\"My", "Recipe\"", ",", "\"\"", ")", ";", "Recipe", "recipe3", "=", "new", "Recipe", "(", "10", ",", "\"My", "Recipe\"", ",", "\"\"", ")", ";", "Assert", ".", "assertEquals", "(", "true", ",", "recipe2", ".", "equals", "(", "recipe3", ")", ")", ";", "Assert", ".", "assertEquals", "(", "false", ",", "recipe3", ".", "equals", "(", "null", ")", ")", ";", "Assert", ".", "assertEquals", "(", "false", ",", "recipe3", ".", "equals", "(", "new", "Object", "(", ")", ")", ")", ";", "Assert", ".", "assertEquals", "(", "false", ",", "recipe3", ".", "equals", "(", "new", "ArrayList", "<", "Object", ">", "(", ")", ")", ")", ";", "recipe2", "=", "new", "Recipe", "(", "101", ",", "\"My", "Recipe\"", ",", "\"\"", ")", ";", "Object", "obj", "=", "new", "Recipe", "(", "102", ",", "\"My", "Recipe\"", ",", "\"\"", ")", ";", "Assert", ".", "assertEquals", "(", "false", ",", "recipe2", ".", "equals", "(", "obj", ")", ")", ";", "Assert", ".", "assertEquals", "(", "true", ",", "recipe2", ".", "equals", "(", "recipe2", ")", ")", ";", "recipe2", "=", "new", "Recipe", "(", "101", ",", "\"My", "Recipe\"", ",", "\"\"", ")", ";", "Object", "obj2", "=", "new", "Recipe", "(", "101", ",", "\"My", "Recipe\"", ",", "\"\"", ")", ";", "boolean", "flag", "=", "recipe2", ".", "equals", "(", "obj2", ")", ";", "Assert", ".", "assertEquals", "(", "true", ",", "flag", ")", ";", "}", "@", "Test", "public", "void", "testGettersAndSetters", "(", ")", "{", "recipe", ".", "setId", "(", "1", ")", ";", "recipe", ".", "setContents", "(", "\"\"", ")", ";", "recipe", ".", "setTitle", "(", "\"\"", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "recipe", ".", "getId", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"\"", ",", "recipe", ".", "getContents", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"\"", ",", "recipe", ".", "getTitle", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testConstructors", "(", ")", "{", "recipe", "=", "new", "Recipe", "(", ")", ";", "Assert", ".", "assertNotNull", "(", "recipe", ")", ";", "recipe", "=", "new", "Recipe", "(", "1", ",", "\"My", "Recipe\"", ",", "\"\"", ")", ";", "Assert", ".", "assertNotNull", "(", "recipe", ")", ";", "Assert", ".", "assertEquals", "(", "1", ",", "recipe", ".", "getId", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"\"", ",", "recipe", ".", "getContents", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"My", "Recipe\"", ",", "recipe", ".", "getTitle", "(", ")", ")", ";", "Assert", ".", "assertEquals", "(", "\"\"", ",", "recipe", ".", "toString", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testHashCode", "(", ")", "{", "recipe", "=", "new", "Recipe", "(", "1", ",", "\"My", "Recipe\"", ",", "\"\"", ")", ";", "Assert", ".", "assertEquals", "(", "32", ",", "recipe", ".", "hashCode", "(", ")", ")", ";", "recipe", "=", "new", "Recipe", "(", "100", ",", "\"My", "Recipe\"", ",", "\"\"", ")", ";", "Assert", ".", "assertEquals", "(", "131", ",", "recipe", ".", "hashCode", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testAddAuthors", "(", ")", "{", "Assert", ".", "assertEquals", "(", "0", ",", "recipe", ".", "getAuthors", "(", ")", ".", "size", "(", ")", ")", ";", "Author", "author1", "=", "new", "Author", "(", "1", ",", "\"\"", ")", ";", "Author", "author2", "=", "new", "Author", "(", "2", ",", "\"\"", ")", ";", "recipe", "=", "new", "Recipe", "(", "1", ",", "\"My", "Recipe\"", ",", "\"\"", ")", ";", "recipe", ".", "addAuthorToRecipe", "(", "author1", ")", ";", "recipe", ".", "addAuthorToRecipe", "(", "author2", ")", ";", "int", "testSize", "=", "recipe", ".", "getAuthors", "(", ")", ".", "size", "(", ")", ";", "Assert", ".", "assertEquals", "(", "2", ",", "testSize", ")", ";", "}", "}", "</s>" ]
7,569
[ "<s>", "package", "com", ".", "akkineni", ".", "test", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "junit", ".", "runners", ".", "Suite", ";", "import", "org", ".", "junit", ".", "runners", ".", "Suite", ".", "SuiteClasses", ";", "import", "com", ".", "akkineni", ".", "domain", ".", "AuthorTest", ";", "import", "com", ".", "akkineni", ".", "domain", ".", "RecipeTest", ";", "@", "RunWith", "(", "value", "=", "Suite", ".", "class", ")", "@", "SuiteClasses", "(", "value", "=", "{", "RecipeTest", ".", "class", ",", "AuthorTest", ".", "class", "}", ")", "public", "class", "DomainClassesTestSuite", "{", "}", "</s>" ]
7,570
[ "<s>", "package", "cuke4duke", ".", "mojo", ";", "import", "org", ".", "apache", ".", "maven", ".", "artifact", ".", "Artifact", ";", "import", "org", ".", "apache", ".", "maven", ".", "artifact", ".", "repository", ".", "DefaultArtifactRepository", ";", "import", "org", ".", "apache", ".", "maven", ".", "artifact", ".", "repository", ".", "layout", ".", "DefaultRepositoryLayout", ";", "import", "org", ".", "apache", ".", "maven", ".", "plugin", ".", "MojoExecutionException", ";", "import", "org", ".", "apache", ".", "maven", ".", "project", ".", "MavenProject", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertEquals", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertTrue", ";", "public", "class", "CucumberMojoTest", "{", "private", "CucumberMojo", "mojo", ";", "@", "Before", "public", "void", "setUp", "(", ")", "{", "mojo", "=", "new", "CucumberMojo", "(", ")", ";", "mojo", ".", "launchDirectory", "=", "new", "File", "(", "\".\"", ")", ";", "mojo", ".", "mavenProject", "=", "new", "MavenProject", "(", ")", ";", "mojo", ".", "mavenProject", ".", "setFile", "(", "new", "File", "(", "\"../.\"", ")", ")", ";", "mojo", ".", "compileClasspathElements", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "mojo", ".", "pluginArtifacts", "=", "new", "ArrayList", "<", "Artifact", ">", "(", ")", ";", "mojo", ".", "testClasspathElements", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "mojo", ".", "localRepository", "=", "new", "DefaultArtifactRepository", "(", "\"\"", ",", "\"\"", ",", "new", "DefaultRepositoryLayout", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldAddCucumberArgs", "(", ")", "{", "String", "cucumberArg", "=", "\"testArg\"", ";", "mojo", ".", "cucumberArgs", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "mojo", ".", "cucumberArgs", ".", "add", "(", "cucumberArg", ")", ";", "assertTrue", "(", "mojo", ".", "allCucumberArgs", "(", ")", ".", "contains", "(", "cucumberArg", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldAllowZeroAddCucumberArgs", "(", ")", "{", "mojo", ".", "extraCucumberArgs", "=", "null", ";", "mojo", ".", "allCucumberArgs", "(", ")", ";", "}", "@", "Test", "public", "void", "shouldSplitAddCucumberArgsIntoRealCucumberArgs", "(", ")", "{", "mojo", ".", "extraCucumberArgs", "=", "\"\"", ";", "assertEquals", "(", "\"\"", ",", "mojo", ".", "allCucumberArgs", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldIgnoreNullJvmArg", "(", ")", "throws", "MojoExecutionException", "{", "mojo", ".", "jvmArgs", "=", "Arrays", ".", "asList", "(", "\"-Dfoo=bar\"", ",", "null", ",", "\"\"", ")", ";", "assertEquals", "(", "Arrays", ".", "asList", "(", "\"-Dfoo=bar\"", ",", "\"\"", ")", ",", "Arrays", ".", "asList", "(", "mojo", ".", "cucumber", "(", "\"\"", ")", ".", "getCommandLine", "(", ")", ".", "getVmCommand", "(", ")", ".", "getArguments", "(", ")", ")", ")", ";", "}", "}", "</s>" ]
7,571
[ "<s>", "package", "cuke4duke", ".", "mojo", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "maven", ".", "artifact", ".", "Artifact", ";", "import", "org", ".", "apache", ".", "maven", ".", "artifact", ".", "DependencyResolutionRequiredException", ";", "import", "org", ".", "apache", ".", "maven", ".", "artifact", ".", "repository", ".", "ArtifactRepository", ";", "import", "org", ".", "apache", ".", "maven", ".", "plugin", ".", "AbstractMojo", ";", "import", "org", ".", "apache", ".", "maven", ".", "plugin", ".", "MojoExecutionException", ";", "import", "org", ".", "apache", ".", "maven", ".", "plugin", ".", "logging", ".", "Log", ";", "import", "org", ".", "apache", ".", "maven", ".", "project", ".", "MavenProject", ";", "import", "org", ".", "apache", ".", "maven", ".", "settings", ".", "Proxy", ";", "import", "org", ".", "apache", ".", "maven", ".", "settings", ".", "Settings", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildEvent", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildListener", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "Project", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "Path", ";", "import", "org", ".", "codehaus", ".", "plexus", ".", "util", ".", "StringUtils", ";", "import", "cuke4duke", ".", "ant", ".", "GemTask", ";", "public", "abstract", "class", "AbstractJRubyMojo", "extends", "AbstractMojo", "{", "protected", "MavenProject", "mavenProject", ";", "private", "Settings", "settings", ";", "protected", "File", "launchDirectory", ";", "protected", "File", "gemDirectory", ";", "protected", "List", "<", "String", ">", "compileClasspathElements", ";", "protected", "List", "<", "Artifact", ">", "pluginArtifacts", ";", "protected", "List", "<", "String", ">", "testClasspathElements", ";", "protected", "ArtifactRepository", "localRepository", ";", "protected", "abstract", "List", "<", "String", ">", "getJvmArgs", "(", ")", ";", "protected", "void", "installGem", "(", "String", "gemArgs", ")", "throws", "MojoExecutionException", "{", "GemTask", "gem", "=", "new", "GemTask", "(", ")", ";", "if", "(", "gemDirectory", "!=", "null", "&&", "gemDirectory", ".", "exists", "(", ")", ")", "{", "gem", ".", "setDir", "(", "gemDirectory", ")", ";", "}", "gem", ".", "setProject", "(", "getProject", "(", ")", ")", ";", "gem", ".", "setArgs", "(", "gemArgs", "+", "getProxyArg", "(", ")", ")", ";", "gem", ".", "execute", "(", ")", ";", "}", "protected", "String", "getProxyArg", "(", ")", "{", "Proxy", "activeProxy", "=", "this", ".", "settings", ".", "getActiveProxy", "(", ")", ";", "if", "(", "activeProxy", "==", "null", ")", "{", "return", "\"\"", ";", "}", "String", "proxyArg", "=", "\"\"", "+", "activeProxy", ".", "getProtocol", "(", ")", "+", "\"://\"", "+", "activeProxy", ".", "getHost", "(", ")", "+", "\":\"", "+", "activeProxy", ".", "getPort", "(", ")", ";", "getLog", "(", ")", ".", "debug", "(", "\"\"", "+", "proxyArg", ")", ";", "return", "proxyArg", ";", "}", "protected", "File", "jrubyHome", "(", ")", "{", "return", "new", "File", "(", "localRepository", ".", "getBasedir", "(", ")", ",", "\".jruby\"", ")", ";", "}", "protected", "Project", "getProject", "(", ")", "throws", "MojoExecutionException", "{", "Project", "project", "=", "new", "Project", "(", ")", ";", "project", ".", "setBaseDir", "(", "mavenProject", ".", "getBasedir", "(", ")", ")", ";", "project", ".", "setProperty", "(", "\"jruby.home\"", ",", "jrubyHome", "(", ")", ".", "getAbsolutePath", "(", ")", ")", ";", "project", ".", "addBuildListener", "(", "new", "LogAdapter", "(", ")", ")", ";", "Path", "jrubyClasspath", "=", "new", "Path", "(", "project", ")", ";", "project", ".", "addReference", "(", "\"\"", ",", "jrubyClasspath", ")", ";", "try", "{", "append", "(", "jrubyClasspath", ",", "testClasspathElements", ")", ";", "append", "(", "jrubyClasspath", ",", "compileClasspathElements", ")", ";", "append", "(", "jrubyClasspath", ",", "pluginArtifacts", ")", ";", "return", "project", ";", "}", "catch", "(", "DependencyResolutionRequiredException", "e", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"\"", ",", "e", ")", ";", "}", "}", "protected", "void", "append", "(", "Path", "classPath", ",", "List", "<", "?", ">", "artifacts", ")", "throws", "DependencyResolutionRequiredException", "{", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", "artifacts", ".", "size", "(", ")", ")", ";", "for", "(", "Object", "elem", ":", "artifacts", ")", "{", "String", "path", ";", "if", "(", "elem", "instanceof", "Artifact", ")", "{", "Artifact", "a", "=", "(", "Artifact", ")", "elem", ";", "File", "file", "=", "a", ".", "getFile", "(", ")", ";", "if", "(", "file", "==", "null", ")", "{", "throw", "new", "DependencyResolutionRequiredException", "(", "a", ")", ";", "}", "path", "=", "file", ".", "getPath", "(", ")", ";", "}", "else", "{", "path", "=", "elem", ".", "toString", "(", ")", ";", "}", "list", ".", "add", "(", "path", ")", ";", "}", "Path", "p", "=", "new", "Path", "(", "classPath", ".", "getProject", "(", ")", ")", ";", "p", ".", "setPath", "(", "StringUtils", ".", "join", "(", "list", ".", "iterator", "(", ")", ",", "File", ".", "pathSeparator", ")", ")", ";", "classPath", ".", "append", "(", "p", ")", ";", "}", "public", "class", "LogAdapter", "implements", "BuildListener", "{", "public", "void", "buildStarted", "(", "BuildEvent", "event", ")", "{", "log", "(", "event", ")", ";", "}", "public", "void", "buildFinished", "(", "BuildEvent", "event", ")", "{", "log", "(", "event", ")", ";", "}", "public", "void", "targetStarted", "(", "BuildEvent", "event", ")", "{", "log", "(", "event", ")", ";", "}", "public", "void", "targetFinished", "(", "BuildEvent", "event", ")", "{", "log", "(", "event", ")", ";", "}", "public", "void", "taskStarted", "(", "BuildEvent", "event", ")", "{", "log", "(", "event", ")", ";", "}", "public", "void", "taskFinished", "(", "BuildEvent", "event", ")", "{", "log", "(", "event", ")", ";", "}", "public", "void", "messageLogged", "(", "BuildEvent", "event", ")", "{", "log", "(", "event", ")", ";", "}", "private", "void", "log", "(", "BuildEvent", "event", ")", "{", "int", "priority", "=", "event", ".", "getPriority", "(", ")", ";", "Log", "log", "=", "getLog", "(", ")", ";", "String", "message", "=", "event", ".", "getMessage", "(", ")", ";", "switch", "(", "priority", ")", "{", "case", "Project", ".", "MSG_ERR", ":", "log", ".", "error", "(", "message", ")", ";", "break", ";", "case", "Project", ".", "MSG_WARN", ":", "log", ".", "warn", "(", "message", ")", ";", "break", ";", "case", "Project", ".", "MSG_INFO", ":", "log", ".", "info", "(", "message", ")", ";", "break", ";", "case", "Project", ".", "MSG_VERBOSE", ":", "log", ".", "debug", "(", "message", ")", ";", "break", ";", "case", "Project", ".", "MSG_DEBUG", ":", "log", ".", "debug", "(", "message", ")", ";", "break", ";", "default", ":", "log", ".", "info", "(", "message", ")", ";", "break", ";", "}", "}", "}", "}", "</s>" ]
7,572
[ "<s>", "package", "cuke4duke", ".", "mojo", ";", "import", "cuke4duke", ".", "ant", ".", "CucumberTask", ";", "import", "cuke4duke", ".", "internal", ".", "Utils", ";", "import", "org", ".", "apache", ".", "maven", ".", "plugin", ".", "MojoExecutionException", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "Commandline", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "CucumberMojo", "extends", "AbstractJRubyMojo", "{", "protected", "String", "features", "=", "\"features\"", ";", "protected", "boolean", "installGems", "=", "false", ";", "private", "boolean", "skip", ";", "protected", "boolean", "failOnError", "=", "true", ";", "protected", "List", "<", "String", ">", "gems", ";", "protected", "List", "<", "String", ">", "cucumberArgs", "=", "Collections", ".", "<", "String", ">", "emptyList", "(", ")", ";", "protected", "String", "extraCucumberArgs", ";", "protected", "List", "<", "String", ">", "jvmArgs", ";", "public", "void", "execute", "(", ")", "throws", "MojoExecutionException", "{", "if", "(", "installGems", ")", "{", "for", "(", "String", "gemSpec", ":", "gems", ")", "{", "installGem", "(", "gemSpec", ")", ";", "}", "}", "if", "(", "skip", ")", "{", "getLog", "(", ")", ".", "info", "(", "\"\"", ")", ";", "return", ";", "}", "CucumberTask", "cucumber", "=", "cucumber", "(", "allCucumberArgs", "(", ")", ")", ";", "try", "{", "cucumber", ".", "execute", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "if", "(", "failOnError", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"\"", ",", "e", ")", ";", "}", "}", "}", "public", "CucumberTask", "cucumber", "(", "String", "args", ")", "throws", "MojoExecutionException", "{", "CucumberTask", "cucumber", "=", "new", "CucumberTask", "(", ")", ";", "cucumber", ".", "setProject", "(", "getProject", "(", ")", ")", ";", "for", "(", "String", "jvmArg", ":", "getJvmArgs", "(", ")", ")", "{", "if", "(", "jvmArg", "!=", "null", ")", "{", "Commandline", ".", "Argument", "arg", "=", "cucumber", ".", "createJvmarg", "(", ")", ";", "arg", ".", "setValue", "(", "jvmArg", ")", ";", "}", "}", "cucumber", ".", "setArgs", "(", "args", ")", ";", "return", "cucumber", ";", "}", "String", "allCucumberArgs", "(", ")", "{", "List", "<", "String", ">", "allCucumberArgs", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "cucumberArgs", "!=", "null", ")", "allCucumberArgs", ".", "addAll", "(", "cucumberArgs", ")", ";", "if", "(", "extraCucumberArgs", "!=", "null", ")", "allCucumberArgs", ".", "add", "(", "extraCucumberArgs", ")", ";", "allCucumberArgs", ".", "add", "(", "features", ")", ";", "return", "Utils", ".", "join", "(", "allCucumberArgs", ".", "toArray", "(", ")", ",", "\"", "\"", ")", ";", "}", "protected", "List", "<", "String", ">", "getJvmArgs", "(", ")", "{", "return", "(", "jvmArgs", "!=", "null", ")", "?", "jvmArgs", ":", "Collections", ".", "<", "String", ">", "emptyList", "(", ")", ";", "}", "}", "</s>" ]
7,573
[ "<s>", "package", "cuke4duke", ".", "steps", ";", "import", "cuke4duke", ".", "app", ".", "HelloService", ";", "import", "org", ".", "springframework", ".", "beans", ".", "factory", ".", "annotation", ".", "Autowired", ";", "import", "org", ".", "springframework", ".", "stereotype", ".", "Component", ";", "@", "Component", "public", "class", "SpringSteps", "extends", "AbstractSteps", "{", "@", "Autowired", "private", "HelloService", "helloService", ";", "protected", "HelloService", "getHelloService", "(", ")", "{", "return", "helloService", ";", "}", "}", "</s>" ]
7,574
[ "<s>", "package", "cuke4duke", ".", "steps", ";", "import", "cuke4duke", ".", "app", ".", "HelloService", ";", "public", "class", "PicoContainerSteps", "extends", "AbstractSteps", "{", "private", "final", "HelloService", "helloService", ";", "public", "PicoContainerSteps", "(", "HelloService", "helloService", ")", "{", "this", ".", "helloService", "=", "helloService", ";", "}", "protected", "HelloService", "getHelloService", "(", ")", "{", "return", "helloService", ";", "}", "}", "</s>" ]
7,575
[ "<s>", "package", "cuke4duke", ".", "steps", ";", "import", "cuke4duke", ".", "annotation", ".", "I18n", ".", "EN", ".", "*", ";", "import", "cuke4duke", ".", "app", ".", "HelloService", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "abstract", "class", "AbstractSteps", "{", "private", "final", "Map", "<", "String", ",", "Integer", ">", "cukes", "=", "new", "HashMap", "<", "String", ",", "Integer", ">", "(", ")", ";", "protected", "abstract", "HelloService", "getHelloService", "(", ")", ";", "@", "Given", "(", "\"\"", ")", "public", "void", "iHaveNCukes", "(", "int", "n", ",", "String", "color", ")", "{", "this", ".", "cukes", ".", "put", "(", "color", ",", "n", ")", ";", "}", "@", "Then", "(", "\"\"", ")", "public", "void", "iShouldHaveNCukes", "(", "int", "n", ",", "String", "color", ")", "{", "if", "(", "n", "!=", "cukes", ".", "get", "(", "color", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Expected", "\"", "+", "n", "+", "\",", "got", "\"", "+", "cukes", ".", "get", "(", "color", ")", ")", ";", "}", "}", "@", "Given", "(", "\"Longs:", "(\\\\d+)\"", ")", "public", "void", "longs", "(", "long", "n", ")", "{", "}", "@", "Given", "(", "\"I", "say", "hello\"", ")", "public", "void", "iSayHello", "(", ")", "{", "String", "hello", "=", "getHelloService", "(", ")", ".", "hello", "(", ")", ";", "if", "(", "!", "hello", ".", "equals", "(", "\"\"", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "}", "public", "void", "thisIsNotAStep", "(", ")", "{", "}", "}", "</s>" ]
7,576
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "java", ";", "import", "cuke4duke", ".", "annotation", ".", "Pending", ";", "import", "cuke4duke", ".", "spi", ".", "jruby", ".", "JRuby", ";", "import", "cuke4duke", ".", "spi", ".", "jruby", ".", "JRubyExceptionFactory", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "public", "class", "MethodInvokerTest", "{", "private", "class", "SomethingWithPending", "{", "@", "Pending", "@", "SuppressWarnings", "(", "\"unused\"", ")", "public", "void", "dontExecuteMe", "(", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "}", "@", "Before", "public", "void", "definePendingException", "(", ")", "{", "JRuby", ".", "getRuntime", "(", ")", ".", "evalScriptlet", "(", "\"\"", ")", ";", "}", "@", "Test", "(", "expected", "=", "org", ".", "jruby", ".", "exceptions", ".", "RaiseException", ".", "class", ")", "public", "void", "shouldRaiseCucumberPendingWhenAnnotatedWithPending", "(", ")", "throws", "Throwable", "{", "Method", "dontExecuteMe", "=", "SomethingWithPending", ".", "class", ".", "getDeclaredMethod", "(", "\"\"", ")", ";", "MethodInvoker", "mi", "=", "new", "MethodInvoker", "(", "new", "JRubyExceptionFactory", "(", ")", ")", ";", "mi", ".", "invoke", "(", "dontExecuteMe", ",", "new", "SomethingWithPending", "(", ")", ",", "new", "Object", "[", "0", "]", ")", ";", "}", "}", "</s>" ]
7,577
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "java", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertEquals", ";", "public", "class", "MethodFormatTest", "{", "private", "Method", "methodWithArgsAndException", ";", "private", "Method", "methodWithoutArgs", ";", "public", "void", "methodWithoutArgs", "(", ")", "{", "}", "public", "List", "methodWithArgsAndException", "(", "String", "foo", ",", "Map", "bar", ")", "throws", "IllegalArgumentException", ",", "IOException", "{", "return", "null", ";", "}", "@", "Before", "public", "void", "lookupMethod", "(", ")", "throws", "NoSuchMethodException", "{", "this", ".", "methodWithoutArgs", "=", "this", ".", "getClass", "(", ")", ".", "getMethod", "(", "\"\"", ")", ";", "this", ".", "methodWithArgsAndException", "=", "this", ".", "getClass", "(", ")", ".", "getMethod", "(", "\"\"", ",", "String", ".", "class", ",", "Map", ".", "class", ")", ";", "}", "@", "Test", "public", "void", "shouldUseSimpleFormatWhenMethodHasException", "(", ")", "{", "assertEquals", "(", "\"\"", ",", "new", "MethodFormat", "(", "\"%c.%m(%a)\"", ")", ".", "format", "(", "methodWithArgsAndException", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldUseSimpleFormatWhenMethodHasNoException", "(", ")", "{", "assertEquals", "(", "\"\"", ",", "new", "MethodFormat", "(", "\"%c.%m(%a)\"", ")", ".", "format", "(", "methodWithoutArgs", ")", ")", ";", "}", "}", "</s>" ]
7,578
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "java", ";", "import", "cuke4duke", ".", "annotation", ".", "I18n", ".", "EN", ".", "*", ";", "import", "cuke4duke", ".", "StepMother", ";", "import", "cuke4duke", ".", "internal", ".", "jvmclass", ".", "ClassAnalyzer", ";", "import", "cuke4duke", ".", "internal", ".", "jvmclass", ".", "ClassLanguage", ";", "import", "cuke4duke", ".", "internal", ".", "jvmclass", ".", "ClassLanguageMixin", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "AbstractStepDefinition", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "StepDefinition", ";", "import", "cuke4duke", ".", "spi", ".", "ExceptionFactory", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "mockito", ".", "Mock", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "static", "junit", ".", "framework", ".", "Assert", ".", "assertEquals", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "import", "static", "org", ".", "mockito", ".", "MockitoAnnotations", ".", "initMocks", ";", "public", "class", "JavaAnalyzerTest", "{", "@", "Mock", "private", "StepMother", "stepMother", ";", "@", "Mock", "private", "ClassLanguageMixin", "languageMixin", ";", "public", "JavaAnalyzerTest", "(", ")", "{", "initMocks", "(", "this", ")", ";", "}", "public", "abstract", "static", "class", "FlintStone", "{", "@", "Given", "(", "\"\"", ")", "public", "Class", "whereIsDino", "(", ")", "{", "return", "getClass", "(", ")", ";", "}", "}", "public", "static", "class", "Fred", "extends", "FlintStone", "{", "}", "public", "static", "class", "Wilma", "extends", "FlintStone", "{", "}", "@", "Test", "public", "void", "shouldAllowOneInheritedSubclass", "(", ")", "throws", "Throwable", "{", "ClassLanguage", "classLanguage", "=", "new", "ClassLanguage", "(", "languageMixin", ",", "mock", "(", "ExceptionFactory", ".", "class", ")", ",", "stepMother", ",", "Arrays", ".", "<", "ClassAnalyzer", ">", "asList", "(", "new", "JavaAnalyzer", "(", ")", ")", ")", ";", "classLanguage", ".", "addClass", "(", "FlintStone", ".", "class", ")", ";", "classLanguage", ".", "addClass", "(", "Fred", ".", "class", ")", ";", "classLanguage", ".", "begin_scenario", "(", "null", ")", ";", "List", "<", "StepDefinition", ">", "stepDefinitions", "=", "classLanguage", ".", "getStepDefinitions", "(", ")", ";", "assertEquals", "(", "1", ",", "stepDefinitions", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "Fred", ".", "class", ",", "(", "(", "AbstractStepDefinition", ")", "stepDefinitions", ".", "get", "(", "0", ")", ")", ".", "invokeWithArgs", "(", "new", "Object", "[", "0", "]", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "Exception", ".", "class", ")", "public", "void", "shouldFailWithTwoInheritedSubclass", "(", ")", "throws", "Throwable", "{", "ClassLanguage", "classLanguage", "=", "new", "ClassLanguage", "(", "languageMixin", ",", "mock", "(", "ExceptionFactory", ".", "class", ")", ",", "stepMother", ",", "Arrays", ".", "<", "ClassAnalyzer", ">", "asList", "(", "new", "JavaAnalyzer", "(", ")", ")", ")", ";", "classLanguage", ".", "addClass", "(", "FlintStone", ".", "class", ")", ";", "classLanguage", ".", "addClass", "(", "Fred", ".", "class", ")", ";", "classLanguage", ".", "addClass", "(", "Wilma", ".", "class", ")", ";", "classLanguage", ".", "begin_scenario", "(", "null", ")", ";", "List", "<", "StepDefinition", ">", "stepDefinitions", "=", "classLanguage", ".", "getStepDefinitions", "(", ")", ";", "assertEquals", "(", "1", ",", "stepDefinitions", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "Fred", ".", "class", ",", "(", "(", "AbstractStepDefinition", ")", "stepDefinitions", ".", "get", "(", "0", ")", ")", ".", "invokeWithArgs", "(", "new", "Object", "[", "0", "]", ")", ")", ";", "}", "}", "</s>" ]
7,579
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "jvmclass", ";", "import", "cuke4duke", ".", "StepMother", ";", "import", "cuke4duke", ".", "annotation", ".", "Order", ";", "import", "cuke4duke", ".", "internal", ".", "java", ".", "JavaAnalyzer", ";", "import", "cuke4duke", ".", "internal", ".", "java", ".", "JavaHook", ";", "import", "cuke4duke", ".", "spi", ".", "ExceptionFactory", ";", "import", "org", ".", "hamcrest", ".", "BaseMatcher", ";", "import", "org", ".", "hamcrest", ".", "Description", ";", "import", "org", ".", "hamcrest", ".", "Matcher", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "mockito", ".", "InOrder", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertEquals", ";", "import", "static", "org", ".", "mockito", ".", "Matchers", ".", "argThat", ";", "import", "static", "org", ".", "mockito", ".", "Matchers", ".", "eq", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "inOrder", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "public", "class", "ClassLanguageTest", "{", "private", "ClassLanguage", "language", ";", "@", "Before", "public", "void", "createLanguage", "(", ")", "throws", "Throwable", "{", "language", "=", "new", "ClassLanguage", "(", "mock", "(", "ClassLanguageMixin", ".", "class", ")", ",", "mock", "(", "ExceptionFactory", ".", "class", ")", ",", "mock", "(", "StepMother", ".", "class", ")", ",", "Collections", ".", "<", "ClassAnalyzer", ">", "emptyList", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldLoadExistingClassFromJavaFileName", "(", ")", "throws", "Throwable", "{", "language", ".", "load_code_file", "(", "\"\"", ")", ";", "}", "@", "Test", "(", "expected", "=", "ClassNotFoundException", ".", "class", ")", "public", "void", "shouldFailToLoadMissingClassFromJavaFileName", "(", ")", "throws", "Throwable", "{", "language", ".", "load_code_file", "(", "\"\"", ")", ";", "}", "public", "static", "class", "A", "{", "private", "final", "B", "b", ";", "public", "A", "(", "B", "b", ")", "{", "this", ".", "b", "=", "b", ";", "}", "@", "cuke4duke", ".", "annotation", ".", "Before", "(", ")", "@", "Order", "(", "1", ")", "public", "void", "doA", "(", ")", "{", "assertEquals", "(", "\"\"", ",", "b", ".", "message", ")", ";", "}", "}", "public", "static", "class", "B", "{", "public", "String", "message", ";", "@", "cuke4duke", ".", "annotation", ".", "Before", "(", ")", "@", "Order", "(", "2", ")", "public", "void", "doB", "(", ")", "{", "message", "=", "\"Hello", "from", "B\"", ";", "}", "}", "@", "Test", "public", "void", "shouldRunBeforeHooksInOrderOfDependencies", "(", ")", "throws", "Throwable", "{", "ObjectFactory", "objectFactory", "=", "new", "PicoFactory", "(", ")", ";", "ClassLanguageMixin", "languageMixin", "=", "mock", "(", "ClassLanguageMixin", ".", "class", ")", ";", "language", "=", "new", "ClassLanguage", "(", "languageMixin", ",", "mock", "(", "ExceptionFactory", ".", "class", ")", ",", "mock", "(", "StepMother", ".", "class", ")", ",", "Collections", ".", "<", "ClassAnalyzer", ">", "singletonList", "(", "new", "JavaAnalyzer", "(", ")", ")", ",", "objectFactory", ")", ";", "language", ".", "addClass", "(", "A", ".", "class", ")", ";", "language", ".", "addClass", "(", "B", ".", "class", ")", ";", "language", ".", "begin_scenario", "(", "null", ")", ";", "InOrder", "order", "=", "inOrder", "(", "languageMixin", ")", ";", "order", ".", "verify", "(", "languageMixin", ")", ".", "add_hook", "(", "eq", "(", "\"before\"", ")", ",", "argThat", "(", "isHook", "(", "\"doA\"", ")", ")", ")", ";", "order", ".", "verify", "(", "languageMixin", ")", ".", "add_hook", "(", "eq", "(", "\"before\"", ")", ",", "argThat", "(", "isHook", "(", "\"doB\"", ")", ")", ")", ";", "}", "private", "Matcher", "<", "JavaHook", ">", "isHook", "(", "String", "methodName", ")", "{", "return", "new", "HookMatcher", "(", "methodName", ")", ";", "}", "private", "class", "HookMatcher", "extends", "BaseMatcher", "<", "JavaHook", ">", "{", "private", "final", "String", "methodName", ";", "private", "String", "actualMethodName", ";", "public", "HookMatcher", "(", "String", "methodName", ")", "{", "this", ".", "methodName", "=", "methodName", ";", "}", "public", "void", "describeTo", "(", "Description", "description", ")", "{", "description", ".", "appendText", "(", "\"Expected", "\"", "+", "methodName", "+", "\",", "but", "got", "\"", "+", "actualMethodName", ")", ";", "}", "public", "boolean", "matches", "(", "Object", "o", ")", "{", "JavaHook", "hook", "=", "(", "JavaHook", ")", "o", ";", "actualMethodName", "=", "hook", ".", "getMethod", "(", ")", ".", "getName", "(", ")", ";", "return", "methodName", ".", "equals", "(", "actualMethodName", ")", ";", "}", "}", "}", "</s>" ]
7,580
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "jvmclass", ";", "import", "cuke4duke", ".", "annotation", ".", "Transform", ";", "public", "class", "MyTransforms", "{", "@", "Transform", "public", "boolean", "overrideBooleanTransform", "(", "String", "yes", ")", "{", "if", "(", "yes", ".", "equals", "(", "\"yes\"", ")", ")", "return", "true", ";", "else", "return", "false", ";", "}", "}", "</s>" ]
7,581
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "jvmclass", ";", "import", "com", ".", "google", ".", "inject", ".", "AbstractModule", ";", "public", "class", "SomeModule", "extends", "AbstractModule", "{", "@", "Override", "protected", "void", "configure", "(", ")", "{", "}", "}", "</s>" ]
7,582
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "jvmclass", ";", "import", "com", ".", "google", ".", "inject", ".", "AbstractModule", ";", "import", "cuke4duke", ".", "internal", ".", "jvmclass", ".", "GuiceFactoryTest", ".", "SomeClass", ".", "SomeInnerClass", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "GuiceFactoryTest", "{", "public", "static", "class", "SomeClass", "{", "public", "class", "SomeInnerClass", "{", "}", "public", "Object", "someInstance", "=", "new", "Object", "(", ")", "{", "}", ";", "}", "public", "class", "SomeModule", "extends", "AbstractModule", "{", "@", "Override", "protected", "void", "configure", "(", ")", "{", "}", "}", "private", "GuiceFactory", "guiceFactory", ";", "@", "Before", "public", "void", "setUp", "(", ")", "throws", "Throwable", "{", "guiceFactory", "=", "new", "GuiceFactory", "(", "\"\"", ")", ";", "}", "@", "Test", "public", "void", "shouldNotAbortIfClassCannotBeInstantiated", "(", ")", "{", "guiceFactory", ".", "addClass", "(", "SomeClass", ".", "class", ")", ";", "SomeClass", "instance", "=", "new", "SomeClass", "(", ")", ";", "Class", "<", "?", "extends", "SomeInnerClass", ">", "someInnerClass", "=", "instance", ".", "new", "SomeInnerClass", "(", ")", ".", "getClass", "(", ")", ";", "if", "(", "guiceFactory", ".", "canHandle", "(", "someInnerClass", ")", ")", "{", "guiceFactory", ".", "addClass", "(", "someInnerClass", ")", ";", "}", "guiceFactory", ".", "createObjects", "(", ")", ";", "}", "}", "</s>" ]
7,583
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "jvmclass", ";", "import", "cuke4duke", ".", "Scenario", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "AbstractProgrammingLanguage", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertEquals", ";", "public", "class", "ArgumentsConverterTest", "{", "private", "AbstractProgrammingLanguage", "p", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "p", "=", "new", "AbstractProgrammingLanguage", "(", "null", ",", "null", ")", "{", "@", "Override", "public", "void", "load_code_file", "(", "String", "file", ")", "throws", "Throwable", "{", "}", "@", "Override", "protected", "void", "begin_scenario", "(", "Scenario", "scenario", ")", "throws", "Throwable", "{", "}", "@", "Override", "public", "void", "end_scenario", "(", ")", "throws", "Throwable", "{", "}", "@", "Override", "protected", "Object", "customTransform", "(", "Object", "arg", ",", "Class", "<", "?", ">", "parameterType", ",", "Locale", "locale", ")", "throws", "Throwable", "{", "return", "null", ";", "}", "}", ";", "}", "@", "Test", "public", "void", "shouldConvertFromStringToObject", "(", ")", "throws", "Throwable", "{", "assertEquals", "(", "\"An", "Object\"", ",", "p", ".", "transformOne", "(", "\"An", "Object\"", ",", "Object", ".", "class", ",", "Locale", ".", "getDefault", "(", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldConvertFromStringToInt", "(", ")", "throws", "Throwable", "{", "assertEquals", "(", "3", ",", "p", ".", "transformOne", "(", "\"3\"", ",", "Integer", ".", "TYPE", ",", "Locale", ".", "getDefault", "(", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldConvertFromStringToInteger", "(", ")", "throws", "Throwable", "{", "assertEquals", "(", "4", ",", "p", ".", "transformOne", "(", "\"4\"", ",", "Integer", ".", "class", ",", "Locale", ".", "getDefault", "(", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldConvertFromStringToLongPrimitive", "(", ")", "throws", "Throwable", "{", "assertEquals", "(", "3L", ",", "p", ".", "transformOne", "(", "\"3\"", ",", "Long", ".", "TYPE", ",", "Locale", ".", "getDefault", "(", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldConvertFromStringToLong", "(", ")", "throws", "Throwable", "{", "assertEquals", "(", "4L", ",", "p", ".", "transformOne", "(", "\"4\"", ",", "Long", ".", "class", ",", "Locale", ".", "getDefault", "(", ")", ")", ")", ";", "}", "}", "</s>" ]
7,584
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "language", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "java", ".", "io", ".", "UnsupportedEncodingException", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertEquals", ";", "public", "class", "JdkPatternArgumentMatcherTest", "{", "@", "Test", "public", "void", "shouldDealWithOnlyAscii", "(", ")", "throws", "UnsupportedEncodingException", "{", "assertVariables", "(", "\"\"", ",", "\"\"", ",", "\"vi\"", ",", "3", ",", "\"dette\"", ",", "13", ")", ";", "}", "@", "Test", "public", "void", "shouldDealWithUnicodeInsideCaptures", "(", ")", "throws", "UnsupportedEncodingException", "{", "assertVariables", "(", "\"\"", ",", "\"\"", ",", "\"v-UNK-\"", ",", "3", ",", "\"d-UNK-tte\"", ",", "14", ")", ";", "}", "@", "Test", "public", "void", "shouldDealWithUnicodeOutsideCaptures", "(", ")", "throws", "UnsupportedEncodingException", "{", "assertVariables", "(", "\"\"", ",", "\"\"", ",", "\"vi\"", ",", "4", ",", "\"dette\"", ",", "15", ")", ";", "}", "@", "Test", "public", "void", "shouldDealWithUnicodeEverywhere", "(", ")", "throws", "UnsupportedEncodingException", "{", "assertVariables", "(", "\"\"", ",", "\"\"", ",", "\"v-UNK-\"", ",", "4", ",", "\"d-UNK-tte\"", ",", "16", ")", ";", "}", "private", "void", "assertVariables", "(", "String", "regex", ",", "String", "string", ",", "String", "v1", ",", "int", "pos1", ",", "String", "v2", ",", "int", "pos2", ")", "throws", "UnsupportedEncodingException", "{", "List", "<", "StepArgument", ">", "args", "=", "JdkPatternArgumentMatcher", ".", "argumentsFrom", "(", "Pattern", ".", "compile", "(", "regex", ")", ",", "string", ")", ";", "assertEquals", "(", "2", ",", "args", ".", "size", "(", ")", ")", ";", "assertEquals", "(", "v1", ",", "args", ".", "get", "(", "0", ")", ".", "getVal", "(", ")", ")", ";", "assertEquals", "(", "pos1", ",", "args", ".", "get", "(", "0", ")", ".", "getByteOffset", "(", ")", ")", ";", "assertEquals", "(", "v2", ",", "args", ".", "get", "(", "1", ")", ".", "getVal", "(", ")", ")", ";", "assertEquals", "(", "pos2", ",", "args", ".", "get", "(", "1", ")", ".", "getByteOffset", "(", ")", ")", ";", "}", "}", "</s>" ]
7,585
[ "<s>", "package", "cuke4duke", ".", "internal", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "java", ".", "text", ".", "NumberFormat", ";", "import", "java", ".", "text", ".", "ParseException", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "public", "class", "UtilsTest", "{", "@", "Test", "public", "void", "shouldCreateEnglishLocale", "(", ")", "{", "assertEquals", "(", "Locale", ".", "ENGLISH", ",", "Utils", ".", "localeFor", "(", "\"en\"", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldCreateUSLocale", "(", ")", "{", "assertEquals", "(", "Locale", ".", "US", ",", "Utils", ".", "localeFor", "(", "\"en-US\"", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldFormatLolcatDoubles", "(", ")", "throws", "ParseException", "{", "assertEquals", "(", "10.4", ",", "NumberFormat", ".", "getInstance", "(", "Utils", ".", "localeFor", "(", "\"en-LOL\"", ")", ")", ".", "parse", "(", "\"10.4\"", ")", ".", "doubleValue", "(", ")", ",", "0.0", ")", ";", "}", "@", "Test", "public", "void", "shouldFormatEnglishDoubles", "(", ")", "throws", "ParseException", "{", "assertEquals", "(", "10.4", ",", "NumberFormat", ".", "getInstance", "(", "Utils", ".", "localeFor", "(", "\"en-US\"", ")", ")", ".", "parse", "(", "\"10.4\"", ")", ".", "doubleValue", "(", ")", ",", "0.0", ")", ";", "}", "@", "Test", "public", "void", "shouldFormatNorwegianDoubles", "(", ")", "throws", "ParseException", "{", "assertEquals", "(", "10.4", ",", "NumberFormat", ".", "getInstance", "(", "Utils", ".", "localeFor", "(", "\"no\"", ")", ")", ".", "parse", "(", "\"10,4\"", ")", ".", "doubleValue", "(", ")", ",", "0.0", ")", ";", "}", "@", "Test", "public", "void", "shouldFormatNorwegianDoublesWithEnglishLocaleDifferently", "(", ")", "throws", "ParseException", "{", "assertEquals", "(", "104.0", ",", "NumberFormat", ".", "getInstance", "(", "Utils", ".", "localeFor", "(", "\"en-US\"", ")", ")", ".", "parse", "(", "\"10,4\"", ")", ".", "doubleValue", "(", ")", ",", "0.0", ")", ";", "}", "}", "</s>" ]
7,586
[ "<s>", "package", "cuke4duke", ".", "junit", ";", "import", "cuke4duke", ".", "annotation", ".", "I18n", ".", "EN", ".", "*", ";", "import", "cuke4duke", ".", "Table", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertEquals", ";", "public", "class", "JunitCukeSteps", "{", "private", "final", "Map", "<", "String", ",", "Integer", ">", "cukes", "=", "new", "HashMap", "<", "String", ",", "Integer", ">", "(", ")", ";", "@", "Given", "(", "\"\"", ")", "public", "void", "iHaveNCukes", "(", "int", "n", ",", "String", "color", ")", "{", "this", ".", "cukes", ".", "put", "(", "color", ",", "n", ")", ";", "}", "@", "Then", "(", "\"\"", ")", "public", "void", "iShouldHaveNCukes", "(", "int", "n", ",", "String", "color", ")", "{", "int", "cukesOfColor", "=", "cukes", ".", "get", "(", "color", ")", ";", "if", "(", "n", "!=", "cukesOfColor", ")", "{", "throw", "new", "RuntimeException", "(", "\"Expected", "\"", "+", "n", "+", "\",", "got", "\"", "+", "cukes", ".", "get", "(", "color", ")", ")", ";", "}", "}", "@", "When", "(", "\"\"", ")", "public", "void", "aTable", "(", "Table", "table", ")", "{", "assertEquals", "(", "1", ",", "table", ".", "hashes", "(", ")", ".", "size", "(", ")", ")", ";", "}", "@", "Given", "(", "\"Longs:", "(\\\\d+)\"", ")", "public", "void", "longs", "(", "long", "n", ")", "{", "}", "public", "void", "thisIsNotAStep", "(", ")", "{", "}", "}", "</s>" ]
7,587
[ "<s>", "package", "cuke4duke", ".", "app", ";", "import", "org", ".", "springframework", ".", "stereotype", ".", "Service", ";", "@", "Service", "public", "class", "SpringHelloService", "implements", "HelloService", "{", "public", "String", "hello", "(", ")", "{", "return", "\"\"", ";", "}", "}", "</s>" ]
7,588
[ "<s>", "package", "cuke4duke", ".", "app", ";", "public", "class", "PicoContainerHelloService", "implements", "HelloService", "{", "public", "String", "hello", "(", ")", "{", "return", "\"\"", ";", "}", "}", "</s>" ]
7,589
[ "<s>", "package", "cuke4duke", ".", "app", ";", "public", "interface", "HelloService", "{", "String", "hello", "(", ")", ";", "}", "</s>" ]
7,590
[ "<s>", "package", "cuke4duke", ".", "ant", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildException", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "Java", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "Environment", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "Path", ";", "import", "java", ".", "io", ".", "File", ";", "public", "class", "JRubyTask", "extends", "Java", "{", "public", "JRubyTask", "(", ")", "{", "setFork", "(", "true", ")", ";", "setFailonerror", "(", "true", ")", ";", "}", "@", "Override", "public", "void", "execute", "(", ")", "throws", "BuildException", "{", "setClassname", "(", "\"\"", ")", ";", "setClasspath", "(", "getJrubyClasspath", "(", ")", ")", ";", "ensureJrubyHomeExists", "(", ")", ";", "setJRubyHome", "(", ")", ";", "super", ".", "execute", "(", ")", ";", "}", "protected", "File", "getJrubyHome", "(", ")", "{", "String", "gemHome", "=", "getProject", "(", ")", ".", "getProperty", "(", "\"jruby.home\"", ")", ";", "if", "(", "gemHome", "==", "null", ")", "{", "throw", "new", "BuildException", "(", "\"\"", ")", ";", "}", "return", "new", "File", "(", "gemHome", ")", ";", "}", "protected", "File", "getBinDir", "(", ")", "{", "return", "new", "File", "(", "getJrubyHome", "(", ")", ",", "\"bin\"", ")", ";", "}", "private", "void", "ensureJrubyHomeExists", "(", ")", "{", "getJrubyHome", "(", ")", ".", "mkdirs", "(", ")", ";", "}", "private", "Path", "getJrubyClasspath", "(", ")", "{", "Object", "jrubyClasspath", "=", "getProject", "(", ")", ".", "getReference", "(", "\"\"", ")", ";", "if", "(", "jrubyClasspath", "==", "null", "||", "!", "(", "jrubyClasspath", "instanceof", "Path", ")", ")", "{", "throw", "new", "BuildException", "(", "\"\"", ")", ";", "}", "return", "(", "Path", ")", "jrubyClasspath", ";", "}", "private", "void", "setJRubyHome", "(", ")", "{", "Environment", ".", "Variable", "gemHome", "=", "new", "Environment", ".", "Variable", "(", ")", ";", "gemHome", ".", "setKey", "(", "\"GEM_HOME\"", ")", ";", "gemHome", ".", "setFile", "(", "getJrubyHome", "(", ")", ")", ";", "this", ".", "addEnv", "(", "gemHome", ")", ";", "Environment", ".", "Variable", "gemPath", "=", "new", "Environment", ".", "Variable", "(", ")", ";", "gemPath", ".", "setKey", "(", "\"GEM_PATH\"", ")", ";", "gemPath", ".", "setFile", "(", "getJrubyHome", "(", ")", ")", ";", "this", ".", "addEnv", "(", "gemPath", ")", ";", "}", "}", "</s>" ]
7,591
[ "<s>", "package", "cuke4duke", ".", "ant", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildException", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "Environment", ";", "import", "java", ".", "io", ".", "File", ";", "public", "class", "CucumberTask", "extends", "JRubyTask", "{", "private", "String", "args", "=", "\"\"", ";", "private", "File", "bin", ";", "public", "void", "execute", "(", ")", "throws", "BuildException", "{", "createArg", "(", ")", ".", "setFile", "(", "getCuke4dukeBinFile", "(", ")", ")", ";", "getCommandLine", "(", ")", ".", "createArgument", "(", ")", ".", "setLine", "(", "args", ")", ";", "super", ".", "execute", "(", ")", ";", "}", "public", "void", "setArgs", "(", "String", "args", ")", "{", "this", ".", "args", "=", "args", ";", "}", "public", "void", "setBin", "(", "File", "bin", ")", "{", "this", ".", "bin", "=", "bin", ";", "}", "public", "void", "setObjectFactory", "(", "String", "name", ")", "{", "Environment", ".", "Variable", "objectFactory", "=", "new", "Environment", ".", "Variable", "(", ")", ";", "objectFactory", ".", "setKey", "(", "\"\"", ")", ";", "objectFactory", ".", "setValue", "(", "\"\"", "+", "name", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "name", ".", "substring", "(", "1", ")", "+", "\"Factory\"", ")", ";", "this", ".", "addSysproperty", "(", "objectFactory", ")", ";", "}", "private", "File", "getCuke4dukeBinFile", "(", ")", "{", "if", "(", "bin", "!=", "null", ")", "{", "return", "bin", ";", "}", "else", "if", "(", "System", ".", "getProperty", "(", "\"\"", ")", "!=", "null", ")", "{", "return", "new", "File", "(", "System", ".", "getProperty", "(", "\"\"", ")", ")", ";", "}", "else", "{", "return", "new", "File", "(", "getBinDir", "(", ")", ",", "\"cuke4duke\"", ")", ";", "}", "}", "}", "</s>" ]
7,592
[ "<s>", "package", "cuke4duke", ".", "ant", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildException", ";", "public", "class", "GemTask", "extends", "JRubyTask", "{", "private", "String", "args", "=", "\"\"", ";", "public", "GemTask", "(", ")", "{", "createJvmarg", "(", ")", ".", "setValue", "(", "\"-Xmx384m\"", ")", ";", "}", "public", "void", "execute", "(", ")", "throws", "BuildException", "{", "createArg", "(", ")", ".", "setValue", "(", "\"-S\"", ")", ";", "createArg", "(", ")", ".", "setValue", "(", "\"gem\"", ")", ";", "getCommandLine", "(", ")", ".", "createArgument", "(", ")", ".", "setLine", "(", "args", ")", ";", "createArg", "(", ")", ".", "setValue", "(", "\"\"", ")", ";", "createArg", "(", ")", ".", "setFile", "(", "getJrubyHome", "(", ")", ")", ";", "createArg", "(", ")", ".", "setValue", "(", "\"--no-ri\"", ")", ";", "createArg", "(", ")", ".", "setValue", "(", "\"--no-rdoc\"", ")", ";", "try", "{", "super", ".", "execute", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "BuildException", "(", "\"\"", "+", "args", ",", "e", ")", ";", "}", "}", "public", "void", "setArgs", "(", "String", "args", ")", "{", "this", ".", "args", "=", "args", ";", "}", "}", "</s>" ]
7,593
[ "<s>", "package", "cuke4duke", ";", "import", "cuke4duke", ".", "internal", ".", "groovy", ".", "GroovyHook", ";", "import", "cuke4duke", ".", "internal", ".", "groovy", ".", "GroovyLanguage", ";", "import", "cuke4duke", ".", "internal", ".", "groovy", ".", "GroovyStepDefinition", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "LanguageMixin", ";", "import", "groovy", ".", "lang", ".", "Closure", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "public", "class", "GroovyDsl", "{", "public", "static", "GroovyLanguage", "groovyLanguage", ";", "public", "static", "LanguageMixin", "languageMixin", ";", "public", "static", "void", "World", "(", "Closure", "body", ")", "{", "groovyLanguage", ".", "registerWorldFactory", "(", "body", ")", ";", "}", "public", "static", "void", "Before", "(", "Object", "...", "tagsAndBody", ")", "{", "addHook", "(", "\"before\"", ",", "tagsAndBody", ")", ";", "}", "public", "static", "void", "After", "(", "Object", "...", "tagsAndBody", ")", "{", "addHook", "(", "\"after\"", ",", "tagsAndBody", ")", ";", "}", "private", "static", "void", "addHook", "(", "String", "phase", ",", "Object", "[", "]", "tagsAndBody", ")", "{", "if", "(", "tagsAndBody", ".", "length", "==", "0", ")", "return", ";", "String", "[", "]", "tagNames", "=", "new", "String", "[", "tagsAndBody", ".", "length", "-", "1", "]", ";", "System", ".", "arraycopy", "(", "tagsAndBody", ",", "0", ",", "tagNames", ",", "0", ",", "tagNames", ".", "length", ")", ";", "Closure", "body", "=", "(", "Closure", ")", "tagsAndBody", "[", "tagsAndBody", ".", "length", "-", "1", "]", ";", "languageMixin", ".", "add_hook", "(", "phase", ",", "new", "GroovyHook", "(", "Arrays", ".", "asList", "(", "tagNames", ")", ",", "body", ",", "groovyLanguage", ")", ")", ";", "}", "public", "static", "void", "Given", "(", "Pattern", "regexp", ",", "Closure", "body", ")", "throws", "Throwable", "{", "registerStepDefinition", "(", "regexp", ",", "body", ")", ";", "}", "public", "static", "void", "When", "(", "Pattern", "regexp", ",", "Closure", "body", ")", "throws", "Throwable", "{", "registerStepDefinition", "(", "regexp", ",", "body", ")", ";", "}", "public", "static", "void", "Then", "(", "Pattern", "regexp", ",", "Closure", "body", ")", "throws", "Throwable", "{", "registerStepDefinition", "(", "regexp", ",", "body", ")", ";", "}", "private", "static", "void", "registerStepDefinition", "(", "Pattern", "regexp", ",", "Closure", "body", ")", "throws", "Throwable", "{", "groovyLanguage", ".", "addStepDefinition", "(", "new", "GroovyStepDefinition", "(", "groovyLanguage", ",", "regexp", ",", "body", ")", ")", ";", "}", "}", "</s>" ]
7,594
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "js", ";", "import", "cuke4duke", ".", "Scenario", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "AbstractProgrammingLanguage", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "LanguageMixin", ";", "import", "cuke4duke", ".", "spi", ".", "ExceptionFactory", ";", "import", "org", ".", "mozilla", ".", "javascript", ".", "Context", ";", "import", "org", ".", "mozilla", ".", "javascript", ".", "NativeFunction", ";", "import", "org", ".", "mozilla", ".", "javascript", ".", "Scriptable", ";", "import", "org", ".", "mozilla", ".", "javascript", ".", "regexp", ".", "NativeRegExp", ";", "import", "org", ".", "mozilla", ".", "javascript", ".", "tools", ".", "shell", ".", "Global", ";", "import", "java", ".", "io", ".", "FileReader", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Locale", ";", "public", "class", "JsLanguage", "extends", "AbstractProgrammingLanguage", "{", "private", "static", "final", "String", "JS_DSL", "=", "\"\"", ";", "private", "final", "List", "<", "String", ">", "jsFiles", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "private", "Context", "cx", ";", "private", "Scriptable", "scope", ";", "public", "JsLanguage", "(", "LanguageMixin", "languageMixin", ",", "ExceptionFactory", "exceptionFactory", ")", "throws", "Exception", "{", "super", "(", "languageMixin", ",", "exceptionFactory", ")", ";", "}", "public", "void", "load_code_file", "(", "String", "jsFile", ")", "throws", "Throwable", "{", "jsFiles", ".", "add", "(", "jsFile", ")", ";", "}", "protected", "void", "begin_scenario", "(", "Scenario", "scenario", ")", "throws", "Throwable", "{", "clearHooksAndStepDefinitions", "(", ")", ";", "cx", "=", "Context", ".", "enter", "(", ")", ";", "scope", "=", "new", "Global", "(", "cx", ")", ";", "scope", ".", "put", "(", "\"jsLanguage\"", ",", "scope", ",", "this", ")", ";", "cx", ".", "evaluateReader", "(", "scope", ",", "new", "InputStreamReader", "(", "getClass", "(", ")", ".", "getResourceAsStream", "(", "JS_DSL", ")", ")", ",", "JS_DSL", ",", "1", ",", "null", ")", ";", "for", "(", "String", "jsFile", ":", "jsFiles", ")", "{", "cx", ".", "evaluateReader", "(", "scope", ",", "new", "FileReader", "(", "jsFile", ")", ",", "jsFile", ",", "1", ",", "null", ")", ";", "}", "}", "public", "void", "addStepDefinition", "(", "Global", "jsStepDefinition", ",", "NativeFunction", "argumentsFrom", ",", "NativeRegExp", "regexp", ",", "NativeFunction", "closure", ")", "throws", "Throwable", "{", "addStepDefinition", "(", "new", "JsStepDefinition", "(", "this", ",", "cx", ",", "scope", ",", "jsStepDefinition", ",", "argumentsFrom", ",", "regexp", ",", "closure", ")", ")", ";", "}", "public", "void", "end_scenario", "(", ")", "throws", "Throwable", "{", "}", "@", "Override", "protected", "Object", "customTransform", "(", "Object", "arg", ",", "Class", "<", "?", ">", "parameterType", ",", "Locale", "locale", ")", "{", "return", "null", ";", "}", "}", "</s>" ]
7,595
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "js", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "AbstractStepDefinition", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "StepArgument", ";", "import", "org", ".", "mozilla", ".", "javascript", ".", "Context", ";", "import", "org", ".", "mozilla", ".", "javascript", ".", "NativeFunction", ";", "import", "org", ".", "mozilla", ".", "javascript", ".", "Scriptable", ";", "import", "org", ".", "mozilla", ".", "javascript", ".", "regexp", ".", "NativeRegExp", ";", "import", "org", ".", "mozilla", ".", "javascript", ".", "tools", ".", "shell", ".", "Global", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "JsStepDefinition", "extends", "AbstractStepDefinition", "{", "private", "final", "Context", "cx", ";", "private", "final", "Scriptable", "scope", ";", "private", "final", "Global", "jsStepDefinition", ";", "private", "final", "NativeFunction", "argumentsFrom", ";", "private", "final", "NativeRegExp", "regexp", ";", "private", "final", "NativeFunction", "closure", ";", "private", "List", "<", "StepArgument", ">", "arguments", ";", "public", "JsStepDefinition", "(", "JsLanguage", "programmingLanguage", ",", "Context", "cx", ",", "Scriptable", "scope", ",", "Global", "jsStepDefinition", ",", "NativeFunction", "argumentsFrom", ",", "NativeRegExp", "regexp", ",", "NativeFunction", "closure", ")", "throws", "Throwable", "{", "super", "(", "programmingLanguage", ")", ";", "this", ".", "cx", "=", "cx", ";", "this", ".", "scope", "=", "scope", ";", "this", ".", "jsStepDefinition", "=", "jsStepDefinition", ";", "this", ".", "argumentsFrom", "=", "argumentsFrom", ";", "this", ".", "regexp", "=", "regexp", ";", "this", ".", "closure", "=", "closure", ";", "register", "(", ")", ";", "}", "public", "String", "regexp_source", "(", ")", "{", "return", "regexp", ".", "toString", "(", ")", ";", "}", "public", "String", "file_colon_line", "(", ")", "{", "return", "regexp_source", "(", ")", ";", "}", "public", "Object", "invokeWithArgs", "(", "Object", "[", "]", "args", ")", "throws", "Throwable", "{", "return", "closure", ".", "call", "(", "cx", ",", "scope", ",", "scope", ",", "args", ")", ";", "}", "public", "List", "<", "StepArgument", ">", "arguments_from", "(", "String", "stepName", ")", "{", "arguments", "=", "null", ";", "argumentsFrom", ".", "call", "(", "cx", ",", "scope", ",", "jsStepDefinition", ",", "new", "Object", "[", "]", "{", "stepName", ",", "this", "}", ")", ";", "return", "arguments", ";", "}", "public", "void", "addArguments", "(", "List", "<", "StepArgument", ">", "arguments", ")", "{", "this", ".", "arguments", "=", "arguments", ";", "}", "}", "</s>" ]
7,596
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "clj", ";", "import", "clojure", ".", "lang", ".", "AFunction", ";", "import", "cuke4duke", ".", "internal", ".", "Utils", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "AbstractStepDefinition", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "JdkPatternArgumentMatcher", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "StepArgument", ";", "import", "java", ".", "io", ".", "UnsupportedEncodingException", ";", "import", "java", ".", "lang", ".", "reflect", ".", "InvocationTargetException", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "public", "class", "CljStepDefinition", "extends", "AbstractStepDefinition", "{", "private", "final", "Pattern", "regexp", ";", "private", "final", "AFunction", "closure", ";", "public", "CljStepDefinition", "(", "CljLanguage", "cljLanguage", ",", "Pattern", "regexp", ",", "AFunction", "closure", ")", "throws", "Throwable", "{", "super", "(", "cljLanguage", ")", ";", "this", ".", "regexp", "=", "regexp", ";", "this", ".", "closure", "=", "closure", ";", "register", "(", ")", ";", "}", "public", "String", "regexp_source", "(", ")", "{", "return", "regexp", ".", "pattern", "(", ")", ";", "}", "public", "String", "file_colon_line", "(", ")", "{", "return", "regexp_source", "(", ")", ";", "}", "@", "Override", "public", "Object", "invokeWithArgs", "(", "Object", "[", "]", "javaArgs", ")", "throws", "Throwable", "{", "Method", "functionInvoke", "=", "lookupInvokeMethod", "(", "javaArgs", ")", ";", "try", "{", "return", "functionInvoke", ".", "invoke", "(", "closure", ",", "javaArgs", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "throw", "e", ".", "getTargetException", "(", ")", ";", "}", "}", "public", "List", "<", "StepArgument", ">", "arguments_from", "(", "String", "stepName", ")", "throws", "UnsupportedEncodingException", "{", "return", "JdkPatternArgumentMatcher", ".", "argumentsFrom", "(", "regexp", ",", "stepName", ")", ";", "}", "private", "Method", "lookupInvokeMethod", "(", "Object", "[", "]", "args", ")", "throws", "NoSuchMethodException", "{", "return", "AFunction", ".", "class", ".", "getMethod", "(", "\"invoke\"", ",", "Utils", ".", "objectClassArray", "(", "args", ".", "length", ")", ")", ";", "}", "}", "</s>" ]
7,597
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "clj", ";", "import", "clojure", ".", "lang", ".", "AFunction", ";", "import", "cuke4duke", ".", "Scenario", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "AbstractHook", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "CljHook", "extends", "AbstractHook", "{", "private", "final", "AFunction", "closure", ";", "public", "CljHook", "(", "List", "<", "String", ">", "tagExpressions", ",", "AFunction", "closure", ")", "{", "super", "(", "tagExpressions", ")", ";", "this", ".", "closure", "=", "closure", ";", "}", "public", "void", "invoke", "(", "String", "location", ",", "Scenario", "scenario", ")", "throws", "Throwable", "{", "closure", ".", "call", "(", ")", ";", "}", "}", "</s>" ]
7,598
[ "<s>", "package", "cuke4duke", ".", "internal", ".", "clj", ";", "import", "clojure", ".", "lang", ".", "AFunction", ";", "import", "clojure", ".", "lang", ".", "Compiler", ";", "import", "clojure", ".", "lang", ".", "RT", ";", "import", "cuke4duke", ".", "Scenario", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "AbstractProgrammingLanguage", ";", "import", "cuke4duke", ".", "internal", ".", "language", ".", "LanguageMixin", ";", "import", "cuke4duke", ".", "spi", ".", "ExceptionFactory", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "public", "class", "CljLanguage", "extends", "AbstractProgrammingLanguage", "{", "private", "static", "CljLanguage", "instance", ";", "public", "CljLanguage", "(", "LanguageMixin", "languageMixin", ",", "ExceptionFactory", "exceptionFactory", ")", "throws", "Exception", "{", "super", "(", "languageMixin", ",", "exceptionFactory", ")", ";", "instance", "=", "this", ";", "clearHooksAndStepDefinitions", "(", ")", ";", "RT", ".", "load", "(", "\"\"", ")", ";", "}", "public", "static", "void", "addCljStepDefinition", "(", "Pattern", "regexp", ",", "AFunction", "closure", ")", "throws", "Throwable", "{", "instance", ".", "addStepDefinition", "(", "new", "CljStepDefinition", "(", "instance", ",", "regexp", ",", "closure", ")", ")", ";", "}", "public", "static", "void", "addCljBeforeHook", "(", "AFunction", "closure", ")", "{", "instance", ".", "addBeforeHook", "(", "new", "CljHook", "(", "Collections", ".", "<", "String", ">", "emptyList", "(", ")", ",", "closure", ")", ")", ";", "}", "public", "static", "void", "addCljAfterHook", "(", "AFunction", "closure", ")", "{", "instance", ".", "addAfterHook", "(", "new", "CljHook", "(", "Collections", ".", "<", "String", ">", "emptyList", "(", ")", ",", "closure", ")", ")", ";", "}", "public", "void", "load_code_file", "(", "String", "cljFile", ")", "throws", "Throwable", "{", "Compiler", ".", "loadFile", "(", "cljFile", ")", ";", "}", "protected", "void", "begin_scenario", "(", "Scenario", "scenario", ")", "throws", "Throwable", "{", "}", "public", "void", "end_scenario", "(", ")", "throws", "Throwable", "{", "}", "@", "Override", "protected", "Object", "customTransform", "(", "Object", "arg", ",", "Class", "<", "?", ">", "parameterType", ",", "Locale", "locale", ")", "{", "return", "null", ";", "}", "}", "</s>" ]
7,599
[ "<s>", "package", "cuke4duke", ".", "internal", ";", "import", "java", ".", "util", ".", "Locale", ";", "public", "class", "Utils", "{", "public", "static", "String", "join", "(", "Object", "[", "]", "objects", ",", "String", "separator", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "int", "i", "=", "0", ";", "for", "(", "Object", "o", ":", "objects", ")", "{", "if", "(", "i", "!=", "0", ")", "sb", ".", "append", "(", "separator", ")", ";", "sb", ".", "append", "(", "o", ")", ";", "i", "++", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "static", "Class", "<", "?", ">", "[", "]", "objectClassArray", "(", "int", "n", ")", "{", "Class", "<", "?", ">", "[", "]", "arr", "=", "new", "Class", "<", "?", ">", "[", "n", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "arr", "[", "i", "]", "=", "Object", ".", "class", ";", "}", "return", "arr", ";", "}", "public", "static", "Locale", "localeFor", "(", "String", "isoString", ")", "{", "String", "[", "]", "languageAndCountry", "=", "isoString", ".", "split", "(", "\"-\"", ")", ";", "if", "(", "languageAndCountry", ".", "length", "==", "1", ")", "{", "return", "new", "Locale", "(", "isoString", ")", ";", "}", "else", "{", "return", "new", "Locale", "(", "languageAndCountry", "[", "0", "]", ",", "languageAndCountry", "[", "1", "]", ")", ";", "}", "}", "}", "</s>" ]