sdblib

UnsupportedOperationException();
    }
  }
  
  public static <T> Iterator<T> iterator(T[] array)
  {
    return new ArrayIterator(array);
  }
  
  public static int size(Object obj)
  {
    if ((obj instanceof Object[])) {
      return size((Object[])obj);
    }
    if ((obj instanceof boolean[])) {
      return size((boolean[])obj);
    }
    if ((obj instanceof byte[])) {
      return size((byte[])obj);
    }
    if ((obj instanceof char[])) {
      return size((char[])obj);
    }
    if ((obj instanceof short[])) {
      return size((short[])obj);
    }
    if ((obj instanceof int[])) {
      return size((int[])obj);
    }
    if ((obj instanceof long[])) {
      return size((long[])obj);
    }
    if ((obj instanceof float[])) {
      return size((float[])obj);
    }
    if ((obj instanceof double[])) {
      return size((double[])obj);
    }
    if ((obj instanceof Collection)) {
      return CollectionUtil.size((Collection)obj);
    }
    return 0;
  }
  
  public static int size(boolean[] objs)
  {
    if (objs == null) {
      return 0;
    }
    return objs.length;
  }
  
  public static int size(byte[] objs)
  {
    if (objs == null) {
      return 0;
    }
    return objs.length;
  }
  
  public static int size(char[] objs)
  {
    if (objs == null) {
      return 0;
    }
    return objs.length;
  }
  
  public static int size(short[] objs)
  {
    if (objs == null) {
      return 0;
    }
    return objs.length;
  }
  
  public static int size(int[] objs)
  {
    if (objs == null) {
      return 0;
    }
    return objs.length;
  }
  
  public static int size(long[] objs)
  {
    if (objs == null) {
      return 0;
    }
    return objs.length;
  }
  
  public static int size(float[] objs)
  {
    if (objs == null) {
      return 0;
    }
    return objs.length;
  }
  
  public static int size(double[] objs)
  {
    if (objs == null) {
      return 0;
    }
    return objs.length;
  }
  
  public static <T> int size(T[] objs)
  {
    if (objs == null) {
      return 0;
    }
    return objs.length;
  }
  
  public static <T> T[] add(T[] array, T obj)
  {
    Class<?> compType = Object.class;
    if (array != null) {
      compType = array.getClass().getComponentType();
    } else if (obj != null) {
      compType = obj.getClass();
    }
    int newArrLength = size(array) + 1;
    Object[] newArr = 
      (Object[])Array.newInstance(compType, newArrLength);
    if (array != null) {
      System.arraycopy(array, 0, newArr, 0, array.length);
    }
    newArr[(newArrLength - 1)] = obj;
    return newArr;
  }
  
  public static <T> T[] remove(Object[] array, int start, int end)
  {
    Assert.notNull(array);
    Assert.isTrue(
      start <= end, 
      "start indnex(" + start + ") is greater than end index(" + end + ")");
    
    int startIndex = Math.max(0, start);
    int endIndex = Math.min(array.length, end);
    if (endIndex <= startIndex) {
      return array;
    }
    Class<?> compType = array.getClass().getComponentType();
    
    int removeSize = endIndex - startIndex;
    
    int newArrLength = size(array) - removeSize;
    
    Object[] newArr = 
      (Object[])Array.newInstance(compType, newArrLength);
    
    System.arraycopy(array, 0, newArr, 0, startIndex);
    System.arraycopy(array, endIndex, newArr, startIndex, array.length - endIndex);
    
    return newArr;
  }
  
  public static <T> T[] remove(Object[] array, int index)
  {
    return remove(array, index, index + 1);
  }
  
  public static <K, V> boolean contains(K[] array, V element)
  {
    if (array == null) {
      return false;
    }
    Object[] arrayOfObject = array;int j = array.length;
    for (int i = 0; i < j; i++)
    {
      Object candidate = arrayOfObject[i];
      if (ObjectUtil.equals(candidate, element)) {
        return true;
      }
    }
    return false;
  }
  
  public static <K> K get(K[] array, int index)
  {
    if (array == null) {
      return null;
    }
    if (index < 0) {
      return null;
    }
    if (array.length <= index) {
      return null;
    }
    return (K)array[index];
  }
  
  public static Boolean[] convertToWrapper(boolean[] array)
  {
    int nArray = size(array);
    Boolean[] ret = new Boolean[nArray];
    for (int i = 0; i < nArray; i++) {
      ret[i] = Boolean.valueOf(array[i]);
    }
    return ret;
  }
  
  public static Byte[] convertToWrapper(byte[] array)
  {
    int nArray = size(array);
    Byte[] ret = new Byte[nArray];
    for (int i = 0; i < nArray; i++) {
      ret[i] = Byte.valueOf(array[i]);
    }
    return ret;
  }
  
  public static Character[] convertToWrapper(char[] array)
  {
    int nArray = size(array);
    Character[] ret = new Character[nArray];
    for (int i = 0; i < nArray; i++) {
      ret[i] = Character.valueOf(array[i]);
    }
    return ret;
  }
  
  public static Short[] convertToWrapper(short[] array)
  {
    int nArray = size(array);
    Short[] ret = new Short[nArray];
    for (int i = 0; i < nArray; i++) {
      ret[i] = Short.valueOf(array[i]);
    }
    return ret;
  }
  
  public static Integer[] convertToWrapper(int[] array)
  {
    int nArray = size(array);
    Integer[] ret = new Integer[nArray];
    for (int i = 0; i < nArray; i++) {
      ret[i] = Integer.valueOf(array[i]);
    }
    return ret;
  }
  
  public static Long[] convertToWrapper(long[] array)
  {
    int nArray = size(array);
    Long[] ret = new Long[nArray];
    for (int i = 0; i < nArray; i++) {
      ret[i] = Long.valueOf(array[i]);
    }
    return ret;
  }
  
  public static Float[] convertToWrapper(float[] array)
  {
    int nArray = size(array);
    Float[] ret = new Float[nArray];
    for (int i = 0; i < nArray; i++) {
      ret[i] = Float.valueOf(array[i]);
    }
    return ret;
  }
  
  public static Double[] convertToWrapper(double[] array)
  {
    int nArray = size(array);
    Double[] ret = new Double[nArray];
    for (int i = 0; i < nArray; i++) {
      ret[i] = Double.valueOf(array[i]);
    }
    return ret;
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.ArrayUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.text.MessageFormat;
import java.util.Collection;
import java.util.Map;

public class Assert
{
  public static void fail(Object msg)
  {
    if ((msg instanceof String)) {
      throw new IllegalArgumentException((String)msg);
    }
    if (msg != null) {
      throw new IllegalArgumentException(msg.toString());
    }
  }
  
  public static void isTrue(boolean exp, String msg)
  {
    if (exp) {
      return;
    }
    fail(msg);
  }
  
  public static void isFalse(boolean exp, String msg)
  {
    if (!exp) {
      return;
    }
    fail(msg);
  }
  
  public static void isTrue(boolean exp)
  {
    isTrue(exp, "Expression must be true");
  }
  
  public static void isFalse(boolean exp)
  {
    isFalse(exp, "Expression must be false");
  }
  
  public static void isNull(Object obj, String msg)
  {
    isTrue(obj == null, msg);
  }
  
  public static void notNull(Object obj, String msg)
  {
    isFalse(obj == null, msg);
  }
  
  public static void isNull(Object obj)
  {
    isNull(obj, "Object must be null");
  }
  
  public static void notNull(Object obj)
  {
    notNull(obj, "Object must NOT be null");
  }
  
  public static void isEqual(Object obj1, Object obj2, String message)
  {
    if (ObjectUtil.equals(obj1, obj2)) {
      return;
    }
    fail(message);
  }
  
  public static void isEqual(Object obj1, Object obj2)
  {
    isEqual(obj1, obj2, "Objects are not equal");
  }
  
  public static void hasLength(String text, String msg)
  {
    if (StringUtil.hasLength(text)) {
      return;
    }
    fail(msg);
  }
  
  public static void hasLength(String text)
  {
    hasLength(text, "String argument must have length; it must not be null or empty");
  }
  
  public static void hasText(String text, String message)
  {
    if (StringUtil.hasText(text)) {
      return;
    }
    fail(message);
  }
  
  public static void hasText(String text)
  {
    hasText(text, "String argument must have text; it must not be null, empty, or blank");
  }
  
  public static void doesNotContain(String textToSearch, String substring, String msg)
  {
    if (!StringUtil.hasLength(textToSearch)) {
      return;
    }
    if (!StringUtil.hasLength(substring)) {
      return;
    }
    if (!textToSearch.contains(substring)) {
      return;
    }
    fail(msg);
  }
  
  public static void doesNotContain(String textToSearch, String substring)
  {
    doesNotContain(
      textToSearch, 
      substring, 
      "String argument must not contain the substring [" + substring + "]");
  }
  
  public static void contains(String textToSearch, String substring, String msg)
  {
    if (!StringUtil.hasLength(textToSearch)) {
      return;
    }
    if (!StringUtil.hasLength(substring)) {
      return;
    }
    if (textToSearch.contains(substring)) {
      return;
    }
    fail(msg);
  }
  
  public static void contains(String textToSearch, String substring)
  {
    contains(
      textToSearch, 
      substring, 
      "String argument must contain the substring [" + substring + "]");
  }
  
  public static <T> void notEmpty(T[] array, String message)
  {
    if (ArrayUtil.isEmpty(array)) {
      fail(message);
    }
  }
  
  public static void notEmpty(Object[] array)
  {
    notEmpty(array, "Array must not be empty: it must contain at least 1 element");
  }
  
  public static void noNullElements(Object[] array, String msg)
  {
    int i = 0;
    for (int n = ArrayUtil.size(array); i < n; i++) {
      if (array[i] == null) {
        fail(msg);
      }
    }
  }
  
  public static void noNullElements(Object[] array)
  {
    noNullElements(array, "Array must not contain any null elements");
  }
  
  public static void notEmpty(Collection<?> collection, String msg)
  {
    if (!CollectionUtil.isEmpty(collection)) {
      return;
    }
    fail(msg);
  }
  
  public static void notEmpty(Collection<?> collection)
  {
    notEmpty(collection, "Collection must not be empty: it must contain at least 1 element");
  }
  
  public static void notEmpty(Map<?, ?> map, String msg)
  {
    if (!MapUtil.isEmpty(map)) {
      return;
    }
    fail(msg);
  }
  
  public static void notEmpty(Map<?, ?> map)
  {
    notEmpty(map, "Map must not be empty; it must contain at least one entry");
  }
  
  public static void isInstanceOf(Class<?> type, Object obj, String msg)
  {
    notNull(type, "Type to check against must not be null");
    if (type.isInstance(obj)) {
      return;
    }
    fail(MessageFormat.format(
      "{0}, Object of class [{1}] must be aan instance of {2}", new Object[] {
      msg, 
      obj == null ? "null" : obj.getClass().getName(), 
      type }));
  }
  
  public static void isInstanceOf(Class<?> type, Object obj)
  {
    isInstanceOf(type, obj, "");
  }
  
  public static void isAssignable(Class<?> superType, Class<?> subType, String msg)
  {
    notNull(superType, "Type to check against must not be null");
    notNull(subType, "Type to assign must not be null");
    if (superType.isAssignableFrom(subType)) {
      return;
    }
    fail(MessageFormat.format(
      "{0}, {1} is not assignable to {2}", new Object[] {
      msg, 
      subType, 
      superType }));
  }
  
  public static void isAssignable(Class<?> superType, Class<?> subType)
  {
    isAssignable(superType, subType, "");
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.Assert
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

public final class ByteUtil
{
  public static void toBytes(int src, byte[] dest, int offset, int length)
  {
    for (int i = 0; i < length; i++) {
      dest[(offset + i)] = ((byte)(src >> 8 * i & 0xFF));
    }
  }
  
  public static void toBytes(int src, byte[] dest, int offset)
  {
    toBytes(src, dest, offset, 4);
  }
  
  public static long fromBytes(byte[] value, int offset, int length)
  {
    long result = 0L;
    int i = 0;
    for (int n = length; i < n; i++) {
      result |= (value[(offset + i)] & 0xFF) << 8 * i;
    }
    return result;
  }
  
  public static int fromBytes(byte[] value, int offset)
  {
    return (int)fromBytes(value, offset, 4);
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.ByteUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.util.Enumeration;
import java.util.Iterator;

class CollectionUtil$EnumerationAdapter<K>
  implements Iterator<K>
{
  protected final Enumeration<K> enumeration;
  
  public CollectionUtil$EnumerationAdapter(Enumeration<K> enumeration)
  {
    Assert.notNull(enumeration);
    this.enumeration = enumeration;
  }
  
  public boolean hasNext()
  {
    return enumeration.hasMoreElements();
  }
  
  public K next()
  {
    return (K)enumeration.nextElement();
  }
  
  public void remove()
  {
    throw new UnsupportedOperationException();
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.CollectionUtil.EnumerationAdapter
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;

public class CollectionUtil
{
  protected static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
  protected static final byte[] EMPTY_BYTES = EMPTY_BYTE_ARRAY;
  private static final String ARRAY_START = "{";
  private static final String ARRAY_END = "}";
  private static final String EMPTY_ARRAY = "{}";
  private static final String ARRAY_ELEMENT_SEPARATOR = ", ";
  private static final Set<Class<?>> APPROXIMABLE_COLLECTION_TYPES = Collections.unmodifiableSet(new HashSet(Arrays.asList(new Class[] {
    Collection.class, 
    Set.class, HashSet.class, SortedSet.class, LinkedHashSet.class, TreeSet.class, 
    List.class, LinkedList.class, ArrayList.class })));
  private static final Set<Class<?>> APPROXIMABLE_MAP_TYPES = Collections.unmodifiableSet(new HashSet(Arrays.asList(new Class[] {
    Map.class, SortedMap.class, HashMap.class, LinkedHashMap.class, TreeMap.class })));
  public static final Collection<Object> EMPTY_COLLECTION = Collections.unmodifiableCollection(new ArrayList());
  private static final int MULTIPLIER = 31;
  private static final int INITIAL_HASH = 7;
  
  public static boolean isEmpty(Collection<?> collection)
  {
    if (collection == null) {
      return true;
    }
    return collection.isEmpty();
  }
  
  public static int size(Collection<?> collection)
  {
    if (collection == null) {
      return 0;
    }
    return collection.size();
  }
  
  public static <T> T pickupFirst(Collection<T> collection)
  {
    if (isEmpty(collection)) {
      return null;
    }
    Iterator<T> iter = collection.iterator();
    return (T)(iter.hasNext() ? iter.next() : null);
  }
  
  public static <T> T removeFirst(Collection<T> collection)
  {
    if (isEmpty(collection)) {
      return null;
    }
    Iterator<T> iter = collection.iterator();
    if (iter.hasNext())
    {
      T ret = iter.next();
      iter.remove();
      return ret;
    }
    return null;
  }
  
  public static <T> T pickupLast(Collection<T> collection)
  {
    if (isEmpty(collection)) {
      return null;
    }
    Iterator<T> iter = collection.iterator();
    
    T temp = null;
    while (iter.hasNext()) {
      temp = iter.next();
    }
    return temp;
  }
  
  public static <T> T removeLast(Collection<T> collection)
  {
    if (isEmpty(collection)) {
      return null;
    }
    Iterator<T> iter = collection.iterator();
    
    T temp = null;
    while (iter.hasNext()) {
      temp = iter.next();
    }
    iter.remove();
    return temp;
  }
  
  static class EnumerationAdapter<K>
    implements Iterator<K>
  {
    protected final Enumeration<K> enumeration;
    
    public EnumerationAdapter(Enumeration<K> enumeration)
    {
      Assert.notNull(enumeration);
      this.enumeration = enumeration;
    }
    
    public boolean hasNext()
    {
      return enumeration.hasMoreElements();
    }
    
    public K next()
    {
      return (K)enumeration.nextElement();
    }
    
    public void remove()
    {
      throw new UnsupportedOperationException();
    }
  }
  
  public static <E> Iterator<E> iterator(Enumeration<E> enumeration)
  {
    return new EnumerationAdapter(enumeration);
  }
  
  public static boolean contains(Iterator<Object> iterator, Object element)
  {
    if (iterator == null) {
      return false;
    }
    while (iterator.hasNext())
    {
      Object candidate = iterator.next();
      if (ObjectUtil.equals(candidate, element)) {
        return true;
      }
    }
    return false;
  }
  
  public static boolean contains(Enumeration<Object> enumeration, Object element)
  {
    if (enumeration == null) {
      return false;
    }
    while (enumeration.hasMoreElements())
    {
      Object candidate = enumeration.nextElement();
      if (ObjectUtil.equals(candidate, element)) {
        return true;
      }
    }
    return false;
  }
  
  public static boolean contains(Collection<Object> collection, Object element)
  {
    if (collection == null) {
      return false;
    }
    for (Object candidate : collection) {
      if (ObjectUtil.equals(candidate, element)) {
        return true;
      }
    }
    return false;
  }
  
  public static boolean containsAny(Collection<?> source, Collection<?> candidates)
  {
    if ((isEmpty(source)) || (isEmpty(candidates))) {
      return false;
    }
    for (Object candidate : candidates) {
      if (source.contains(candidate)) {
        return true;
      }
    }
    return false;
  }
  
  public static boolean isApproximableCollectionType(Class<?> collectionType)
  {
    return APPROXIMABLE_COLLECTION_TYPES.contains(collectionType);
  }
  
  public static boolean isApproximableMapType(Class<?> mapType)
  {
    return APPROXIMABLE_MAP_TYPES.contains(mapType);
  }
  
  public static <K> Collection<K> createApproximableCollection(Collection<K> collection, int initialCapacity)
  {
    if ((collection instanceof LinkedList)) {
      return new LinkedList();
    }
    if ((collection instanceof List)) {
      return new ArrayList(initialCapacity);
    }
    if ((collection instanceof SortedSet)) {
      return new TreeSet(((SortedSet)collection).comparator());
    }
    return new LinkedHashSet(initialCapacity);
  }
  
  public static <K, V> Map<K, V> createApproximableMap(Map<K, V> map, int initialCapacity)
  {
    if ((map instanceof SortedMap)) {
      return new TreeMap(((SortedMap)map).comparator());
    }
    return new LinkedHashMap(initialCapacity);
  }
  
  public static String toString(Object obj)
  {
    if (obj == null) {
      return "<<null>>";
    }
    if ((obj instanceof String)) {
      return (String)obj;
    }
    if (obj.getClass().isArray())
    {
      int length = Array.getLength(obj);
      if (length == 0) {
        return "{}";
      }
      StringBuilder buffer = new StringBuilder();
      
      buffer.append("{");
      for (int i = 0; i < length; i++)
      {
        if (i != 0) {
          buffer.append(", ");
        }
        buffer.append(toString(Array.get(obj, i)));
      }
      buffer.append("}");
      return buffer.toString();
    }
    return (String)ObjectUtil.nvl(new String[] { obj.toString(), "" });
  }
  
  public static <E> String concatenate(E[] array, String separator)
  {
    return concatenate(array == null ? null : new ArrayUtil.ArrayIterator(array), separator);
  }
  
  public static <E> String concatenate(Collection<E> col, String separator)
  {
    return concatenate(col == null ? null : col.iterator(), separator);
  }
  
  public static <E> String concatenate(Iterator<E> iter, String separator)
  {
    if (iter == null) {
      return "<<null>>";
    }
    if (!iter.hasNext()) {
      return "{}";
    }
    StringBuilder buffer = new StringBuilder();
    boolean bInit = false;
    while (iter.hasNext())
    {
      Object obj = iter.next();
      if (bInit) {
        buffer.append(separator);
      }
      bInit = true;
      
      buffer.append(toString(obj));
    }
    return buffer.toString();
  }
  
  public static int hashCode(Object obj)
  {
    if (obj == null) {
      return 0;
    }
    if (obj.getClass().isArray())
    {
      if ((obj instanceof Object[])) {
        return hashCode((Object[])obj);
      }
      if ((obj instanceof boolean[])) {
        return hashCode((boolean[])obj);
      }
      if ((obj instanceof byte[])) {
        return hashCode((byte[])obj);
      }
      if ((obj instanceof char[])) {
        return hashCode((char[])obj);
      }
      if ((obj instanceof double[])) {
        return hashCode((double[])obj);
      }
      if ((obj instanceof float[])) {
        return hashCode((float[])obj);
      }
      if ((obj instanceof int[])) {
        return hashCode((int[])obj);
      }
      if ((obj instanceof long[])) {
        return hashCode((long[])obj);
      }
      if ((obj instanceof short[])) {
        return hashCode((short[])obj);
      }
    }
    return obj.hashCode();
  }
  
  public static int hashCode(Object[] array)
  {
    if (array == null) {
      return 0;
    }
    int hash = 7;
    int i = 0;
    for (int arraySize = array.length; i < arraySize; i++) {
      hash = 31 * hash + hashCode(array[i]);
    }
    return hash;
  }
  
  public static int hashCode(boolean[] array)
  {
    if (array == null) {
      return 0;
    }
    int hash = 7;
    int i = 0;
    for (int arraySize = array.length; i < arraySize; i++) {
      hash = 31 * hash + hashCode(array[i]);
    }
    return hash;
  }
  
  public static int hashCode(byte[] array)
  {
    if (array == null) {
      return 0;
    }
    int hash = 7;
    int i = 0;
    for (int arraySize = array.length; i < arraySize; i++) {
      hash = 31 * hash + array[i];
    }
    return hash;
  }
  
  public static int hashCode(char[] array)
  {
    if (array == null) {
      return 0;
    }
    int hash = 7;
    int i = 0;
    for (int arraySize = array.length; i < arraySize; i++) {
      hash = 31 * hash + hashCode(array[i]);
    }
    return hash;
  }
  
  public static int hashCode(double[] array)
  {
    if (array == null) {
      return 0;
    }
    int hash = 7;
    int i = 0;
    for (int arraySize = array.length; i < arraySize; i++) {
      hash = 31 * hash + hashCode(array[i]);
    }
    return hash;
  }
  
  public static int hashCode(float[] array)
  {
    if (array == null) {
      return 0;
    }
    int hash = 7;
    int i = 0;
    for (int arraySize = array.length; i < arraySize; i++) {
      hash = 31 * hash + hashCode(array[i]);
    }
    return hash;
  }
  
  public static int hashCode(int[] array)
  {
    if (array == null) {
      return 0;
    }
    int hash = 7;
    int i = 0;
    for (int arraySize = array.length; i < arraySize; i++) {
      hash = 31 * hash + hashCode(array[i]);
    }
    return hash;
  }
  
  public static int hashCode(long[] array)
  {
    if (array == null) {
      return 0;
    }
    int hash = 7;
    int i = 0;
    for (int arraySize = array.length; i < arraySize; i++) {
      hash = 31 * hash + hashCode(array[i]);
    }
    return hash;
  }
  
  public static int hashCode(short[] array)
  {
    if (array == null) {
      return 0;
    }
    int hash = 7;
    int i = 0;
    for (int arraySize = array.length; i < arraySize; i++) {
      hash = 31 * hash + hashCode(array[i]);
    }
    return hash;
  }
  
  public static int hashCode(boolean bool)
  {
    return bool ? 1231 : 1237;
  }
  
  public static int hashCode(double dbl)
  {
    long bits = Double.doubleToLongBits(dbl);
    return hashCode(bits);
  }
  
  public static int hashCode(float flt)
  {
    return Float.floatToIntBits(flt);
  }
  
  public static int hashCode(long lng)
  {
    return (int)(lng ^ lng >>> 32);
  }
  
  public static <K> boolean equals(Collection<? extends K>... cols)
  {
    boolean bInit = false;
    int size = 0;
    Collection[] arrayOfCollection = cols;int j = cols.length;
    for (int i = 0; i < j; i++)
    {
      Collection<? extends K> col = arrayOfCollection[i];
      if (!bInit)
      {
        if (col == null) {
          size = -1;
        } else {
          size = col.size();
        }
        bInit = true;
      }
      if (size < 0)
      {
        if (col != null) {
          return false;
        }
      }
      else if ((col == null) || (col.size() != size)) {
        return false;
      }
    }
    if (size < 0) {
      return true;
    }
    Iterator[] iters = new Iterator[cols.length];
    int i = 0;
    for (int n = iters.length; i < n; i++) {
      iters[i] = cols[i].iterator();
    }
    int i;
    int n;
    for (; iters[0].hasNext(); i < n)
    {
      Object obj = iters[0].next();
      i = 1;n = iters.length; continue;
      
      K other = iters[i].next();
      if (!ObjectUtil.equals(obj, other)) {
        return false;
      }
      i++;
    }
    return true;
  }
  
  public static boolean equals(Object[]... objsVar)
  {
    boolean bInit = false;
    int size = 0;
    Object[][] arrayOfObject = objsVar;int j = objsVar.length;
    for (int i = 0; i < j; i++)
    {
      Object[] objs = arrayOfObject[i];
      if (!bInit)
      {
        if (objs == null) {
          size = -1;
        } else {
          size = objs.length;
        }
        bInit = true;
      }
      if (size < 0)
      {
        if (objs != null) {
          return false;
        }
      }
      else if ((objs == null) || (objs.length != size)) {
        return false;
      }
    }
    if (size < 0) {
      return true;
    }
    int i = 1;
    for (int n = objsVar.length; i < n; i++) {
      for (int j = 0; j < size; j++) {
        if (!ObjectUtil.equals(objsVar[0][j], objsVar[i][j])) {
          return false;
        }
      }
    }
    return true;
  }
  
  public static void swap(Object[] objs, int i, int j)
  {
    Object temp = objs[i];
    objs[i] = objs[j];
    objs[j] = temp;
  }
  
  public static int isAvailableGenericTypeForCollection(Collection<?> collection, Class<?> targetClass)
  {
    if (collection.size() < 1) {
      return 0;
    }
    boolean foundNotNull = false;
    for (Object o : collection) {
      if (o != null)
      {
        foundNotNull = true;
        if (o.getClass().isAssignableFrom(targetClass)) {
          return 1;
        }
      }
    }
    if (foundNotNull) {
      return -1;
    }
    return 0;
  }
  
  public static <E> List<E> resolveSetAsList(Set<E> set)
  {
    Iterator<E> itr = set.iterator();
    ArrayList<E> result = new ArrayList();
    while (itr.hasNext())
    {
      E obj = itr.next();
      result.add(obj);
    }
    return result;
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.CollectionUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.io.IOException;
import org.tizen.sdblib.DeviceState;
import org.tizen.sdblib.IDevice;
import org.tizen.sdblib.exception.TimeoutException;
import org.tizen.sdblib.service.SyncResult;
import org.tizen.sdblib.service.SyncService;

public class DeviceUtil
{
  public static boolean isOnline(IDevice device)
  {
    if (device == null) {
      return false;
    }
    return DeviceState.ONLINE.equals(device.getState());
  }
  
  public static String uploadPackage(String localPath, IDevice device)
    throws IOException
  {
    try
    {
      String filename = FilenameUtil.getFilename(localPath);
      String remoteFilePath = FilenameUtil.addTailingPath("/tmp", filename);
      
      Log.d("device", String.format("Uploading %1$s onto device '%2$s'", new Object[] { filename, device.getSerialNumber() }));
      
      SyncService sync = device.getSyncService();
      if (sync == null) {
        throw new IOException("Unable to open sync connection!");
      }
      SyncResult result = sync.push(localPath, device.getFileEntry(remoteFilePath));
      if (!result.isOk()) {
        throw new IOException(String.format("Unable to upload file: %1$s", new Object[] { result.getMessage() }));
      }
      return remoteFilePath;
    }
    catch (TimeoutException e)
    {
      Log.e("device", "Unable to open sync connection! Timeout.");
      throw e;
    }
    catch (IOException e)
    {
      Log.e("device", String.format("Unable to open sync connection! reason: %1$s", new Object[] { e.getMessage() }));
      throw e;
    }
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.DeviceUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import org.tizen.sdblib.service.FileEntry;
import org.tizen.sdblib.service.FileEntryType;
import org.tizen.sdblib.service.ISyncProgressMonitor;

public class FileEntryUtil
{
  public static long getTotalSize(FileEntry[] entries, ISyncProgressMonitor monitor)
    throws InterruptedException
  {
    long count = 0L;
    FileEntry[] arrayOfFileEntry1 = entries;int j = entries.length;
    for (int i = 0; i < j; i++)
    {
      FileEntry e = arrayOfFileEntry1[i];
      if ((monitor != null) && (monitor.isCanceled())) {
        throw new InterruptedException("The long running operation was cancelled");
      }
      FileEntryType type = e.getType();
      if (type.canHaveChild())
      {
        FileEntry[] children = e.getChildren();
        count += getTotalSize(children, monitor);
      }
      else if (type == FileEntryType.File)
      {
        count += ParsingUtil.parseLong(e.getSize(), 0L);
      }
    }
    return count;
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.FileEntryUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class FilenameUtil
{
  public static final char SEPARATOR_DIRECTORY = '/';
  public static final int IS_VALID_NAME = 0;
  public static final int HAS_INVALID_CHARACTER = 1;
  public static final int HAS_NO_NAME = 2;
  public static final int IS_NULL = 3;
  public static boolean FILE_HAS_QUOTE_CHARACTER = false;
  
  public static String[] getCanonicalFragments(String path)
  {
    ArrayList<String> ret = new ArrayList();
    char[] characters = path.toCharArray();
    
    StringBuilder buffer = new StringBuilder();
    int status = 0;
    int i = 0;
    for (int n = characters.length; i < n; i++)
    {
      char ch = characters[i];
      switch (status)
      {
      case 0: 
        if (('/' == ch) || (File.separatorChar == ch))
        {
          String fragment = buffer.toString();
          if (!StringUtil.isEmpty(fragment)) {
            ret.add(fragment);
          }
          buffer.delete(0, buffer.length());
        }
        else if ('\'' == ch)
        {
          status = 3;
        }
        else
        {
          buffer.append(ch);
        }
        break;
      case 2: 
        if ('\'' != ch)
        {
          buffer.append('\\');
          buffer.append(ch);
        }
        status = 3;
        break;
      case 3: 
        if ('\'' == ch) {
          status = 0;
        } else if ('\\' == ch) {
          status = 2;
        } else {
          buffer.append(ch);
        }
        break;
      }
    }
    if (buffer.length() > 0)
    {
      String fragment = buffer.toString();
      if (!StringUtil.isEmpty(fragment)) {
        ret.add(fragment);
      }
      buffer.delete(0, buffer.length());
    }
    return (String[])ret.toArray(new String[0]);
  }
  
  public static String[] getSimpleCanonicalFragments(String path)
  {
    ArrayList<String> ret = new ArrayList();
    char[] characters = path.toCharArray();
    
    StringBuilder buffer = new StringBuilder();
    
    int i = 0;
    for (int n = characters.length; i < n; i++)
    {
      char ch = characters[i];
      if (('/' == ch) || (File.separatorChar == ch))
      {
        String fragment = buffer.toString();
        if (!StringUtil.isEmpty(fragment)) {
          ret.add(fragment);
        }
        buffer.delete(0, buffer.length());
      }
      else
      {
        buffer.append(ch);
      }
    }
    if (buffer.length() > 0)
    {
      String fragment = buffer.toString();
      if (!StringUtil.isEmpty(fragment)) {
        ret.add(fragment);
      }
      buffer.delete(0, buffer.length());
    }
    return (String[])ret.toArray(new String[0]);
  }
  
  public static String getTailingPath(String path, int start)
  {
    String[] fragments = getCanonicalFragments(path);
    
    StringBuilder buffer = new StringBuilder();
    
    int i = Math.max(0, ArrayUtil.size(fragments) - start);
    for (int n = ArrayUtil.size(fragments); i < n; i++)
    {
      buffer.append(fragments[i]);
      if (i < ArrayUtil.size(fragments) - 1) {
        buffer.append('/');
      }
    }
    return buffer.toString();
  }
  
  public static String removeTailingPath(String path, int numberOfPath)
  {
    String[] fragments = getCanonicalFragments(path);
    
    StringBuilder buffer = new StringBuilder();
    
    int i = 0;
    for (int n = Math.max(0, ArrayUtil.size(fragments) - numberOfPath); i < n; i++)
    {
      buffer.append('/');
      buffer.append(fragments[i]);
    }
    String ret = buffer.toString();
    if (ret.length() > 0) {
      return buffer.toString().substring((path.startsWith("/")) || (path.startsWith(File.separator)) ? 0 : 1);
    }
    return "";
  }
  
  public static String addTailingPath(String path, String pathToAdd)
  {
    return StringUtil.trimTrailingCharacter(path, '/') + '/' + StringUtil.trimLeadingCharacter(pathToAdd, '/');
  }
  
  public static boolean isAncestor(String root, String filePath)
  {
    String[] rootFragments = getCanonicalFragments(root);
    String[] fileFragments = getCanonicalFragments(filePath);
    if (fileFragments.length < rootFragments.length) {
      return false;
    }
    int i = 0;
    for (int n = rootFragments.length; i < n; i++) {
      if (!ObjectUtil.equals(rootFragments[i], fileFragments[i])) {
        return false;
      }
    }
    return true;
  }
  
  public static String getRelativePath(String root, String filePath)
  {
    String[] rootFragments = getCanonicalFragments(root);
    String[] fileFragments = getCanonicalFragments(filePath);
    int nRoot = rootFragments.length;
    int nFile = fileFragments.length;
    StringBuilder buffer = new StringBuilder();
    
    int nLoop = nRoot < nFile ? 
      nRoot : nFile;
    
    int nStartDiffer = nLoop;
    for (int i = 0; i < nLoop; i++) {
      if (!ObjectUtil.equals(rootFragments[i], fileFragments[i]))
      {
        nStartDiffer = i;
        break;
      }
    }
    for (int i = 0; i < nRoot - nStartDiffer; i++)
    {
      if (buffer.length() > 0) {
        buffer.append('/');
      }
      buffer.append("..");
    }
    for (int i = nStartDiffer; i < fileFragments.length; i++)
    {
      if (buffer.length() > 0) {
        buffer.append('/');
      }
      buffer.append(fileFragments[i]);
    }
    return buffer.toString();
  }
  
  public static String getCanonicalPath(File file)
    throws IOException
  {
    String osCanonicalPath = file.getCanonicalPath();
    
    return getCanonicalForm(osCanonicalPath);
  }
  
  public static String getCanonicalForm(String path)
  {
    String[] fragments = getCanonicalFragments(path.replace(File.separatorChar, '/'));
    
    Stack<String> stack = new Stack();
    
    int i = 0;
    String fragment;
    for (int n = ArrayUtil.size(fragments); i < n; i++)
    {
      fragment = fragments[i];
      if (!".".equals(fragment)) {
        if ("..".equals(fragment))
        {
          if (!stack.isEmpty()) {
            stack.pop();
          }
        }
        else {
          stack.push(fragment);
        }
      }
    }
    if (stack.isEmpty()) {
      return "/";
    }
    StringBuilder buffer = new StringBuilder();
    for (String f : stack)
    {
      buffer.append("/");
      buffer.append(f);
    }
    return buffer.toString();
  }
  
  public static String getFilename(String path)
  {
    return getTailingPath(path, 1);
  }
  
  public static String getEscapedName(String fileName)
  {
    Pattern sEscapePattern = Pattern.compile("([\\\\\"$])");
    return sEscapePattern.matcher(fileName).replaceAll("\\\\$1");
  }
  
  public static String addDoubleQuote(String str)
  {
    return "\"" + str + "\"";
  }
  
  public static String getName(String nameWithExt)
  {
    Assert.notNull(nameWithExt);
    
    int index = nameWithExt.lastIndexOf('.');
    if (index < 0) {
      return nameWithExt;
    }
    return nameWithExt.substring(0, index);
  }
  
  public static String getExtension(String nameWithExt)
  {
    Assert.notNull(nameWithExt);
    
    int index = nameWithExt.lastIndexOf('.');
    if (index < 0) {
      return "";
    }
    return nameWithExt.substring(index + 1);
  }
  
  public static boolean equals(File file1, File file2)
  {
    try
    {
      return ObjectUtil.equals(
        getCanonicalPath(file1), 
        getCanonicalPath(file2));
    }
    catch (IOException e)
    {
      throw new IllegalArgumentException(e);
    }
  }
  
  public static boolean equals(String path1, String path2)
  {
    return ObjectUtil.equals(path1, path2);
  }
}

/* Location:
 * Qualified Name:     org.tizen.sdblib.util.FilenameUtil
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.tizen.sdblib.util;

import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.channels.Selector;
import org.tizen.sdblib.service.ISyncProgressMonitor;

public class IOUtil
{
  private static final int BUFFER_SIZE = 8192;
  
  public static void tryClose(Closeable obj)
  {
    if (obj == null) {
      return;
    }
    try
    {
      obj.close();
    }
    catch (IOException e)
    {
      Log.e("sdb", "failed to close :" + e);
    }
  }
  
  public static void tryClose(Object... closeables)
  {
    if (closeables == null) {
      return;
    }
    Object[] arrayOfObject = closeables;int j = closeables.length;
    for (int i = 0; i < j; i++)
    {
      Object obj = arrayOfObject[i];
      if (obj != null) {
        try
        {
          if ((obj instanceof Closeable)) {
            ((Closeable)obj).close();
          } else if ((obj instanceof Selector)) {
            ((Selector)obj).close();
          } else if ((obj instanceof Socket)) {
            ((Socket)obj).close();
          } else if ((obj instanceof ServerSocket)) {
            ((ServerSocket)obj).close();
          }
        }
        catch (IOException localIOException)
        {
          Log.w("util", "close failed :" + obj);
        }
      }
    }
  }
  
  public static void tryFlush(Flushable... flushables)
  {
    if (flushables == null) {
      return;
    }
    Flushable[] arrayOfFlushable = flushables;int j = flushables.length;
    for (int i = 0; i < j; i++)
    {
      Flushable flushable = arrayOfFlushable[i];
      if (flushable != null) {
        try
        {
          flushable.flush();
        }
        catch (IOException localIOException)
        {
          Log.w("util", "Fail to flush " + flushable);
        }
      }
    }
  }
  
  public static void redirect(InputStream in, Outp
1 2 3 4 5 6 7

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd