All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vertexium.cypher.ast.model.CypherString Maven / Gradle / Ivy

There is a newer version: 4.10.0
Show newest version
package org.vertexium.cypher.ast.model;

import org.vertexium.cypher.exceptions.VertexiumCypherSyntaxErrorException;
import org.vertexium.cypher.utils.StringUtils;

public class CypherString extends CypherLiteral {
    public CypherString(String value) {
        super(unescape(value));
    }

    private static String unescape(String value) {
        try {
            return StringUtils.unescape(value);
        } catch (IllegalArgumentException ex) {
            String type = "Unknown";
            if (ex.getMessage().equals("string too short for \\u escape")) {
                type = "InvalidUnicodeLiteral";
            }
            throw new VertexiumCypherSyntaxErrorException(type + ": could not parse string \"" + value + "\"", ex);
        }
    }

    @Override
    public String toString() {
        return String.format("'%s'", getValue());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy