001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Nuxeo - initial API and implementation
011 *
012 * $Id$
013 */
014
015package org.nuxeo.ecm.core.query.sql.model;
016
017/**
018 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
019 */
020public class StringLiteral extends Literal {
021
022    private static final long serialVersionUID = -7576440083973254527L;
023
024    public final String value;
025
026    public StringLiteral(String value) {
027        this.value = value;
028    }
029
030    @Override
031    public void accept(IVisitor visitor) {
032        visitor.visitStringLiteral(this);
033    }
034
035    @Override
036    public String asString() {
037        return value;
038    }
039
040    @Override
041    public String toString() {
042        return new StringBuffer(value.length() + 2).append("\'").append(value).append("\'").toString();
043    }
044
045    @Override
046    public boolean equals(Object obj) {
047        if (obj == this) {
048            return true;
049        }
050        if (obj instanceof StringLiteral) {
051            return value.contentEquals(((StringLiteral) obj).value);
052        }
053        return false;
054    }
055
056    @Override
057    public int hashCode() {
058        return value.hashCode();
059    }
060
061}