Example usage for java.lang StringBuffer setLength

List of usage examples for java.lang StringBuffer setLength

Introduction

In this page you can find the example usage for java.lang StringBuffer setLength.

Prototype

@Override
public synchronized void setLength(int newLength) 

Source Link

Usage

From source file:org.ojbc.bundles.adapters.staticmock.StaticMockQuery.java

static String buildIncidentSearchXPathFromIncidentSearchMessage(Document incidentSearchRequestMessage)
        throws Exception {

    String incidentNumber = XmlUtils.xPathStringSearch(incidentSearchRequestMessage,
            "/isr-doc:IncidentSearchRequest/isr:Incident/nc:ActivityIdentification/nc:IdentificationID");
    String incidentCategory = XmlUtils.xPathStringSearch(incidentSearchRequestMessage,
            "/isr-doc:IncidentSearchRequest/isr:Incident/isr:IncidentCategoryCode");
    String city = XmlUtils.xPathStringSearch(incidentSearchRequestMessage,
            "/isr-doc:IncidentSearchRequest/nc:Location/nc:LocationAddress/isr:StructuredAddress/incident-location-codes-demostate:LocationCityTownCode");

    List<String> conditions = new ArrayList<String>();

    if (incidentNumber != null && incidentNumber.trim().length() > 0) {
        conditions.add(/* www .  j a v a2  s .c o m*/
                "lexs:Digest/lexsdigest:EntityActivity/nc:Activity[nc:ActivityCategoryText='Incident']/nc:ActivityIdentification/nc:IdentificationID='"
                        + incidentNumber + "'");
    }

    if (city != null && city.trim().length() > 0) {
        conditions.add(
                "lexs:Digest/lexsdigest:EntityLocation/nc:Location[nc:LocationAddress/nc:StructuredAddress/nc:LocationCityName='"
                        + city
                        + "' and @s:id=/ir:IncidentReport/lexspd:doPublish/lexs:PublishMessageContainer/lexs:PublishMessage/lexs:DataItemPackage/lexs:Digest/lexsdigest:Associations/lexsdigest:IncidentLocationAssociation/nc:LocationReference/@s:ref]");
    }

    if (incidentCategory != null && incidentCategory.trim().length() > 0) {
        conditions.add(
                "lexs:StructuredPayload/inc-ext:IncidentReport/inc-ext:Incident[inc-ext:IncidentCategoryCode='"
                        + incidentCategory + "']");
    }

    if (conditions.isEmpty()) {
        return null;
    }

    StringBuffer xPath = new StringBuffer();
    xPath.append(
            "/ir:IncidentReport/lexspd:doPublish/lexs:PublishMessageContainer/lexs:PublishMessage/lexs:DataItemPackage[");

    for (String condition : conditions) {
        xPath.append(condition).append(" and ");
    }
    xPath.setLength(xPath.length() - 5);

    xPath.append("]");

    return xPath.toString();
}

From source file:org.ojbc.bundles.adapters.staticmock.StaticMockQuery.java

static String buildIncidentSearchXPathFromVehicleSearchMessage(Document vehicleSearchRequestMessage)
        throws Exception {

    String vin = XmlUtils.xPathStringSearch(vehicleSearchRequestMessage,
            "/vsr-doc:VehicleSearchRequest/vsr:Vehicle/nc:VehicleIdentification/nc:IdentificationID");
    String color = XmlUtils.xPathStringSearch(vehicleSearchRequestMessage,
            "/vsr-doc:VehicleSearchRequest/vsr:Vehicle/nc:VehicleColorPrimaryCode");
    String model = XmlUtils.xPathStringSearch(vehicleSearchRequestMessage,
            "/vsr-doc:VehicleSearchRequest/vsr:Vehicle/nc:ItemModelName");
    String plate = XmlUtils.xPathStringSearch(vehicleSearchRequestMessage,
            "/vsr-doc:VehicleSearchRequest/vsr:Vehicle/nc:ConveyanceRegistrationPlateIdentification/nc:IdentificationID");
    String make = XmlUtils.xPathStringSearch(vehicleSearchRequestMessage,
            "/vsr-doc:VehicleSearchRequest/vsr:Vehicle/vsr:VehicleMakeCode");

    List<String> conditions = new ArrayList<String>();

    if (vin != null && vin.trim().length() > 0) {
        conditions.add(/*from  w  w  w.jav a  2 s.com*/
                "lexs:Digest/lexsdigest:EntityVehicle/nc:Vehicle/nc:VehicleIdentification/nc:IdentificationID='"
                        + vin + "'");
    }
    if (plate != null && plate.trim().length() > 0) {
        conditions.add(
                "lexs:Digest/lexsdigest:EntityVehicle/nc:Vehicle/nc:ConveyanceRegistrationPlateIdentification/nc:IdentificationID='"
                        + plate + "'");
    }
    if (color != null && color.trim().length() > 0) {
        conditions.add(
                "lexs:Digest/lexsdigest:EntityVehicle/nc:Vehicle/nc:VehicleColorPrimaryCode='" + color + "'");
    }
    if (model != null && model.trim().length() > 0) {
        conditions.add("lexs:Digest/lexsdigest:EntityVehicle/nc:Vehicle/nc:VehicleModelCode='" + model + "'");
    }
    if (make != null && make.trim().length() > 0) {
        conditions.add("lexs:Digest/lexsdigest:EntityVehicle/nc:Vehicle/nc:VehicleMakeCode='" + make + "'");
    }

    if (conditions.isEmpty()) {
        return null;
    }

    StringBuffer xPath = new StringBuffer();
    xPath.append(
            "/ir:IncidentReport/lexspd:doPublish/lexs:PublishMessageContainer/lexs:PublishMessage/lexs:DataItemPackage[");

    for (String condition : conditions) {
        xPath.append(condition).append(" and ");
    }
    xPath.setLength(xPath.length() - 5);

    xPath.append("]");

    return xPath.toString();
}

From source file:org.eclipse.wb.tests.designer.core.model.ObjectInfoTest.java

/**
 * Test for {@link ObjectInfo#addChild(ObjectInfo)} broadcast.
 *//*from ww  w  .  j  a v a 2s .co  m*/
