Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2002-2014 "Neo Technology," Network Engine for Objects in Lund AB [http://neotechnology.com] This file is part of Neo4j. Neo4j is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 package org.neo4j.server.plugins;
 
 import java.net.URI;
 import java.util.List;
 import java.util.Map;
 
 public abstract class ParameterList
 {
     private final Map<StringObjectdata;
 
     public ParameterListMap<StringObjectdata )
     {
         this. = data;
     }
 
     public Map<StringObjectasMap()
     {
         return Collections.unmodifiableMap );
     }
 
     private static abstract class Converter<T>
     {
         abstract T convertGraphDatabaseAPI graphDbObject value )
                 throws BadInputException;
 
         abstract T[] newArrayint size );
     }
 
     private <T> T[] getListString nameGraphDatabaseAPI graphDb,
             Converter<T> converter ) throws BadInputException
     {
         Object value = .getname );
         if ( value == null ) return null;
         List<T> result = new ArrayList<T>();
         if ( value instanceof Object[] )
         {
             for ( Object element : (Object[]) value )
             {
                 result.addconverter.convertgraphDbelement ) );
             }
         }
         else if ( value instanceof Iterable<?> )
         {
             for ( Object element : (Iterable<?>) value )
             {
                 result.addconverter.convertgraphDbelement ) );
             }
         }
         else
         {
             throw new BadInputExceptionname + " is not a list" );
         }
         return result.toArrayconverter.newArrayresult.size() ) );
     }
 
     public String getStringString name ) throws BadInputException
     {
         Object value = .getname );
         if ( value == null ) return null;
         return convertStringvalue );
     }
 
     public String[] getStringListString name ) throws BadInputException
     {
         return getListnamenullnew Converter<String>()
         {
             @Override
             String convertGraphDatabaseAPI graphDbObject value )
                     throws BadInputException
             {
                 return convertStringvalue );
             }
 
            @Override
            String[] newArrayint size )
            {
                return new String[size];
            }
        } );
    }
    protected abstract String convertStringObject value )
            throws BadInputException;
    public Integer getIntegerString name ) throws BadInputException
    {
        Object value = .getname );
        if ( value == null ) return null;
        return convertIntegervalue );
    }
    public Integer[] getIntegerListString name ) throws BadInputException
    {
        return getListnamenullnew Converter<Integer>()
        {
            @Override
            Integer convertGraphDatabaseAPI graphDbObject value )
                    throws BadInputException
            {
                return convertIntegervalue );
            }
            @Override
            Integer[] newArrayint size )
            {
                return new Integer[size];
            }
        } );
    }
    protected abstract Integer convertIntegerObject value )
            throws BadInputException;
    public Long getLongString name ) throws BadInputException
    {
        Object value = .getname );
        if ( value == null ) return null;
        return convertLongvalue );
    }
    public Long[] getLongListString name ) throws BadInputException
    {
        return getListnamenullnew Converter<Long>()
        {
            @Override
            Long convertGraphDatabaseAPI graphDbObject value )
                    throws BadInputException
            {
                return convertLongvalue );
            }
            @Override
            Long[] newArrayint size )
            {
                return new Long[size];
            }
        } );
    }
    protected abstract Long convertLongObject value )
            throws BadInputException;
    public Byte getByteString name ) throws BadInputException
    {
        Object value = .getname );
        if ( value == null ) return null;
        return convertBytevalue );
    }
    public Byte[] getByteListString name ) throws BadInputException
    {
        return getListnamenullnew Converter<Byte>()
        {
            @Override
            Byte convertGraphDatabaseAPI graphDbObject value )
                    throws BadInputException
            {
                return convertBytevalue );
            }
            @Override
            Byte[] newArrayint size )
            {
                return new Byte[size];
            }
        } );
    }
    protected abstract Byte convertByteObject value )
            throws BadInputException;
    public Character getCharacterString name ) throws BadInputException
    {
        Object value = .getname );
        if ( value == null ) return null;
        return convertCharactervalue );
    }
    public Character[] getCharacterListString name ) throws BadInputException
    {
        return getListnamenullnew Converter<Character>()
        {
            @Override
            Character convertGraphDatabaseAPI graphDbObject value )
                    throws BadInputException
            {
                return convertCharactervalue );
            }
            @Override
            Character[] newArrayint size )
            {
                return new Character[size];
            }
        } );
    }
    protected abstract Character convertCharacterObject value )
            throws BadInputException;
    public Boolean getBooleanString name ) throws BadInputException
    {
        Object value = .getname );
        if ( value == null ) return null;
        return convertBooleanvalue );
    }
    public Boolean[] getBooleanListString name ) throws BadInputException
    {
        return getListnamenullnew Converter<Boolean>()
        {
            @Override
            Boolean convertGraphDatabaseAPI graphDbObject value )
                    throws BadInputException
            {
                return convertBooleanvalue );
            }
            @Override
            Boolean[] newArrayint size )
            {
                return new Boolean[size];
            }
        } );
    }
    protected abstract Boolean convertBooleanObject value )
            throws BadInputException;
    public Short getShortString name ) throws BadInputException
    {
        Object value = .getname );
        if ( value == null ) return null;
        return convertShortvalue );
    }
    public Short[] getShortListString name ) throws BadInputException
    {
        return getListnamenullnew Converter<Short>()
        {
            @Override
            Short convertGraphDatabaseAPI graphDbObject value )
                    throws BadInputException
            {
                return convertShortvalue );
            }
            @Override
            Short[] newArrayint size )
            {
                return new Short[size];
            }
        } );
    }
    protected abstract Short convertShortObject value )
            throws BadInputException;
    public Float getFloatString name ) throws BadInputException
    {
        Object value = .getname );
        if ( value == null ) return null;
        return convertFloatvalue );
    }
    public Float[] getFloatListString name ) throws BadInputException
    {
        return getListnamenullnew Converter<Float>()
        {
            @Override
            Float convertGraphDatabaseAPI graphDbObject value )
                    throws BadInputException
            {
                return convertFloatvalue );
            }
            @Override
            Float[] newArrayint size )
            {
                return new Float[size];
            }
        } );
    }
    protected abstract Float convertFloatObject value )
            throws BadInputException;
    public Double getDoubleString name ) throws BadInputException
    {
        Object value = .getname );
        if ( value == null ) return null;
        return convertDoublevalue );
    }
    public Double[] getDoubleListString name ) throws BadInputException
    {
        return getListnamenullnew Converter<Double>()
        {
            @Override
            Double convertGraphDatabaseAPI graphDbObject value )
                    throws BadInputException
            {
                return convertDoublevalue );
            }
            @Override
            Double[] newArrayint size )
            {
                return new Double[size];
            }
        } );
    }
    protected abstract Double convertDoubleObject value )
            throws BadInputException;
    public Node getNodeGraphDatabaseAPI graphDbString name )
            throws BadInputException
    {
        Object value = .getname );
        if ( value == null ) return null;
        return convertNodegraphDbvalue );
    }
    public Node[] getNodeListGraphDatabaseAPI graphDbString name )
            throws BadInputException
    {
        return getListnamegraphDbnew Converter<Node>()
        {
            @Override
            Node convertGraphDatabaseAPI graphDbObject value )
                    throws BadInputException
            {
                return convertNodegraphDbvalue );
            }
            @Override
            Node[] newArrayint size )
            {
                return new Node[size];
            }
        } );
    }
    protected abstract Node convertNodeGraphDatabaseAPI graphDb,
            Object value ) throws BadInputException;
    public Relationship getRelationshipGraphDatabaseAPI graphDb,
            String name ) throws BadInputException
    {
        Object value = .getname );
        if ( value == null ) return null;
        return convertRelationshipgraphDbvalue );
    }
            String name ) throws BadInputException
    {
        return getListnamegraphDbnew Converter<Relationship>()
        {
            @Override
            Relationship convertGraphDatabaseAPI graphDbObject value )
                    throws BadInputException
            {
                return convertRelationshipgraphDbvalue );
            }
            @Override
            Relationship[] newArrayint size )
            {
                return new Relationship[size];
            }
        } );
    }
    protected abstract Relationship convertRelationship(
            GraphDatabaseAPI graphDbObject value )
            throws BadInputException;
    public URI getUriString name ) throws BadInputException
    {
        Object value = .getname );
        if ( value == null ) return null;
        return convertURIvalue );
    }
    public URI[] getUriListString name ) throws BadInputException
    {
        return getListnamenullnew Converter<URI>()
        {
            @Override
            URI convertGraphDatabaseAPI graphDbObject value )
                    throws BadInputException
            {
                return convertURIvalue );
            }
            @Override
            URI[] newArrayint size )
            {
                return new URI[size];
            }
        } );
    }
    protected URI convertURIObject value ) throws BadInputException
    {
        try
        {
            return new URIconvertStringvalue ) );
        }
        catch ( URISyntaxException e )
        {
            throw new BadInputExceptione );
        }
    }
    public Map getMapString name ) throws BadInputException
    {
        Object value = .getname );
        if ( value instanceof Map )
        {
            return (Mapvalue;
        }
        else if ( value instanceof String )
        {
            throw new BadInputException(
                    "Maps encoded as Strings not supported" );
        }
        return null;
    }
New to GrepCode? Check out our FAQ X