Example usage for java.lang StringBuilder insert

List of usage examples for java.lang StringBuilder insert

Introduction

In this page you can find the example usage for java.lang StringBuilder insert.

Prototype

@Override
public StringBuilder insert(int offset, double d) 

Source Link

Usage

From source file:com.evolveum.polygon.scim.StandardScimHandlingStrategy.java

@Override
public Uid update(Uid uid, String resourceEndPoint, ObjectTranslator objectTranslator,
        Set<Attribute> attributes, ScimConnectorConfiguration conf) {
    ServiceAccessManager accessManager = new ServiceAccessManager(conf);

    Header authHeader = accessManager.getAuthHeader();
    String scimBaseUri = accessManager.getBaseUri();

    if (authHeader == null || scimBaseUri.isEmpty()) {

        throw new ConnectorException(
                "The data needed for authorization of request to the provider was not found.");
    }/*from w w w  . j  a  va 2s.  co  m*/

    HttpClient httpClient = initHttpClient(conf);

    String uri = new StringBuilder(scimBaseUri).append(SLASH).append(resourceEndPoint).append(SLASH)
            .append(uid.getUidValue()).toString();
    LOGGER.info("The uri for the update request: {0}", uri);

    String responseString = null;
    try {
        LOGGER.info("Query url: {0}", uri);
        JSONObject jsonObject = objectTranslator.translateSetToJson(attributes, null, resourceEndPoint);
        //   LOGGER.info("The update json object: {0}", jsonObject);

        HttpPatch httpPatch = buildHttpPatch(uri, authHeader, jsonObject);

        try (CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(httpPatch)) {

            int statusCode = response.getStatusLine().getStatusCode();

            HttpEntity entity = response.getEntity();

            if (entity != null) {
                responseString = EntityUtils.toString(entity);
            } else {
                responseString = "";
            }
            if (statusCode == 200 || statusCode == 201) {
                LOGGER.info("Update of resource was succesfull");

                if (!responseString.isEmpty()) {
                    JSONObject json = new JSONObject(responseString);
                    LOGGER.ok("Json response: {0}", json.toString());
                    Uid id = new Uid(json.getString(ID));
                    return id;

                } else {
                    LOGGER.warn("Service provider response is empty, no response after the update procedure");
                }
            } else if (statusCode == 204) {

                LOGGER.warn("Status code {0}. Response body left intentionally empty", statusCode);

                return uid;
            } else if (statusCode == 404) {

                ErrorHandler.onNoSuccess(responseString, statusCode, uri);

                StringBuilder errorBuilder = new StringBuilder("The resource with the uid: ").append(uid)
                        .append(" was not found.");

                throw new UnknownUidException(errorBuilder.toString());

            } else if (statusCode == 500 && GROUPS.equals(resourceEndPoint)) {

                Uid id = groupUpdateProcedure(statusCode, jsonObject, uri, authHeader, conf);

                if (id != null) {

                    return id;
                } else {
                    ErrorHandler.onNoSuccess(responseString, statusCode, "updating object");
                }
            } else {
                handleInvalidStatus("while updating resource. ", responseString, "updating object", statusCode);
            }
        }
    } catch (UnsupportedEncodingException e) {

        LOGGER.error("Unsupported encoding: {0}. Occurrence in the process of updating a resource object ",
                e.getMessage());
        LOGGER.info("Unsupported encoding: {0}. Occurrence in the process of updating a resource object ", e);

        throw new ConnectorException(
                "Unsupported encoding, Occurrence in the process of updating a resource object ", e);

    } catch (JSONException e) {

        LOGGER.error(
                "An exception has occurred while processing a json object. Occurrence in the process of updating a resource object: {0}",
                e.getLocalizedMessage());
        LOGGER.info(
                "An exception has occurred while processing a json object. Occurrence in the process of updating a resource object: {0}",
                e);

        throw new ConnectorException(
                "An exception has occurred while processing a json object,Occurrence in the process of updating a resource object",
                e);
    } catch (ClientProtocolException e) {
        LOGGER.error(
                "An protocol exception has occurred while in the process of updating a resource object. Possible mismatch in the interpretation of the HTTP specification: {0}",
                e.getLocalizedMessage());
        LOGGER.info(
                "An protocol exception has occurred while in the process of updating a resource object. Possible mismatch in the interpretation of the HTTP specification: {0}",
                e);
        throw new ConnectionFailedException(
                "An protocol exception has occurred while in the process of updating a resource object, Possible mismatch in the interpretation of the HTTP specification.",
                e);
    } catch (IOException e) {

        StringBuilder errorBuilder = new StringBuilder(
                "An error has occurred while processing the http response. Occurrence in the process of updating a resource object wit the Uid: ");

        errorBuilder.append(uid.toString());

        if ((e instanceof SocketTimeoutException || e instanceof NoRouteToHostException)) {
            errorBuilder.insert(0, "The connection timed out. ");

            throw new OperationTimeoutException(errorBuilder.toString(), e);
        } else {

            LOGGER.error(
                    "An error has occurred while processing the http response. Occurrence in the process of updating a resource object: {0}",
                    e.getLocalizedMessage());
            LOGGER.info(
                    "An error has occurred while processing the http response. Occurrence in the process of updating a resource object: {0}",
                    e);

            throw new ConnectorIOException(errorBuilder.toString(), e);
        }
    }
    return null;

}

From source file:com.quinsoft.zeidon.zeidonoperations.ZDRVROPR.java