public void test_broadcast() throws Exception {
    TestObjectInfo parent = new TestObjectInfo("parent");
    TestObjectInfo child_1 = new TestObjectInfo("child_1");
    TestObjectInfo child_2 = new TestObjectInfo("child_2");
    // add listener
    final StringBuffer buffer = new StringBuffer();
    parent.addBroadcastListener(new ObjectInfoChildAddBefore() {
        public void invoke(ObjectInfo _parent, ObjectInfo _child, ObjectInfo[] nextChild) {
            buffer.append("childAddBefore " + _parent + " " + _child + "\n");
        }
    });
    parent.addBroadcastListener(new ObjectInfoChildAddAfter() {
        public void invoke(ObjectInfo _parent, ObjectInfo _child) {
            buffer.append("childAddAfter " + _parent + " " + _child + "\n");
        }
    });
    ObjectEventListener listener = new ObjectEventListener() {
        @Override
        public void childRemoveBefore(ObjectInfo _parent, ObjectInfo _child) throws Exception {
            buffer.append("childRemoveBefore " + _parent + " " + _child + "\n");
        }
    };
    parent.addBroadcastListener(listener);
    // do operations
    parent.addChild(child_1);
    child_1.addChild(child_2);
    assertEquals(
            "childAddBefore parent child_1\n" + "childAddAfter parent child_1\n"
                    + "childAddBefore child_1 child_2\n" + "childAddAfter child_1 child_2\n",
            buffer.toString());
    // remove listener and do more operations
    {
        buffer.setLength(0);
        // remove listener
        parent.removeBroadcastListener(listener);
        // do operation
        assertEquals("", buffer.toString());
        parent.removeChild(child_1);
        // no log expected
        assertEquals("", buffer.toString());
    }
}

From source file:cc.siara.csv_ml_demo.MultiLevelCSVSwingDemo.java

/**
 * Evaluates given XPath from Input box against Document generated by
 * parsing csv_ml in input box and sets value or node list to output box.
 *//*from ww  w.  j av a2  s.c  om*/
private void processXPath() {
    XPath xpath = XPathFactory.newInstance().newXPath();
    Document doc = parseInputToDOM();
    if (doc == null)
        return;
    StringBuffer out_str = new StringBuffer();
    try {
        XPathExpression expr = xpath.compile(tfXPath.getText());
        try {
            Document outDoc = Util.parseXMLToDOM("<output></output>");
            Element rootElement = outDoc.getDocumentElement();
            NodeList ret = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
            for (int i = 0; i < ret.getLength(); i++) {
                Object o = ret.item(i);
                if (o instanceof String) {
                    out_str.append(o);
                } else if (o instanceof Node) {
                    Node n = (Node) o;
                    short nt = n.getNodeType();
                    switch (nt) {
                    case Node.TEXT_NODE:
                    case Node.ATTRIBUTE_NODE:
                    case Node.CDATA_SECTION_NODE: // Only one value gets
                                                  // evaluated?
                        if (out_str.length() > 0)
                            out_str.append(',');
                        if (nt == Node.ATTRIBUTE_NODE)
                            out_str.append(n.getNodeValue());
                        else
                            out_str.append(n.getTextContent());
                        break;
                    case Node.ELEMENT_NODE:
                        rootElement.appendChild(outDoc.importNode(n, true));
                        break;
                    }
                }
            }
            if (out_str.length() > 0) {
                rootElement.setTextContent(out_str.toString());
                out_str.setLength(0);
            }
            out_str.append(Util.docToString(outDoc, true));
        } catch (Exception e) {
            // Thrown most likely because the given XPath evaluates to a
            // string
            out_str.append(expr.evaluate(doc));
        }
    } catch (XPathExpressionException e) {
        e.printStackTrace();
    }
    taOutput.setText(out_str.toString());
    tfOutputSize.setText(String.valueOf(out_str.length()));
}

From source file:org.kuali.rice.kim.impl.identity.PersonServiceImpl.java

/**
 * @see org.kuali.rice.kim.api.identity.PersonService#resolvePrincipalNamesToPrincipalIds(org.kuali.rice.krad.bo.BusinessObject, java.util.Map)
 *//*  w  w w . j a v  a  2 s  .com*/
