Java Code Examples for java.nio.charset.CharacterCodingException#toString()

The following examples show how to use java.nio.charset.CharacterCodingException#toString() . 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: Text.java    From pxf with Apache License 2.0 5 votes vote down vote up
/**
 * Sets to contain the contents of a string.
 *
 * @param string input string
 */
public void set(String string) {
    try {
        ByteBuffer bb = encode(string, true);
        bytes = bb.array();
        length = bb.limit();
    } catch (CharacterCodingException e) {
        throw new RuntimeException("Should not have happened "
                + e.toString());
    }
}
 
Example 2
Source File: Text.java    From pxf with Apache License 2.0 5 votes vote down vote up
/**
 * Convert text back to string
 *
 * @see java.lang.Object#toString()
 */
@Override
public String toString() {
    try {
        return decode(bytes, 0, length);
    } catch (CharacterCodingException e) {
        throw new RuntimeException("Should not have happened "
                + e.toString());
    }
}
 
Example 3
Source File: Text.java    From Canova with Apache License 2.0 5 votes vote down vote up
/** Set to contain the contents of a string.
 */
public void set(String string) {
    try {
        ByteBuffer bb = encode(string, true);
        bytes = bb.array();
        length = bb.limit();
    }catch(CharacterCodingException e) {
        throw new RuntimeException("Should not have happened " + e.toString());
    }
}
 
Example 4
Source File: Text.java    From Canova with Apache License 2.0 5 votes vote down vote up
/**
 * Convert text back to string
 * @see java.lang.Object#toString()
 */
public String toString() {
    try {
        return decode(bytes, 0, length);
    } catch (CharacterCodingException e) {
        throw new RuntimeException("Should not have happened " + e.toString());
    }
}
 
Example 5
Source File: Text.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/** Set to contain the contents of a string. 
 */
public void set(String string) {
  try {
    ByteBuffer bb = encode(string, true);
    bytes = bb.array();
    length = bb.limit();
  }catch(CharacterCodingException e) {
    throw new RuntimeException("Should not have happened " + e.toString()); 
  }
}
 
Example 6
Source File: Text.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/** 
 * Convert text back to string
 * @see java.lang.Object#toString()
 */
public String toString() {
  try {
    return decode(bytes, 0, length);
  } catch (CharacterCodingException e) { 
    throw new RuntimeException("Should not have happened " + e.toString()); 
  }
}
 
Example 7
Source File: StringRecord.java    From stratosphere with Apache License 2.0 5 votes vote down vote up
/**
 * Set to contain the contents of a string.
 */
public void set(final String string) {
	try {
		final ByteBuffer bb = encode(string, true);
		this.bytes = bb.array();
		this.length = bb.limit();
		this.hash = 0;
	} catch (CharacterCodingException e) {
		throw new RuntimeException("Should not have happened " + e.toString());
	}
}
 
Example 8
Source File: StringRecord.java    From stratosphere with Apache License 2.0 5 votes vote down vote up
/**
 * Convert text back to string
 * 
 * @see java.lang.Object#toString()
 */
public String toString() {
	try {
		return decode(bytes, 0, length);
	} catch (CharacterCodingException e) {
		throw new RuntimeException("Should not have happened " + e.toString());
	}
}
 
Example 9
Source File: Text.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/** Set to contain the contents of a string. 
 */
public void set(String string) {
  try {
    ByteBuffer bb = encode(string, true);
    bytes = bb.array();
    length = bb.limit();
  }catch(CharacterCodingException e) {
    throw new RuntimeException("Should not have happened " + e.toString()); 
  }
}
 
Example 10
Source File: Text.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/** 
 * Convert text back to string
 * @see java.lang.Object#toString()
 */
public String toString() {
  try {
    return decode(bytes, 0, length);
  } catch (CharacterCodingException e) { 
    throw new RuntimeException("Should not have happened " + e.toString()); 
  }
}
 
Example 11
Source File: MainActivity.java    From ArscEditor with Apache License 2.0 4 votes vote down vote up
@Override
protected String doInBackground(String... params) {
	switch (ResType) {

	case ARSC:
		for (ContentValues resource : RESOURCES) {
			// 获取资源的键
			String NAME = (String) resource.get(MyObj.NAME);
			// 获取资源的值
			String VALUE = (String) resource.get(MyObj.VALUE);
			// 获取资源类型
			String TYPE = (String) resource.get(MyObj.TYPE);
			// 获取资源分支
			String CONFIG = (String) resource.get(MyObj.CONFIG);

			// 如果资源的Config开头存在-符号,并且Config列表中不存在该资源的Config元素,并且资源种类是params[0]的值
			if (CONFIG.startsWith("-") && !Configs.contains(CONFIG.substring(1)) && TYPE.equals(params[0]))
				// 向Config列表中添加元素
				Configs.add(CONFIG.substring(1));
			// 如果资源的Config开头不存在-符号,并且Config列表中不存在该资源的Config元素,并且资源种类是params[0]的值
			else if (!CONFIG.startsWith("-") && !Configs.contains(CONFIG) && TYPE.equals(params[0]))
				Configs.add(CONFIG);

			// 如果资源的Config开头存在-符号,并且Config列表中存在该资源的Config元素,并且Config是params[1]的值
			if (TYPE.equals(params[0]) && CONFIG.startsWith("-") && CONFIG.substring(1).equals(params[1])) {
				// 向储存字符串的列表中添加字符串成员
				txtOriginal.add(VALUE);
				// 向储存修改后的字符串的列表中添加空成员
				txtTranslated.add("");
				// 向储存资源的键的列表添加键
				txtTranslated_Key.add(NAME);
				// 如果资源的Config开头不存在-符号,并且Config列表中存在该资源的Config元素,并且Config是params[1]的值
			} else if (TYPE.equals(params[0]) && !CONFIG.startsWith("-") && CONFIG.equals(params[1])) {
				// 向储存字符串的列表中添加字符串成员
				txtOriginal.add(VALUE);
				// 向储存修改后的字符串的列表中添加空成员
				txtTranslated.add("");
				// 向储存资源的键的列表添加键
				txtTranslated_Key.add(NAME);
			}
		}
		break;
	case AXML:
		try {
			mAndRes.mAXMLDecoder.getStrings(txtOriginal);
			for (int i = 0; i < txtOriginal.size(); i++) {
				// 向储存修改后的字符串的列表中添加空成员
				txtTranslated.add("");
				// 向储存资源的键添加空成员
				txtTranslated_Key.add("");
			}
		} catch (CharacterCodingException e) {
			return e.toString();
		}
		break;
	case DEX:

		break;
	}
	// 返回一个成功的标志
	return getString(R.string.success);
}