public int BuildCSV_FromEntityAttribute(View vTgt, String cpcTgtEntity, String cpcTgtAttribute, View vSrc,
        String cpcSrcListEntityScope, String cpcSrcEAC, int lFlag) {
    Stack<ZNameItem> EntityStack = new Stack<ZNameItem>(); // tag stack (need not be unique)
    Stack<ZNameItem> AttributeStack = new Stack<ZNameItem>(); // tag stack (need not be unique)
    Stack<ZNameItem> ValueStack = new Stack<ZNameItem>(); // tag stack (need not be unique)
    Stack<ZNameItem> ContextStack = new Stack<ZNameItem>(); // tag stack (need not be unique)
    ZNameItem pEntityItem;/*from w ww  . j a v  a  2s  .  c o m*/
    ZNameItem pAttribItem;
    ZNameItem pValueItem;
    ZNameItem pContextItem;
    String pchSrcListEntity;
    String pchSrcListScope;
    StringBuilder sb;
    String pch = null;
    int ulCurrLth;
    int ulMaxLth = 0;
    int k;
    int nRC;

    k = zstrchr(cpcSrcListEntityScope, '.');
    if (k > 0) {
        pchSrcListEntity = cpcSrcListEntityScope.substring(0, k);
        pchSrcListScope = cpcSrcListEntityScope.substring(k + 1);
    } else {
        pchSrcListEntity = cpcSrcListEntityScope;
        pchSrcListScope = null;
    }

    fnSetEntityAttribList(EntityStack, AttributeStack, ValueStack, ContextStack, pchSrcListEntity, cpcSrcEAC);

    if (EntityStack.size() == 0 || AttributeStack.size() == 0)
        return (-3); // entity.attribute.context parameter not well-formed

    MutableInt nLth = new MutableInt(0);
    GetAttributeLength(nLth, vTgt, cpcTgtEntity, cpcTgtAttribute);
    ulMaxLth = nLth.intValue();
    sb = new StringBuilder(ulMaxLth + 16); // extra room for adding <crlf> or <p></p>
    sb.setLength(0); // Use sb.setLength( 0 ); to clear a string buffer.

    // DisplayObjectInstance( vSrc, "", "" );
    ulCurrLth = 0;
    nRC = SetCursorFirstEntity(vSrc, pchSrcListEntity, pchSrcListScope);
    while (nRC >= zCURSOR_SET) {
        k = 0;
        if (k < AttributeStack.size()) {
            pEntityItem = EntityStack.get(k);
            pAttribItem = AttributeStack.get(k);
            pValueItem = ValueStack.get(k);
            pContextItem = ContextStack.get(k);
        } else {
            pEntityItem = null;
            pAttribItem = null;
            pValueItem = null;
            pContextItem = null;
        }

        while (pAttribItem != null) {
            if ((lFlag & 0x00000001) != 0) {
                sb.insert(ulCurrLth++, '<');
                sb.insert(ulCurrLth++, 'p');
                sb.insert(ulCurrLth++, '>');
            }

            pch = GetStringFromAttributeByContext(pch, vSrc, pEntityItem.getName(), pAttribItem.getName(),
                    pContextItem.getName(), ulMaxLth - ulCurrLth);
            ulCurrLth = zstrcpy(sb, ulCurrLth, pch);
            k++;
            if (k < AttributeStack.size()) {
                pEntityItem = EntityStack.get(k);
                pAttribItem = AttributeStack.get(k);
                pValueItem = ValueStack.get(k);
                pContextItem = ContextStack.get(k);
            } else {
                pEntityItem = null;
                pAttribItem = null;
                pValueItem = null;
                pContextItem = null;
            }

            if (pAttribItem != null) {
                sb.insert(ulCurrLth++, ',');
                sb.insert(ulCurrLth++, ' ');
            } else {
                if ((lFlag & 0x00000001) != 0) {
                    sb.insert(ulCurrLth++, '<');
                    sb.insert(ulCurrLth++, '/');
                    sb.insert(ulCurrLth++, 'p');
                    sb.insert(ulCurrLth++, '>');
                } else {
                    sb.insert(ulCurrLth++, '\r');
                    sb.insert(ulCurrLth++, '\n');
                }
            }

            if (ulCurrLth >= ulMaxLth) {
                break;
            }
        }

        if (ulCurrLth >= ulMaxLth)
            nRC = zCALL_ERROR;
        else
            nRC = SetCursorNextEntity(vSrc, pchSrcListEntity, pchSrcListScope);
    }

    SetAttributeFromString(vTgt, cpcTgtEntity, cpcTgtAttribute, sb.toString());
    return 0;
}

From source file:edu.cmu.cylab.starslinger.view.SaveActivity.java

private void saveSelectedContacts() {
    StringBuilder errors = new StringBuilder();

    // save the contacts
    int selected = 0;
    Intent data = new Intent();
    int exchanged = mContacts.size();
    for (int i = 0; i < exchanged; i++) {

        // save if selected
        String contactLookupKey = null;
        ContactStruct mem = mContacts.get(i);

        // create custom data for export to third party as well...
        data.putExtra(extra.NAME + selected, mem.name.toString());
        data.putExtra(extra.PHOTO + selected, mem.photoBytes);
        if (mem.contactmethodList != null) {
            for (ContactMethod item : mem.contactmethodList) {
                if (item.kind == Contacts.KIND_IM && mAccessor.isCustomIm(item.label)) {
                    data.putExtra(item.label + selected, SSUtil.finalDecode(item.data.getBytes()));
                }//from w  w w . jav  a2  s. c o  m
            }
        }

        boolean checked = SaveContactAdapter.isPositionChecked(i);
        if (checked && isValidContact(mem)) {
            Name name = mem.name;
            if (name == null || name.toString() == null || TextUtils.isEmpty(name.toString().trim())) {
                errors.append("\n  Bad Name found");
                continue;
            }
            contactLookupKey = getContactLookupKeyByName(name.toString());

            String rawContactId = null;
            if (!TextUtils.isEmpty(contactLookupKey)) {
                String where = Data.LOOKUP_KEY + " = ?";
                String[] whereParameters = new String[] { contactLookupKey };
                Cursor c = getContentResolver().query(Data.CONTENT_URI, null, where, whereParameters, null);
                if (c != null) {
                    try {
                        if (c.moveToFirst()) {
                            do {
                                rawContactId = c.getString(c.getColumnIndex(Data.RAW_CONTACT_ID));
                            } while (c.moveToNext());
                        }
                    } finally {
                        c.close();
                    }
                }

                // for an update we have to be careful to prevent import
                // of duplicate data, so here we can query the aggregate
                // contact for equivalently matching contact fields and
                // prevent the import so we won't get duplicate phone
                // numbers for example, one with international prefix
                // and one without.
                mem = loadContactDataNoDuplicates(this, contactLookupKey, mem, true);
            }

            // for name-only contact don't add to address book, just
            // return a null lookup key.
            if (hasAddressBookData(mem)) {

                if (!TextUtils.isEmpty(rawContactId)) {
                    // name match, so update...
                    if (!mAccessor.updateOldContact(mem, SaveActivity.this, mSelectedAcctType,
                            mSelectedAcctName, rawContactId)) {
                        errors.append("\n  ").append(name.toString()).append(" ")
                                .append(getString(R.string.error_ContactUpdateFailed));
                        continue;
                    }
                } else {
                    // no name match, so insert...
                    rawContactId = mAccessor.insertNewContact(mem, mSelectedAcctType, mSelectedAcctName,
                            SaveActivity.this);
                    if (!TextUtils.isEmpty(rawContactId)) {
                        contactLookupKey = getContactLookupKeyByRawContactId(rawContactId);
                    } else {
                        errors.append("\n  ").append(name.toString()).append(" ")
                                .append(getString(R.string.error_ContactInsertFailed));
                        continue;
                    }
                }

                data.putExtra(extra.CONTACT_LOOKUP_KEY + selected, contactLookupKey);
            }
        }

        selected++;
    }

    // add redundant check for correct number of contacts imported...
    data.putExtra(extra.EXCHANGED_TOTAL, exchanged);

    if (errors.length() > 0) {
        errors.insert(0, mSelectedAcctName);
        showNote(errors.toString());
        return;
    }

    if (selected == 0) {
        setResult(RESULT_SELNONE, data);
    } else {
        setResult(RESULT_SAVE, data);
    }
    finish();
}