@Override
@SuppressWarnings("unchecked")
public Map<String, String> resolvePrincipalNamesToPrincipalIds(BusinessObject businessObject,
        Map<String, String> fieldValues) {
    if (fieldValues == null) {
        return null;
    }
    if (businessObject == null) {
        return fieldValues;
    }
    StringBuffer resolvedPrincipalIdPropertyName = new StringBuffer();
    // save off all criteria which are not references to Person properties
    // leave person properties out so they can be resolved and replaced by this method
    Map<String, String> processedFieldValues = getNonPersonSearchCriteria(businessObject, fieldValues);
    for (String propertyName : fieldValues.keySet()) {
        if (!StringUtils.isBlank(fieldValues.get(propertyName)) // property has a value
                && isPersonProperty(businessObject, propertyName) // is a property on a Person object
        ) {
            // strip off the prefix on the property
            int lastPropertyIndex = PropertyAccessorUtils.getLastNestedPropertySeparatorIndex(propertyName);
            String personPropertyName = lastPropertyIndex != -1
                    ? StringUtils.substring(propertyName, lastPropertyIndex + 1)
                    : propertyName;
            // special case - the user ID
            if (StringUtils.equals(KIMPropertyConstants.Person.PRINCIPAL_NAME, personPropertyName)) {
                Class targetBusinessObjectClass = null;
                BusinessObject targetBusinessObject = null;
                resolvedPrincipalIdPropertyName.setLength(0); // clear the buffer without requiring a new object allocation on each iteration
                // get the property name up until the ".principalName"
                // this should be a reference to the Person object attached to the BusinessObject
                String personReferenceObjectPropertyName = lastPropertyIndex != -1
                        ? StringUtils.substring(propertyName, 0, lastPropertyIndex)
                        : StringUtils.EMPTY;
                // check if the person was nested within another BO under the master BO.  If so, go up one more level
                // otherwise, use the passed in BO class as the target class
                if (PropertyAccessorUtils.isNestedOrIndexedProperty(personReferenceObjectPropertyName)) {
                    int lastTargetIndex = PropertyAccessorUtils
                            .getLastNestedPropertySeparatorIndex(personReferenceObjectPropertyName);
                    String targetBusinessObjectPropertyName = lastTargetIndex != -1
                            ? StringUtils.substring(personReferenceObjectPropertyName, 0, lastTargetIndex)
                            : StringUtils.EMPTY;
                    DataObjectWrapper<BusinessObject> wrapper = KradDataServiceLocator.getDataObjectService()
                            .wrap(businessObject);
                    targetBusinessObject = (BusinessObject) wrapper
                            .getPropertyValueNullSafe(targetBusinessObjectPropertyName);
                    if (targetBusinessObject != null) {
                        targetBusinessObjectClass = targetBusinessObject.getClass();
                        resolvedPrincipalIdPropertyName.append(targetBusinessObjectPropertyName).append(".");
                    } else {
                        LOG.error("Could not find target property '" + propertyName + "' in class "
                                + businessObject.getClass().getName() + ". Property value was null.");
                    }
                } else { // not a nested Person property
                    targetBusinessObjectClass = businessObject.getClass();
                    targetBusinessObject = businessObject;
                }

                if (targetBusinessObjectClass != null) {
                    // use the relationship metadata in the KNS to determine the property on the
                    // host business object to put back into the map now that the principal ID
                    // (the value stored in application tables) has been resolved
                    int lastIndex = PropertyAccessorUtils
                            .getLastNestedPropertySeparatorIndex(personReferenceObjectPropertyName);
                    String propName = lastIndex != -1
                            ? StringUtils.substring(personReferenceObjectPropertyName, lastIndex + 1)
                            : personReferenceObjectPropertyName;
                    DataObjectRelationship rel = getBusinessObjectMetaDataService()
                            .getBusinessObjectRelationship(targetBusinessObject, propName);
                    if (rel != null) {
                        String sourcePrimitivePropertyName = rel
                                .getParentAttributeForChildAttribute(KIMPropertyConstants.Person.PRINCIPAL_ID);
                        resolvedPrincipalIdPropertyName.append(sourcePrimitivePropertyName);
                        // get the principal - for translation of the principalName to principalId
                        String principalName = fieldValues.get(propertyName);
                        Principal principal = getIdentityService().getPrincipalByPrincipalName(principalName);
                        if (principal != null) {
                            processedFieldValues.put(resolvedPrincipalIdPropertyName.toString(),
                                    principal.getPrincipalId());
                        } else {
                            processedFieldValues.put(resolvedPrincipalIdPropertyName.toString(), null);
                            try {
                                // if the principalName is bad, then we need to clear out the Person object
                                // and base principalId property
                                // so that their values are no longer accidentally used or re-populate
                                // the object
                                KRADUtils.setObjectProperty(targetBusinessObject,
                                        resolvedPrincipalIdPropertyName.toString(), null);
                                KRADUtils.setObjectProperty(targetBusinessObject, propName, null);
                                KRADUtils.setObjectProperty(targetBusinessObject, propName + ".principalName",
                                        principalName);
                            } catch (Exception ex) {
                                LOG.error(
                                        "Unable to blank out the person object after finding that the person with the given principalName does not exist.",
                                        ex);
                            }
                        }
                    } else {
                        LOG.error("Missing relationship for " + propName + " on "
                                + targetBusinessObjectClass.getName());
                    }
                } else { // no target BO class - the code below probably will not work
                    processedFieldValues.put(resolvedPrincipalIdPropertyName.toString(), null);
                }
            }
            // if the property does not seem to match the definition of a Person property but it
            // does end in principalName then...
            // this is to handle the case where the user ID is on an ADD line - a case excluded from isPersonProperty()
        } else if (propertyName.endsWith("." + KIMPropertyConstants.Person.PRINCIPAL_NAME)) {
            // if we're adding to a collection and we've got the principalName; let's populate universalUser
            String principalName = fieldValues.get(propertyName);
            if (StringUtils.isNotEmpty(principalName)) {
                String containerPropertyName = propertyName;
                if (containerPropertyName.startsWith(KRADConstants.MAINTENANCE_ADD_PREFIX)) {
                    containerPropertyName = StringUtils.substringAfter(propertyName,
                            KRADConstants.MAINTENANCE_ADD_PREFIX);
                }
                // get the class of the object that is referenced by the property name
                // if this is not true then there's a principalName collection or primitive attribute
                // directly on the BO on the add line, so we just ignore that since something is wrong here
                if (PropertyAccessorUtils.isNestedOrIndexedProperty(containerPropertyName)) {
                    // the first part of the property is the collection name
                    String collectionName = StringUtils.substringBefore(containerPropertyName, ".");
                    // what is the class held by that collection?
                    // JHK: I don't like this.  This assumes that this method is only used by the maintenance
                    // document service.  If that will always be the case, this method should be moved over there.
                    Class<? extends BusinessObject> collectionBusinessObjectClass = getMaintenanceDocumentDictionaryService()
                            .getCollectionBusinessObjectClass(getMaintenanceDocumentDictionaryService()
                                    .getDocumentTypeName(businessObject.getClass()), collectionName);
                    if (collectionBusinessObjectClass != null) {
                        // we are adding to a collection; get the relationships for that object;
                        // is there one for personUniversalIdentifier?
                        List<DataObjectRelationship> relationships = getBusinessObjectMetaDataService()
                                .getBusinessObjectRelationships(collectionBusinessObjectClass);
                        // JHK: this seems like a hack - looking at all relationships for a BO does not guarantee that we get the right one
                        // JHK: why not inspect the objects like above?  Is it the property path problems because of the .add. portion?
                        for (DataObjectRelationship rel : relationships) {
                            String parentAttribute = rel.getParentAttributeForChildAttribute(
                                    KIMPropertyConstants.Person.PRINCIPAL_ID);
                            if (parentAttribute == null) {
                                continue;
                            }
                            // there is a relationship for personUserIdentifier; use that to find the universal user
                            processedFieldValues.remove(propertyName);
                            String fieldPrefix = StringUtils
                                    .substringBeforeLast(StringUtils.substringBeforeLast(propertyName,
                                            "." + KIMPropertyConstants.Person.PRINCIPAL_NAME), ".");
                            String relatedPrincipalIdPropertyName = fieldPrefix + "." + parentAttribute;
                            // KR-683 Special handling for extension objects
                            if (EXTENSION.equals(StringUtils.substringAfterLast(fieldPrefix, "."))
                                    && EXTENSION.equals(StringUtils.substringBefore(parentAttribute, "."))) {
                                relatedPrincipalIdPropertyName = fieldPrefix + "."
                                        + StringUtils.substringAfter(parentAttribute, ".");
                            }
                            String currRelatedPersonPrincipalId = processedFieldValues
                                    .get(relatedPrincipalIdPropertyName);
                            if (StringUtils.isBlank(currRelatedPersonPrincipalId)) {
                                Principal principal = getIdentityService()
                                        .getPrincipalByPrincipalName(principalName);
                                if (principal != null) {
                                    processedFieldValues.put(relatedPrincipalIdPropertyName,
                                            principal.getPrincipalId());
                                } else {
                                    processedFieldValues.put(relatedPrincipalIdPropertyName, null);
                                }
                            }
                        } // relationship loop
                    } else {
                        if (LOG.isDebugEnabled()) {
                            LOG.debug(
                                    "Unable to determine class for collection referenced as part of property: "
                                            + containerPropertyName + " on "
                                            + businessObject.getClass().getName());
                        }
                    }
                } else {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Non-nested property ending with 'principalName': " + containerPropertyName
                                + " on " + businessObject.getClass().getName());
                    }
                }
            }
        }
    }
    return processedFieldValues;
}

