當前位置: 首頁>>代碼示例>>Java>>正文


Java Base64Coder類代碼示例

本文整理匯總了Java中org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder的典型用法代碼示例。如果您正苦於以下問題:Java Base64Coder類的具體用法?Java Base64Coder怎麽用?Java Base64Coder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Base64Coder類屬於org.yaml.snakeyaml.external.biz.base64Coder包,在下文中一共展示了Base64Coder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: itemStackArrayToBase64

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
/**
 * 
 * A method to serialize an {@link ItemStack} array to Base64 String.
 * 
 * <p />
 * 
 * Based off of {@link #toBase64(Inventory)}.
 * 
 * @param items to turn into a Base64 String.
 * @return Base64 string of the items.
 * @throws IllegalStateException
 */
public static String itemStackArrayToBase64(ItemStack[] items) throws IllegalStateException {
	try {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
        
        // Write the size of the inventory
        dataOutput.writeInt(items.length);
        
        // Save every element in the list
        for (int i = 0; i < items.length; i++) {
            dataOutput.writeObject(items[i]);
        }
        
        // Serialize that array
        dataOutput.close();
        return Base64Coder.encodeLines(outputStream.toByteArray());
    } catch (Exception e) {
        throw new IllegalStateException("Unable to save item stacks.", e);
    }
}
 
開發者ID:untocodes,項目名稱:Vaults,代碼行數:33,代碼來源:Invtobase.java

示例2: getProfile

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
public static GameProfile getProfile(UUID uuid, String name, String skinUrl, String capeUrl)
{
    GameProfile profile = new GameProfile(uuid, name);
    boolean cape = capeUrl != null && !capeUrl.isEmpty();

    List<Object> args = new ArrayList<Object>();
    args.add(System.currentTimeMillis());
    args.add(UUIDTypeAdapter.fromUUID(uuid));
    args.add(name);
    args.add(skinUrl);
    if (cape)
    {
        args.add(capeUrl);
    }

    profile.getProperties().put("textures", new Property("textures", Base64Coder.encodeString(String.format(cape ? JSON_CAPE : JSON_SKIN, args.toArray(new Object[args.size()])))));
    return profile;
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:19,代碼來源:GameProfileBuilder.java

示例3: representData

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
public Node representData(Object data) {
    Tag tag = Tag.STR;
    Character style = null;
    String value = data.toString();
    if (StreamReader.NON_PRINTABLE.matcher(value).find()) {
        tag = Tag.BINARY;
        char[] binary;
        try {
            binary = Base64Coder.encode(value.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new YAMLException(e);
        }
        value = String.valueOf(binary);
        style = '|';
    }
    // if no other scalar style is explicitly set, use literal style for
    // multiline scalars
    if (defaultScalarStyle == null && MULTILINE_PATTERN.matcher(value).find()) {
        style = '|';
    }
    return representScalar(tag, value, style);
}
 
開發者ID:imkiva,項目名稱:AndroidApktool,代碼行數:23,代碼來源:SafeRepresenter.java

示例4: getProfile

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
/**
 * Builds a GameProfile for the specified args
 *
 * @param name    The name
 * @param skinUrl Url from the skin image
 * @param capeUrl Url from the cape image
 * @return A GameProfile built from the arguments
 * @see GameProfile
 */
public static GameProfile getProfile(String name, String skinUrl, String capeUrl) {
    UUID id = UUID.randomUUID();
    GameProfile profile = new GameProfile(id, name);
    boolean cape = capeUrl != null && !capeUrl.isEmpty();

    List<Object> args = new ArrayList<>();
    args.add(System.currentTimeMillis());
    args.add(UUIDTypeAdapter.fromUUID(id));
    args.add(name);
    args.add(skinUrl);
    if (cape) args.add(capeUrl);

    profile.getProperties().clear();
    profile.getProperties().put("textures", new Property("textures", Base64Coder.encodeString(String.format(cape ? JSON_CAPE : JSON_SKIN, args.toArray(new Object[args.size()])))));
    return profile;
}
 
開發者ID:AlphaHelixDev,項目名稱:AlphaLibary,代碼行數:26,代碼來源:GameProfileBuilder.java

示例5: toBase64

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
/**
 * A method to serialize an inventory to Base64 string.
 * 
 * <p />
 * 
 * Special thanks to Comphenix in the Bukkit forums or also known
 * as aadnk on GitHub.
 * 
 * <a href="https://gist.github.com/aadnk/8138186">Original Source</a>
 * 
 * @param inventory to serialize
 * @return Base64 string of the provided inventory
 * @throws IllegalStateException
 */
public static String toBase64(Inventory inventory) throws IllegalStateException {
    try {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
        
        dataOutput.writeInt(inventory.getSize());
        
        for (int i = 0; i < inventory.getSize(); i++) {
            dataOutput.writeObject(inventory.getItem(i));
        }
        
        dataOutput.close();
        return Base64Coder.encodeLines(outputStream.toByteArray());
    } catch (Exception e) {
        throw new IllegalStateException("Unable to save item stacks.", e);
    }
}
 
開發者ID:untocodes,項目名稱:Vaults,代碼行數:32,代碼來源:Invtobase.java

示例6: fromBase64

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
/**
 * 
 * A method to get an {@link Inventory} from an encoded, Base64, string.
 * 
 * <p />
 * 
 * Special thanks to Comphenix in the Bukkit forums or also known
 * as aadnk on GitHub.
 * 
 * <a href="https://gist.github.com/aadnk/8138186">Original Source</a>
 * 
 * @param data Base64 string of data containing an inventory.
 * @return Inventory created from the Base64 string.
 * @throws IOException
 */
public static Inventory fromBase64(String data) throws IOException {
    try {
        ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
        BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
        Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt(),"Vault");
        
        for (int i = 0; i < inventory.getSize(); i++) {
            inventory.setItem(i, (ItemStack) dataInput.readObject());
        }
        
        dataInput.close();
        return inventory;
    } catch (ClassNotFoundException e) {
        throw new IOException("Unable to decode class type.", e);
    }
}
 
開發者ID:untocodes,項目名稱:Vaults,代碼行數:32,代碼來源:Invtobase.java

示例7: itemStackArrayFromBase64

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
/**
     * Gets an array of ItemStacks from Base64 string.
     * 
     * <p />
     * 
     * Base off of {@link #fromBase64(String)}.
     * 
     * @param data Base64 string to convert to ItemStack array.
     * @return ItemStack array created from the Base64 string.
     * @throws IOException
     */
    public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
    	try {
            ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
            BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
            ItemStack[] items = new ItemStack[dataInput.readInt()];
    
            for (int i = 0; i < items.length; i++) {
            	items[i] = (ItemStack) dataInput.readObject();
            }
            
            dataInput.close();
            return items;
        } catch (ClassNotFoundException e) {
            throw new IOException("Unable to decode class type.", e);
        }
}
 
