Example usage for java.lang Character toString

List of usage examples for java.lang Character toString

Introduction

In this page you can find the example usage for java.lang Character toString.

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this Character 's value.

Usage

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

private String mapAsciiKeyCodeToKey(int keyCode) {
    Map<Integer, Keys> keysMap = new HashMap<Integer, Keys>();
    keysMap.put(0, Keys.NULL);//from  www. jav  a  2 s.c  o  m
    keysMap.put(8, Keys.BACK_SPACE);
    keysMap.put(9, Keys.TAB);
    keysMap.put(10, Keys.RETURN);
    keysMap.put(13, Keys.ENTER);
    keysMap.put(24, Keys.CANCEL);
    keysMap.put(27, Keys.ESCAPE);
    keysMap.put(32, Keys.SPACE);
    keysMap.put(42, Keys.MULTIPLY);
    keysMap.put(43, Keys.ADD);
    keysMap.put(44, Keys.SUBTRACT);
    keysMap.put(56, Keys.DECIMAL);
    keysMap.put(57, Keys.DIVIDE);
    keysMap.put(59, Keys.SEMICOLON);
    keysMap.put(61, Keys.EQUALS);
    keysMap.put(127, Keys.DELETE);
    Keys key = keysMap.get(keyCode);

    if (key == null) {
        Character c = (char) keyCode;
        return c.toString();
    }

    return key.toString();
}

From source file:com.rapidminer.operator.preprocessing.GuessValueTypes.java

@Override
public ExampleSet apply(ExampleSet exampleSet) throws OperatorException {
    // init// ww w. j  a  va2  s .  c  o  m
    char decimalPointCharacter = getParameterAsString(PARAMETER_DECIMAL_POINT_CHARACTER).charAt(0);
    Character groupingCharacter = null;
    if (isParameterSet(PARAMETER_NUMBER_GROUPING_CHARACTER)) {
        groupingCharacter = getParameterAsString(PARAMETER_NUMBER_GROUPING_CHARACTER).charAt(0);
    }

    Set<Attribute> attributeSet = attributeSelector.getAttributeSubset(exampleSet, false);
    int size = attributeSet.size();

    int[] inputValueTypes = new int[size];

    int index = 0;
    for (Attribute attribute : attributeSet) {
        inputValueTypes[index++] = attribute.getValueType();
    }

    // init progress
    getProgress().setTotal(100);
    double totalProgress = exampleSet.size() * attributeSet.size();
    long progressCounter = 0;

    // guessed value types
    int[] guessedValueTypes = new int[size];
    index = 0;
    for (Attribute attribute : attributeSet) {
        progressCounter = exampleSet.size() * index;
        getProgress().setCompleted((int) (50 * ((progressCounter - 1) / totalProgress)));
        if (!attribute.isNominal() && !attribute.isNumerical()) {
            index++;
            continue;
        }
        for (Example example : exampleSet) {
            // trigger progress
            if (progressCounter++ % 500_000 == 0) {
                getProgress().setCompleted((int) (50 * ((progressCounter - 1) / totalProgress)));
            }
            double originalValue = example.getValue(attribute);
            if (!Double.isNaN(originalValue)) {
                if (guessedValueTypes[index] != Ontology.NOMINAL) {
                    try {
                        String valueString = example.getValueAsString(attribute);
                        if (!Attribute.MISSING_NOMINAL_VALUE.equals(valueString)) {
                            if (groupingCharacter != null) {
                                valueString = valueString.replace(groupingCharacter.toString(), "");
                            }
                            valueString = valueString.replace(decimalPointCharacter, '.');
                            double value = Double.parseDouble(valueString);
                            if (guessedValueTypes[index] != Ontology.REAL) {
                                if (Tools.isEqual(Math.round(value), value)) {
                                    guessedValueTypes[index] = Ontology.INTEGER;
                                } else {
                                    guessedValueTypes[index] = Ontology.REAL;
                                }
                            }
                        }
                    } catch (NumberFormatException e) {
                        guessedValueTypes[index] = Ontology.NOMINAL;
                        break;
                    }
                }
            }
        }
        index++;
    }

    // if we could not guess any type, use the default one
    for (int i = 0; i < size; i++) {
        if (guessedValueTypes[i] == 0) {
            guessedValueTypes[i] = inputValueTypes[i];
        }
    }

    progressCounter = 0;
    getProgress().setCompleted(50);

    // the example set contains at least one example and the guessing was performed
    if (exampleSet.size() > 0) {
        // new attributes
        List<AttributeRole> newAttributes = new LinkedList<AttributeRole>();
        index = 0;
        for (Attribute attribute : attributeSet) {
            if (!attribute.isNominal() && !attribute.isNumerical()) {
                index++;
                continue;
            }

            AttributeRole role = exampleSet.getAttributes().getRole(attribute);

            Attribute newAttribute = AttributeFactory.createAttribute(guessedValueTypes[index]);
            exampleSet.getExampleTable().addAttribute(newAttribute);
            AttributeRole newRole = new AttributeRole(newAttribute);
            newRole.setSpecial(role.getSpecialName());
            newAttributes.add(newRole);

            // copy data
            for (Example e : exampleSet) {
                double oldValue = e.getValue(attribute);
                if (Ontology.ATTRIBUTE_VALUE_TYPE.isA(guessedValueTypes[index], Ontology.NUMERICAL)) {
                    if (!Double.isNaN(oldValue)) {
                        String valueString = e.getValueAsString(attribute);
                        if (Attribute.MISSING_NOMINAL_VALUE.equals(valueString)) {
                            e.setValue(newAttribute, Double.NaN);
                        } else {
                            if (groupingCharacter != null) {
                                valueString = valueString.replace(groupingCharacter.toString(), "");
                            }
                            valueString = valueString.replace(decimalPointCharacter, '.');
                            e.setValue(newAttribute, Double.parseDouble(valueString));
                        }
                    } else {
                        e.setValue(newAttribute, Double.NaN);
                    }
                } else {
                    if (!Double.isNaN(oldValue)) {
                        String value = e.getValueAsString(attribute);
                        e.setValue(newAttribute, newAttribute.getMapping().mapString(value));
                    } else {
                        e.setValue(newAttribute, Double.NaN);
                    }
                }

                // trigger progress
                if (++progressCounter % 500_000 == 0) {
                    getProgress().setCompleted((int) (50 * (progressCounter / totalProgress) + 50));
                }
            }

            exampleSet.getAttributes().remove(role);
            newAttribute.setName(attribute.getName());

            index++;
        }

        for (AttributeRole role : newAttributes) {
            if (role.isSpecial()) {
                exampleSet.getAttributes().setSpecialAttribute(role.getAttribute(), role.getSpecialName());
            } else {
                exampleSet.getAttributes().addRegular(role.getAttribute());
            }
        }

        // trigger progress
        getProgress().complete();
    }

    return exampleSet;
}