From source file:com.arksoft.epamms.ZGlobal1_Operation.java

/**
   public String/* ww w.  j av  a  2 s.  co m*/
   GetGeneralPath( View  vSubtask, int lFlag, String stringFileType, String stringTarget )
   {
      char   stringReturn;
      char   stringCLSID;
      int nRC = FALSE;
        
      stringReturn = "";
      lFlag = 3; // set flag to 3 as that is all we currently support
      if ( lFlag == 3 ) //open for view
      {
 GetRegistryCLSID( stringCLSID, stringFileType );
 // nRC = GetRegistryHTMLViewValue( "", stringCLSID, REG_SZ, stringReturn, sizeof( stringReturn ) );
 nRC = GetRegistryGeneralValue( "", "rtffile", stringCLSID, REG_SZ, stringReturn, sizeof( stringReturn ) );
        
 TraceLineS( "Flag 3 stringCLSID !", stringCLSID ) ;
 TraceLineS( "Flag 3 Return !", stringReturn ) ;
 if ( nRC == FALSE )
 {
    // for win98 in case we are not in win2K
    nRC = GetRegistryGeneralValue( "", "rtffile", stringCLSID, REG_EXPAND_SZ,
                                   stringReturn, sizeof( stringReturn ) );
    TraceLineS( "Flag 3C stringCLSID !", stringCLSID ) ;
    TraceLineS( "Flag 3C Return !", stringReturn ) ;
 }
      }
        
      TraceLineS( "RIGHT BEFORE STRCopy:", stringReturn ) ;
      stringTarget = zstrcpy( stringTarget, stringReturn );
      TraceLineS( "RIGHT AFTER STRCopy", "" ) ;
      return stringTarget;
   }
        
   ////////////////////////////////////////////////////////////////////////////////////////////////////
   //
   //  Method Name: ConvertExternalValueOfAttribute
   //
   //    Convert an external value for an attribute to its internal value.
   //
   ////////////////////////////////////////////////////////////////////////////////////////////////////
   public int
   ConvertExternalValueOfAttribute( String lpReturnedString,
                            String srcString,
                            View   lpView,
                            String entityName,
                            String attributeName )
   {
      zVIEW  wXferO;
      zVIEW  vDynamicT;
      zVIEW  vQualObject;
      zVIEW  zqFrameOrig;
      zVIEW  zqFrame;
      LPVIEWENTITY lpEntityDef;
      LPVIEWATTRIB lpAttributeDef;
      LPDOMAIN     lpDomain;
      String  DataType;
      String  Msg;
      String  SavedTableName;
      String  stringYearIndicator;
      int  lInternalTableValue;
      int nLth;
      int nRC;
        
      GetViewByName( wXferO, "wXferO", lpView, zLEVEL_TASK );
      lpReturnedString = "";
      lpEntityDef = String MiGetEntityDefForView( lpView, entityName );
      if ( lpEntityDef == 0 )
 return -16;
        
      // Position on attribute.
#ifdef VIEWENTITY_OD
      lpAttributeDef = String zGETPTR( lpEntityDef->hFirstOD_Attrib );
      nRC = 1;
      while ( lpAttributeDef > 0 && nRC > 0 )
      {
 if ( zstrcmp( lpAttributeDef->stringName, attributeName ) == 0 )
    nRC = 0;
        
 if ( nRC > 0 )
    lpAttributeDef = String zGETPTR( lpAttributeDef->hNextOD_Attrib );
      }
#else
      lpAttributeDef = String zGETPTR( lpEntityDef->hFirstAttributeDef );
      nRC = 1;
      while ( lpAttributeDef > 0 && nRC > 0 )
      {
 if ( zstrcmp( lpAttributeDef->stringName, attributeName ) == 0 )
    nRC = 0;
        
 if ( nRC > 0 )
    lpAttributeDef = String zGETPTR( lpAttributeDef->hNextAttributeDef );
      }
// #endif
      if ( nRC > 0 )
      {
 MessageSend( lpView, "", "Data Conversion",
              "The attribute specified was not found.",
              zMSGQ_OBJECT_CONSTRAINT_ERROR, 0 );
 return -1;
      }
        
      // If input is null, simply return because output has already been set to null.
      if ( *srcString == 0 )
 return 0;
        
      nLth = zstrlen( srcString );
        
      // Process depending on whether or not the Domain is a Table.
      lpDomain = (LPDOMAIN) zGETPTR( lpAttributeDef->hDomain );
      if ( lpDomain->cDomainType == 'T' )
      {
 if ( *(lpDomain->stringDomainOper) == 0 )
 {
    // The domain is a static table so convert the value through the table interface.
    if ( lpDomain->cType == zTYPE_INTEGER )
    {
       nRC = TableEntryExtToInt( &lInternalTableValue, lpView, lpDomain, 0, srcString );
       zltoa( lInternalTableValue, lpReturnedString );
    }
    else
       nRC = TableEntryExtToInt( lpReturnedString, lpView, lpDomain, 0, srcString );  // Internal value is STRING.
    if ( nRC < 0 )
    {
       zstrcpy( Msg, "Invalid input value for attribute, " );
       zstrcat( Msg, attributeName );
       zstrcat( Msg, "." );
       MessageSend( lpView, "", "Data Conversion",
                    Msg,
                    zMSGQ_OBJECT_CONSTRAINT_ERROR, 0 );
       return -1;
    }
 }
 else
 {
    if ( zstrcmp( lpDomain->stringName, "FAISIR_DynamicTableSingle" ) == 0 )
    {
       // Get Year Indicator value as GeneralParameter in zqFrame object.
       // If we get to this section of code, we must have come from zqFrame and the lpView is actually
       // the zqFrame view.
       // (This is very similar to the code in DomainC.)
       GetViewByName( zqFrameOrig, "zqFrame", lpView, zLEVEL_TASK );
       CreateViewFromView( zqFrame, zqFrameOrig );
       nRC = SetCursorFirstEntityByString( zqFrame, "GeneralParameter", "AttributeName", "YearIndicator", "" );
       if ( nRC < zCURSOR_SET )
          *stringYearIndicator = 0;
       else
          GetStringFromAttribute( stringYearIndicator, zqFrame, "GeneralParameter", "Value" );
       if ( *stringYearIndicator == 0 )
       {
          MessageSend( lpView, "", "Data Validation",
                       "A YearIndicator value must be specified as a General Parameter in the Query.",
                       zMSGQ_DOMAIN_ERROR, 0 );
          return zCALL_ERROR;
       }
        
       zstrcpy( SavedTableName, "X_" );
       zstrcat( SavedTableName, lpDomain->stringName );
       zstrcat( SavedTableName, stringYearIndicator );    // Build the concatenated name.
        
       // Either get existing view or activate new one.
       nRC = GetViewByName( vDynamicT, SavedTableName, lpView, zLEVEL_TASK );
       if ( nRC < 0 )
       {
          // Set up Qualification object for YearIndicator.
          SfActivateSysEmptyOI( vQualObject, "KZDBHQUA", lpView, zMULTIPLE );
          CreateEntity( vQualObject, "EntitySpec", zPOS_AFTER );
          SetAttributeFromString( vQualObject, "EntitySpec", "EntityName", "FAISIRDomain" );
          CreateEntity( vQualObject, "QualAttrib", zPOS_AFTER );
          SetAttributeFromString( vQualObject, "QualAttrib", "EntityName", "FAISIRDomain" );
          SetAttributeFromString( vQualObject, "QualAttrib", "AttributeName", "YearIndicator" );
          SetAttributeFromString( vQualObject, "QualAttrib", "Value", stringYearIndicator );
          SetAttributeFromString( vQualObject, "QualAttrib", "Oper", "=" );
        
          // Activate the Domains for the YearIndicator.
          nRC = ActivateObjectInstance( vDynamicT, "mFAISIRD", zqFrame, vQualObject, zMULTIPLE );
          DropView( vQualObject );
          if ( nRC < 0 )
          {
             MessageSend( lpView, "", "Data Validation",
                          "A YearIndicator value must be specified as a General Parameter in the Query.",
                          zMSGQ_DOMAIN_ERROR, 0 );
             return zCALL_ERROR;
          }
        
          SetNameForView( vDynamicT, SavedTableName, 0, zLEVEL_APPLICATION );
          CreateViewFromViewForTask( &vDynamicT, vDynamicT, 0 );
          SetNameForView( vDynamicT, SavedTableName, lpView, zLEVEL_TASK );
       }
        
       // Position on correct table entry.
       nRC = SetCursorFirstEntityByString( vDynamicT, "FAISIRDomain", "Name", attributeName, "" );
       if ( nRC >= zCURSOR_SET )
          nRC = SetCursorFirstEntityByString( vDynamicT, "FAISIRDomainValue", "ExternalDescription", srcString, "" );
       if ( nRC < 0 )
       {
          zstrcpy( Msg, "Invalid input value for attribute, " );
          zstrcat( Msg, attributeName );
          zstrcat( Msg, "." );
          MessageSend( lpView, "", "Data Conversion",
                       Msg,
                       zMSGQ_OBJECT_CONSTRAINT_ERROR, 0 );
          return -1;
       }
        
       GetStringFromAttribute( lpReturnedString, vDynamicT, "FAISIRDomainValue", "InternalStringValue" );
        
       DropView( zqFrame );
    }
    else
    {
       // The domain is a regular dynamic table so use the object in memory or activate it.
       zstrcpy( SavedTableName, "X_" );
       zstrcat( SavedTableName, lpDomain->stringName );
       nRC = GetViewByName( vDynamicT, SavedTableName, lpView, zLEVEL_TASK );
       if ( nRC < 0 )
          nRC = GetViewByName( vDynamicT, SavedTableName, lpView, zLEVEL_APPLICATION );
        
       if ( nRC < 0 )
       {
          // The table wasn't in memory, so call the dynamic table routine to load it.
          // Note that we will call the routine with an invalid request type, which will load
          // the table but not take action.
          SfActivateSysEmptyOI( &vQualObject, "KZDBHQUA", lpView, zMULTIPLE );
          CreateEntity( vQualObject, "EntitySpec", zPOS_AFTER );
          SetAttributeFromString( vQualObject, "EntitySpec", "EntityName", "Domain" );
          CreateEntity( vQualObject, "QualAttrib", zPOS_AFTER );
          SetAttributeFromString( vQualObject, "QualAttrib", "EntityName", "Domain" );
          SetAttributeFromString( vQualObject, "QualAttrib", "AttributeName", "Name" );
          SetAttributeFromString( vQualObject, "QualAttrib", "Value", lpDomain->stringName );
          SetAttributeFromString( vQualObject, "QualAttrib", "Oper", "=" );
          nRC = ActivateObjectInstance( &vDynamicT, "DOMAINT", lpView,
                                        vQualObject, zSINGLE | zLEVEL_APPLICATION );
          SetNameForView( vDynamicT, SavedTableName, lpView, zLEVEL_APPLICATION );
       }
        
       // Locate the entry in the table by external value and return the internal value.
       nRC = SetCursorFirstEntityByString( vDynamicT, "DomainValue",
                                           "ExternalDescription",
                                           srcString, 0 );
       if ( nRC < 0 )
       {
          zstrcpy( Msg, "Invalid input value for attribute, " );
          zstrcat( Msg, attributeName );
          zstrcat( Msg, "." );
          MessageSend( lpView, "", "Data Conversion",
                       Msg,
                       zMSGQ_OBJECT_CONSTRAINT_ERROR, 0 );
          return -1;
       }
        
       GetStringFromAttribute( lpReturnedString, vDynamicT, "DomainValue", "InternalStringValue" );
    }
 }
      }
      else
      {
 // If Domain Type is not Table, use data type for conversion through wXferO attribute.
 DataType = lpDomain->cType;
 if ( DataType == 'L' )
 {
    nRC = SetAttributeFromVariable( wXferO, "Root", "WorkInteger",
                                   srcString, zTYPE_STRING,
                                   nLth, 0, zUSE_DEFAULT_CONTEXT );
    if ( nRC >= 0 )
       GetStringFromAttribute( lpReturnedString, wXferO, "Root", "WorkInteger" );
    else
       return -1;
 }
 else
 if ( DataType == 'T' )
 {
    nRC = SetAttributeFromVariable( wXferO, "Root", "WorkDate",
                                    srcString, zTYPE_STRING,
                                    nLth, "M/D/YYYY", 0 );
    if ( nRC >= 0 )
       GetStringFromAttribute( lpReturnedString, wXferO, "Root", "WorkDate" );
    else
       return -1;
 }
 else
 if ( DataType == 'D' )
 {
    nRC = SetAttributeFromVariable( wXferO, "Root", "WorkDate",
                                    srcString, zTYPE_STRING,
                                    nLth, "M/D/YYYY", 0 );
    if ( nRC >= 0 )
       GetStringFromAttribute( lpReturnedString, wXferO, "Root", "WorkDate" );
    else
       return -1;
 }
 else
 if ( DataType == 'M' )
 {
    nRC = SetAttributeFromVariable( wXferO, "Root", "WorkDecimal",
                                    srcString, zTYPE_STRING,
                                    nLth, 0, zUSE_DEFAULT_CONTEXT );
    if ( nRC >= 0 )
       GetStringFromAttribute( lpReturnedString, wXferO, "Root", "WorkDecimal" );
    else
       return -1;
 }
 else
    zstrcpy( lpReturnedString, srcString );
      }
        
      return 0;
   } // ConvertExternalValueOfAttribute
