Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2013 SAP AG Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
package com.sap.core.odata.core.edm;
Implementation of the EDM simple type Int32.

Author(s):
SAP AG
public class EdmInt32 extends AbstractSimpleType {
  private static final EdmInt32 instance = new EdmInt32();
  public static EdmInt32 getInstance() {
    return ;
  }
  public boolean isCompatible(final EdmSimpleType simpleType) {
    return simpleType instanceof Bit
        || simpleType instanceof Uint7
        || simpleType instanceof EdmByte
        || simpleType instanceof EdmSByte
        || simpleType instanceof EdmInt16
        || simpleType instanceof EdmInt32;
  }
  public Class<?> getDefaultType() {
    return Integer.class;
  }
  protected <T> T internalValueOfString(final String valuefinal EdmLiteralKind literalKindfinal EdmFacets facetsfinal Class<T> returnTypethrows EdmSimpleTypeException {
    Integer valueInteger;
    try {
      valueInteger = Integer.parseInt(value);
    } catch (final NumberFormatException e) {
    }
    if (returnType.isAssignableFrom(Integer.class)) {
      return returnType.cast(valueInteger);
    } else if (returnType.isAssignableFrom(Byte.class)) {
      if (valueInteger >= . && valueInteger <= .) {
        return returnType.cast(valueInteger.byteValue());
      } else {
      }
    } else if (returnType.isAssignableFrom(Short.class)) {
      if (valueInteger >= . && valueInteger <= .) {
        return returnType.cast(valueInteger.shortValue());
      } else {
      }
    } else if (returnType.isAssignableFrom(Long.class)) {
      return returnType.cast(valueInteger.longValue());
    } else {
    }
  }
  protected <T> String internalValueToString(final T valuefinal EdmLiteralKind literalKindfinal EdmFacets facetsthrows EdmSimpleTypeException {
    if (value instanceof Byte || value instanceof Short || value instanceof Integer) {
      return value.toString();
    } else if (value instanceof Long) {
      if ((Longvalue >= . && (Longvalue <= .) {
        return value.toString();
      } else {
      }
    } else {
    }
  }
New to GrepCode? Check out our FAQ X