From source file:de.innovationgate.utils.WGUtils.java

private static String processDeserializedToken(String token, boolean trimTokens, Character stringDelimiter,
        boolean removeTokenStringDelimiter) {
    if (trimTokens) {
        token = token.trim();//  www . ja  v  a2s .  co m
    }

    if (removeTokenStringDelimiter && stringDelimiter != null && token.startsWith(stringDelimiter.toString())
            && token.endsWith(stringDelimiter.toString())) {
        token = token.substring(1, token.length() - 1);
    }
    return token;
}

From source file:de.innovationgate.utils.WGUtils.java

/**
 * Removes all characters from a string that are not legal as JavaScript identifier
 * Interprets an underscore as the next character being forced to upper case.
 * The upper case rules, that are enforced when param enforceUpperCaseRules is true are:
 * <ul>//w  w w  .j  ava2  s.c o  m
 * <li>Non-alphabetic characters at the beginning are stripped off
 * <li>The first alphabetic character is uppercase
 * <li>An alphabetic character preceded by an underscore (which is removed) will also be uppercase
 * <li>All other alphabetic characters are lowercase
 * </ul>
 * @param txt The string
 * @param enforceUpperCaseRules If true enforces the upper case rules described above, meant to transfor, a lowercase design reference to an Object Identifier with cases in an reversible way.
 * In that case the created string can be reverted to the original by using {@link #fromJSIdentifier(String)}.
 * @return The string converted to a valid JS identifier
 */