From source file:com.lfv.lanzius.server.WorkspaceView.java

@Override
protected void paintComponent(Graphics g) {
    int w = getWidth();
    int h = getHeight();

    Document doc = server.getDocument();

    Color storedCol = g.getColor();
    Font storedFont = g.getFont();

    // Fill workspace area
    g.setColor(getBackground());/* ww  w  . ja v  a2  s .c o  m*/
    g.fillRect(0, 0, w, h);

    // Should the cached version be updated?
    int updateDocumentVersion = server.getDocumentVersion();
    boolean update = (documentVersion != updateDocumentVersion);

    // Check if we have cached the latest document version, otherwise cache the terminals
    if (update) {
        log.debug("Updating view to version " + updateDocumentVersion);
        terminalMap.clear();
        groupList.clear();
        if (doc != null) {
            synchronized (doc) {

                // Clear the visible attribute on all groups
                // except the started or paused ones
                Element egd = doc.getRootElement().getChild("GroupDefs");
                Iterator iter = egd.getChildren().iterator();
                while (iter.hasNext()) {
                    Element eg = (Element) iter.next();
                    boolean isVisible = !DomTools.getAttributeString(eg, "state", "stopped", false)
                            .equals("stopped");
                    eg.setAttribute("visible", String.valueOf(isVisible));
                }

                // Gather information about terminals and cache it
                Element etd = doc.getRootElement().getChild("TerminalDefs");
                iter = etd.getChildren().iterator();
                while (iter.hasNext()) {
                    Element et = (Element) iter.next();
                    int tid = DomTools.getAttributeInt(et, "id", 0, false);
                    if (tid > 0) {
                        // Create terminal and add it to list
                        Terminal t = new Terminal(tid, DomTools.getAttributeInt(et, "x", 0, false),
                                DomTools.getAttributeInt(et, "y", 0, false),
                                DomTools.getChildText(et, "Name", "T/" + tid, false),
                                DomTools.getAttributeBoolean(et, "online", false, false),
                                DomTools.getAttributeBoolean(et, "selected", false, false));
                        terminalMap.put(tid, t);

                        // Is the terminal monitored?
                        t.isMonitored = DomTools.getAttributeBoolean(et, "monitored", false, false);

                        // Examine the Player element under PlayerSetup
                        t.groupColor = null;
                        Element ep = DomTools.getElementFromSection(doc, "PlayerSetup", "terminalid",
                                String.valueOf(tid));

                        // Has linked player for this terminal
                        if (ep != null) {
                            StringBuffer sb = new StringBuffer();

                            // Append player name
                            sb.append(DomTools.getChildText(ep, "Name", "P/?", true));
                            sb.append(" (");

                            // Append role list
                            boolean hasRoles = false;
                            Element ers = ep.getChild("RoleSetup");
                            if (ers != null) {
                                Iterator iterr = ers.getChildren().iterator();

                                while (iterr.hasNext()) {
                                    Element er = (Element) iterr.next();
                                    String id = er.getAttributeValue("id");
                                    er = DomTools.getElementFromSection(doc, "RoleDefs", "id", id);
                                    if (er != null) {
                                        sb.append(DomTools.getChildText(er, "Name", "R/" + id, false));
                                        sb.append(", ");
                                        hasRoles = true;
                                    }
                                }
                                if (hasRoles) {
                                    // Trim last comma
                                    int len = sb.length();
                                    sb.setLength(Math.max(len - 2, 0));
                                }
                                sb.append(")");
                            }
                            t.roles = sb.toString();

                            // Is the player relocated?
                            t.isRelocated = DomTools.getAttributeBoolean(ep, "relocated", false, false);

                            // Get group name and color
                            Element eg = DomTools.getElementFromSection(doc, "GroupDefs", "id",
                                    DomTools.getAttributeString(ep, "groupid", "0", true));
                            t.groupColor = Color.lightGray;
                            if (eg != null) {
                                String sc = DomTools.getChildText(eg, "Color", null, false);
                                if (sc != null) {
                                    try {
                                        t.groupColor = Color.decode(sc);
                                    } catch (NumberFormatException ex) {
                                        log.warn("Invalid color attribute on Group node, defaulting to grey");
                                    }
                                }
                                //t.name += "  "+DomTools.getChildText(eg, "Name", "G/"+eg.getAttributeValue("id"), false);
                                t.groupName = DomTools.getChildText(eg, "Name",
                                        "G/" + eg.getAttributeValue("id"), false);

                                // This group should now be visible
                                eg.setAttribute("visible", "true");
                            } else
                                log.warn("Invalid groupid attribute on Player node, defaulting to grey");
                        }
                    } else
                        log.error("Invalid id attribute on Terminal node, skipping");
                }

                // Gather information about groups and cache it
                iter = egd.getChildren().iterator();
                while (iter.hasNext()) {
                    Element eg = (Element) iter.next();
                    if (DomTools.getAttributeBoolean(eg, "visible", false, false)) {
                        int gid = DomTools.getAttributeInt(eg, "id", 0, true);
                        if (gid > 0) {
                            Group grp = new Group(gid, DomTools.getChildText(eg, "Name", "G/" + gid, false),
                                    DomTools.getAttributeBoolean(eg, "selected", false, false));
                            groupList.add(grp);

                            // group color
                            String sc = DomTools.getChildText(eg, "Color", null, false);
                            if (sc != null) {
                                try {
                                    grp.color = Color.decode(sc);
                                } catch (NumberFormatException ex) {
                                    log.warn("Invalid color attribute on Group node, defaulting to grey");
                                }
                            }

                            // state color
                            grp.stateColor = Color.red;
                            String state = DomTools.getAttributeString(eg, "state", "stopped", false);
                            if (state.equals("started"))
                                grp.stateColor = Color.green;
                            else if (state.equals("paused"))
                                grp.stateColor = Color.orange;
                        }
                    }
                }
            }
        }
    }

    if (doc == null) {
        g.setColor(Color.black);
        String text = "No configuration loaded. Select 'Load configuration...' from the file menu.";
        g.drawString(text, (w - SwingUtilities.computeStringWidth(g.getFontMetrics(), text)) / 2, h * 5 / 12);
    } else {
        g.setFont(new Font("Dialog", Font.BOLD, 13));

        Iterator<Terminal> itert = terminalMap.values().iterator();
        while (itert.hasNext()) {
            Terminal t = itert.next();

            // Draw box
            int b = t.isSelected ? SERVERVIEW_SELECTION_BORDER : 1;
            g.setColor(Color.black);
            g.fillRect(t.x + SERVERVIEW_SELECTION_BORDER - b, t.y + SERVERVIEW_SELECTION_BORDER - b,
                    SERVERVIEW_TERMINAL_WIDTH + 2 * b, SERVERVIEW_TERMINAL_HEIGHT + 2 * b);
            g.setColor(t.groupColor == null ? Color.white : t.groupColor);
            g.fillRect(t.x + SERVERVIEW_SELECTION_BORDER, t.y + SERVERVIEW_SELECTION_BORDER,
                    SERVERVIEW_TERMINAL_WIDTH, SERVERVIEW_TERMINAL_HEIGHT);

            // Inner areas
            Rectangle r = new Rectangle(t.x + SERVERVIEW_SELECTION_BORDER + SERVERVIEW_TERMINAL_BORDER,
                    t.y + SERVERVIEW_SELECTION_BORDER + SERVERVIEW_TERMINAL_BORDER,
                    SERVERVIEW_TERMINAL_WIDTH - 2 * SERVERVIEW_TERMINAL_BORDER,
                    g.getFontMetrics().getHeight() + 4);

            g.setColor(Color.white);
            g.fillRect(r.x, r.y, r.width, r.height);
            g.fillRect(r.x, r.y + r.height + SERVERVIEW_TERMINAL_BORDER + 2, r.width,
                    SERVERVIEW_TERMINAL_HEIGHT - 3 * SERVERVIEW_TERMINAL_BORDER - r.height - 2);
            g.setColor(Color.black);
            g.drawRect(r.x, r.y, r.width, r.height);
            g.drawRect(r.x, r.y + r.height + SERVERVIEW_TERMINAL_BORDER + 2, r.width,
                    SERVERVIEW_TERMINAL_HEIGHT - 3 * SERVERVIEW_TERMINAL_BORDER - r.height - 2);

            // Name of terminal and group
            if (server.isaClient(t.tid)) {
                g.drawImage(indicatorIsa.getImage(), r.x + r.width - 20, r.y + SERVERVIEW_TERMINAL_HEIGHT - 26,
                        null);
            }
            g.drawString(t.name + " " + t.groupName, r.x + 4, r.y + r.height - 4);

            double px = r.x + 4;
            double py = r.y + r.height + SERVERVIEW_TERMINAL_BORDER + 5;

            // Draw monitored indicator
            if (t.isMonitored) {
                g.drawImage(indicatorMonitored.getImage(), r.x + r.width - 9, r.y + 3, null);
            }

            // Draw relocated indicator
            if (t.isRelocated) {
                g.drawImage(indicatorRelocated.getImage(), r.x + r.width - 9, r.y + 13, null);
            }

            // Draw online indicator
            r.setBounds(r.x, r.y + r.height, r.width, 3);
            g.setColor(t.isOnline ? Color.green : Color.red);
            g.fillRect(r.x, r.y, r.width, r.height);
            g.setColor(Color.black);
            g.drawRect(r.x, r.y, r.width, r.height);

            // Roles
            if (t.roles.length() > 0) {
                LineBreakMeasurer lbm = new LineBreakMeasurer(new AttributedString(t.roles).getIterator(),
                        new FontRenderContext(null, false, true));

                TextLayout layout;
                while ((layout = lbm
                        .nextLayout(SERVERVIEW_TERMINAL_WIDTH - 2 * SERVERVIEW_TERMINAL_BORDER)) != null) {
                    if (py < t.y + SERVERVIEW_TERMINAL_HEIGHT) {
                        py += layout.getAscent();
                        layout.draw((Graphics2D) g, (int) px, (int) py);
                        py += layout.getDescent() + layout.getLeading();
                    }
                }
            }
        }

        // Draw group indicators
        int nbrGroupsInRow = w
                / (2 * Constants.SERVERVIEW_SELECTION_BORDER + 2 + Constants.SERVERVIEW_GROUP_WIDTH);
        if (nbrGroupsInRow < 1)
            nbrGroupsInRow = 1;
        int nbrGroupRows = (groupList.size() + nbrGroupsInRow - 1) / nbrGroupsInRow;

        int innerWidth = Constants.SERVERVIEW_GROUP_WIDTH;
        int innerHeight = g.getFontMetrics().getHeight() + 5;

        int outerWidth = innerWidth + 2 * Constants.SERVERVIEW_SELECTION_BORDER + 2;
        int outerHeight = innerHeight + 2 * Constants.SERVERVIEW_SELECTION_BORDER + 2;

        int x = 0;
        int y = h - outerHeight * nbrGroupRows;

        g.setColor(Color.white);
        g.fillRect(0, y, w, h - y);
        g.setColor(Color.black);
        g.drawLine(0, y - 1, w - 1, y - 1);

        Iterator<Group> iterg = groupList.iterator();
        while (iterg.hasNext()) {
            Group grp = iterg.next();

            // Group box
            grp.boundingRect.setBounds(x, y, outerWidth, outerHeight);
            int b = grp.isSelected ? Constants.SERVERVIEW_SELECTION_BORDER : 1;
            g.setColor(Color.black);
            g.fillRect(x + Constants.SERVERVIEW_SELECTION_BORDER - b + 1,
                    y + Constants.SERVERVIEW_SELECTION_BORDER - b + 1, innerWidth + 2 * b, innerHeight + 2 * b);
            g.setColor(grp.color);
            g.fillRect(x + Constants.SERVERVIEW_SELECTION_BORDER + 1,
                    y + Constants.SERVERVIEW_SELECTION_BORDER + 1, innerWidth, innerHeight);

            g.setColor(Color.black);
            g.drawString(grp.name, x + Constants.SERVERVIEW_SELECTION_BORDER + 4,
                    y + Constants.SERVERVIEW_SELECTION_BORDER + innerHeight - 4 + 1);

            // Draw started indicator
            g.setColor(grp.stateColor);
            g.fillRect(x + Constants.SERVERVIEW_SELECTION_BORDER + 1,
                    y + Constants.SERVERVIEW_SELECTION_BORDER + 1, innerWidth, 2);
            g.setColor(Color.black);
            g.drawLine(x + Constants.SERVERVIEW_SELECTION_BORDER + 1,
                    y + Constants.SERVERVIEW_SELECTION_BORDER + 3,
                    x + Constants.SERVERVIEW_SELECTION_BORDER + 1 + innerWidth,
                    y + Constants.SERVERVIEW_SELECTION_BORDER + 3);

            x += outerWidth;
            if ((x + outerWidth) > w) {
                x = 0;
                y += outerHeight;
            }
        }
    }

    // Store cached version
    documentVersion = updateDocumentVersion;

    g.setColor(storedCol);
    g.setFont(storedFont);
}