**/

////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  Method Name: AddSpacesToString
//
//    Insert spaces within a Zeidon string name where capital letters exist.
//
////////////////////////////////////////////////////////////////////////////////////////////////////
public String AddSpacesToString(String stringZeidonName) {
    StringBuilder sb = new StringBuilder(stringZeidonName);
    int k;

    for (k = 1; k < sb.length(); k++) {
        if (sb.charAt(k) >= 'A' && sb.charAt(k) <= 'Z') {
            sb.insert(k, ' ');
            k++;
        }
    }

    return sb.toString();

}

From source file:org.tomahawk.tomahawk_android.utils.TomahawkExceptionReporter.java

/**
 * Pull information from the given {@link CrashReportData} and send it via HTTP to
 * oops.tomahawk-player.org or sends it as a TEXT intent, if IS_SILENT is true
 *//* w  w w .  j a  va 2 s .c  o  m*/
@Override
public void send(CrashReportData data) throws ReportSenderException {
    StringBuilder body = new StringBuilder();

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    nameValuePairs.add(new BasicNameValuePair("Version", data.getProperty(ReportField.APP_VERSION_NAME)));

    nameValuePairs.add(new BasicNameValuePair("BuildID", data.getProperty(ReportField.BUILD)));
    nameValuePairs.add(new BasicNameValuePair("ProductName", "tomahawk-android"));
    nameValuePairs.add(new BasicNameValuePair("Vendor", "Tomahawk"));
    nameValuePairs.add(new BasicNameValuePair("timestamp", data.getProperty(ReportField.USER_CRASH_DATE)));

    for (NameValuePair pair : nameValuePairs) {
        body.append("--thkboundary\r\n");
        body.append("Content-Disposition: form-data; name=\"");
        body.append(pair.getName()).append("\"\r\n\r\n").append(pair.getValue()).append("\r\n");
    }

    body.append("--thkboundary\r\n");
    body.append("Content-Disposition: form-data; name=\"upload_file_minidump\"; filename=\"")
            .append(data.getProperty(ReportField.REPORT_ID)).append("\"\r\n");
    body.append("Content-Type: application/octet-stream\r\n\r\n");

    body.append("============== Tomahawk Exception Report ==============\r\n\r\n");
    body.append("Report ID: ").append(data.getProperty(ReportField.REPORT_ID)).append("\r\n");
    body.append("App Start Date: ").append(data.getProperty(ReportField.USER_APP_START_DATE)).append("\r\n");
    body.append("Crash Date: ").append(data.getProperty(ReportField.USER_CRASH_DATE)).append("\r\n\r\n");

    body.append("--------- Phone Details  ----------\r\n");
    body.append("Phone Model: ").append(data.getProperty(ReportField.PHONE_MODEL)).append("\r\n");
    body.append("Brand: ").append(data.getProperty(ReportField.BRAND)).append("\r\n");
    body.append("Product: ").append(data.getProperty(ReportField.PRODUCT)).append("\r\n");
    body.append("Display: ").append(data.getProperty(ReportField.DISPLAY)).append("\r\n");
    body.append("-----------------------------------\r\n\r\n");

    body.append("----------- Stack Trace -----------\r\n");
    body.append(data.getProperty(ReportField.STACK_TRACE)).append("\r\n");
    body.append("-----------------------------------\r\n\r\n");

    body.append("------- Operating System  ---------\r\n");
    body.append("App Version Name: ").append(data.getProperty(ReportField.APP_VERSION_NAME)).append("\r\n");
    body.append("Total Mem Size: ").append(data.getProperty(ReportField.TOTAL_MEM_SIZE)).append("\r\n");
    body.append("Available Mem Size: ").append(data.getProperty(ReportField.AVAILABLE_MEM_SIZE)).append("\r\n");
    body.append("Dumpsys Meminfo: ").append(data.getProperty(ReportField.DUMPSYS_MEMINFO)).append("\r\n");
    body.append("-----------------------------------\r\n\r\n");

    body.append("-------------- Misc ---------------\r\n");
    body.append("Package Name: ").append(data.getProperty(ReportField.PACKAGE_NAME)).append("\r\n");
    body.append("File Path: ").append(data.getProperty(ReportField.FILE_PATH)).append("\r\n");

    body.append("Android Version: ").append(data.getProperty(ReportField.ANDROID_VERSION)).append("\r\n");
    body.append("Build: ").append(data.getProperty(ReportField.BUILD)).append("\r\n");
    body.append("Initial Configuration:  ").append(data.getProperty(ReportField.INITIAL_CONFIGURATION))
            .append("\r\n");
    body.append("Crash Configuration: ").append(data.getProperty(ReportField.CRASH_CONFIGURATION))
            .append("\r\n");
    body.append("Settings Secure: ").append(data.getProperty(ReportField.SETTINGS_SECURE)).append("\r\n");
    body.append("User Email: ").append(data.getProperty(ReportField.USER_EMAIL)).append("\r\n");
    body.append("User Comment: ").append(data.getProperty(ReportField.USER_COMMENT)).append("\r\n");
    body.append("-----------------------------------\r\n\r\n");

    body.append("---------------- Logs -------------\r\n");
    body.append("Logcat: ").append(data.getProperty(ReportField.LOGCAT)).append("\r\n\r\n");
    body.append("Events Log: ").append(data.getProperty(ReportField.EVENTSLOG)).append("\r\n\r\n");
    body.append("Radio Log: ").append(data.getProperty(ReportField.RADIOLOG)).append("\r\n");
    body.append("-----------------------------------\r\n\r\n");

    body.append("=======================================================\r\n\r\n");
    body.append("--thkboundary\r\n");
    body.append(
            "Content-Disposition: form-data; name=\"upload_file_tomahawklog\"; filename=\"Tomahawk.log\"\r\n");
    body.append("Content-Type: text/plain\r\n\r\n");
    body.append(data.getProperty(ReportField.LOGCAT));
    body.append("\r\n--thkboundary--\r\n");

    if ("true".equals(data.getProperty(ReportField.IS_SILENT))) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        body.insert(0, "Please tell us why you're sending us this log:\n\n\n\n\n");
        intent.putExtra(Intent.EXTRA_TEXT, body.toString());
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "support@tomahawk-player.org" });
        intent.putExtra(Intent.EXTRA_SUBJECT, "Tomahawk Android Log");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        TomahawkApp.getContext().startActivity(intent);
    } else {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://oops.tomahawk-player.org/addreport.php");
        httppost.setHeader("Content-type", "multipart/form-data; boundary=thkboundary");
        try {
            httppost.setEntity(new StringEntity(body.toString()));
            httpclient.execute(httppost);
        } catch (ClientProtocolException e) {
            Log.e(TAG, "send: " + e.getClass() + ": " + e.getLocalizedMessage());
        } catch (IOException e) {
            Log.e(TAG, "send: " + e.getClass() + ": " + e.getLocalizedMessage());
        }
    }
}