public static String toJSIdentifier(String txt, boolean enforceUpperCaseRules) {

    StringBuilder out = new StringBuilder();

    // Flags for enforceUpperCaseRules
    boolean upperCase = true; // First character is uppercase
    boolean startCharacter = true;

    for (int i = 0; i < txt.length(); i++) {
        Character c = txt.charAt(i);

        if (enforceUpperCaseRules) {
            // Must start with a letter
            if (startCharacter && !Character.isLetter(c)) {
                continue;
            }

            // Convert letters to uppercase, depending on flag
            if (Character.isLetter(c)) {
                if (upperCase) {
                    c = Character.toUpperCase(c);
                    upperCase = false;
                } else {
                    c = Character.toLowerCase(c);
                }
            }
            // Trigger the next letter to be uppercase
            else if (c == '_') {
                upperCase = true;
                continue;
            }
        }

        Pattern p = (startCharacter ? JS_IDENTIFIER_FIRSTCHARS : JS_IDENTIFIER_CHARS);
        if (p.matcher(c.toString()).matches()) {
            out.append(c);
            startCharacter = false;
        } else if (enforceUpperCaseRules) {
            throw new IllegalArgumentException(
                    "This string cannot be transformed to a reversible JS identifier because it contains invalid characters: "
                            + txt);
        }
    }

    return out.toString();

}

From source file:edu.mit.isda.permitws.permit.java

@SuppressWarnings("unchecked")

public StringBuffer createAuthorizationXML(StringBuffer xml, String category, String functionName,
        String functionDesc, String qualifierType, String qualifierName, String qualifierCode,
        String kerberosName, String firstName, String lastName, Long authId, Date effDate, Date expDate,
        Boolean isActive, Character doFunction, String grantAuthorization, String modifiedBy, Date modifiedDate,
        String proxyUserName, boolean isEditable) throws Exception {
    xml.append("\r\n{\"category\":\"" + category.trim() + "\",");
    xml.append("\"functionName\":\"" + functionName.trim() + "\",");
    if (functionDesc != null) {
        xml.append("\"functionDesc\":\"" + functionDesc.trim() + "\",");
    } else {/*from  w  w w  . j a  v  a2 s  .c  o m*/
        xml.append("\"functionDesc\":\"\",");
    }
    xml.append("\"qualifierType\":\"" + qualifierType.trim() + "\",");
    String qName = qualifierName.trim().replaceAll("[\"]", "'");
    xml.append("\"qualifierName\":\"" + qName + "\",");
    if (qualifierCode != null)
        xml.append("\"qualifierCode\":\"" + qualifierCode.trim() + "\",");
    else
        xml.append("\"qualifierCode\":\"null\",");
    xml.append("\"kerberosName\":\"" + kerberosName.trim() + "\",");
    xml.append("\"firstName\":\"" + firstName.trim() + "\",");
    xml.append("\"lastName\":\"" + lastName.trim() + "\",");
    xml.append("\"authorizationID\":\"" + authId.toString() + "\",");

    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
    xml.append("\"effectiveDate\":\"" + formatter.format(effDate) + "\",");
    if (null == expDate) {
        xml.append("\"expirationDate\":\"\",");
    } else {
        xml.append("\"expirationDate\":\"" + formatter.format(expDate) + "\",");
    }
    if (null != isActive) {
        xml.append("\"active\":\"" + isActive.toString() + "\",");
    }

    xml.append("\"doFunction\":\"" + doFunction.toString() + "\",");
    xml.append("\"grantAuthorization\":\"" + grantAuthorization + "\",");
    xml.append("\"modifiedBy\":\"" + modifiedBy + "\",");
    xml.append("\"modifiedDate\":\"" + formatter.format(modifiedDate) + "\",");
    xml.append("\"proxyUser\":\"" + proxyUserName + "\",");
    xml.append("\"isEditable\":\"" + new Boolean(isEditable).toString() + "\"},");

    return (xml);
}

From source file:com.rackspacecloud.client.cloudfiles.FilesClient.java

/**
 * /*from ww w .ja  v a2 s . c o  m*/
 * 
 * @param container
 *             
 * @param startsWith
 *             
 * @param path
 *             
 * @param limit
 *             
 * @param marker
 *             markerlimit
 * @param delimter
 *             
 * 
 * @return A list of FilesObjects starting with the given string
 * @throws IOException
 *              IO
 * @throws HttpException
 *              Http
 * @throws FilesExcepiton
 *              
 * @throws FilesAuthorizationException
 *              
 */