From source file:ExposedFloat.java

void updateNumberFields() {

    int intBits = Float.floatToIntBits(value);

    if (Float.isNaN(value)) {
        base10Field.setText(notANumberString);
    } else if (Float.isInfinite(value)) {
        if ((intBits >>> 31) == 1) {
            // This is a negative infinity
            base10Field.setText(negativeInfinityString);
        } else {//  w w  w .j  a v a2  s  .  co m
            // This is a positive infinity
            base10Field.setText(positiveInfinityString);
        }
    } else if (intBits == (int) 0x80000000) {
        base10Field.setText("-0");
    } else {
        base10Field.setText(Float.toString(value));
    }

    int v = intBits;
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < 8; ++i) {
        // Get lowest bit
        int remainder = v & 0xf;

        // Convert bit to a character and insert it into the beginning of the string
        switch (remainder) {
        case 0:
            buf.insert(0, "0");
            break;
        case 1:
            buf.insert(0, "1");
            break;
        case 2:
            buf.insert(0, "2");
            break;
        case 3:
            buf.insert(0, "3");
            break;
        case 4:
            buf.insert(0, "4");
            break;
        case 5:
            buf.insert(0, "5");
            break;
        case 6:
            buf.insert(0, "6");
            break;
        case 7:
            buf.insert(0, "7");
            break;
        case 8:
            buf.insert(0, "8");
            break;
        case 9:
            buf.insert(0, "9");
            break;
        case 10:
            buf.insert(0, "a");
            break;
        case 11:
            buf.insert(0, "b");
            break;
        case 12:
            buf.insert(0, "c");
            break;
        case 13:
            buf.insert(0, "d");
            break;
        case 14:
            buf.insert(0, "e");
            break;
        case 15:
            buf.insert(0, "f");
            break;
        }

        // Shift the int to the right one bit
        v >>>= 4;
    }
    hexField.setText(buf.toString());

    v = intBits;
    buf.setLength(0);
    for (int i = 0; i < 32; ++i) {
        // Get lowest bit
        int remainder = v & 0x1;

        // Convert bit to a character and insert it into the beginning of the string
        if (remainder == 0) {
            buf.insert(0, "0");
        } else {
            buf.insert(0, "1");
        }

        // Shift the int to the right one bit
        v >>>= 1;
    }
    binaryField.setText(buf.toString());

    if (intBits < 0) {

        signField.setText("1");
    } else {

        signField.setText("0");
    }

    v = intBits >> 23;
    buf.setLength(0);
    for (int i = 0; i < 8; ++i) {
        // Get lowest bit
        int remainder = v & 0x1;

        // Convert bit to a character and insert it into the beginning of the string
        if (remainder == 0) {
            buf.insert(0, "0");
        } else {
            buf.insert(0, "1");
        }

        // Shift the int to the right one bit
        v >>>= 1;
    }
    exponentField.setText(buf.toString());

    // Do the mantissa
    v = intBits;
    buf.setLength(0);
    for (int i = 0; i < 23; ++i) {
        // Get lowest bit
        int remainder = v & 0x1;

        // Convert bit to a character and insert it into the beginning of the string
        if (remainder == 0) {
            buf.insert(0, "0");
        } else {
            buf.insert(0, "1");
        }

        // Shift the int to the right one bit
        v >>>= 1;
    }
    if (((intBits >> 23) & 0xff) == 0) {
        // This is a denormalized number, first bit is 0
        buf.insert(0, "0");
    } else {
        // This is a normalized number, first bit is 1
        buf.insert(0, "1");
    }
    mantissaField.setText(buf.toString());

    // Print out a denormalized base 2 version.
    buf.setLength(0);
    if (Float.isNaN(value)) {
        buf.append(notANumberString);
    } else if (Float.isInfinite(value)) {
        if ((intBits >>> 31) == 1) {
            // This is a negative infinity
            buf.append(negativeInfinityString);
        } else {
            // This is a positive infinity
            buf.append(positiveInfinityString);
        }
    } else {

        if ((intBits >>> 31) == 1) {
            // This is a negative number
            buf.append("-");
        }

        // Convert mantissa to int.
        v = (intBits & 0x007fffff);
        if (((intBits >> 23) & 0xff) != 0) {
            // Set bit 23 if the number is normalized
            v |= 0x00800000;
        }
        buf.append(v);

        // print out the exponent
        v = (intBits >> 23) & 0xff;
        if (v != 150 && intBits != 0 && intBits != (int) 0x80000000) {
            if (v != 0) {
                // regular normalized number
                buf.append("e" + (v - 150));
            } else {
                // denormalized number
                buf.append("e-149");
            }
        }
    }

    base2Field.setText(buf.toString());
}

