001/*
002 * (C) Copyright 2006-2008 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Alexandre Russel
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.platform.annotations.gwt.client.util;
021
022/**
023 * @author <a href="mailto:arussel@nuxeo.com">Alexandre Russel</a>
024 */
025public class XPointerFactory {
026
027    private static final String IMAGE_RANGE = "image-range";
028
029    private static final String STRING_RANGE = "string-range";
030
031    private static final String NULL_RANGE = "null-range";
032
033    private XPointerFactory() {
034    }
035
036    public static XPointer getXPointer(String xpointer) {
037        if (xpointer.contains(STRING_RANGE)) {
038            return new StringRangeXPointer(xpointer);
039        } else if (xpointer.contains(IMAGE_RANGE)) {
040            return new ImageRangeXPointer(xpointer);
041        } else if (xpointer.contains(NULL_RANGE)) {
042            return new NullRangeXPointer(xpointer);
043        }
044        return null;
045    }
046
047    public static boolean isStringRange(String xpointer) {
048        return xpointer.contains(STRING_RANGE);
049    }
050
051    public static boolean isImageRange(String xpointer) {
052        return xpointer.contains(IMAGE_RANGE);
053    }
054
055}