開發者ID:untocodes,項目名稱:Vaults,代碼行數:28,代碼來源:Invtobase.java

示例8: getSkullFromURL

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
public static ItemStack getSkullFromURL(String url, String name)
		throws Exception {
	ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
	SkullMeta sm = (SkullMeta) skull.getItemMeta();
	sm.setOwner("NacOJerk");
	skull.setItemMeta(sm);
	url = Base64Coder.encodeString("{textures:{SKIN:{url:\"" + url
			+ "\"}}}");
	GameProfile gp = new GameProfile(UUID.randomUUID(), name);
	gp.getProperties().put("textures", new Property("textures", url));
	Object isskull = asNMSCopy(skull);
	Object nbt = getNMS("NBTTagCompound").getConstructor().newInstance();
	Method serialize = getNMS("GameProfileSerializer").getMethod(
			"serialize", getNMS("NBTTagCompound"), GameProfile.class);
	serialize.invoke(null, nbt, gp);
	Object nbtr = isskull.getClass().getMethod("getTag").invoke(isskull);
	nbtr.getClass().getMethod("set", String.class, getNMS("NBTBase"))
			.invoke(nbtr, "SkullOwner", nbt);
	isskull.getClass().getMethod("setTag", getNMS("NBTTagCompound"))
			.invoke(isskull, nbtr);
	skull = asBukkitCopy(isskull);
	return skull;
}
 
開發者ID:NacOJerk,項目名稱:Pokecraft,代碼行數:24,代碼來源:ItemStackUtils.java

示例9: itemStackArrayToBase64

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
/**
 * 
 * @param items
 * @return A base64 encoded String
 * @throws IllegalStateException
 * 
 * It encodes an {@link ItemStack} array to a base64 String 
 */
public static String itemStackArrayToBase64(ItemStack[] items) throws IllegalStateException
{
   	try {
           ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
           BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
           
           dataOutput.writeInt(items.length);
           
           for (int i = 0; i < items.length; i++) {
               dataOutput.writeObject(items[i]);
           }
           
           dataOutput.close();
           return Base64Coder.encodeLines(outputStream.toByteArray());
       } catch (Exception e) {
           throw new IllegalStateException("Unable to save item stacks.", e);
       }
 }
 
開發者ID:benfah,項目名稱:Bags,代碼行數:27,代碼來源:InventorySerializer.java

示例10: itemStackArrayFromBase64

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
   	try {
           ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
           BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
           ItemStack[] items = new ItemStack[dataInput.readInt()];
   
           for (int i = 0; i < items.length; i++) {
           	items[i] = (ItemStack) dataInput.readObject();
           }
           
           dataInput.close();
           return items;
       } catch (ClassNotFoundException e) {
           throw new IOException("Unable to decode class type.", e);
       }
}
 
