Package org.simplestructruedata.entities

Examples of org.simplestructruedata.entities.SSDSetCharacter


        if (dataBase.charAt(0) != SSDDefaultConstants.OPENS_BRACES) {
            throw new SSDException("The string base must starts with:" + SSDDefaultConstants.OPENS_BRACES);
        } else {
            SSDContextManager ctx = new SSDContextManager();

            SSDSetCharacter string = new SSDSetCharacter();
            for (int i = 1; i < dataBase.length(); i++) {
                char currentChar = dataBase.charAt(i);
                if (SSDUtils.isReservedCharacter(currentChar)) {
                    // special escapade character
                    if (currentChar == SSDDefaultConstants.ESCAPE) {
                        currentChar = dataBase.charAt(++i);
                        string.add(currentChar);
                        continue;
                    }
                    // special assignment or comma characters
                    if (currentChar == SSDDefaultConstants.ASSIGN || currentChar == SSDDefaultConstants.COMMA) {
                        currentChar = dataBase.charAt(++i);
                    }
                    // special opens or closes braces characters
                    if (currentChar == SSDDefaultConstants.OPENS_BRACES) {
                        if (ctx.getCurrentObject() instanceof SSDObjectArray) {
                            SSDObjectArray objectArray = (SSDObjectArray)ctx.getCurrentObject();
                            ctx.addToHeap(new SSDObjectNode(objectArray.getNextIdentifier()));
                        } else {
                            ctx.addToHeap(new SSDObjectNode(string.getString()));
                        }
                        string.clear();
                        continue;
                    } else if (currentChar == SSDDefaultConstants.CLOSES_BRACES) {
                        ctx.closeObject();
                        string.clear();
                        continue;
                    }
                    // special opens or closes brackets characters
                    if (currentChar == SSDDefaultConstants.OPENS_BRACKETS) {
                        if (ctx.getCurrentObject() instanceof SSDObjectArray) {
                            SSDObjectArray objectArray = (SSDObjectArray)ctx.getCurrentObject();
                            ctx.addToHeap(new SSDObjectArray(objectArray.getNextIdentifier()));
                        } else {
                            ctx.addToHeap(new SSDObjectArray(string.getString()));
                        }
                        string.clear();
                        continue;
                    } else if (currentChar == SSDDefaultConstants.CLOSES_BRACKETS) {
                        ctx.closeObject();
                        string.clear();
                        continue;
                    }
                    // special quotation marks character
                    if (currentChar == SSDDefaultConstants.QUOTATION_MARKS) {
                        if (ctx.getCurrentObject() instanceof SSDObjectLeaf) {
                            SSDObjectLeaf objectLeaf = (SSDObjectLeaf) ctx.getCurrentObject();
                            objectLeaf.setValue(string.getString());
                            ctx.closeObject();
                        } else if (ctx.getCurrentObject() instanceof SSDObjectArray) {
                            SSDObjectArray objectArray = (SSDObjectArray)ctx.getCurrentObject();
                            ctx.addToHeap(new SSDObjectLeaf(objectArray.getNextIdentifier()));
                        } else {
                            ctx.addToHeap(new SSDObjectLeaf(string.getString()));
                        }
                        string.clear();
                        continue;
                    }
                }
                string.add(currentChar);
            }
            return ctx;
        }
    }
View Full Code Here


    public static String formatEscapes(String base) {
        if (base == null) {
            throw new IllegalArgumentException("parameter base can't be null");
        }
        SSDSetCharacter string = new SSDSetCharacter();
        for (int i = 0; i < base.length(); i++) {
            char character = base.charAt(i);
            if (isReservedCharacter(character)) {
                string.add(SSDDefaultConstants.ESCAPE);
            }
            string.add(character);
        }
        return string.getString();
    }
View Full Code Here

TOP

Related Classes of org.simplestructruedata.entities.SSDSetCharacter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.