text:
package org.apache.yoko.orb.OB;

import org.omg.CORBA.OMGVMCID;
import org.apache.yoko.ApacheVMCID;

public final class MinorCodes {
    public final static int OMGVMCID = org.omg.CORBA.OMGVMCID.value;

    public final static int OOCVMCID = org.apache.yoko.ApacheVMCID.value;

    // ----------------------------------------------------------------------
    // Minor error codes for INITIALIZE
    // ----------------------------------------------------------------------

    public final static int MinorORBDestroyed = 1 | OOCVMCID;

    public static String describeInitialize(int minor) {
        String result = null;

        switch (minor) {
        case MinorORBDestroyed:
            result = "ORB already destroyed";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for NO_IMPLEMENT
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    public final static int MinorMissingLocalValueImplementation = 1 | OMGVMCID;

    public final static int MinorIncompatibleValueImplementationVersion = 2 | OMGVMCID;

    public final static int MinorNotSupportedByLocalObject = 3 | OMGVMCID;

    public final static int MinorDIINotSupportedByLocalObject = 4 | OMGVMCID;

    public static String describeNoImplement(int minor) {
        String result = null;

        switch (minor) {
        case MinorMissingLocalValueImplementation:
            result = "missing local value implementation";
            break;

        case MinorIncompatibleValueImplementationVersion:
            result = "incompatible value implementation version";
            break;

        case MinorNotSupportedByLocalObject:
            result = "operation not supported by local object";
            break;

        case MinorDIINotSupportedByLocalObject:
            result = "DII operation not supported by local object";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for OBJECT_NOT_EXIST
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    public final static int MinorUnregisteredValue = 1 | OMGVMCID;

    public final static int MinorCannotDispatch = 2 | OMGVMCID;

    public static String describeObjectNotExist(int minor) {
        String result = null;

        switch (minor) {
        case MinorUnregisteredValue:
            result = "attempt to pass an unregistered value as an object "
                    + "reference";
            break;

        case MinorCannotDispatch:
            result = "unable to dispatch - servant or POA not found";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for BAD_PARAM
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    public final static int MinorValueFactoryError = 1 | OMGVMCID;

    public final static int MinorRepositoryIdExists = 2 | OMGVMCID;

    public final static int MinorNameExists = 3 | OMGVMCID;

    public final static int MinorInvalidContainer = 4 | OMGVMCID;

    public final static int MinorNameClashInInheritedContext = 5 | OMGVMCID;

    public final static int MinorBadAbstractInterfaceType = 6 | OMGVMCID;

    public final static int MinorBadSchemeName = 7 | OMGVMCID;

    public final static int MinorBadAddress = 8 | OMGVMCID;

    public final static int MinorBadSchemeSpecificPart = 9 | OMGVMCID;

    public final static int MinorOther = 10 | OMGVMCID;

    public final static int MinorInvalidAbstractInterfaceInheritance = 11 | OMGVMCID;

    public final static int MinorInvalidValueInheritance = 12 | OMGVMCID;

    public final static int MinorIncompleteTypeCodeParameter = 13 | OMGVMCID;

    public final static int MinorInvalidObjectId = 14 | OMGVMCID;

    public final static int MinorInvalidName = 15 | OMGVMCID;

    public final static int MinorInvalidId = 16 | OMGVMCID;

    public final static int MinorInvalidMemberName = 17 | OMGVMCID;

    public final static int MinorDuplicateLabel = 18 | OMGVMCID;

    public final static int MinorIncompatibleLabelType = 19 | OMGVMCID;

    public final static int MinorInvalidDiscriminatorType = 20 | OMGVMCID;

    public final static int MinorNoExceptionInAny = 21 | OMGVMCID;

    public final static int MinorUnlistedUserException = 22 | OMGVMCID;

    public final static int MinorNoWcharCodeSet = 23 | OMGVMCID;

    public final static int MinorServiceContextIdOutOfRange = 24 | OMGVMCID;

    public final static int MinorEnumValueOutOfRange = 25 | OMGVMCID;

    public final static int MinorInvalidServiceContextId = 26 | OMGVMCID;

    public final static int MinorObjectIsNull = 27 | OMGVMCID;

    public final static int MinorInvalidComponentId = 28 | OMGVMCID;

    public final static int MinorInvalidProfileId = 29 | OMGVMCID;

    public final static int MinorDuplicatePolicyType = 30 | OMGVMCID;

    //
    // Yoko specific minor codes
    //
    public final static int MinorDuplicateDeclarator = 1 | OOCVMCID;

    public final static int MinorInvalidValueModifier = 2 | OOCVMCID;

    public final static int MinorDuplicateValueInit = 3 | OOCVMCID;

    public final static int MinorAbstractValueInit = 4 | OOCVMCID;

    public final static int MinorDuplicateBaseType = 5 | OOCVMCID;

    public final static int MinorSingleThreadedOnly = 6 | OOCVMCID;

    public final static int MinorNameRedefinitionInImmediateScope = 7 | OOCVMCID;

    public final static int MinorInvalidValueBoxType = 8 | OOCVMCID;

    public final static int MinorInvalidLocalInterfaceInheritance = 9 | OOCVMCID;

    public final static int MinorConstantTypeMismatch = 10 | OOCVMCID;

    public final static int MinorInvalidPattern = 11 | OOCVMCID;

    public final static int MinorInvalidScope = 12 | OOCVMCID;

    public final static int MinorInvalidContextID = 13 | OOCVMCID;

    public final static int MinorIncompatibleObjectType = 14 | OOCVMCID;

    public static String describeBadParam(int minor) {
        String result = null;

        switch (minor) {
        case MinorValueFactoryError:
            result = "failure to register, unregister or lookup value factory";
            break;

        case MinorRepositoryIdExists:
            result = "repository id already exists";
            break;

        case MinorNameExists:
            result = "name already exists";
            break;

        case MinorInvalidContainer:
            result = "target is not a valid container";
            break;

        case MinorNameClashInInheritedContext:
            result = "name clash in inherited context";
            break;

        case MinorBadAbstractInterfaceType:
            result = "incorrect type for abstract interface";
            break;

        case MinorBadSchemeName:
            result = "bad scheme name";
            break;

        case MinorBadAddress:
            result = "bad address";
            break;

        case MinorBadSchemeSpecificPart:
            result = "bad scheme specific part";
            break;

        case MinorOther:
            result = "other";
            break;

        case MinorInvalidAbstractInterfaceInheritance:
            result = "invalid abstract interface inheritance";
            break;

        case MinorInvalidValueInheritance:
            result = "invalid valuetype inheritance";
            break;

        case MinorIncompleteTypeCodeParameter:
            result = "incomplete TypeCode parameter";
            break;

        case MinorInvalidObjectId:
            result = "invalid object id";
            break;

        case MinorInvalidName:
            result = "invalid name in TypeCode operation";
            break;

        case MinorInvalidId:
            result = "invalid repository id in TypeCode operation";
            break;

        case MinorInvalidMemberName:
            result = "invalid member name in TypeCode operation";
            break;

        case MinorDuplicateLabel:
            result = "duplicate union label value";
            break;

        case MinorIncompatibleLabelType:
            result = "incompatible union label value";
            break;

        case MinorInvalidDiscriminatorType:
            result = "invalid union discriminator type";
            break;

        case MinorNoExceptionInAny:
            result = "exception does not contain an any";
            break;

        case MinorUnlistedUserException:
            result = "unlisted user exception";
            break;

        case MinorNoWcharCodeSet:
            result = "wchar transmission code set not in service context";
            break;

        case MinorServiceContextIdOutOfRange:
            result = "service context is not in OMG-defined range";
            break;

        case MinorEnumValueOutOfRange:
            result = "enum value out of range";
            break;

        case MinorInvalidServiceContextId:
            result = "invalid service context ID";
            break;

        case MinorObjectIsNull:
            result = "Object parameter to register_initial_reference is null";
            break;

        case MinorInvalidComponentId:
            result = "invalid component ID";
            break;

        case MinorInvalidProfileId:
            result = "invalid profile ID";
            break;

        case MinorDuplicatePolicyType:
            result = "duplicate policy types";
            break;

        case MinorDuplicateDeclarator:
            result = "duplicate declarator";
            break;

        case MinorInvalidValueModifier:
            result = "invalid valuetype modifier";
            break;

        case MinorDuplicateValueInit:
            result = "duplicate valuetype initializer";
            break;

        case MinorAbstractValueInit:
            result = "abstract valuetype cannot have initializers";
            break;

        case MinorDuplicateBaseType:
            result = "base type appears more than once";
            break;

        case MinorSingleThreadedOnly:
            result = "ORB doesn't support multiple threads";
            break;

        case MinorNameRedefinitionInImmediateScope:
            result = "invalid name redefinition in an immediate scope";
            break;

        case MinorInvalidValueBoxType:
            result = "invalid type for valuebox";
            break;

        case MinorInvalidLocalInterfaceInheritance:
            result = "invalid local interface inheritance";
            break;

        case MinorConstantTypeMismatch:
            result = "constant type doesn't match definition";
            break;

        case MinorInvalidPattern:
            result = "invalid pattern";
            break;

        case MinorInvalidScope:
            result = "invalid scope";
            break;

        case MinorInvalidContextID:
            result = "invalid context ID";
            break;

        case MinorIncompatibleObjectType:
            result = "incompatible object type";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for BAD_INV_ORDER
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    public final static int MinorDependencyPreventsDestruction = 1 | OMGVMCID;

    public final static int MinorIndestructibleObject = 2 | OMGVMCID;

    public final static int MinorDestroyWouldBlock = 3 | OMGVMCID;

    public final static int MinorShutdownCalled = 4 | OMGVMCID;

    public final static int MinorDuplicateSend = 5 | OMGVMCID;

    public final static int MinorServantManagerAlreadySet = 6 | OMGVMCID;

    public final static int MinorInvalidUseOfDSIArguments = 7 | OMGVMCID;

    public final static int MinorInvalidUseOfDSIContext = 8 | OMGVMCID;

    public final static int MinorInvalidUseOfDSIResult = 9 | OMGVMCID;

    public final static int MinorRequestAlreadySent = 10 | OMGVMCID;

    public final static int MinorRequestNotSent = 11 | OMGVMCID;

    public final static int MinorResponseAlreadyReceived = 12 | OMGVMCID;

    public final static int MinorSynchronousRequest = 13 | OMGVMCID;

    public final static int MinorInvalidPICall = 14 | OMGVMCID;

    public final static int MinorServiceContextExists = 15 | OMGVMCID;

    public final static int MinorPolicyFactoryExists = 16 | OMGVMCID;

    public final static int MinorNoCreatePOA = 17 | OMGVMCID;

    //
    // Yoko specific minor codes
    //
    public final static int MinorBadConcModel = 1 | OOCVMCID;

    public final static int MinorORBRunning = 2 | OOCVMCID;

    public static String describeBadInvOrder(int minor) {
        String result = null;

        switch (minor) {
        case MinorDependencyPreventsDestruction:
            result = "dependency prevents destruction of object";
            break;

        case MinorIndestructibleObject:
            result = "destroy invoked on indestructible object";
            break;

        case MinorDestroyWouldBlock:
            result = "operation would deadlock";
            break;

        case MinorShutdownCalled:
            result = "ORB has shutdown";
            break;

        case MinorDuplicateSend:
            result = "request has already been sent";
            break;

        case MinorServantManagerAlreadySet:
            result = "servant manager already set";
            break;

        case MinorInvalidUseOfDSIArguments:
            result = "invalid use of DSI arguments";
            break;

        case MinorInvalidUseOfDSIContext:
            result = "invalid use of DSI context";
            break;

        case MinorInvalidUseOfDSIResult:
            result = "invalid use of DSI result";
            break;

        case MinorRequestAlreadySent:
            result = "DII request has already been sent";
            break;

        case MinorRequestNotSent:
            result = "DII request has not been sent yet";
            break;

        case MinorResponseAlreadyReceived:
            result = "DII response has already been received";
            break;

        case MinorSynchronousRequest:
            result = "operation not supported on synchronous DII request";
            break;

        case MinorInvalidPICall:
            result = "invalid Portable Interceptor call";
            break;

        case MinorServiceContextExists:
            result = "a service context already exists with the given ID";
            break;

        case MinorPolicyFactoryExists:
            result = "a factory already exists for that PolicyType";
            break;

        case MinorNoCreatePOA:
            result = "cannot create POA while undergoing destruction";
            break;

        case MinorBadConcModel:
            result = "invalid concurrency model";
            break;

        case MinorORBRunning:
            result = "ORB::run already called";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for COMM_FAILURE
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    /* None yet */

    //
    // Yoko specific minor codes
    //
    public final static int MinorRecv = 1 | OOCVMCID;

    public final static int MinorSend = 2 | OOCVMCID;

    public final static int MinorRecvZero = 3 | OOCVMCID;

    public final static int MinorSendZero = 4 | OOCVMCID;

    public final static int MinorSocket = 5 | OOCVMCID;

    public final static int MinorSetsockopt = 6 | OOCVMCID;

    public final static int MinorGetsockopt = 7 | OOCVMCID;

    public final static int MinorBind = 8 | OOCVMCID;

    public final static int MinorListen = 9 | OOCVMCID;

    public final static int MinorConnect = 10 | OOCVMCID;

    public final static int MinorAccept = 11 | OOCVMCID;

    public final static int MinorSelect = 12 | OOCVMCID;

    public final static int MinorSetSoTimeout = 26 | OOCVMCID;

    public final static int MinorGetsockname = 27 | OOCVMCID;

    public final static int MinorGetpeername = 28 | OOCVMCID;

    public final static int MinorGethostname = 13 | OOCVMCID;

    public final static int MinorGethostbyname = 14 | OOCVMCID;

    public final static int MinorWSAStartup = 15 | OOCVMCID;

    public final static int MinorWSACleanup = 16 | OOCVMCID;

    public final static int MinorNoGIOP = 17 | OOCVMCID;

    public final static int MinorUnknownMessage = 18 | OOCVMCID;

    public final static int MinorWrongMessage = 19 | OOCVMCID;

    public final static int MinorMessageError = 21 | OOCVMCID;

    public final static int MinorFragment = 22 | OOCVMCID;

    public final static int MinorUnknownReqId = 24 | OOCVMCID;

    public final static int MinorVersion = 25 | OOCVMCID;

    public final static int MinorPipe = 23 | OOCVMCID;

    public final static int MinorUnknownReplyMessage = 29 | OOCVMCID;

    //
    // Yoko deprecated minor codes
    //
    public final static int MinorDeprecatedCloseConnection = 20 | OOCVMCID;

    public static String describeCommFailure(int minor) {
        String result = null;

        switch (minor) {
        case MinorRecv:
            result = "recv() failed";
            break;

        case MinorSend:
            result = "send() failed";
            break;

        case MinorRecvZero:
            result = "recv() returned zero";
            break;

        case MinorSendZero:
            result = "send() returned zero";
            break;

        case MinorSocket:
            result = "socket() failed";
            break;

        case MinorSetsockopt:
            result = "setsockopt() failed";
            break;

        case MinorGetsockopt:
            result = "getsockopt() failed";
            break;

        case MinorBind:
            result = "bind() failed";
            break;

        case MinorListen:
            result = "listen() failed";
            break;

        case MinorConnect:
            result = "connect() failed";
            break;

        case MinorAccept:
            result = "accept() failed";
            break;

        case MinorSelect:
            result = "select() failed";
            break;

        case MinorSetSoTimeout:
            result = "setSoTimeout() failed";
            break;

        case MinorGethostname:
            result = "gethostname() failed";
            break;

        case MinorGethostbyname:
            result = "gethostbyname() failed";
            break;

        case MinorWSAStartup:
            result = "WSAStartup() failed";
            break;

        case MinorWSACleanup:
            result = "WSACleanup() failed";
            break;

        case MinorNoGIOP:
            result = "not a GIOP message";
            break;

        case MinorUnknownMessage:
            result = "unknown GIOP message";
            break;

        case MinorWrongMessage:
            result = "wrong GIOP message";
            break;

        case MinorMessageError:
            result = "got a `MessageError' message";
            break;

        case MinorFragment:
            result = "invalid fragment message";
            break;

        case MinorUnknownReqId:
            result = "unknown request id";
            break;

        case MinorVersion:
            result = "unsupported GIOP version";
            break;

        case MinorPipe:
            result = "pipe() failed";
            break;

        case MinorUnknownReplyMessage:
            result = "unknown GIOP message in reply";
            break;

        case MinorDeprecatedCloseConnection:
            result = "got a `CloseConnection' message";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for INTF_REPOS
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    /* None yet */

    //
    // Yoko specific minor codes
    //
    public final static int MinorNoIntfRepos = 1 | OOCVMCID;

    public final static int MinorLookupAmbiguous = 2 | OOCVMCID;

    public final static int MinorIllegalRecursion = 3 | OOCVMCID;

    public final static int MinorNoEntry = 4 | OOCVMCID;

    public static String describeIntfRepos(int minor) {
        String result = null;

        switch (minor) {
        case MinorNoIntfRepos:
            result = "interface repository is not available";
            break;

        case MinorLookupAmbiguous:
            result = "search name for lookup() is ambiguous";
            break;

        case MinorIllegalRecursion:
            result = "illegal recursion";
            break;

        case MinorNoEntry:
            result = "repository ID not found";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for MARSHAL
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    public final static int MinorNoValueFactory = 1 | OMGVMCID;

    public final static int MinorDSIResultBeforeContext = 2 | OMGVMCID;

    public final static int MinorDSIInvalidParameterList = 3 | OMGVMCID;

    public final static int MinorLocalObject = 4 | OMGVMCID;

    public final static int MinorWcharSentByClient = 5 | OMGVMCID;

    public final static int MinorWcharSentByServer = 6 | OMGVMCID;

    //
    // Yoko specific minor codes
    //
    public final static int MinorReadOverflow = 1 | OOCVMCID;

    public final static int MinorReadBooleanOverflow = 2 | OOCVMCID;

    public final static int MinorReadCharOverflow = 3 | OOCVMCID;

    public final static int MinorReadWCharOverflow = 4 | OOCVMCID;

    public final static int MinorReadOctetOverflow = 5 | OOCVMCID;

    public final static int MinorReadShortOverflow = 6 | OOCVMCID;

    public final static int MinorReadUShortOverflow = 7 | OOCVMCID;

    public final static int MinorReadLongOverflow = 8 | OOCVMCID;

    public final static int MinorReadULongOverflow = 9 | OOCVMCID;

    public final static int MinorReadLongLongOverflow = 10 | OOCVMCID;

    public final static int MinorReadULongLongOverflow = 11 | OOCVMCID;

    public final static int MinorReadFloatOverflow = 12 | OOCVMCID;

    public final static int MinorReadDoubleOverflow = 13 | OOCVMCID;

    public final static int MinorReadLongDoubleOverflow = 14 | OOCVMCID;

    public final static int MinorReadStringOverflow = 15 | OOCVMCID;

    public final static int MinorReadStringZeroLength = 16 | OOCVMCID;

    public final static int MinorReadStringNullChar = 17 | OOCVMCID;

    public final static int MinorReadStringNoTerminator = 18 | OOCVMCID;

    public final static int MinorReadWStringOverflow = 19 | OOCVMCID;

    public final static int MinorReadWStringZeroLength = 20 | OOCVMCID;

    public final static int MinorReadWStringNullWChar = 21 | OOCVMCID;

    public final static int MinorReadWStringNoTerminator = 22 | OOCVMCID;

    public final static int MinorReadFixedOverflow = 23 | OOCVMCID;

    public final static int MinorReadFixedInvalid = 24 | OOCVMCID;

    public final static int MinorReadBooleanArrayOverflow = 25 | OOCVMCID;

    public final static int MinorReadCharArrayOverflow = 26 | OOCVMCID;

    public final static int MinorReadWCharArrayOverflow = 27 | OOCVMCID;

    public final static int MinorReadOctetArrayOverflow = 28 | OOCVMCID;

    public final static int MinorReadShortArrayOverflow = 29 | OOCVMCID;

    public final static int MinorReadUShortArrayOverflow = 30 | OOCVMCID;

    public final static int MinorReadLongArrayOverflow = 31 | OOCVMCID;

    public final static int MinorReadULongArrayOverflow = 32 | OOCVMCID;

    public final static int MinorReadLongLongArrayOverflow = 33 | OOCVMCID;

    public final static int MinorReadULongLongArrayOverflow = 34 | OOCVMCID;

    public final static int MinorReadFloatArrayOverflow = 35 | OOCVMCID;

    public final static int MinorReadDoubleArrayOverflow = 36 | OOCVMCID;

    public final static int MinorReadLongDoubleArrayOverflow = 37 | OOCVMCID;

    public final static int MinorReadInvTypeCodeIndirection = 38 | OOCVMCID;

    public final static int MinorLongDoubleNotSupported = 40 | OOCVMCID;

    public final static int MinorNativeNotSupported = 41 | OOCVMCID;

    public final static int MinorReadInvalidIndirection = 42 | OOCVMCID;

    public final static int MinorReadIDMismatch = 43 | OOCVMCID;

    public final static int MinorReadUnsupported = 44 | OOCVMCID;

    public final static int MinorWriteUnsupported = 45 | OOCVMCID;

    public final static int MinorLoadStub = 46 | OOCVMCID;

    //
    // Yoko deprecated minor codes
    //
    public final static int MinorDeprecatedWriteObjectLocal = 39 | OOCVMCID;

    public static String describeMarshal(int minor) {
        String result = null;

        switch (minor) {
        case MinorNoValueFactory:
            result = "no valuetype factory";
            break;

        case MinorDSIResultBeforeContext:
            result = "DSI result cannot be set before context";
            break;

        case MinorDSIInvalidParameterList:
            result = "DSI argument list does not describe all parameters";
            break;

        case MinorLocalObject:
            result = "attempt to marshal local object";
            break;

        case MinorWcharSentByClient:
            result = "wchar data sent by client on GIOP 1.0 connection";
            break;

        case MinorWcharSentByServer:
            result = "wchar data returned by server on GIOP 1.0 connection";
            break;

        case MinorReadOverflow:
            result = "input stream buffer overflow";
            break;

        case MinorReadBooleanOverflow:
            result = "overflow while reading boolean";
            break;

        case MinorReadCharOverflow:
            result = "overflow while reading char";
            break;

        case MinorReadWCharOverflow:
            result = "overflow while reading wchar";
            break;

        case MinorReadOctetOverflow:
            result = "overflow while reading octet";
            break;

        case MinorReadShortOverflow:
            result = "overflow while reading short";
            break;

        case MinorReadUShortOverflow:
            result = "overflow while reading ushort";
            break;

        case MinorReadLongOverflow:
            result = "overflow while reading long";
            break;

        case MinorReadULongOverflow:
            result = "overflow while reading ulong";
            break;

        case MinorReadLongLongOverflow:
            result = "overflow while reading longlong";
            break;

        case MinorReadULongLongOverflow:
            result = "overflow while reading ulonglong";
            break;

        case MinorReadFloatOverflow:
            result = "overflow while reading float";
            break;

        case MinorReadDoubleOverflow:
            result = "overflow while reading double";
            break;

        case MinorReadLongDoubleOverflow:
            result = "overflow while reading longdouble";
            break;

        case MinorReadStringOverflow:
            result = "overflow while reading string";
            break;

        case MinorReadStringZeroLength:
            result = "encountered zero-length string";
            break;

        case MinorReadStringNullChar:
            result = "encountered null char in string";
            break;

        case MinorReadStringNoTerminator:
            result = "terminating null char missing in string";
            break;

        case MinorReadWStringOverflow:
            result = "overflow while reading wstring";
            break;

        case MinorReadWStringZeroLength:
            result = "encountered zero-length wstring";
            break;

        case MinorReadWStringNullWChar:
            result = "encountered null wchar in wstring";
            break;

        case MinorReadWStringNoTerminator:
            result = "terminating null wchar missing in wstring";
            break;

        case MinorReadFixedOverflow:
            result = "overflow while reading fixed";
            break;

        case MinorReadFixedInvalid:
            result = "invalid encoding for fixed value";
            break;

        case MinorReadBooleanArrayOverflow:
            result = "overflow while reading boolean array";
            break;

        case MinorReadCharArrayOverflow:
            result = "overflow while reading char array";
            break;

        case MinorReadWCharArrayOverflow:
            result = "overflow while reading wchar array";
            break;

        case MinorReadOctetArrayOverflow:
            result = "overflow while reading octet array";
            break;

        case MinorReadShortArrayOverflow:
            result = "overflow while reading short array";
            break;

        case MinorReadUShortArrayOverflow:
            result = "overflow while reading ushort array";
            break;

        case MinorReadLongArrayOverflow:
            result = "overflow while reading long array";
            break;

        case MinorReadULongArrayOverflow:
            result = "overflow while reading ulong array";
            break;

        case MinorReadLongLongArrayOverflow:
            result = "overflow while reading longlong array";
            break;

        case MinorReadULongLongArrayOverflow:
            result = "overflow while reading ulonglong array";
            break;

        case MinorReadFloatArrayOverflow:
            result = "overflow while reading float array";
            break;

        case MinorReadDoubleArrayOverflow:
            result = "overflow while reading double array";
            break;

        case MinorReadLongDoubleArrayOverflow:
            result = "overflow while reading longdouble array";
            break;

        case MinorReadInvTypeCodeIndirection:
            result = "invalid TypeCode indirection";
            break;

        case MinorLongDoubleNotSupported:
            result = "long double is not supported";
            break;

        case MinorNativeNotSupported:
            result = "long double is not supported";
            break;

        case MinorDeprecatedWriteObjectLocal:
            result = "attempt to marshal a locality-constrained object";
            break;

        case MinorReadInvalidIndirection:
            result = "invalid indirection location";
            break;

        case MinorReadIDMismatch:
            result = "type ID mismatch";
            break;

        case MinorReadUnsupported:
            result = "reading unsupported type";
            break;

        case MinorWriteUnsupported:
            result = "writing unsupported type";
            break;

        case MinorLoadStub:
            result = "error loading stub class";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for IMP_LIMIT
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    public final static int MinorNoUsableProfile = 1 | OMGVMCID;

    //
    // Yoko specific minor codes
    //
    public final static int MinorMessageSizeLimit = 1 | OOCVMCID;

    public final static int MinorThreadLimit = 2 | OOCVMCID;

    public static String describeImpLimit(int minor) {
        String result = null;

        switch (minor) {
        case MinorNoUsableProfile:
            result = "no usable profile in IOR";
            break;

        case MinorMessageSizeLimit:
            result = "maximum message size exceeded";
            break;

        case MinorThreadLimit:
            result = "can't create new thread";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for NO_MEMORY
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    /* None yet */

    //
    // Yoko specific minor codes
    //
    public final static int MinorAllocationFailure = 1 | OOCVMCID;

    public static String describeNoMemory(int minor) {
        String result = null;

        switch (minor) {
        case MinorAllocationFailure:
            result = "memory allocation failure";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for TRANSIENT
    // ----------------------------------------------------------------------

    //
    // PortableInterceptor minor codes
    //
    public final static int MinorRequestDiscarded = 1 | OMGVMCID;

    public final static int MinorNoUsableProfileInIOR = 2 | OMGVMCID;

    public final static int MinorRequestCancelled = 3 | OMGVMCID;

    public final static int MinorPOADestroyed = 4 | OMGVMCID;

    //
    // Yoko specific minor codes
    //
    public final static int MinorConnectFailed = 1 | OOCVMCID;

    public final static int MinorCloseConnection = 2 | OOCVMCID;

    public final static int MinorActiveConnectionManagement = 3 | OOCVMCID;

    public final static int MinorForcedShutdown = 4 | OOCVMCID;

    public final static int MinorLocationForwardHopCountExceeded = 5 | OOCVMCID;

    public static String describeTransient(int minor) {
        String result = null;

        switch (minor) {
        case MinorRequestDiscarded:
            result = "request has been discarded";
            break;

        case MinorNoUsableProfileInIOR:
            result = "no usable profile in IOR";
            break;

        case MinorRequestCancelled:
            result = "request has been cancelled";
            break;

        case MinorPOADestroyed:
            result = "POA has been destroyed";
            break;

        case MinorConnectFailed:
            result = "attempt to establish connection failed";
            break;

        case MinorCloseConnection:
            result = "got a `CloseConnection' message";
            break;

        case MinorActiveConnectionManagement:
            result = "active connection management closed connection";
            break;

        case MinorForcedShutdown:
            result = "forced connection shutdown because of timeout";
            break;

        case MinorLocationForwardHopCountExceeded:
            result = "maximum forwarding count (10) exceeded";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for NO_RESOURCES
    // ----------------------------------------------------------------------

    //
    // PortableInterceptor minor codes
    //
    public final static int MinorInvalidBinding = 1 | OMGVMCID;

    public static String describeNoResources(int minor) {
        String result = null;

        switch (minor) {
        case MinorInvalidBinding:
            result = "Portable Interceptor operation not supported in "
                    + "binding";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for UNKNOWN
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    public final static int MinorUnknownUserException = 1 | OMGVMCID;

    public final static int MinorSystemExceptionNotSupported = 2 | OMGVMCID;

    public static String describeUnknown(int minor) {
        String result = null;

        switch (minor) {
        case MinorUnknownUserException:
            result = "an unknown user exception was raised";
            break;

        case MinorSystemExceptionNotSupported:
            result = "an unsupported system exception was raised";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for INV_POLICY
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    public final static int MinorCannotReconcilePolicy = 1 | OMGVMCID;

    public final static int MinorInvalidPolicyType = 2 | OMGVMCID;

    public final static int MinorNoPolicyFactory = 3 | OMGVMCID;

    //
    // Yoko specific minor codes
    //
    public final static int MinorNoPolicy = 1 | OOCVMCID;

    public static String describeInvPolicy(int minor) {
        String result = null;

        switch (minor) {
        case MinorCannotReconcilePolicy:
            result = "cannot reconcile IOR policy with effective policy "
                    + "override";
            break;

        case MinorInvalidPolicyType:
            result = "invalid PolicyType";
            break;

        case MinorNoPolicyFactory:
            result = "no PolicyFactory for the PolicyType has been registered";
            break;

        case MinorNoPolicy:
            result = "no policy for the PolicyType is available";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for INV_OBJREF
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    public final static int MinorNoWcharSupport = 1 | OMGVMCID;

    public final static int MinorWcharCodeSetRequired = 2 | OMGVMCID;

    public static String describeInvObjref(int minor) {
        String result = null;

        switch (minor) {
        case MinorNoWcharSupport:
            result = "wchar code set support not specified";
            break;

        case MinorWcharCodeSetRequired:
            result = "code set component required for wchar/wstring";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for BAD_TYPECODE
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    public final static int MinorIncompleteTypeCode = 1 | OMGVMCID;

    public final static int MinorInvalidMemberType = 2 | OMGVMCID;

    //
    // Yoko specific minor codes
    //
    public final static int MinorInvalidUnionDiscriminator = 1 | OOCVMCID;

    public final static int MinorInvalidPropertyType = 2 | OOCVMCID;

    public static String describeBadTypecode(int minor) {
        String result = null;

        switch (minor) {
        case MinorIncompleteTypeCode:
            result = "attempt to marshal incomplete TypeCode";
            break;

        case MinorInvalidMemberType:
            result = "invalid member type in TypeCode operation";
            break;

        case MinorInvalidUnionDiscriminator:
            result = "invalid union discriminator type";
            break;

        case MinorInvalidPropertyType:
            result = "property value does not contain a string";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for OBJ_ADAPTER
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    public final static int MinorSystemExceptionInUnknownAdapter = 1 | OMGVMCID;

    public final static int MinorServantNotFound = 2 | OMGVMCID;

    public final static int MinorNoDefaultServant = 3 | OMGVMCID;

    public final static int MinorNoServantManager = 4 | OMGVMCID;

    public final static int MinorIncarnateViolatedPOAPolicy = 5 | OMGVMCID;

    public static String describeObjAdapter(int minor) {
        String result = null;

        switch (minor) {
        case MinorSystemExceptionInUnknownAdapter:
            result = "unknown_adapter raised a system exception";
            break;

        case MinorServantNotFound:
            result = "servant not found";
            break;

        case MinorNoDefaultServant:
            result = "no default servant available";
            break;

        case MinorNoServantManager:
            result = "no servant manager available";
            break;

        case MinorIncarnateViolatedPOAPolicy:
            result = "incarnate violated a POA policy";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for DATA_CONVERSION
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //
    public final static int MinorNoCharacterMapping = 1 | OMGVMCID;

    //
    // Yoko specific minor codes
    //

    public final static int MinorNoAlias = 1 | OOCVMCID;

    public final static int MinorUTF8Overflow = 2 | OOCVMCID;

    public final static int MinorUTF8Encoding = 3 | OOCVMCID;

    public static String describeDataConversion(int minor) {
        String result = null;

        switch (minor) {
        case MinorNoCharacterMapping:
            result = "character does not map to negotiated transmission "
                    + "code set";
            break;
        case MinorNoAlias:
            result = "alias types not supported";
            break;
        case MinorUTF8Overflow:
            result = "UTF8 overflow";
            break;
        case MinorUTF8Encoding:
            result = "invalid UTF8 character1";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for BAD_OPERATION
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //

    //
    // Yoko specific minor codes
    //
    public final static int MinorTypeMismatch = 1 | OOCVMCID;

    public final static int MinorNullValueNotAllowed = 2 | OOCVMCID;

    public static String describeBadOperation(int minor) {
        String result = null;

        switch (minor) {
        case MinorTypeMismatch:
            result = "Type mismatch";
            break;

        case MinorNullValueNotAllowed:
            result = "Null value not allowed";
            break;
        }

        return result;
    }

    // ----------------------------------------------------------------------
    // Minor error codes for BAD_CONTEXT
    // ----------------------------------------------------------------------

    //
    // Standard minor codes
    //

    //
    // Yoko specific minor codes
    //
    public final static int MinorNoPatternMatch = 1 | OOCVMCID;

    public static String describeBadContext(int minor) {
        String result = null;

        switch (minor) {
        case MinorNoPatternMatch:
            result = "No match found";
            break;
        }

        return result;
    }
}


text:
<?php

namespace Symfony\Component\Serializer\Mapping\Loader;

use Symfony\Component\Serializer\Exception\MappingException;
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
use Symfony\Component\Yaml\Parser;

/**
 * YAML File Loader.
 *
 * @author Kévin Dunglas <dunglas@gmail.com>
 */
class YamlFileLoader extends FileLoader
{
    private $yamlParser;

    /**
     * An array of YAML class descriptions.
     *
     * @var array
     */
    private $classes = null;

    /**
     * {@inheritdoc}
     */
    public function loadClassMetadata(ClassMetadataInterface $classMetadata)
    {
        if (null === $this->classes) {
            $this->classes = $this->getClassesFromYaml();
        }

        if (!$this->classes) {
            return false;
        }

        if (isset($this->classes[$classMetadata->getName()])) {
            $yaml = $this->classes[$classMetadata->getName()];

            if (isset($yaml['attributes']) && is_array($yaml['attributes'])) {
                $attributesMetadata = $classMetadata->getAttributesMetadata();

                foreach ($yaml['attributes'] as $attribute => $data) {
                    if (isset($attributesMetadata[$attribute])) {
                        $attributeMetadata = $attributesMetadata[$attribute];
                    } else {
                        $attributeMetadata = new AttributeMetadata($attribute);
                        $classMetadata->addAttributeMetadata($attributeMetadata);
                    }

                    if (isset($data['groups'])) {
                        if (!is_array($data['groups'])) {
                            throw new MappingException('The "groups" key must be an array of strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName());
                        }

                        foreach ($data['groups'] as $group) {
                            if (!is_string($group)) {
                                throw new MappingException('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName());
                            }

                            $attributeMetadata->addGroup($group);
                        }
                    }

                    if (isset($data['max_depth'])) {
                        if (!is_int($data['max_depth'])) {
                            throw new MappingException('The "max_depth" value must an integer  in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName());
                        }

                        $attributeMetadata->setMaxDepth($data['max_depth']);
                    }
                }
            }

            return true;
        }

        return false;
    }

    /**
     * Return the names of the classes mapped in this file.
     *
     * @return string[] The classes names
     */
    public function getMappedClasses()
    {
        if (null === $this->classes) {
            $this->classes = $this->getClassesFromYaml();
        }

        return array_keys($this->classes);
    }

    private function getClassesFromYaml()
    {
        if (!stream_is_local($this->file)) {
            throw new MappingException(sprintf('This is not a local file "%s".', $this->file));
        }

        if (null === $this->yamlParser) {
            $this->yamlParser = new Parser();
        }

        $classes = $this->yamlParser->parse(file_get_contents($this->file));

        if (empty($classes)) {
            return array();
        }

        if (!is_array($classes)) {
            throw new MappingException(sprintf('The file "%s" must contain a YAML array.', $this->file));
        }

        return $classes;
    }
}

redpajama_set_name: RedPajamaGithub


text:
package no.kantega.publishing.security.action;

import no.kantega.publishing.security.SecuritySession;
import no.kantega.publishing.security.data.LoginRestrictor;
import no.kantega.security.api.identity.DefaultIdentityResolver;
import no.kantega.security.api.identity.IdentityResolver;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class LoginHelper {
    static void registerSuccessfulLogin(LoginRestrictor userLoginRestrictor,
                                               LoginRestrictor ipLoginRestrictor,
                                               HttpServletRequest request,
                                               String username,
                                               String domain) {

        userLoginRestrictor.registerLoginAttempt(username, true);
        ipLoginRestrictor.registerLoginAttempt(request.getRemoteAddr(), true);

        HttpSession session = request.getSession(true);
        IdentityResolver resolver = SecuritySession.getInstance(request).getRealm().getIdentityResolver();

        // Set session logon info
        session.setAttribute(resolver.getAuthenticationContext() + DefaultIdentityResolver.SESSION_IDENTITY_NAME, username);
        session.setAttribute(resolver.getAuthenticationContext() + DefaultIdentityResolver.SESSION_IDENTITY_DOMAIN, domain);

        // Finish login by getting instance
        SecuritySession.getInstance(request);
    }
}


text:
import java.util.ArrayList;

/**
 * Author: Alex Yang
 * Date: 9/9/2014
 * Dependencies:
 *  - Node.java
 * Description:
 *  - Implement a stack data structure which will start a new stack when the
 *  previous stack exceeds a certain threshold.  However, push and pop should
 *  function as if there is only one stack.
 * Solution(s):
 *  - Recursive leftshift to end to implement PopAt.  Essentially uses a
 *  rollover system, to shift elements of each of the stacks, by removing
 *  the bottom element and pushing it to the previous stack, while re-setting
 *  the bottom elements.
 *  - Implemented separate StackLimited class with helpful class methods.
 */

class SetOfStacks {
  public static void main(String args[]) throws Exception {
    SetOfStacks stack = new SetOfStacks(1);
    stack.push(1);
    stack.push(2);
    stack.push(3);
    System.out.println(stack.popAt(1));
    System.out.println(stack.pop());
    System.out.println(stack.pop());
  }

  ArrayList<StackLimited> stacks = new ArrayList<StackLimited>();
  public int capacity;

  public SetOfStacks(int capacity) {
    this.capacity = capacity;
  }

  public StackLimited getLastStack() {
    if (stacks.size() == 0) return null;
    return stacks.get(stacks.size() - 1);
  }

  public void push(int value) {
    StackLimited last = this.getLastStack();
    if (last != null && !last.isFull()) {
      last.push(value);
    } else {
      StackLimited stack = new StackLimited(capacity);
      stack.push(value);
      stacks.add(stack);
    }
  }

  public int pop() {
    StackLimited last = this.getLastStack();
    int value = last.pop();
    if (last.size == 0) stacks.remove(stacks.size() - 1);
    return value;
  }

  public boolean isEmpty() {
    StackLimited last = getLastStack();
    return last == null || last.isEmpty();
  }

  public int popAt(int stackIndex) {
    return leftShift(stackIndex, true);
  }

  public int leftShift(int index, boolean removeTop) {
    StackLimited stack = stacks.get(index);
    int removed_item;

    if (removeTop) {
      removed_item = stack.pop();
    } else {
      removed_item = stack.removeBottom();
    }

    if (stack.isEmpty()) {
      stacks.remove(index);
    } else if (stacks.size() > index + 1) {
      int value = leftShift(index + 1, false);
      stack.push(value);
    }
    return removed_item;
  }
}

class StackLimited {
  private int capacity;
  public Node<Integer> top, bottom;
  public int size = 0;

  public StackLimited (int capacity) {
    this.capacity = capacity;
  }

  public boolean isFull() {
    return this.size == this.capacity;
  }

  public boolean push(int value) {
    if (size >= capacity) return false;
    size++;
    Node<Integer> n = new Node<Integer>(value);
    if (size == 1) bottom = n;
    join(n, top);
    top = n;
    return true;
  }

  public int pop() {
    Node<Integer> t = top;
    top = top.prev;
    size--;
    return t.data;
  }

  public boolean isEmpty() {
    return this.size == 0;
  }

  public int removeBottom() {
    Node<Integer> b = bottom;
    bottom = bottom.next;
    if (bottom != null) bottom.prev = null;
    size--;
    return b.data;
  }

  public void join (Node<Integer> above, Node<Integer> below) {
    if (below != null) below.next = above;
    if (above != null) above.prev = below;
  }
}


text:
xa.uploader
===========

Live Demo here

jQuery File Uploader with Drag-Drop

This is a two-part file uploader which allows you to upload files to any http server.

* requirements:
 * jQuery (should work with most versions)
 * xa.uploader.js (main uploader library)
 * xa.uploader_ui.js (only required for the UI uploader)

UI Uploader is easy to use.
===========================
```javascript

$('.uploader-container').uploader({
 action:'/upload-url',  //upload URL
 maxbytes:20971520,     //maximum file size

 /* Allowed Parameters  ***********************************************************
  * maxbytes:20971520,              //max upload size in bytes                    *
  * multiple:true,                  //multiple file upload                        *
  * upload_max:2,                   //maximum number of uploads at a time         *
  * accept:'image/*',               //specify the file types uploader browses for *
  * ext:'jpg;jpeg;png;gif;bmp', //filter extensions (works on drop and browse)*
  *********************************************************************************/
});

```

Usage
=====

 1.1: Simple Uploader (no ui, if you want to build your own)
      This automatically uses the given jQuery element as the
      browse button

```javascript
    // jQuery usage
    // browse button
    $('.upload-button').uploader_browse({
      action:'/upload/url',
      maxbytes:20971520,              //max upload size in bytes
      multiple:true,                  //multiple file upload
      upload_max:2,                   //maximum number of uploads at a time
      accept:'image/*',               //specify the file types uploader browses for
      ext:'jpg;jpeg;png;gif;bmp', //filter extensions (works on drop and browse)
      file_added:function(file_data,uploader){
        // fires when a file is added to the list.
      },
      progress:function(file_data,params){
        // fires when progress changes
      },
      complete:function(file_data,params){
        // fires when an item is done uploading.
        // file_data will be null when all files have uploaded
      },
      failed:function(file_data,params){
        // fires when an upload fails.
      },
      cancelled:function(file_data,params){
        // fires when upload is cancelled
      }

    }).uploader_drop({target:'body'}); // allow upload file-drop

```

 1.2: Same as above, but does not use a jQuery element
```javascript

    // Generic Usage
    var uploader = $.xa.uploader({
      // parameters, just the same as in jQuery sample
    });
    // call this event
    // to browse for a file to upload
    uploader.upload();

```


text:
/*
  NOTE: THIS FILE HAS BEEN CREATED AUTOMATICALLY,
  ANY CHANGES WILL BE OVERWRITTEN WITHOUT NOTICE!
*/

/*
  Cuda Templates.

  Copyright (C) 2008 Institute for Computer Graphics and Vision,
                     Graz University of Technology

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef CUDA_IPLREFERENCE1D_H
#define CUDA_IPLREFERENCE1D_H

#include <cudatemplates/iplreference.hpp>

namespace Cuda {

/**
   IplReference template specialized for 1 dimension(s).
*/
template <class Type>
class IplReference1D : public IplReference<Type, 1>
{
public:
#ifndef CUDA_NO_DEFAULT_CONSTRUCTORS
  /**
     Default constructor.
  */
  inline IplReference1D()
  {
  }
#endif

  /**
     Constructor.
     @param _image pointer to IplImage to be referenced.
  */
  inline IplReference1D(IplImage *_image):
    Layout<Type, 1>(),
    Pointer<Type, 1>(),
    IplReference<Type, 1>(_image)
  {
  }

  /**
     Constructor.
     @param _size size of memory block.
     @param _image pointer to IplImage to be referenced.
  */
  inline IplReference1D(const Size<1> &_size, IplImage *_image):
    Layout<Type, 1>(_size),
    Pointer<Type, 1>(_size),
    IplReference<Type, 1>(_size, _image)
  {
  }
};

}  // namespace Cuda

#endif


text:
package com.kaaprotech.satu.util;

import java.io.PrintWriter;
import java.io.StringWriter;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;

public final class CmdLineUtil {

    public static final String IN = "in";

    public static final String OUT = "out";

    public static final String JSON = "json";

    public static String getCommandLineUsageMessage() {
        final HelpFormatter formatter = new HelpFormatter();
        final StringWriter sw = new StringWriter();
        final PrintWriter pw = new PrintWriter(sw, true);
        pw.println();
        formatter.printHelp(pw, 120, "Satu", null, getOptions(), 2, 10, null);
        return sw.getBuffer().toString();
    }

    public static CommanndLineValues parseCommanndLineArgs(String[] args) {
        final CommandLine commandLine;
        try {
            final CommandLineParser parser = new GnuParser();
            commandLine = parser.parse(getOptions(), args);
        }
        catch (ParseException e) {
            System.err.println("Satu: Failed to parse command line arguments: " + e.getMessage());
            throw new RuntimeException(e);
        }

        final String[] in = commandLine.getOptionValues(IN);
        final String out = commandLine.getOptionValue(OUT);
        final boolean json = commandLine.hasOption(JSON);
        return new CommanndLineValuesImpl(in, out, json);
    }

    @SuppressWarnings("static-access")
    private static Options getOptions() {
        final Options options = new Options();
        OptionBuilder.create("init");
        final Option in = OptionBuilder.withArgName(IN).hasArgs().withDescription("One or more model files").isRequired().create(IN);
        options.addOption(in);
        final Option out = OptionBuilder.withArgName(OUT).hasArg().withDescription("Output root directory").isRequired().create(OUT);
        options.addOption(out);
        final Option json = OptionBuilder.withArgName(JSON).hasArg(false).withDescription("Add json support to generated code").isRequired(false).create(JSON);
        options.addOption(json);
        return options;
    }

    private static final class CommanndLineValuesImpl implements CommanndLineValues {

        private final String[] modelFiles_;

        private final String outDirectory_;

        private final boolean jsonCompatible_;

        public CommanndLineValuesImpl(String[] modelFiles, String outDirectory, boolean jsonCompatible) {
            modelFiles_ = modelFiles;
            outDirectory_ = outDirectory;
            jsonCompatible_ = jsonCompatible;
        }

        public String[] getModelFiles() {
            return modelFiles_;
        }

        public String getOutDirectory() {
            return outDirectory_;
        }

        public boolean isJsonCompatible() {
            return jsonCompatible_;
        }
    }

    public interface CommanndLineValues {

        String[] getModelFiles();

        String getOutDirectory();

        boolean isJsonCompatible();
    }
}


text:
package mysqlctl

import (
	"github.com/spf13/pflag"

	"vitess.io/vitess/go/vt/log"
	"vitess.io/vitess/go/vt/servenv"
)

// This file handles using command line flags to create a Mycnf object.
// Since whoever links with this module doesn't necessarely need the flags,
// RegisterFlags needs to be called explicitly to set the flags up.

var (
	// the individual command line parameters
	flagServerID              int
	flagMysqlPort             int
	flagDataDir               string
	flagInnodbDataHomeDir     string
	flagInnodbLogGroupHomeDir string
	flagSocketFile            string
	flagGeneralLogPath        string
	flagErrorLogPath          string
	flagSlowLogPath           string
	flagRelayLogPath          string
	flagRelayLogIndexPath     string
	flagRelayLogInfoPath      string
	flagBinLogPath            string
	flagMasterInfoFile        string
	flagPidFile               string
	flagTmpDir                string
	flagSecureFilePriv        string

	// the file to use to specify them all
	flagMycnfFile string
)

// RegisterFlags registers the command line flags for
// specifying the values of a mycnf config file. See NewMycnfFromFlags
// to get the supported modes.
func RegisterFlags() {
	servenv.OnParse(func(fs *pflag.FlagSet) {
		fs.IntVar(&flagServerID, "mycnf_server_id", flagServerID, "mysql server id of the server (if specified, mycnf-file will be ignored)")
		fs.IntVar(&flagMysqlPort, "mycnf_mysql_port", flagMysqlPort, "port mysql is listening on")
		fs.StringVar(&flagDataDir, "mycnf_data_dir", flagDataDir, "data directory for mysql")
		fs.StringVar(&flagInnodbDataHomeDir, "mycnf_innodb_data_home_dir", flagInnodbDataHomeDir, "Innodb data home directory")
		fs.StringVar(&flagInnodbLogGroupHomeDir, "mycnf_innodb_log_group_home_dir", flagInnodbLogGroupHomeDir, "Innodb log group home directory")
		fs.StringVar(&flagSocketFile, "mycnf_socket_file", flagSocketFile, "mysql socket file")
		fs.StringVar(&flagGeneralLogPath, "mycnf_general_log_path", flagGeneralLogPath, "mysql general log path")
		fs.StringVar(&flagErrorLogPath, "mycnf_error_log_path", flagErrorLogPath, "mysql error log path")
		fs.StringVar(&flagSlowLogPath, "mycnf_slow_log_path", flagSlowLogPath, "mysql slow query log path")
		fs.StringVar(&flagRelayLogPath, "mycnf_relay_log_path", flagRelayLogPath, "mysql relay log path")
		fs.StringVar(&flagRelayLogIndexPath, "mycnf_relay_log_index_path", flagRelayLogIndexPath, "mysql relay log index path")
		fs.StringVar(&flagRelayLogInfoPath, "mycnf_relay_log_info_path", flagRelayLogInfoPath, "mysql relay log info path")
		fs.StringVar(&flagBinLogPath, "mycnf_bin_log_path", flagBinLogPath, "mysql binlog path")
		fs.StringVar(&flagMasterInfoFile, "mycnf_master_info_file", flagMasterInfoFile, "mysql master.info file")
		fs.StringVar(&flagPidFile, "mycnf_pid_file", flagPidFile, "mysql pid file")
		fs.StringVar(&flagTmpDir, "mycnf_tmp_dir", flagTmpDir, "mysql tmp directory")
		fs.StringVar(&flagSecureFilePriv, "mycnf_secure_file_priv", flagSecureFilePriv, "mysql path for loading secure files")

		fs.StringVar(&flagMycnfFile, "mycnf-file", flagMycnfFile, "path to my.cnf, if reading all config params from there")
	})
}

// NewMycnfFromFlags creates a Mycnf object from the command line flags.
//
// Multiple modes are supported:
//   - at least mycnf_server_id is set on the command line
//     --> then we read all parameters from the command line, and not from
//     any my.cnf file.
//   - mycnf_server_id is not passed in, but mycnf-file is passed in
//     --> then we read that mycnf file
//   - mycnf_server_id and mycnf-file are not passed in:
//     --> then we use the default location of the my.cnf file for the
//     provided uid and read that my.cnf file.
//
// RegisterCommandLineFlags should have been called before calling
// this, otherwise we'll panic.
func NewMycnfFromFlags(uid uint32) (mycnf *Mycnf, err error) {
	if flagServerID != 0 {
		log.Info("mycnf_server_id is specified, using command line parameters for mysql config")
		return &Mycnf{
			ServerID:              uint32(flagServerID),
			MysqlPort:             int32(flagMysqlPort),
			DataDir:               flagDataDir,
			InnodbDataHomeDir:     flagInnodbDataHomeDir,
			InnodbLogGroupHomeDir: flagInnodbLogGroupHomeDir,
			SocketFile:            flagSocketFile,
			GeneralLogPath:        flagGeneralLogPath,
			ErrorLogPath:          flagErrorLogPath,
			SlowLogPath:           flagSlowLogPath,
			RelayLogPath:          flagRelayLogPath,
			RelayLogIndexPath:     flagRelayLogIndexPath,
			RelayLogInfoPath:      flagRelayLogInfoPath,
			BinLogPath:            flagBinLogPath,
			MasterInfoFile:        flagMasterInfoFile,
			PidFile:               flagPidFile,
			TmpDir:                flagTmpDir,
			SecureFilePriv:        flagSecureFilePriv,

			// This is probably not going to be used by anybody,
			// but fill in a default value. (Note it's used by
			// mysqld.Start, in which case it is correct).
			Path: MycnfFile(uint32(flagServerID)),
		}, nil
	}

	if flagMycnfFile == "" {
		flagMycnfFile = MycnfFile(uid)
		log.Infof("No mycnf_server_id, no mycnf-file specified, using default config for server id %v: %v", uid, flagMycnfFile)
	} else {
		log.Infof("No mycnf_server_id specified, using mycnf-file file %v", flagMycnfFile)
	}
	mycnf = NewMycnf(uid, 0)
	mycnf.Path = flagMycnfFile
	return ReadMycnf(mycnf)
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<results title="frequencies">
 <result title="frequency" count="15">Ae. furcifer</result>
 <result title="frequency" count="12">Ae. taylori</result>
 <result title="frequency" count="9">Ae. luteocephalus</result>
 <result title="frequency" count="9">Ae. africanus</result>
 <result title="frequency" count="9">Ae. vittatus</result>
 <result title="frequency" count="5">Ae. aegypti</result>
 <result title="frequency" count="4">Ae. dalzieli</result>
 <result title="frequency" count="4">An. coustani</result>
 <result title="frequency" count="4">Cx. perfuscus</result>
 <result title="frequency" count="4">Ae. metallicus</result>
 <result title="frequency" count="3">Ae. hirsutus</result>
 <result title="frequency" count="3">Ma. uniformis</result>
 <result title="frequency" count="2">Ae. unilinaetus</result>
 <result title="frequency" count="1">Erythrocebus patas</result>
 <result title="frequency" count="1">Chlorocebus sabaeus</result>
 <result title="frequency" count="1">Ae. pseudoscutellaris</result>
 <result title="frequency" count="1">Aedes furcifer</result>
</results>


text: Split bar chart and main program


text:
<?php
echo '<?xml version="1.0" encoding="UTF-8"?>';
/** @var \Argentum\FacturacionModerna\Document\Invoice $invoice */
?>
<cfdi:Comprobante
    xmlns:cfdi="http://www.sat.gob.mx/cfd/3"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd"
    version="3.2"
    tipoDeComprobante="ingreso"
    fecha="<?php echo substr($invoice->getDate()->format('c'), 0, 19); ?>"
    noCertificado=""
    certificado=""
    sello=""
    formaDePago="<?php echo $invoice->getPaymentType(); ?>"
    metodoDePago="<?php echo $invoice->getPaymentMethod(); ?>"
    LugarExpedicion="<?php echo $invoice->getFrom()->getAddress(); ?>"
    subTotal="<?php echo number_format($invoice->getSubtotal(), 4, '.', ''); ?>"
    descuento="<?php echo $invoice->getDiscount(); ?>"
    total="<?php echo number_format($invoice->getTotal(), 4, '.', ''); ?>"
    <?php if (!empty($invoice->getSerie())) echo 'Serie="' . $invoice->getSerie() . '"'; ?>
    folio="<?php echo $invoice->getId(); ?>"
    condicionesDePago="<?php echo $invoice->getPaymentConditions(); ?>"
    NumCtaPago="<?php echo $invoice->getPaymentAccount(); ?>"
    Moneda="<?php echo $invoice->getCurrency(); ?>"
>
    <cfdi:Emisor
        nombre="<?php echo $invoice->getFrom()->getName(); ?>"
        rfc="<?php echo $invoice->getFrom()->getId(); ?>"
    >
        <cfdi:DomicilioFiscal
            calle="<?php echo $invoice->getFrom()->getAddress()->getAddress_1(); ?>"
            <?php echo !empty($invoice->getFrom()->getAddress()->getAddress_2()) ? 'noExterior="'.$invoice->getFrom()->getAddress()->getAddress_2().'"' : ''; ?>
            <?php echo !empty($invoice->getFrom()->getAddress()->getAddress_3()) ? 'noInterior="'.$invoice->getFrom()->getAddress()->getAddress_3().'"' : ''; ?>
            <?php echo !empty($invoice->getFrom()->getAddress()->getNeighborhood()) ? 'colonia="'.$invoice->getFrom()->getAddress()->getNeighborhood().'"' : ''; ?>
            municipio="<?php echo $invoice->getFrom()->getAddress()->getLocality(); ?>"
            estado="<?php echo $invoice->getFrom()->getAddress()->getState(); ?>"
            pais="<?php echo $invoice->getFrom()->getAddress()->getCountry(); ?>"
            codigoPostal="<?php echo $invoice->getFrom()->getAddress()->getPostcode(); ?>"
        />
        <cfdi:RegimenFiscal
            Regimen="<?php echo (!empty($invoice->getFrom()->getFiscalRegime()) ? $invoice->getFrom()->getFiscalRegime() : $invoice->getScheme()); ?>"
        />
    </cfdi:Emisor>
    <cfdi:Receptor
        nombre="<?php echo $invoice->getTo()->getName(); ?>"
        rfc="<?php echo $invoice->getTo()->getId(); ?>"
    >
        <cfdi:Domicilio
            <?php echo !empty($invoice->getTo()->getAddress()->getAddress_1()) ? 'calle="'.$invoice->getTo()->getAddress()->getAddress_1().'"' : ''; ?>
            <?php echo !empty($invoice->getTo()->getAddress()->getAddress_2()) ? 'noExterior="'.$invoice->getTo()->getAddress()->getAddress_2().'"' : ''; ?>
            <?php echo !empty($invoice->getTo()->getAddress()->getAddress_3()) ? 'noInterior="'.$invoice->getTo()->getAddress()->getAddress_3().'"' : ''; ?>
            <?php echo !empty($invoice->getTo()->getAddress()->getNeighborhood()) ? 'colonia="'.$invoice->getTo()->getAddress()->getNeighborhood().'"' : ''; ?>
            <?php echo !empty($invoice->getTo()->getAddress()->getPostcode()) ? 'codigoPostal="'.$invoice->getTo()->getAddress()->getPostcode().'"' : ''; ?>
            <?php echo !empty($invoice->getTo()->getAddress()->getLocality()) ? 'municipio="'.$invoice->getTo()->getAddress()->getLocality().'"' : ''; ?>
            <?php echo !empty($invoice->getTo()->getAddress()->getState()) ? 'estado="'.$invoice->getTo()->getAddress()->getState().'"' : ''; ?>
            pais="<?php echo $invoice->getTo()->getAddress()->getCountry(); ?>"
        />
    </cfdi:Receptor>
    <cfdi:Conceptos>
        <?php foreach ($invoice->getItems() as $item) : ?>
            <cfdi:Concepto
                cantidad="<?php echo number_format($item->getQuantity(), 4, '.', ''); ?>"
                unidad="<?php echo (!empty($item->getUnit()) ? $item->getUnit() : 'No aplica'); ?>"
                descripcion="<?php echo $item->getName(); ?>"
                valorUnitario="<?php echo number_format($item->getPrice(), 4, '.', ''); ?>"
                importe="<?php echo number_format($item->getQuantity() * $item->getPrice(), 4, '.', ''); ?>"
            ></cfdi:Concepto>
        <?php endforeach; ?>
    </cfdi:Conceptos>
    <?php if (count($invoice->getTaxes())) : ?>
    <cfdi:Impuestos
        totalImpuestosTrasladados="<?php echo number_format($invoice->getTaxesAmount(), 4, '.', ''); ?>"
    >
        <cfdi:Traslados>
            <?php foreach ($invoice->getTaxes() as $tax) : ?>
                <cfdi:Traslado
                    impuesto="<?php echo $tax->getName(); ?>"
                    tasa="<?php echo number_format($tax->getRate(), 2, '.', ''); ?>"
                    importe="<?php echo number_format($tax->getAmount($tax->getBaseAmount()), 4, '.', ''); ?>"
                ></cfdi:Traslado>
            <?php endforeach; ?>
        </cfdi:Traslados>
    </cfdi:Impuestos>
    <?php endif; ?>
</cfdi:Comprobante>


text:
layout: page
title: Poole - Forbes Wedding
date: 2016-05-24
author: Nicole Cortez
tags: weekly links, java
status: published
summary: Vestibulum mattis sed enim vel.
banner: images/banner/meeting-01.jpg
booking:
  startDate: 03/26/2016
  endDate: 03/27/2016
  ctyhocn: RICARHX
  groupCode: PFW
published: true
---
Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec iaculis scelerisque posuere. Cras rhoncus erat ut congue gravida. Proin tempus vehicula vestibulum. In tempus varius libero eget semper. Aliquam in vestibulum purus, eu venenatis lorem. Etiam ullamcorper posuere pulvinar. Duis luctus tempor dui mollis tempor.

* Pellentesque mattis felis ut maximus lobortis
* Nullam at risus sed enim tristique ultricies at vitae nibh
* Sed efficitur tellus sit amet orci ultricies, in faucibus ex eleifend
* Sed accumsan urna eget elit gravida dictum.

Aenean facilisis nulla nec eros dapibus, ac luctus odio aliquet. Ut in dolor sed magna commodo luctus. Praesent vitae felis at velit bibendum tincidunt. Integer id nisl eget elit gravida faucibus. Ut placerat nunc vitae mauris semper, a dignissim dolor ultrices. Cras bibendum mi at massa placerat congue. Maecenas tincidunt nibh imperdiet felis facilisis tristique. Aliquam urna erat, porttitor gravida ipsum id, hendrerit rhoncus lectus. Cras tempus, arcu nec porta maximus, nibh nisl posuere magna, in tincidunt odio nulla non turpis. Morbi laoreet libero eu aliquet semper. Cras molestie at odio ac porttitor. Nulla sed nisl non purus elementum euismod ut eu purus. Nulla vestibulum in elit in sollicitudin. Proin finibus malesuada nunc, in hendrerit urna suscipit ut. Sed sem erat, laoreet non elementum id, bibendum et sapien.


text:
package griffon.pivot.support.adapters;

import groovy.lang.Closure;

/**
 * @author Andres Almiray
 */
public class CalendarBindingAdapter implements GriffonPivotAdapter, org.apache.pivot.wtk.CalendarBindingListener {
    private Closure selectedDateKeyChanged;
    private Closure selectedDateBindTypeChanged;
    private Closure selectedDateBindMappingChanged;

    public Closure getSelectedDateKeyChanged() {
        return this.selectedDateKeyChanged;
    }

    public Closure getSelectedDateBindTypeChanged() {
        return this.selectedDateBindTypeChanged;
    }

    public Closure getSelectedDateBindMappingChanged() {
        return this.selectedDateBindMappingChanged;
    }

    public void setSelectedDateKeyChanged(Closure selectedDateKeyChanged) {
        this.selectedDateKeyChanged = selectedDateKeyChanged;
        if (this.selectedDateKeyChanged != null) {
            this.selectedDateKeyChanged.setDelegate(this);
            this.selectedDateKeyChanged.setResolveStrategy(Closure.DELEGATE_FIRST);
        }
    }

    public void setSelectedDateBindTypeChanged(Closure selectedDateBindTypeChanged) {
        this.selectedDateBindTypeChanged = selectedDateBindTypeChanged;
        if (this.selectedDateBindTypeChanged != null) {
            this.selectedDateBindTypeChanged.setDelegate(this);
            this.selectedDateBindTypeChanged.setResolveStrategy(Closure.DELEGATE_FIRST);
        }
    }

    public void setSelectedDateBindMappingChanged(Closure selectedDateBindMappingChanged) {
        this.selectedDateBindMappingChanged = selectedDateBindMappingChanged;
        if (this.selectedDateBindMappingChanged != null) {
            this.selectedDateBindMappingChanged.setDelegate(this);
            this.selectedDateBindMappingChanged.setResolveStrategy(Closure.DELEGATE_FIRST);
        }
    }

    public void selectedDateKeyChanged(org.apache.pivot.wtk.Calendar arg0, java.lang.String arg1) {
        if (selectedDateKeyChanged != null) {
            selectedDateKeyChanged.call(arg0, arg1);
        }
    }

    public void selectedDateBindTypeChanged(org.apache.pivot.wtk.Calendar arg0, org.apache.pivot.wtk.BindType arg1) {
        if (selectedDateBindTypeChanged != null) {
            selectedDateBindTypeChanged.call(arg0, arg1);
        }
    }

    public void selectedDateBindMappingChanged(org.apache.pivot.wtk.Calendar arg0, org.apache.pivot.wtk.Calendar.SelectedDateBindMapping arg1) {
        if (selectedDateBindMappingChanged != null) {
            selectedDateBindMappingChanged.call(arg0, arg1);
        }
    }

}


text:
class Container;

class CardMovedMessage
        : public Message
{
public:
    explicit CardMovedMessage(PlayCardEvent playCardEvent);
    explicit CardMovedMessage(CreatureDestroyedEvent creatureDestroyedEvent);
    ~CardMovedMessage();

private:
    int getZoneID(const std::shared_ptr<Container>& container);
};

#endif //WHISPERERENGINE_CARDMOVEDMESSAGE_H


text:
require "vagrant"

module VagrantPlugins
  module LibcloudHelper
    class Plugin < Vagrant.plugin("2")

      include Vagrant::Action::Builtin

      require_relative "action"
      require_relative "providers/virtualbox/driver/base"
      require_relative "providers/virtualbox/driver/meta"

      name "libcloud_helper"

      config "libcloud_helper" do
        require_relative "config"
        Config
      end

      action_hook(:libcloud_helper, :machine_action_up) do |hook|
        hook.after VagrantPlugins::ProviderVirtualBox::Action::Customize,
                   VagrantPlugins::LibcloudHelper::Action.allocate_sata_ports
      end
    end
  end
end


text:
<?php

namespace CodeIgniter\Database\Live;

use CodeIgniter\Config\Factories;
use CodeIgniter\Database\SQLite3\Connection;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\DatabaseTestTrait;
use Config\Database;

/**
 * @group DatabaseLive
 *
 * @internal
 */
final class ConnectTest extends CIUnitTestCase
{
    use DatabaseTestTrait;

    protected $group1;
    protected $group2;
    protected $tests;

    protected function setUp(): void
    {
        parent::setUp();

        $config = config('Database');

        $this->group1 = $config->default;
        $this->group2 = $config->default;
        $this->tests  = $config->tests;

        $this->group1['DBDriver'] = 'MySQLi';
        $this->group2['DBDriver'] = 'Postgre';
    }

    public function testConnectWithMultipleCustomGroups()
    {
        // We should have our test database connection already.
        $instances = $this->getPrivateProperty(Database::class, 'instances');
        $this->assertCount(1, $instances);

        $db1 = Database::connect($this->group1);
        $db2 = Database::connect($this->group2);

        $this->assertNotSame($db1, $db2);

        $instances = $this->getPrivateProperty(Database::class, 'instances');
        $this->assertCount(3, $instances);
    }

    public function testConnectReturnsProvidedConnection()
    {
        $config = config('Database');

        // This will be the tests database
        $db = Database::connect();
        $this->assertSame($config->tests['DBDriver'], $this->getPrivateProperty($db, 'DBDriver'));

        // Get an instance of the system's default db so we have something to test with.
        $db1 = Database::connect($this->group1);
        $this->assertSame('MySQLi', $this->getPrivateProperty($db1, 'DBDriver'));

        // If a connection is passed into connect, it should simply be returned to us...
        $db2 = Database::connect($db1);
        $this->assertSame($db1, $db2);
    }

    public function testConnectWorksWithGroupName()
    {
        $config = config('Database');

        $db = Database::connect('tests');
        $this->assertSame($config->tests['DBDriver'], $this->getPrivateProperty($db, 'DBDriver'));

        $config                      = config('Database');
        $config->default['DBDriver'] = 'MySQLi';
        Factories::injectMock('config', 'Database', $config);

        $db1 = Database::connect('default');
        $this->assertNotInstanceOf(Connection::class, $db1);
        $this->assertSame('MySQLi', $this->getPrivateProperty($db1, 'DBDriver'));
    }

    public function testConnectWithFailover()
    {
        $this->tests['failover'][] = $this->tests;

        unset($this->tests['failover'][0]['failover']);

        $this->tests['username'] = 'wrong';

        $db1 = Database::connect($this->tests);

        $this->assertSame($this->tests['failover'][0]['DBDriver'], $this->getPrivateProperty($db1, 'DBDriver'));
        $this->assertGreaterThanOrEqual(0, count($db1->listTables()));
    }
}


text:
set -e

# Include definitions of dataset and tuning related variables.
source "$(dirname $0)/../../lib/setup.sh" "$1"
source_lib "config/common.sh"
source_lib "config/tuning.sh"

name="$2"
config_file="$3/config"
load_checkpoint="$3/best"

save_checkpoints=false
turns=0

# Evaluation

dyneval=true
batch_size=1024
max_training_eval_batches=500
max_grad_norm=0.0
eval_softmax_temperature=-0.8
eval_softmax_temperature_estimation_num_tokens=50000
l2_penalty=0.0

# Tuning parameters

priority=200
num_workers=60

tuneables="batch_size,max_time_steps,
  dyneval_learning_rate,dyneval_decay_rate,dyneval_epsilon"
name="$(default_name)_${name}"
source_lib "run.sh" "$1"


text:
tasks-rs: JAX-RS, JPA quickstart
==============================
Author: Mike Musgrove
Level: Intermediate
Technologies: JPA, JAX-RS
Summary: The `tasks-rs` quickstart demonstrates how to implement a JAX-RS service that uses JPA persistence.
Prerequisites: tasks
Target Product: JBoss EAP
Source: <https://github.com/jboss-developer/jboss-eap-quickstarts/>

What is it?
-----------

The `tasks-rs` quickstart demonstrates how to implement a JAX-RS service that uses JPA persistence deployed to Red Hat JBoss Enterprise Application Platform.

* The client uses HTTP to interact with the service. It builds on the *tasks* quickstarts which provide simple Task management with secure login.

* The service interface is implemented using JAX-RS. The SecurityContext JAX-RS annotation is used to inject the security details into each REST method.

The application manages User and Task JPA entities. A user represents an authenticated principal and is associated with zero or more Tasks. Service methods validate that there is an authenticated principal and the first time a principal is seen, a JPA User entity is created to correspond to the principal. JAX-RS annotated methods are provided for associating Tasks with this User and for listing and removing Tasks.

_Note: This quickstart uses the H2 database included with Red Hat JBoss Enterprise Application Platform 7. It is a lightweight, relational example datasource that is used for examples only. It is not robust or scalable, is not supported, and should NOT be used in a production environment!_

_Note: This quickstart uses a `*-ds.xml` datasource configuration file for convenience and ease of database configuration. These files are deprecated in JBoss EAP and should not be used in a production environment. Instead, you should configure the datasource using the Management CLI or Management Console. Datasource configuration is documented in the [Administration and Configuration Guide](https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/) for Red Hat JBoss Enterprise Application Platform._

System requirements
-------------------

The application this project produces is designed to be run on Red Hat JBoss Enterprise Application Platform 7 or later.

All you need to build this project is Java 8.0 (Java SDK 1.8) or later and Maven 3.1.1 or later. See [Configure Maven for JBoss EAP 7](https://github.com/jboss-developer/jboss-developer-shared-resources/blob/master/guides/CONFIGURE_MAVEN_JBOSS_EAP7.md#configure-maven-to-build-and-deploy-the-quickstarts) to make sure you are configured correctly for testing the quickstarts.

Use of EAP_HOME
---------------

In the following instructions, replace `EAP_HOME` with the actual path to your JBoss EAP installation. The installation path is described in detail here: [Use of EAP_HOME and JBOSS_HOME Variables](https://github.com/jboss-developer/jboss-developer-shared-resources/blob/master/guides/USE_OF_EAP_HOME.md#use-of-eap_home-and-jboss_home-variables).

Add an Application User
---------------

This quickstart uses secured management interfaces and requires that you create the following application user to access the running application.

| **UserName** | **Realm** | **Password** | **Roles** |
|:-----------|:-----------|:-----------|:-----------|
| quickstartUser| ApplicationRealm | quickstartPwd1!| guest |

To add the application user, open a command prompt and type the following command:

        For Linux:   EAP_HOME/bin/add-user.sh -a -u 'quickstartUser' -p 'quickstartPwd1!' -g 'guest'
        For Windows: EAP_HOME\bin\add-user.bat  -a -u 'quickstartUser' -p 'quickstartPwd1!' -g 'guest'

If you prefer, you can use the add-user utility interactively.
For an example of how to use the add-user utility, see the instructions located here: [Add an Application User](https://github.com/jboss-developer/jboss-developer-shared-resources/blob/master/guides/CREATE_USERS.md#add-an-application-user).

Start the JBoss EAP Server
-------------------------

1. Open a command prompt and navigate to the root of the JBoss EAP directory.
2. The following shows the command line to start the server:

        For Linux:   EAP_HOME/bin/standalone.sh
        For Windows: EAP_HOME\bin\standalone.bat

Build and Deploy the Quickstart
-------------------------

1. Make sure you have started the JBoss EAP server as described above.
2. Open a command prompt and navigate to the root directory of this quickstart.
3. Type this command to build and deploy the archive:

        mvn clean install wildfly:deploy

4. This will deploy `target/jboss-tasks-rs.war` to the running instance of the server.

Access the Application Resources
---------------------

Application resources for this quickstart are prefixed with the URL http://localhost:8080/jboss-tasks-rs/ and can be accessed by an HTTP client.

* For methods that accept *GET*, a web browser can be used.
* Otherwise, you must use cURL or some other command line tool that supports HTTP *POST* and *DELETE* methods.

Below you will find instructions to create, display, and delete tasks.

### Create a Task

To associate a task called `task1` with the user `quickstartUser`, you must authenticate as user `quickstartUser` and send an HTTP *POST* request to the url 'http://localhost:8080/jboss-tasks-rs/tasks/task1'.

To issue the *POST* command using cURL, type the following command:

    curl -i -u 'quickstartUser:quickstartPwd1!' -H "Content-Length: 0" -X POST http://localhost:8080/jboss-tasks-rs/tasks/task1

You will see the following response:

    HTTP/1.1 201 Created
    Server: Apache-Coyote/1.1
    Location: http://localhost:8080/jboss-tasks-rs/tasks/1
    Content-Length: 0
    Date: Sun, 15 Apr 2012 22:46:26 GMT

This is what happens when the command is issued:

* The `-i` flag tells cURL to print the returned headers. Notice that the `Location` header contains the URI of the resource corresponding to the new task you have just created.
* The `-u` flag provides the authentication information for the request.
* The `-H` flag adds a header to the outgoing request.
* The `-X` flag tells cURL which HTTP method to use. The HTTP *POST* is used to create resources.
* The `Location` header of the response contains the URI of the resource representing the newly created task.

The final argument to cURL determines the title of the task. Note that this approach is perhaps not very restful but it simplifies this quickstart. A better approach would be to *POST* to "http://localhost:8080/jboss-tasks-rs/tasks" passing the task title in the body of the request.

### Display the XML Representation of a Task

To display the XML representation of the newly created resource, issue a *GET* request on the task URI returned in the `Location` header during the create.

1. To issue a *GET* using a browser, open a browser and access the URI. You will be challenged to enter valid authentication credentials.

    <http://localhost:8080/jboss-tasks-rs/tasks/1>
2. To issue a *GET* using cURL, type the following command:

        curl -H "Accept: application/xml" -u 'quickstartUser:quickstartPwd1!' -X GET http://localhost:8080/jboss-tasks-rs/tasks/1

    The `-H flag tells the server that the client wishes to accept XML content.

Using either of the above *GET* methods, you should see the following XML:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
       <task id="1" ownerName="quickstartUser">
          <title>task1</title>
      </task>

### Display the XML Representation of all Tasks for a User

To obtain a list of all tasks for user `quickstartUser` in XML format, authenticate as user `quickstartUser` and send an HTTP `GET` request to the resource `tasks` URL.

1. To issue a *GET* using a browser, open a browser and access the following URL. You will be challenged to enter valid authentication credentials.

    <http://localhost:8080/jboss-tasks-rs/tasks>

2. To list all tasks associated with the user `quickstartUser` using cURL, type:

        curl -H "Accept: application/xml" -u 'quickstartUser:quickstartPwd1!' -X GET http://localhost:8080/jboss-tasks-rs/tasks

Using either of the above *GET* methods, you should see the following XML:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <collection>
        <task id="1" ownerName="quickstartUser">
        <title>task1</title>
        </task>
    </collection>

### Delete a Task

To delete a task, again authenticate as principal `quickstartUser` and send an HTTP *DELETE* request to the URI that represents the task.

To delete the task with id `1`:

    curl -i -u 'quickstartUser:quickstartPwd1!' -X DELETE http://localhost:8080/jboss-tasks-rs/tasks/1

You will see this response:

    HTTP/1.1 204 No Content
    Server: Apache-Coyote/1.1
    Pragma: No-cache
    Cache-Control: no-cache
    Expires: Thu, 01 Jan 1970 01:00:00 GMT
    Date: Sun, 15 Apr 2012 22:51:56 GMT

Now list all tasks associated with user `quickstartUser`:

    curl -u 'quickstartUser:quickstartPwd1!' -X GET http://localhost:8080/jboss-tasks-rs/tasks

You will see a response with an empty collection:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <collection/>

Modify this Quickstart to Support JSON Representations of Tasks
-----------------------------------------------------------------

JSON is not part of the JAX-RS standard but most JAX-RS implementations do support it. This quickstart can be modified to support JSON by uncommenting a few lines. Look for lines beginning with "// JSON:":

1. Open the file src/main/java/org/jboss/as/quickstarts/tasksrs/model/Task.java and remove the comments from the following two lines.

        // import org.codehaus.jackson.annotate.JsonIgnore;

        // @JsonIgnore

2. Open the file src/main/java/org/jboss/as/quickstarts/tasksrs/service/TaskResource.java and make sure the *GET* methods produce "application/json" as well as "application/xml". Again, look for lines beginning with "// JSON:".
    * Remove comments from these lines:

        //@Produces({ "application/xml", "application/json" })
    * Add comments to these lines:

        @Produces({ "application/xml" })
3. Open pom.xml and remove the comments from the dependency with artifactId `resteasy-jackson-provider`

        <!--
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson-provider</artifactId>
            <version>2.3.1.GA</version>
            <scope>provided</scope>
        </dependency>
        -->

4. [Create a Task](#create-a-task) as you did for the XML version of this quickstart.
5. Rebuild and redeploy the quickstart.

Now you can view task resources in JSON media type by specifying the correct Accept header. For example, using the cURL tool, type the following command:

    curl -H "Accept: application/json" -u 'quickstartUser:quickstartPwd1!' -X GET http://localhost:8080/jboss-tasks-rs/tasks/1

You will see the following response:

    {"id":1,"title":"task1","ownerName":"quickstartUser"}

Server Log: Expected warnings and errors
-----------------------------------

_Note:_ You will see the following warnings in the server log. You can ignore these warnings.

    JBAS010489: -ds.xml file deployments are deprecated. Support may be removed in a future version.

    HHH000431: Unable to determine H2 database version, certain features may not work

Undeploy the Archive
--------------------

1. Make sure you have started the JBoss EAP server as described above.
2. Open a command prompt and navigate to the root directory of this quickstart.
3. When you are finished testing, type this command to undeploy the archive:

        mvn wildfly:undeploy

Run the Quickstart in Red Hat JBoss Developer Studio or Eclipse
-------------------------------------
You can also start the server and deploy the quickstarts or run the Arquillian tests from Eclipse using JBoss tools. For general information about how to import a quickstart, add a JBoss EAP server, and build and deploy a quickstart, see [Use JBoss Developer Studio or Eclipse to Run the Quickstarts](https://github.com/jboss-developer/jboss-developer-shared-resources/blob/master/guides/USE_JBDS.md#use-jboss-developer-studio-or-eclipse-to-run-the-quickstarts)

Be sure to [Add an Application User](#add-an-application-user) as described above.

_Note:_ When you deploy this quickstart, you see the following error. This is because JBoss Developer Studio automatically attempts to access the URL <http://localhost:8080/jboss-tasks-rs/>, however, all incoming requests are handled by the REST application. You can ignore this error.

    JBWEB000065: HTTP Status 404 - RESTEASY001185: Could not find resource for relative : / of full path: http://localhost:8080/jboss-tasks-rs/

Debug the Application
---------------------

If you want to debug the source code of any library in the project, run the following command to pull the source into your local repository. The IDE should then detect it.

        mvn dependency:sources