From source file:com.cohort.util.String2.java

/** This suggests a camel-case variable name.
 * /*  w  w  w .jav  a  2 s  .c  o  m*/
 * @param s the starting string for the variable name.
 * @return a valid variable name asciiLowerCaseLetter+asciiDigitLetter*, using camel case.
 *   This is a simplistic suggestion. Different strings may return the same variable name.
 *   null returns "null".
 *   "" returns "a".
 */
public static String toVariableName(String s) {
    if (s == null)
        return "null";
    int sLength = s.length();
    if (sLength == 0)
        return "a";
    s = modifyToBeASCII(s);
    s = toTitleCase(s);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < sLength; i++) {
        char c = s.charAt(i);
        if (isDigitLetter(c))
            sb.append(c);
    }
    if (sb.length() == 0)
        return "a";
    char c = sb.charAt(0);
    sb.setCharAt(0, Character.toLowerCase(c));
    if (c >= '0' && c <= '9')
        sb.insert(0, 'a');
    return sb.toString();
}

From source file:edu.harvard.iq.dvn.ingest.dsb.impl.DvnRJobRequest.java

public String getConditionString(List<List<String>> rangeSet, String variableName, String type, int vtype) {

    if ((vtype > 2) || (vtype < 0)) {
        dbgLog.fine("variable type undefined");
        vtype = 1;//  w  ww.j av  a2  s.  c  o m
    }

    String sep = " | ";
    if (type.equals("d")) {
        ;
        sep = " & ";
    }

    dbgLog.fine("range received:\n" + rangeSet);
    dbgLog.fine("variable type =" + vtype);

    StringBuilder finalCondition = new StringBuilder();
    List<Integer> removalList = new ArrayList<Integer>();

    for (int i = 0; i < rangeSet.size(); i++) {

        dbgLog.fine(i + "-th set=\n" + rangeSet.get(i));
        dbgLog.fine("range: 1 and 3:" + rangeSet.get(i).get(1) + "\t" + rangeSet.get(i).get(3));

        StringBuilder condition = new StringBuilder();

        if ((rangeSet.get(i).get(1).equals(rangeSet.get(i).get(3))) && (rangeSet.get(i).get(0).equals("3"))
                && (rangeSet.get(i).get(2).equals("4"))) {
            dbgLog.fine("point case");
            // point type
            if (vtype > 0) {
                if (rangeSet.get(i).get(1).equals(".")) {
                    condition.append("(is.na(" + variableName + "))");
                    dbgLog.fine("missing value case:numeric var");
                } else {
                    condition.append("(" + variableName + " == " + rangeSet.get(i).get(1) + ")");
                }
            } else {
                if (rangeSet.get(i).get(1).equals(".")) {
                    dbgLog.fine("missing value case: char var");
                    condition.append("(is.na(" + variableName + "))");
                } else {
                    // Check for dates and times: 
                    String rawVariableName = variableName;
                    dbgLog.fine("processing variable " + rawVariableName);
                    rawVariableName = rawVariableName.replaceAll("\"\\]\\]$", "");
                    dbgLog.fine("variable name after transformation 0: " + rawVariableName);
                    rawVariableName = rawVariableName.replaceAll("^x\\[\\[\"", "");
                    dbgLog.fine("variable name after transformation 1: " + rawVariableName);
                    String vFormat = variableFormats.get(rawVariableName);
                    dbgLog.fine("Variable " + rawVariableName + ", format: " + vFormat);
                    if (vFormat != null) {
                        // TODO: 
                        // the "as.POSIXct" lines below will likely NOT work once we try 
                        // to support ranges on dates and times.
                        // -- L.A., v3.6
                        // TODO: 
                        // the "as.POSIXct" lines below may need to include different 
                        // formats for the "T", "DT" and "JT" cases - similarly to 
                        // what we are doing in the R code; ("%T", "%F %T", etc.)
                        // Verify.
                        // -- L.A., v3.6
                        // TODO: 
                        // similar case *may* be needed for dates; 
                        // it appears, that on dates, it is legit to simply
                        // say "datevar == '1984-02-01', without as.Date();
                        // but it's probably not safe in the long run...
                        if (vFormat.equals("DT")) {
                            condition.append(
                                    "(" + variableName + " == as.POSIXct('" + rangeSet.get(i).get(1) + "'))");
                        } else if (vFormat.equals("JT")) {
                            condition.append(
                                    "(" + variableName + " == as.POSIXct('" + rangeSet.get(i).get(1) + "'))");
                        } else if (vFormat.equals("T")) {
                            condition.append(
                                    "(" + variableName + " == as.POSIXct('" + rangeSet.get(i).get(1) + "'))");
                        } else {
                            condition.append("(" + variableName + " == '" + rangeSet.get(i).get(1) + "')");
                        }

                    } else {
                        condition.append("(" + variableName + " == '" + rangeSet.get(i).get(1) + "')");
                    }
                }
            }

            if (type.equals("d")) {
                condition.insert(0, " !");
            } else {
                condition.insert(0, " ");
            }
            dbgLog.fine(i + "-th condition point:" + condition.toString());

        } else if (rangeSet.get(i).get(0).equals("2")) {
            dbgLog.fine("point-negation case");
            // point negation
            if (vtype > 0) {

                if (rangeSet.get(i).get(1).equals(".")) {
                    condition.append("(! is.na(" + variableName + "))");
                    dbgLog.fine("missing value case:numeric var");

                } else {
                    condition.append("(" + variableName + " != " + rangeSet.get(i).get(1) + ")");
                }
            } else {
                if (rangeSet.get(i).get(1).equals(".")) {
                    dbgLog.fine("missing value case: char var");
                    condition.append("(! is.na(" + variableName + "))");
                } else {
                    condition.append("(" + variableName + " != '" + rangeSet.get(i).get(1) + "')");
                }
            }

            if (type.equals("d")) {
                condition.insert(0, " !");
            } else {
                condition.insert(0, " ");
            }

            dbgLog.fine(i + "-th condition point(negation):" + condition.toString());

        } else {
            if (vtype > 0) {
                // range type
                StringBuilder conditionL = new StringBuilder();
                StringBuilder conditionU = new StringBuilder();

                if ((rangeSet.get(i).get(0).equals("5")) && (rangeSet.get(i).get(1).equals(""))) {
                    conditionL.append("");

                } else {
                    conditionL.append("(" + variableName + " " + rangeOpMap.get(rangeSet.get(i).get(0)) + ""
                            + rangeSet.get(i).get(1) + ")");
                }

                dbgLog.fine(i + "-th condition(Lower/upper bounds)=" + conditionL.toString());

                if ((rangeSet.get(i).get(2).equals("6")) && (rangeSet.get(i).get(3).equals(""))) {

                    conditionU.append("");

                } else {
                    String andop = null;

                    if (!(conditionL.toString()).equals("")) {
                        andop = " & ";
                    } else {
                        andop = "";
                    }

                    conditionU.append(andop + "(" + variableName + " " + rangeOpMap.get(rangeSet.get(i).get(2))
                            + " " + rangeSet.get(i).get(3) + ")");
                }

                dbgLog.fine("conditionU=" + conditionU.toString());

                condition.append(conditionL.toString() + " " + conditionU.toString());

                if (type.equals("d")) {
                    condition.insert(0, " !");
                } else {
                    condition.insert(0, " ");
                }
            } else {
                removalList.add(i);
            } // end: type check
        } // end: range type-loop

        dbgLog.fine(i + "-th " + condition.toString());

        if (i < (rangeSet.size() - 1)) {
            finalCondition.append(condition.toString() + sep);
        } else {
            finalCondition.append(condition.toString());
        }
    }

    dbgLog.fine("final condition:\n" + finalCondition.toString());

    return finalCondition.toString();

}