From source file:com.fota.Link.sdpApi.java

public String GetBasicUserInfoAndMarketInfo(String CTN) throws JDOMException {
    String resultStr = null;// w w w.  j a  va 2  s  . c om
    StringBuffer logSb = new StringBuffer();
    try {
        String endPointUrl = PropUtil.getPropValue("sdp.oif516.url");

        String strRequest = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' "
                + "xmlns:oas='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'"
                + " xmlns:sdp='http://kt.com/sdp'>" + "     <soapenv:Header>" + "         <oas:Security>"
                + "             <oas:UsernameToken>" + "                 <oas:Username>"
                + PropUtil.getPropValue("sdp.id") + "</oas:Username>" + "                 <oas:Password>"
                + PropUtil.getPropValue("sdp.pw") + "</oas:Password>" + "             </oas:UsernameToken>"
                + "         </oas:Security>" + "     </soapenv:Header>"

                + "     <soapenv:Body>" + "         <sdp:getBasicUserInfoAndMarketInfoRequest>"
                + "         <!--You may enterthe following 6 items in any order-->"
                + "             <sdp:CALL_CTN>" + CTN + "</sdp:CALL_CTN>"
                + "         </sdp:getBasicUserInfoAndMarketInfoRequest>\n" + "     </soapenv:Body>\n"
                + "</soapenv:Envelope>";

        logSb.append("\r\n---------- GetBasicUserInfoAndMarketInfo(" + CTN + ") ----------");
        logSb.append("\r\nendPointUrl : " + endPointUrl);
        logSb.append("\r\nrequest msg : \r\n==============================\r\n" + strRequest
                + "\r\n===============================\r\n");

        logger.info(logSb.toString());
        logSb.setLength(0);

        // connection
        URL url = new URL(endPointUrl);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestProperty("Content-type", "text/xml;charset=utf-8");
        connection.setRequestMethod("POST");
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.connect();

        // output
        OutputStream os = connection.getOutputStream();
        // os.write(strRequest.getBytes(), 0, strRequest.length());
        os.write(strRequest.getBytes("utf-8"));
        os.flush();
        os.close();

        // input
        InputStream is = connection.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is, "utf-8"));
        String line = null;
        String resValue = null;
        String parseStr = null;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
            parseStr = line;

        }

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource temp = new InputSource();
        temp.setCharacterStream(new StringReader(parseStr));
        Document doc = builder.parse(temp); //xml?

        NodeList list = doc.getElementsByTagName("*");

        int i = 0;
        Element element;
        String contents;

        while (list.item(i) != null) {
            element = (Element) list.item(i);
            //            System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            //            System.out.println(element.getNodeName());
            if (element.hasChildNodes()) {
                contents = element.getFirstChild().getNodeValue();
                //            System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55");
                //            System.out.println(element.getNodeName());
                //            System.out.println(element.getFirstChild().getNodeName());
                if (element.getNodeName().equals("sdp:PREPAID")) {
                    resultStr = contents;
                }
                System.out.println(contents);
            }
            i++;
        }
        //resultStr = resValue;         

        connection.disconnect();

    } catch (Exception e) {
        e.printStackTrace();
    }

    return resultStr;
}