public List<FilesObject> listObjectsStartingWith(String container, String startsWith, String path, int limit,
        String marker, Character delimiter) throws IOException, FilesException {
    if (!this.isLoggedin()) {
        throw new FilesAuthorizationException("You must be logged in", null, null);
    }
    if (!isValidContainerName(container)) {
        throw new FilesInvalidNameException(container);
    }
    HttpGet method = null;
    try {
        LinkedList<NameValuePair> parameters = new LinkedList<NameValuePair>();
        parameters.add(new BasicNameValuePair("format", "xml"));
        if (startsWith != null) {
            parameters.add(new BasicNameValuePair(FilesConstants.LIST_CONTAINER_NAME_QUERY, startsWith));
        }
        if (path != null) {
            parameters.add(new BasicNameValuePair("path", path));
        }
        if (limit > 0) {
            parameters.add(new BasicNameValuePair("limit", String.valueOf(limit)));
        }
        if (marker != null) {
            parameters.add(new BasicNameValuePair("marker", marker));
        }
        if (delimiter != null) {
            parameters.add(new BasicNameValuePair("delimiter", delimiter.toString()));
        }

        String uri = parameters.size() > 0 ? makeURI(storageURL + "/" + sanitizeForURI(container), parameters)
                : storageURL;
        method = new HttpGet(uri);
        method.getParams().setIntParameter("http.socket.timeout", connectionTimeOut);
        method.setHeader(FilesConstants.X_AUTH_TOKEN, authToken);
        FilesResponse response = new FilesResponse(client.execute(method));

        if (response.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
            method.removeHeaders(FilesConstants.X_AUTH_TOKEN);
            if (login()) {
                method = new HttpGet(uri);
                method.getParams().setIntParameter("http.socket.timeout", connectionTimeOut);
                method.setHeader(FilesConstants.X_AUTH_TOKEN, authToken);
                response = new FilesResponse(client.execute(method));
            } else {
                throw new FilesAuthorizationException("Re-login failed", response.getResponseHeaders(),
                        response.getStatusLine());
            }
        }

        if (response.getStatusCode() == HttpStatus.SC_OK) {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document document = builder.parse(response.getResponseBodyAsStream());

            NodeList nodes = document.getChildNodes();
            Node containerList = nodes.item(0);
            if (!"container".equals(containerList.getNodeName())) {
                logger.error("Got unexpected type of XML");
                return null;
            }
            ArrayList<FilesObject> objectList = new ArrayList<FilesObject>();
            NodeList objectNodes = containerList.getChildNodes();
            for (int i = 0; i < objectNodes.getLength(); ++i) {
                Node objectNode = objectNodes.item(i);
                String nodeName = objectNode.getNodeName();
                if (!("object".equals(nodeName) || "subdir".equals(nodeName)))
                    continue;
                String name = null;
                String eTag = null;
                long size = -1;
                String mimeType = null;
                String lastModified = null;
                NodeList objectData = objectNode.getChildNodes();
                if ("subdir".equals(nodeName)) {
                    size = 0;
                    mimeType = "application/directory";
                    name = objectNode.getAttributes().getNamedItem("name").getNodeValue();
                }
                for (int j = 0; j < objectData.getLength(); ++j) {
                    Node data = objectData.item(j);
                    if ("name".equals(data.getNodeName())) {
                        name = data.getTextContent();
                    } else if ("content_type".equals(data.getNodeName())) {
                        mimeType = data.getTextContent();
                    } else if ("hash".equals(data.getNodeName())) {
                        eTag = data.getTextContent();
                    } else if ("bytes".equals(data.getNodeName())) {
                        size = Long.parseLong(data.getTextContent());
                    } else if ("last_modified".equals(data.getNodeName())) {
                        lastModified = data.getTextContent();
                    } else {
                        logger.warn("Unexpected tag:" + data.getNodeName());
                    }
                }
                if (name != null) {
                    FilesObject obj = new FilesObject(name, container, this);
                    if (eTag != null)
                        obj.setMd5sum(eTag);
                    if (mimeType != null)
                        obj.setMimeType(mimeType);
                    if (size >= 0)
                        obj.setSize(size);
                    if (lastModified != null)
                        obj.setLastModified(lastModified);
                    objectList.add(obj);
                }
            }
            return objectList;
        } else if (response.getStatusCode() == HttpStatus.SC_NO_CONTENT) {
            logger.debug("Container " + container + " has no Objects");
            return new ArrayList<FilesObject>();
        } else if (response.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
            throw new FilesNotFoundException("Container was not found", response.getResponseHeaders(),
                    response.getStatusLine());
        } else {
            throw new FilesException("Unexpected Server Result", response.getResponseHeaders(),
                    response.getStatusLine());
        }
    } catch (FilesNotFoundException fnfe) {
        throw fnfe;
    } catch (Exception ex) {
        logger.error("Error parsing xml", ex);
        throw new FilesException("Error parsing server resposne", ex);
    } finally {
        if (method != null)
            method.abort();
    }
}

From source file:ffx.potential.parsers.BiojavaFilter.java