From source file:com.gargoylesoftware.htmlunit.NotYetImplementedTest.java

private void save() throws Exception {
    final StringBuilder builder = new StringBuilder();
    builder.append("<html><head>\n");
    builder.append("<style type=\"text/css\">\n");
    builder.append("table.bottomBorder { border-collapse:collapse; }\n");
    builder.append("table.bottomBorder td, table.bottomBorder th { "
            + "border-bottom:1px dotted black;padding:5px; }\n");
    builder.append("table.bottomBorder td.numeric { text-align:right; }\n");
    builder.append("</style>\n");
    builder.append("</head><body>\n");
    builder.append("<p>NotYetImplemented is a condition in which a test is known to fail with HtmlUnit.</p>");
    // statistics
    builder.append("<h3>Overview</h3>");
    final int overviewPos = builder.length();
    // per browser

    // details/*w w w .j av a 2 s  . co  m*/
    builder.append("<h3>Details</h3>");
    builder.append("<table class='bottomBorder'>\n");
    builder.append("  <tr><th>File</th><th>#</th><th>Method</th><th>Line</th><th>Description</th></tr>\n");
    String lastFile = null;

    int count = 0;
    int countIE11 = 0;
    int countFF31 = 0;
    int countFF38 = 0;
    int countChrome = 0;
    int countEdge = 0;
    for (final String entry : entries_) {
        final String[] values = entry.split(";");
        final String file = values[0];
        final String fileName = file.substring(file.lastIndexOf('/') + 1, file.length() - 5);
        final String method = values[1];
        final String line = values[2];
        final String browser = values[3];
        final String description = entry.endsWith(";") ? "&nbsp;"
                : values[values.length - 1].replace("__semicolon__", ";");
        builder.append("  <tr>\n");
        if (!file.equals(lastFile)) {
            int totalCount = 0;
            for (final String e : entries_) {
                if (e.startsWith(file)) {
                    totalCount++;
                }
            }
            if (totalCount != 1) {
                builder.append("    <td rowspan='" + totalCount + "'>");
            } else {
                builder.append("    <td>");
            }
            builder.append(fileName);
            builder.append("</td>\n");
            lastFile = file;
        }
        builder.append("    <td>").append(Integer.toString(count++)).append("</td>\n");
        builder.append("    <td><a href='https://sourceforge.net/p/htmlunit/code/" + "HEAD"
                + "/tree/trunk/htmlunit/" + file + "#l" + line + "'>").append(method).append("</a> ")
                .append(browser).append("</td>\n");
        builder.append("    <td class='numeric'>").append(line).append("</td>\n");
        builder.append("    <td>").append(description).append("</td>\n");
        builder.append("  </tr>\n");

        if (browser.contains("IE11")) {
            countIE11++;
        }
        if (!browser.contains("IE11") && browser.contains("IE")) {
            countIE11++;
        }

        if (browser.contains("FF31")) {
            countFF31++;
        }
        if (browser.contains("FF38")) {
            countFF38++;
        }
        if (!browser.contains("FF31") && !browser.contains("FF38") && browser.contains("FF")) {
            countFF31++;
            countFF38++;
        }
        if (browser.contains("CHROME")) {
            countChrome++;
        }
        if (browser.contains("EDGE")) {
            countEdge++;
        }
        if (browser.contains("All")) {
            countIE11++;
            countFF31++;
            countFF38++;
            countChrome++;
            countEdge++;
        }
    }
    builder.append("</table>\n").append("</body></html>");

    final StringBuilder overview = new StringBuilder();
    overview.append("<table class='bottomBorder'>\n");
    overview.append("  <tr>\n");
    overview.append("    <td class='numeric'>").append(Integer.toString(count)).append("</td>\n");
    overview.append("    <td>methods marked as NotYetImplemented</td>\n");
    overview.append("  </tr>\n");

    overview.append("  <tr>\n");
    overview.append("    <td class='numeric'>").append(Integer.toString(countIE11)).append("</td>\n");
    overview.append("    <td>for IE11</td>\n");
    overview.append("  </tr>\n");

    overview.append("  <tr>\n");
    overview.append("    <td class='numeric'>").append(Integer.toString(countFF31)).append("</td>\n");
    overview.append("    <td>for FF31</td>\n");
    overview.append("  </tr>\n");

    overview.append("  <tr>\n");
    overview.append("    <td class='numeric'>").append(Integer.toString(countFF38)).append("</td>\n");
    overview.append("    <td>for FF38</td>\n");
    overview.append("  </tr>\n");

    overview.append("  <tr>\n");
    overview.append("    <td class='numeric'>").append(Integer.toString(countChrome)).append("</td>\n");
    overview.append("    <td>for Chrome</td>\n");
    overview.append("  </tr>\n");

    overview.append("  <tr>\n");
    overview.append("    <td class='numeric'>").append(Integer.toString(countEdge)).append("</td>\n");
    overview.append("    <td>for Edge</td>\n");
    overview.append("  </tr>\n");

    overview.append("</table>\n");

    builder.insert(overviewPos, overview);

    FileUtils.writeStringToFile(new File(ElementPropertiesTest.getTargetDirectory(), "notYetImplemented.html"),
            builder.toString());
}