From source file:org.ojbc.bundles.adapters.staticmock.StaticMockQuery.java

static String buildFirearmSearchXPathFromMessage(Document firearmSearchRequestMessage) throws Exception {

    String firearmSerialNumber = XmlUtils.xPathStringSearch(firearmSearchRequestMessage,
            "/firearm-search-req-doc:FirearmSearchRequest/firearm-search-req-ext:Firearm/nc:ItemSerialIdentification/nc:IdentificationID");
    String firearmMakeCode = XmlUtils.xPathStringSearch(firearmSearchRequestMessage,
            "/firearm-search-req-doc:FirearmSearchRequest/firearm-search-req-ext:Firearm/firearms-codes-demostate:FirearmMakeCode");
    String firearmMakeText = XmlUtils.xPathStringSearch(firearmSearchRequestMessage,
            "/firearm-search-req-doc:FirearmSearchRequest/firearm-search-req-ext:Firearm/firearm-search-req-ext:FirearmMakeText");
    String firearmModel = XmlUtils.xPathStringSearch(firearmSearchRequestMessage,
            "/firearm-search-req-doc:FirearmSearchRequest/firearm-search-req-ext:Firearm/nc:ItemModelName");
    String firearmCategoryCode = XmlUtils.xPathStringSearch(firearmSearchRequestMessage,
            "/firearm-search-req-doc:FirearmSearchRequest/firearm-search-req-ext:Firearm/nc:FirearmCategoryCode");
    String registrationNumber = XmlUtils.xPathStringSearch(firearmSearchRequestMessage,
            "/firearm-search-req-doc:FirearmSearchRequest/firearm-search-req-ext:ItemRegistration/nc:RegistrationIdentification/nc:IdentificationID");
    String registrationCounty = XmlUtils.xPathStringSearch(firearmSearchRequestMessage,
            "/firearm-search-req-doc:FirearmSearchRequest/firearm-search-req-ext:ItemRegistration/nc:LocationCountyName");

    List<String> firearmConditions = new ArrayList<String>();
    List<String> firearmMakeConditions = new ArrayList<String>();
    List<String> registrationConditions = new ArrayList<String>();

    if (firearmSerialNumber != null && firearmSerialNumber.trim().length() > 0) {
        firearmConditions.add("nc:ItemSerialIdentification/nc:IdentificationID='" + firearmSerialNumber + "'");
    }//from   w  w w .  j a  v  a 2s  .  c  o  m
    if (firearmMakeCode != null && firearmMakeCode.trim().length() > 0) {
        firearmMakeConditions.add("firearms-codes-demostate:FirearmMakeCode='" + firearmMakeCode + "'");
    }
    if (firearmMakeText != null && firearmMakeText.trim().length() > 0) {
        firearmMakeConditions.add("firearm-search-req-ext:FirearmMakeText='" + firearmMakeText + "'");
    }
    if (firearmModel != null && firearmModel.trim().length() > 0) {
        firearmConditions.add("nc:ItemModelName='" + firearmModel + "'");
    }
    if (firearmCategoryCode != null && firearmCategoryCode.trim().length() > 0) {
        firearmConditions.add("nc:FirearmCategoryCode='" + firearmCategoryCode + "'");
    }

    if (registrationNumber != null && registrationNumber.trim().length() > 0) {
        registrationConditions
                .add("nc:RegistrationIdentification/nc:IdentificationID='" + registrationNumber + "'");
    }
    if (registrationCounty != null && registrationCounty.trim().length() > 0) {
        registrationConditions.add("nc:LocationCountyName='" + registrationCounty + "'");
    }

    if (firearmConditions.isEmpty() && registrationConditions.isEmpty()) {
        // no search parameters specified
        return null;
    }

    StringBuffer searchXPath = new StringBuffer(
            "/firearm-doc:PersonFirearmRegistrationQueryResults/firearm-ext:Firearm[");

    if (!firearmConditions.isEmpty()) {
        for (String condition : firearmConditions) {
            searchXPath.append(condition).append(" and ");
        }
        searchXPath.setLength(searchXPath.length() - 5);
    }

    if (!firearmMakeConditions.isEmpty()) {
        if (!firearmConditions.isEmpty()) {
            searchXPath.append(" and ");
        }
        searchXPath.append("(");
        for (String condition : firearmMakeConditions) {
            searchXPath.append(condition).append(" or ");
        }
        searchXPath.setLength(searchXPath.length() - 4);
        searchXPath.append(")");
    }

    if (!registrationConditions.isEmpty()) {
        if (!(firearmMakeConditions.isEmpty() || firearmConditions.isEmpty())) {
            searchXPath.append(" and ");
        }
        searchXPath.append(
                "@s:id = /firearm-doc:PersonFirearmRegistrationQueryResults/nc:PropertyRegistrationAssociation[nc:ItemRegistrationReference/@s:ref = /firearm-doc:PersonFirearmRegistrationQueryResults/firearm-ext:ItemRegistration[");
        for (String condition : registrationConditions) {
            searchXPath.append(condition).append(" and ");
        }
        searchXPath.setLength(searchXPath.length() - 5);
        searchXPath.append("]/@s:id]/nc:ItemReference/@s:ref");
    }

    searchXPath.append("]");
    return searchXPath.toString();

}