/**
 * Convert possibly duplicate chain IDs into unique segIDs.
 *
 * @param c chain ID just read.//from w ww. jav  a2 s .  com
 * @return a unique segID.
 */
private String getSegID(Character c) {
    if (c.equals(' ')) {
        c = 'A';
    }

    // If the chain ID has not changed, return the existing segID.
    if (c.equals(currentChainID)) {
        return currentSegID;
    }

    // Loop through existing segIDs to find the first one that is unused.
    int n = segIDs.size();
    int count = 0;
    for (int i = 0; i < n; i++) {
        String segID = segIDs.get(i);
        if (segID.endsWith(c.toString())) {
            count++;
        }
    }

    // If the count is greater than 0, then append it.
    String newSegID;
    if (count == 0) {
        newSegID = c.toString();
    } else {
        newSegID = Integer.toString(count) + c.toString();
    }

    segIDs.add(newSegID);
    currentChainID = c;
    currentSegID = newSegID;

    return newSegID;
}

From source file:ffx.potential.parsers.PDBFilter.java

/**
 * Convert possibly duplicate chain IDs into unique segIDs.
 *
 * @param c chain ID just read.//w  w w  . j  a v  a2 s  .com
 * @return a unique segID.
 */
private String getSegID(Character c) {
    if (c.equals(' ')) {
        c = 'A';
    }

    // If the chain ID has not changed, return the existing segID.
    if (c.equals(currentChainID)) {
        return currentSegID;
    }

    // Loop through existing segIDs to find the first one that is unused.
    int n = segIDs.size();
    int count = 0;
    for (int i = 0; i < n; i++) {
        String segID = segIDs.get(i);
        if (segID.endsWith(c.toString())) {
            count++;
        }
    }

    // If the count is greater than 0, then append it.
    String newSegID;
    if (count == 0) {
        newSegID = c.toString();
    } else {
        newSegID = Integer.toString(count) + c.toString();
    }

    segIDs.add(newSegID);
    currentChainID = c;
    currentSegID = newSegID;

    if (segidMap.containsKey(c)) {
        segidMap.get(c).add(newSegID);
    } else {
        List<String> newChainList = new ArrayList<>();
        newChainList.add(newSegID);
        segidMap.put(c, newChainList);
    }

    return newSegID;
}

From source file:ffx.potential.parsers.PDBFilter.java

