001/*
002 * (C) Copyright 2006-2008 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Alexandre Russel
018 *
019 * $Id$
020 */
021
022package org.nuxeo.ecm.platform.annotations.gwt.client.util;
023
024/**
025 * @author <a href="mailto:arussel@nuxeo.com">Alexandre Russel</a>
026 */
027public class XPointerFactory {
028
029    private static final String IMAGE_RANGE = "image-range";
030
031    private static final String STRING_RANGE = "string-range";
032
033    private static final String NULL_RANGE = "null-range";
034
035    private XPointerFactory() {
036    }
037
038    public static XPointer getXPointer(String xpointer) {
039        if (xpointer.contains(STRING_RANGE)) {
040            return new StringRangeXPointer(xpointer);
041        } else if (xpointer.contains(IMAGE_RANGE)) {
042            return new ImageRangeXPointer(xpointer);
043        } else if (xpointer.contains(NULL_RANGE)) {
044            return new NullRangeXPointer(xpointer);
045        }
046        return null;
047    }
048
049    public static boolean isStringRange(String xpointer) {
050        return xpointer.contains(STRING_RANGE);
051    }
052
053    public static boolean isImageRange(String xpointer) {
054        return xpointer.contains(IMAGE_RANGE);
055    }
056
057}