Java Code Examples for org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder#encode()
The following examples show how to use
org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder#encode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SafeRepresenter.java From orion.server with Eclipse Public License 1.0 | 6 votes |
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); }
Example 2
Source File: SafeRepresenter.java From snake-yaml with Apache License 2.0 | 6 votes |
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); }
Example 3
Source File: Base64CoderTest.java From snake-yaml with Apache License 2.0 | 5 votes |
private void check(String text, String encoded) throws UnsupportedEncodingException { char[] s1 = Base64Coder.encode(text.getBytes("UTF-8")); String t1 = new String(s1); assertEquals(encoded, t1); byte[] s2 = Base64Coder.decode(encoded.toCharArray()); String t2 = new String(s2, "UTF-8"); assertEquals(text, t2); }
Example 4
Source File: AbstractRepresent.java From Diorite with MIT License | 5 votes |
public final Node representString(String data) { Tag tag = Tag.STR; Character style = null; if (StreamReader.NON_PRINTABLE.matcher(data).find()) { tag = Tag.BINARY; char[] binary; try { binary = Base64Coder.encode(data.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new YAMLException(e); } data = String.valueOf(binary); style = '|'; } // if no other scalar style is explicitly set, use literal style for // multiline scalars if ((this.getDefaultScalarStyle() == null) && Representer.MULTILINE_PATTERN.matcher(data).find()) { style = '|'; } return this.representer.representScalar(tag, data, style); }
Example 5
Source File: RandomEvent.java From civcraft with GNU General Public License v2.0 | 5 votes |
private String getSavedMessagesSaveString() { String out = ""; for (String message : this.savedMessages) { String msgEncoded = new String(Base64Coder.encode(message.getBytes())); out += msgEncoded+","; } return out; }
Example 6
Source File: LoreCraftableMaterial.java From civcraft with GNU General Public License v2.0 | 5 votes |
public static String serializeEnhancements(ItemStack stack) { String out = ""; for (LoreEnhancement enh : LoreCraftableMaterial.getEnhancements(stack)) { out += enh.getClass().getName()+"@"+enh.serialize(stack)+","; } String outEncoded = new String(Base64Coder.encode(out.getBytes())); return outEncoded; }
Example 7
Source File: SafeRepresenter.java From orion.server with Eclipse Public License 1.0 | 4 votes |
public Node representData(Object data) { char[] binary = Base64Coder.encode((byte[]) data); return representScalar(Tag.BINARY, String.valueOf(binary), '|'); }
Example 8
Source File: SafeRepresenter.java From snake-yaml with Apache License 2.0 | 4 votes |
public Node representData(Object data) { char[] binary = Base64Coder.encode((byte[]) data); return representScalar(Tag.BINARY, String.valueOf(binary), '|'); }
Example 9
Source File: AbstractRepresent.java From Diorite with MIT License | 4 votes |
public final Node representByteArray(byte[] data) { char[] binary = Base64Coder.encode(data); return this.representer.representScalar(Tag.BINARY, String.valueOf(binary), '|'); }
Example 10
Source File: InventorySerializer.java From civcraft with GNU General Public License v2.0 | 4 votes |
private static String getSerializedItemStack(ItemStack is) { String serializedItemStack = new String(); String isType = String.valueOf(ItemManager.getId(is.getType())); serializedItemStack += "t@" + isType; if (is.getDurability() != 0) { String isDurability = String.valueOf(is.getDurability()); serializedItemStack += "&d@" + isDurability; } if (is.getAmount() != 1) { String isAmount = String.valueOf(is.getAmount()); serializedItemStack += "&a@" + isAmount; } Map<Enchantment,Integer> isEnch = is.getEnchantments(); if (isEnch.size() > 0) { for (Entry<Enchantment,Integer> ench : isEnch.entrySet()) { serializedItemStack += "&e@" + ItemManager.getId(ench.getKey()) + "@" + ench.getValue(); } } ItemMeta meta = is.getItemMeta(); if (meta != null && meta.hasLore()) { for (String lore : meta.getLore()) { char[] encode = Base64Coder.encode(lore.getBytes()); String encodedString = new String(encode); serializedItemStack += "&l@" + encodedString; } } if (meta != null) { if (meta.getDisplayName() != null) { serializedItemStack += "&D@" + meta.getDisplayName(); } } LoreCraftableMaterial craftMat = LoreCraftableMaterial.getCraftMaterial(is); if (craftMat != null) { serializedItemStack += "&C@" + craftMat.getConfigId(); if (LoreCraftableMaterial.hasEnhancements(is)) { serializedItemStack += "&Enh@" + LoreCraftableMaterial.serializeEnhancements(is); } } AttributeUtil attrs = new AttributeUtil(is); if (attrs.hasColor()) { serializedItemStack += "&LC@" + attrs.getColor(); } return serializedItemStack; }
Example 11
Source File: RandomEvent.java From civcraft with GNU General Public License v2.0 | 3 votes |
private String getComponentVarsSaveString() { String out = ""; for (String key : this.componentVars.keySet()) { String value = this.componentVars.get(key); String keyEncoded = new String(Base64Coder.encode(key.getBytes())); String valueEncoded = new String(Base64Coder.encode(value.getBytes())); out += keyEncoded+":"+valueEncoded+","; } return out; }