@Override
public boolean readNext(boolean resetPosition) {
    // ^ is beginning of line, \\s+ means "one or more whitespace", (\\d+) means match and capture one or more digits.
    Pattern modelPatt = Pattern.compile("^MODEL\\s+(\\d+)");
    modelsRead = resetPosition ? 1 : modelsRead + 1;
    boolean eof = true;

    for (MolecularAssembly system : systems) {
        File file = system.getFile();
        currentFile = file;//from   www  .  ja  v a  2  s .  co m
        try {
            BufferedReader currentReader;
            if (readers.containsKey(system)) {
                currentReader = readers.get(system);
                if (!currentReader.ready()) {
                    currentReader = new BufferedReader(new FileReader(currentFile));
                    readers.put(system, currentReader);
                }
            } else {
                currentReader = new BufferedReader(new FileReader(currentFile));
                readers.put(system, currentReader);
            }
            // Skip to appropriate model.
            String line = currentReader.readLine();
            while (line != null) {
                line = line.trim();
                Matcher m = modelPatt.matcher(line);
                if (m.find()) {
                    int modelNum = Integer.parseInt(m.group(1));
                    if (modelNum == modelsRead) {
                        logger.log(Level.INFO,
                                String.format(" Reading model %d for %s", modelNum, currentFile));
                        eof = false;
                        break;
                    }
                }
                line = currentReader.readLine();
            }

            if (eof) {
                logger.log(Level.INFO, String.format(" End of file reached for %s", file));
                currentReader.close();
                return false;
            }

            // Begin parsing the model.
            boolean modelDone = false;
            line = currentReader.readLine();
            while (line != null) {
                line = line.trim();
                String recID = line.substring(0, Math.min(6, line.length())).trim();
                try {
                    Record record = Record.valueOf(recID);
                    boolean hetatm = true;
                    switch (record) {
                    // =============================================================================
                    //
                    //  7 - 11        Integer       serial       Atom serial number.
                    // 13 - 16        Atom          name         Atom name.
                    // 17             Character     altLoc       Alternate location indicator.
                    // 18 - 20        Residue name  resName      Residue name.
                    // 22             Character     chainID      Chain identifier.
                    // 23 - 26        Integer       resSeq       Residue sequence number.
                    // 27             AChar         iCode        Code for insertion of residues.
                    // 31 - 38        Real(8.3)     x            Orthogonal coordinates for X in Angstroms.
                    // 39 - 46        Real(8.3)     y            Orthogonal coordinates for Y in Angstroms.
                    // 47 - 54        Real(8.3)     z            Orthogonal coordinates for Z in Angstroms.
                    // 55 - 60        Real(6.2)     occupancy    Occupancy.
                    // 61 - 66        Real(6.2)     tempFactor   Temperature factor.
                    // 77 - 78        LString(2)    element      Element symbol, right-justified.
                    // 79 - 80        LString(2)    charge       Charge  on the atom.
                    // =============================================================================
                    //         1         2         3         4         5         6         7
                    //123456789012345678901234567890123456789012345678901234567890123456789012345678
                    //ATOM      1  N   ILE A  16      60.614  71.140 -10.592  1.00  7.38           N
                    //ATOM      2  CA  ILE A  16      60.793  72.149  -9.511  1.00  6.91           C
                    case ATOM:
                        hetatm = false;
                    case HETATM:
                        if (!line.substring(17, 20).trim().equals("HOH")) {
                            //int serial = Hybrid36.decode(5, line.substring(6, 11));
                            String name = line.substring(12, 16).trim();
                            if (name.toUpperCase().contains("1H") || name.toUpperCase().contains("2H")
                                    || name.toUpperCase().contains("3H")) {
                                // VERSION3_2 is presently just a placeholder for "anything non-standard".
                                fileStandard = VERSION3_2;
                            }
                            Character altLoc = line.substring(16, 17).toUpperCase().charAt(0);
                            if (!altLoc.equals(' ') && !altLoc.equals('A') && !altLoc.equals(currentAltLoc)) {
                                break;
                            }
                            String resName = line.substring(17, 20).trim();
                            Character chainID = line.substring(21, 22).charAt(0);

                            List<String> segIDList = segidMap.get(chainID);
                            if (segIDList == null) {
                                logger.log(Level.WARNING,
                                        String.format(
                                                " No " + "known segment ID corresponds to " + "chain ID %s",
                                                chainID.toString()));
                                break;
                            }

                            String segID = segIDList.get(0);
                            if (segIDList.size() > 1) {
                                logger.log(Level.WARNING,
                                        String.format(
                                                " " + "Multiple segment IDs correspond to"
                                                        + "chain ID %s; assuming %s",
                                                chainID.toString(), segID));
                            }

                            int resSeq = Hybrid36.decode(4, line.substring(22, 26));

                            double[] d = new double[3];
                            d[0] = new Double(line.substring(30, 38).trim());
                            d[1] = new Double(line.substring(38, 46).trim());
                            d[2] = new Double(line.substring(46, 54).trim());
                            double occupancy = 1.0;
                            double tempFactor = 1.0;
                            Atom newAtom = new Atom(0, name, altLoc, d, resName, resSeq, chainID, occupancy,
                                    tempFactor, segID);
                            newAtom.setHetero(hetatm);
                            // Check if this is a modified residue.
                            if (modres.containsKey(resName.toUpperCase())) {
                                newAtom.setModRes(true);
                            }

                            Atom returnedAtom = activeMolecularAssembly.findAtom(newAtom);
                            if (returnedAtom != null) {
                                returnedAtom.setXYZ(d);
                                double[] retXYZ = new double[3];
                                returnedAtom.getXYZ(retXYZ);
                            } else {
                                String message = String.format(" " + "Could not find atom %s in assembly",
                                        newAtom.toString());
                                if (dieOnMissingAtom) {
                                    logger.severe(message);
                                } else {
                                    logger.warning(message);
                                }
                            }
                            break;
                        }
                    case ENDMDL:
                    case END: // Technically speaking, END should be at the end of the file, not end of the model.
                        logger.log(Level.FINE, String.format(" Model %d successfully read", modelsRead));
                        modelDone = true;
                    default:
                        break;
                    }
                } catch (Exception ex) {
                    // Do nothing; it's not an ATOM/HETATM line.
                }
                if (modelDone) {
                    break;
                }
                line = currentReader.readLine();

            }
            return true;
        } catch (IOException ex) {
            logger.info(String.format(" Exception in parsing frame %d of %s:" + " %s", modelsRead,
                    system.toString(), ex.toString()));
        }
    }
    return false;
}