From source file:com.hangum.tadpole.engine.sql.util.export.SQLExporter.java

public static String makeFileMergeStatment(String tableName, QueryExecuteResultDTO rsDAO,
        List<String> listWhere, int intLimitCnt, int commit) throws Exception {
    String strTmpDir = PublicTadpoleDefine.TEMP_DIR + tableName + System.currentTimeMillis()
            + PublicTadpoleDefine.DIR_SEPARATOR;
    String strFile = tableName + ".sql";
    String strFullPath = strTmpDir + strFile;

    final String MERGE_STMT = "MERGE INTO " + tableName
            + " A USING (\n SELECT %s FROM DUAL) B \n ON ( %s ) \n WHEN NOT MATCHED THEN \n INSERT ( %s ) \n VALUES ( %s ) \n WHEN MATCHED THEN \n UPDATE SET %s ;"
            + PublicTadpoleDefine.LINE_SEPARATOR;
    Map<Integer, String> mapColumnName = rsDAO.getColumnLabelName();

    // ?? .//from   ww  w  .  j  a  va2s.  c o  m
    StringBuffer sbInsertInto = new StringBuffer();
    int DATA_COUNT = 1000;
    List<Map<Integer, Object>> dataList = rsDAO.getDataList().getData();
    Map<Integer, Integer> mapColumnType = rsDAO.getColumnType();
    String strSource = "";
    String strInsertColumn = "";
    String strInsertValue = "";
    String strUpdate = "";
    String strMatchConditon = "";
    for (int i = 0; i < dataList.size(); i++) {
        Map<Integer, Object> mapColumns = dataList.get(i);

        strSource = "";
        strInsertColumn = "";
        strInsertValue = "";
        strUpdate = "";
        strMatchConditon = "";
        for (int j = 1; j < mapColumnName.size(); j++) {
            String strColumnName = mapColumnName.get(j);

            Object strValue = mapColumns.get(j);
            strValue = strValue == null ? "" : strValue;

            if (!RDBTypeToJavaTypeUtils.isNumberType(mapColumnType.get(j))) {
                strValue = StringEscapeUtils.escapeSql(strValue.toString());
                strValue = StringHelper.escapeSQL(strValue.toString());
                strValue = SQLUtil.makeQuote(strValue.toString());
            }

            boolean isWhere = false;
            for (String strTmpColumn : listWhere) {
                if (strColumnName.equals(strTmpColumn)) {
                    isWhere = true;
                    break;
                }
            }

            strSource += String.format("%s as %s ,", strValue, strColumnName);
            strInsertColumn += String.format(" %s,", strColumnName);
            strInsertValue += String.format(" B.%s,", strColumnName);
            if (isWhere)
                strMatchConditon += String.format("A.%s = B.%s and", strColumnName, strColumnName);
            else
                strUpdate += String.format("A.%s = B.%s,", strColumnName, strColumnName);
        }
        strSource = StringUtils.removeEnd(strSource, ",");
        strInsertColumn = StringUtils.removeEnd(strInsertColumn, ",");
        strInsertValue = StringUtils.removeEnd(strInsertValue, ",");
        strUpdate = StringUtils.removeEnd(strUpdate, ",");
        strMatchConditon = StringUtils.removeEnd(strMatchConditon, "and");

        sbInsertInto.append(String.format(MERGE_STMT, strSource, strMatchConditon, strInsertColumn,
                strInsertValue, strUpdate));

        if (intLimitCnt == i) {
            return sbInsertInto.toString();
        }

        if (commit > 0 && (i % commit) == 0) {
            sbInsertInto
                    .append("COMMIT" + PublicTadpoleDefine.SQL_DELIMITER + PublicTadpoleDefine.LINE_SEPARATOR);
        }

        if ((i % DATA_COUNT) == 0) {
            FileUtils.writeStringToFile(new File(strFullPath), sbInsertInto.toString(), true);
            sbInsertInto.setLength(0);
        }
    }
    if (sbInsertInto.length() > 0) {
        if (commit > 0) {
            sbInsertInto
                    .append("COMMIT" + PublicTadpoleDefine.SQL_DELIMITER + PublicTadpoleDefine.LINE_SEPARATOR);
        }

        FileUtils.writeStringToFile(new File(strFullPath), sbInsertInto.toString(), true);
    }

    return strFullPath;
}