Package com.forgeessentials.data.api

Examples of com.forgeessentials.data.api.ClassContainer


    }

    @Override
    public void buildEntry(HashMap<String, ClassContainer> fields)
    {
        fields.put(KEY, new ClassContainer(String.class));
        fields.put(TYPE, new ClassContainer(int.class));
        fields.put(PRIMITIVE, new ClassContainer(String.class));
        fields.put(TAG_LIST, new ClassContainer(NBTTagList.class));
        fields.put(COMPOUND, new ClassContainer(NBTTagCompound.class));
        fields.put(B_ARRAY, new ClassContainer(byte[].class));
        fields.put(I_ARRAY, new ClassContainer(int[].class));
    }
View Full Code Here


    @Override
    public ClassContainer getTypeOfField(String field)
    {
        if (field.equalsIgnoreCase(COMPOUND))
        {
            return new ClassContainer(NBTTagCompound.class);
        }
        else
        {
            return null;
        }
View Full Code Here

    inLine = AObj.SaveInline();

    Class<?> currentType = type;
    Class<?> tempType;
    Type aTempType;
    ClassContainer tempContainer;
    SaveableField info;

    HashSet<String> overrides = new HashSet<String>();

    // Iterate through this class and superclass's and get saveable fields
    do
    {
      // Locate all members that are saveable.
      for (Field f : currentType.getDeclaredFields())
      {
        if (overrides.contains(f.getName()))
        {
          overrides.remove(f.getName());
          continue;
        }

        // if its a saveable field
        if (f.isAnnotationPresent(SaveableField.class))
        {
          info = f.getAnnotation(SaveableField.class);

          // register ignoire classes....
          if (info != null && !info.overrideParent().isEmpty())
          {
            overrides.add(info.overrideParent());
          }

          tempType = f.getType();
          aTempType = f.getGenericType();
          if (aTempType instanceof ParameterizedType)
          {
            Type[] types = ((ParameterizedType) aTempType).getActualTypeArguments();
            Class<?>[] params = new Class[types.length];
            for (int i = 0; i < types.length; i++)
            {
              if (types[i] instanceof Class)
              {
                params[i] = (Class<?>) types[i];
              }
              else if (types[i] instanceof ParameterizedType)
              {
                params[i] = (Class<?>) ((ParameterizedType) types[i]).getRawType();
              }
            }

            tempContainer = new ClassContainer(tempType, params);
            fields.put(f.getName(), tempContainer);
          }
          else
          {
            tempContainer = new ClassContainer(tempType);
            fields.put(f.getName(), tempContainer);
          }
        }

        // check for UniqueKey
View Full Code Here

  @Override
  public TypeData getTypeDataFromObject(Object objectSaved)
  {
    Class<?> c = objectSaved.getClass();
    TypeData data = DataStorageManager.getDataForType(new ClassContainer(type));
    Field f = null;
    Object obj;

    // do Unique key stuff
    try
View Full Code Here

    private void createTaggedClassFromResult(HashMap<String, Object> result, ITypeInfo info, TypeData data) throws SQLException
    {
        ITypeInfo infoCursor;
        TypeData dataCursor = null;
        ClassContainer tmpClass;
        Object tempVal;

        for (Entry<String, Object> entry : result.entrySet())
        {
            dataCursor = data;
View Full Code Here

        return builder.toString();
    }

    private ArrayList<String> generateInsertBatch(ITypeInfo info, TypeData data)
    {
        ClassContainer type = info.getType();

        ArrayList<Pair<String, String>> fieldValueMap = new ArrayList<Pair<String, String>>();
        ArrayList<String> statements = new ArrayList<String>();

        // MultiVal list
        ArrayList<Pair<String, TypeData>> multiVals = new ArrayList<Pair<String, TypeData>>();

        // Iterate through fields and build up name=>value pair list.
        ArrayList<Pair> temp;
        for (Entry<String, Object> entry : data.getAllFields())
        {
            if (entry.getValue() == null)
            {
                continue;
            }

            temp = fieldToValues(entry.getKey(), info.getTypeOfField(entry.getKey()), entry.getValue());

            // catch multivals and add them to a different list.
            for (Pair p : temp)
            {
                if (((String) p.getFirst()).contains(MULTI_MARKER) && p.getSecond() instanceof TypeData)
                {
                    multiVals.add(p);
                }
                else
                {
                    fieldValueMap.add(p);
                }
            }
        }

        String table = type.getFileSafeName();
        boolean isEntry = false;

        // Deal with unique field. No uniqueFields for these...
        if (!(info instanceof TypeEntryInfo))
        {
View Full Code Here

     * @return Array of field => H2 type names.
     */
    private ArrayList<Pair<String, String>> fieldToColumns(ITypeInfo info, String columnName, String field)
    {
        ArrayList<Pair<String, String>> fields = new ArrayList<Pair<String, String>>();
        ClassContainer con = info.getTypeOfField(field);
        Class type = con.getType();

        if (!StorageManager.isTypeComplex(con))
        {
            if (type.equals(int.class) || type.equals(Integer.class))
            {
View Full Code Here

    private static HashMultimap<UUID, Mail> map = HashMultimap.create();

    public static void AddMail(Mail mail)
    {
        map.put(mail.getReceiver(), mail);
        DataStorageManager.getReccomendedDriver().saveObject(new ClassContainer(Mail.class), mail);

        EntityPlayer player = UserIdent.getPlayerByUuid(mail.getReceiver());

        if (player != null)
        {
View Full Code Here

        }
    }

    public static void LoadAll()
    {
        for (Object obj : DataStorageManager.getReccomendedDriver().loadAllObjects(new ClassContainer(Mail.class)))
        {
            Mail mail = (Mail) obj;
            map.put(mail.getReceiver(), mail);
        }
    }
View Full Code Here

    public static void SaveAll()
    {
        for (Mail mail : map.values())
        {
            DataStorageManager.getReccomendedDriver().saveObject(new ClassContainer(Mail.class), mail);
        }
    }
View Full Code Here

TOP

Related Classes of com.forgeessentials.data.api.ClassContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.