From source file:com.arksoft.epamms.ZGlobal1_Operation.java

/**  these do not seem to be used in Zencas ... good thing because of the global buffer usage.
////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  Method Name: ReadLineToLongPointer//from w ww . ja  v a 2  s. com
//
// Read a line passing the pointer back as a LONG
//
public int
ReadLineIntoGlobalBuffer( View  ViewToWindow, int hFile )
{
   int nRC;
        
   nRC = SysReadLine( ViewToWindow, lpBufferArea, hFile );
        
   return nRC;
        
} // ReadLineToLongPointer
        
public int
SetAttributeFromTabField( View   mCustO,
                     String lpEntityName,
                     String lpAttributeName,
                     int    lFieldPosition )
{
   StringBuffer sb;
   String lpNext;
   int    k;
   int    nRC;
        
   // Position on field based on Field position, assuming fields are delineated by tabs.
   sb = lpBufferArea;
        
   for ( k = lFieldPosition; k > 1; k-- )
   {
 for ( lpNext = sb; *lpNext != '\t'; lpNext++ )
 {
   ;
 }
        
 sb = lpNext + 1;
   }
        
   // Find next tab to change to string end.
   for ( lpNext = sb; *lpNext != '\t'; lpNext++ )
   {
 ;
   }
        
   *lpNext = 0;
        
   // Set the Attribute value.
   nRC = SetAttributeFromString( mCustO, lpEntityName, lpAttributeName, sb );
        
   // Set string end back to tab.
   *lpNext = '\t';
        
   return nRC;
}
**/

////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  Method Name: SeparateName
//
// Separate a name into first and last names
//
public int SeparateName(String fullName, StringBuilder firstName, StringBuilder lastName) {
    // String lpNext;
    int k = 0;
    int nLth = fullName.length();

    String s = fullName.trim(); // remove whitespace from beginning and end of FullName

    // Eliminate any "Mr." or "Ms." characters in front of the name and then point to first non-blank.
    if (s.charAt(k) == 'M' && (s.charAt(k + 1) == 'r' || s.charAt(k + 1) == 's') && s.charAt(k + 2) == '.') {
        k = 3;
        while (s.charAt(k) == ' ')
            k++;
    }

    // put original string into an array of chars
    //
    // char[] charArray = new char[ nLth + 1 ];  // we are eliminating characters, so this should be plenty of room
    int j = 0;
    int nLastBegin = 0;
    // int nFirstEnd = 0;
    while (k <= nLth) {
        if (nLastBegin == 0) {
            if (s.charAt(k) == ' ' || s.charAt(k) == '\t') {
                // nFirstEnd = k;
                firstName.insert(j++, '\0'); // terminate first name
                nLastBegin = k + 1;

                // Skip to next non-blank or end of string.
                while (s.charAt(nLastBegin) == ' ' || s.charAt(nLastBegin) == '\t')
                    nLastBegin++;

                j = 0; // process last name
                while (nLastBegin <= nLth)
                    lastName.insert(j++, s.charAt(nLastBegin++));

                break; // out of outer while loop
            } else {
                firstName.insert(j++, s.charAt(k++)); // process the First Name (all chars to the first blank)
            }
        }
    }

    return 0;
}