Package javax.xml.bind.annotation.adapters

Examples of javax.xml.bind.annotation.adapters.HexBinaryAdapter


            }
        } else if (byte[].class == clazz && part != null && part.getTypeQName() != null
                   && part.getTypeQName().getLocalPart().equals("hexBinary")) {

            String obj = (String)unmarshall(u, source, elName, String.class, unwrap);
            return new HexBinaryAdapter().unmarshal(obj);
        } else if (part != null && u.getSchema() != null
            && !(part.getXmlSchema() instanceof XmlSchemaElement)) {
            //Validating RPC/Lit, make sure we don't try a root element name thing
            source = updateSourceWithXSIType(source, part.getTypeQName());
        }
View Full Code Here


                        writeObject(u, source, new JAXBElement(elName, cls, mObj));
                    }
                } else if (byte[].class == cls
                    && part.getTypeQName() != null
                    && part.getTypeQName().getLocalPart().equals("hexBinary")) {
                    mObj = new HexBinaryAdapter().marshal((byte[])mObj);
                    writeObject(u, source, new JAXBElement(elName, String.class, mObj));
                } else {
                    writeObject(u, source, new JAXBElement(elName, cls, mObj));
                }
            } else {
View Full Code Here

            && part != null
            && part.getTypeQName() != null
            && part.getTypeQName().getLocalPart().equals("hexBinary")) {
           
            String obj = (String)unmarshall(context, schema, source, elName, String.class, au, unwrap);
            return new HexBinaryAdapter().unmarshal(obj);
        }

        Object o = unmarshall(context, schema, source, elName, clazz, au, unwrap);
        if (o != null
            && o.getClass().isArray()
View Full Code Here

                        writeObject(u, source, new JAXBElement(elName, cls, mObj));
                    }
                } else if (byte[].class == cls
                    && part.getTypeQName() != null
                    && part.getTypeQName().getLocalPart().equals("hexBinary")) {
                    mObj = new HexBinaryAdapter().marshal((byte[])mObj);
                    writeObject(u, source, new JAXBElement(elName, String.class, mObj));
                } else if (mObj instanceof JAXBElement) {
                    writeObject(u, source, mObj);
                } else {
                    writeObject(u, source, new JAXBElement(elName, cls, mObj));
View Full Code Here

            && part != null
            && part.getTypeQName() != null
            && part.getTypeQName().getLocalPart().equals("hexBinary")) {
           
            String obj = (String)unmarshall(context, schema, source, elName, String.class, au, unwrap);
            return new HexBinaryAdapter().unmarshal(obj);
        }

        Object o = unmarshall(context, schema, source, elName, clazz, au, unwrap);
        if (o != null
            && o.getClass().isArray()
View Full Code Here

      }
     
     
      // any additional information in the NBT String?
      if (sNBTItemStack != null) {
        byte[]          bytes  = new HexBinaryAdapter().unmarshal(sNBTItemStack);
        ByteArrayInputStream  bais  = new ByteArrayInputStream(bytes);
        DataInputStream      dis    = new DataInputStream(bais);
       
        // MC 1.4.6
        if (version.contains("1.4.6")) {
          net.minecraft.server.v1_4_R1.NBTBase    tag    = net.minecraft.server.v1_4_R1.NBTBase.b(dis);
          net.minecraft.server.v1_4_R1.ItemStack  stack  = org.bukkit.craftbukkit.v1_4_R1.inventory.CraftItemStack.asNMSCopy(itemStack);
         
          stack.setTag((net.minecraft.server.v1_4_R1.NBTTagCompound)tag);
         
          itemStack = org.bukkit.craftbukkit.v1_4_R1.inventory.CraftItemStack.asBukkitCopy(stack);
          ShowCaseStandalone.slog(Level.INFO, "Loaded NBT from DIS - MC 1.4.6");
         
        // MC 1.4.5
        } else if (version.contains("1.4.5")) {
          net.minecraft.server.v1_4_5.NBTBase    tag    = net.minecraft.server.v1_4_5.NBTBase.b(dis);
          net.minecraft.server.v1_4_5.ItemStack  stack  = org.bukkit.craftbukkit.v1_4_5.inventory.CraftItemStack.asNMSCopy(itemStack);
         
          stack.setTag((net.minecraft.server.v1_4_5.NBTTagCompound)tag);
         
          itemStack = org.bukkit.craftbukkit.v1_4_5.inventory.CraftItemStack.asBukkitCopy(stack);
          ShowCaseStandalone.slog(Level.INFO, "Loaded NBT from DIS - MC 1.4.5");
         
        }
      }
     
     
      // any additional information in the NBTStorage?
      if (storNBT != null) {
        // MC 1.4.5
        if (version.contains("1.4.5")) {
          net.minecraft.server.v1_4_R1.ItemStack  stack  = org.bukkit.craftbukkit.v1_4_R1.inventory.CraftItemStack.asNMSCopy(itemStack);
         
          stack.setTag(new com.kellerkindt.scs.internals.NBTStorage(storNBT).getNBTTagCompound());
         
          itemStack = org.bukkit.craftbukkit.v1_4_R1.inventory.CraftItemStack.asBukkitCopy(stack);
          ShowCaseStandalone.slog(Level.INFO, "Loaded NBT from NBTStorage - MC 1.4.5");
       
        // MC 1.4.6
        } else if (version.contains("1.4.6")) {
         

          String tagStringAuthor    = "author";
          String tagStringTitle    = "title";
          String tagStringPages    = "pages";
          String tagStringPagePref  = "page-";
         
          String tagIntegerPagesSize   = "pages";
         
         
          String   author  = storNBT.getString  (tagStringAuthor);
          String   title  = storNBT.getString  (tagStringTitle);
          Integer pSize  = storNBT.getInteger(tagIntegerPagesSize);
         
          net.minecraft.server.v1_4_R1.NBTTagCompound compound  = new net.minecraft.server.v1_4_R1.NBTTagCompound();
         
          if (pSize != null) {
            net.minecraft.server.v1_4_R1.NBTTagList  list  = new net.minecraft.server.v1_4_R1.NBTTagList();
            for (int i = 0; i < pSize; i++) {
              String       page  = storNBT.getString(tagStringPagePref+i);
             
              if (page != null) {
                net.minecraft.server.v1_4_R1.NBTTagString tag  = new net.minecraft.server.v1_4_R1.NBTTagString(page);
                tag.data      = page;
                list.add(tag);
              }
            }
           
            compound.set(tagStringPages, list);
          }
         
          if (title != null)
            compound.setString(tagStringTitle, title);
         
          if (author != null)
            compound.setString(tagStringAuthor, author);
         
         
          net.minecraft.server.v1_4_R1.ItemStack  stack  = org.bukkit.craftbukkit.v1_4_R1.inventory.CraftItemStack.asNMSCopy(itemStack);
         
          stack.setTag(compound);
         
          itemStack = org.bukkit.craftbukkit.v1_4_R1.inventory.CraftItemStack.asBukkitCopy(stack);
          ShowCaseStandalone.slog(Level.INFO, "Loaded NBT from NBTStorage - MC 1.4.6");
         
         
        }
      }
     
      // enchantments available?
      Map<Enchantment, Integer> enchantments = null;
     
      if (sEnchantments != null) {
        enchantments = new HashMap<Enchantment, Integer>();
       
        String ench[]    = sEnchantments.split(",");
        for (String string : ench) {
          Enchantment  enchantment  = Utilities.getEnchantmentFromString    (string);
          int      level    = Utilities.getEnchantmentLevelFromString  (string);
         
          if (enchantment != null) {
            enchantments.put(enchantment, level);
          }

        }
      }
     
      // add the enchantments if there are set some
      if (enchantments != null) {
        for (Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
         
          if (Properties.allowUnsafeEnchantments) {
            itemStack.addUnsafeEnchantment(entry.getKey(), entry.getValue());
          } else {
            itemStack.addEnchantment(entry.getKey(), entry.getValue());
          }
        }
      }
    }
   
   
    // storage version 4
    else if (interpretationVersion == 4) {
      // load binary array
      String   hexString  = storage.getString(args[0]);
      byte[]  array    = new HexBinaryAdapter().unmarshal(hexString);
     
      // init streams
      ByteArrayInputStream  bais  = new ByteArrayInputStream(array);
      ObjectInputStream    ois    = new ObjectInputStream(bais);
     
View Full Code Here

   
    // parse
    NBTBase.a(base, dos);
   
    // to string and return
    return new HexBinaryAdapter().marshal(baos.toByteArray());
  }
View Full Code Here

   * @return Loaded NBTBase
   */
  public static NBTBase getNBTBaseFromString (String string) {
   
    // create streams
    byte[]          bytes  = new HexBinaryAdapter().unmarshal(string);
    ByteArrayInputStream  bais  = new ByteArrayInputStream(bytes);
    DataInputStream      dis    = new DataInputStream(bais);
   
    // load
    return NBTBase.b(dis);
View Full Code Here

    // write map
    oos.writeObject(itemMeta.serialize());
    oos.flush();
   
    // toHexString
    return new HexBinaryAdapter().marshal(baos.toByteArray());
  }
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  public static ItemMeta toItemMeta (String hex) throws IOException {
   
    // create streams
    byte[]          bytes  = new HexBinaryAdapter().unmarshal(hex);
    ByteArrayInputStream  bais  = new ByteArrayInputStream(bytes);
    ObjectInputStream    ois    = new ObjectInputStream(bais);
   
    try {
      return (ItemMeta)ConfigurationSerialization.deserializeObject((Map<String, Object>)ois.readObject());
View Full Code Here

TOP

Related Classes of javax.xml.bind.annotation.adapters.HexBinaryAdapter

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.