開發者ID:benfah,項目名稱:Bags,代碼行數:17,代碼來源:InventorySerializer.java

示例11: test

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
@Test
public void test() throws Exception {
    File file = new File(FileUtils.getFile("").getAbsolutePath() + "/src/main/resources/ezyfox/config/handlers.properties");
    List<Class<?>> classes = ClassFinder.find("com.tvd12.ezyfox.sfs2x.serverhandler");
    StringBuilder builder = new StringBuilder();
    for(Class<?> clazz : classes) {
        if(!Modifier.isAbstract(clazz.getModifiers())
                && Modifier.isPublic(clazz.getModifiers())
                && !Modifier.isStatic(clazz.getModifiers())) {
            ServerEventHandler handler = (ServerEventHandler) clazz.getDeclaredConstructor(
                    BaseAppContext.class).newInstance(newAppContext());
            System.out.println(handler.eventName() + "=" + clazz.getName());
            if(!handler.eventName().equals(ServerEvent.SERVER_INITIALIZING) &&
                    !handler.eventName().equals(ServerEvent.ZONE_EXTENSION_DESTROY) &&
                    !handler.eventName().equals(ServerEvent.ROOM_EXTENSION_DESTROY) &&
                    !handler.eventName().equals(ServerEvent.ROOM_USER_DISCONNECT) &&
            		!handler.eventName().equals(ServerEvent.ROOM_USER_RECONNECT))
                builder.append(handler.eventName() + "=" + clazz.getName()).append("\n");
        }
            
    }
    FileUtils.write(file, Base64Coder.encodeString(builder.toString().trim()));
}
 
開發者ID:youngmonkeys,項目名稱:ezyfox-sfs2x,代碼行數:24,代碼來源:ListServerEventHandlerTest.java

示例12: itemStackArrayToBase64

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
public static String itemStackArrayToBase64(ItemStack[] items) throws IllegalStateException {
	try {
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);

		// Write the size of the inventory
		dataOutput.writeInt(items.length);

		// Save every element in the list
		for (int i = 0; i < items.length; i++) {
			dataOutput.writeObject(items[i]);
		}

		// Serialize that array
		dataOutput.close();
		return Base64Coder.encodeLines(outputStream.toByteArray());
	} catch (Exception e) {
		throw new IllegalStateException("Unable to save item stacks.", e);
	}
}
 
開發者ID:bobmandude9889,項目名稱:iZenith-PVP,代碼行數:21,代碼來源:Util.java

示例13: itemStackArrayFromBase64

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
	try {
		ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
		BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
		ItemStack[] items = new ItemStack[dataInput.readInt()];

		// Read the serialized inventory
		for (int i = 0; i < items.length; i++) {
			items[i] = (ItemStack) dataInput.readObject();
		}

		dataInput.close();
		return items;
	} catch (ClassNotFoundException e) {
		throw new IOException("Unable to decode class type.", e);
	}
}
 
開發者ID:bobmandude9889,項目名稱:iZenith-PVP,代碼行數:18,代碼來源:Util.java

示例14: deserializeItem

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
/**
 * Get an ItemStack from a JsonObject.
 *
 * @param data The Json to read.
 * @param format The data format being used. Refer to {@link PlayerSerializer#serialize(PWIPlayer)}.
 * @return The deserialized item stack.
 */
public ItemStack deserializeItem(JsonObject data, int format) {
    switch (format) {
        case 0:
            return getItem(data);
        case 1:
        case 2:
            try (ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data.get("item").getAsString()));
                 BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream)) {
                return (ItemStack) dataInput.readObject();
            } catch (IOException | ClassNotFoundException ex) {
                ConsoleLogger.severe("Unable to deserialize an item:", ex);
                return new ItemStack(Material.AIR);
            }
        default:
            throw new IllegalArgumentException("Unknown data format '" + format + "'");
    }
}
 
開發者ID:Gnat008,項目名稱:PerWorldInventory,代碼行數:25,代碼來源:ItemSerializer.java

示例15: toBase64

import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; //導入依賴的package包/類
public static String toBase64(Inventory inventory) throws IllegalStateException {
	try {
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);

		// Write the size of the inventory
		dataOutput.writeInt(inventory.getSize());

		// Save every element in the list
		for (int i = 0; i < inventory.getSize(); i++) {
			dataOutput.writeObject(inventory.getItem(i));
		}

		// Serialize that array
		dataOutput.close();
		return Base64Coder.encodeLines(outputStream.toByteArray());
	} catch (Exception e) {
		throw new IllegalStateException("Unable to save item stacks.", e);
	}
}
 
開發者ID:michaelkrauty,項目名稱:Kettle,代碼行數:21,代碼來源:Util.java


注:本文中的org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。