当前位置: 首页>>代码示例>>Java>>正文


Java TranscodeException类代码示例

本文整理汇总了Java中com.ximpleware.TranscodeException的典型用法代码示例。如果您正苦于以下问题:Java TranscodeException类的具体用法?Java TranscodeException怎么用?Java TranscodeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TranscodeException类属于com.ximpleware包,在下文中一共展示了TranscodeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transcodeAndFill2

import com.ximpleware.TranscodeException; //导入依赖的package包/类
public static final int transcodeAndFill2(int initOutPosition, 
        byte[] input, 
        byte[] output,
        int offset, int length, int input_encoding, int output_encoding)
        throws TranscodeException {
    //int len = 0;
    int k = offset;
    int c, i = initOutPosition;
    while (k < offset + length) {
        long l = decode(input, k, input_encoding);
        k = (int) (l >> 32);
        c = (int) l;
        i = encode(output, i, c, output_encoding);
    }
    return i;
}
 
开发者ID:CoolBalance,项目名称:vtd-xml,代码行数:17,代码来源:Transcoder.java

示例2: getLen

import com.ximpleware.TranscodeException; //导入依赖的package包/类
/**
 * 
 * @param ch
 * @param output_encoding
 * @return
 * @throws TranscodeException
 *  
 */
public static final int getLen(int ch, int output_encoding)
        throws TranscodeException {
    switch (output_encoding) {
    case VTDNav.FORMAT_ASCII:
        return ASCII_Coder.getLen(ch);
    case VTDNav.FORMAT_UTF8:
        return UTF8_Coder.getLen(ch);
    case VTDNav.FORMAT_ISO_8859_1:
        return ISO8859_1Coder.getLen(ch);
    case VTDNav.FORMAT_UTF_16LE:
        return UTF16LE_Coder.getLen(ch);
    case VTDNav.FORMAT_UTF_16BE:
        return UTF16BE_Coder.getLen(ch);
    default:
        throw new com.ximpleware.TranscodeException("Unsupported encoding");
    }
}
 
开发者ID:CoolBalance,项目名称:vtd-xml,代码行数:26,代码来源:Transcoder.java

示例3: decode

import com.ximpleware.TranscodeException; //导入依赖的package包/类
/**
 * 
 * @param input
 * @param offset
 * @param input_encoding
 * @return
 * @throws TranscodeException
 *  
 */
public static final long decode(byte[] input, int offset, int input_encoding)
        throws TranscodeException {
    switch (input_encoding) {
    case VTDNav.FORMAT_ASCII:
        return ASCII_Coder.decode(input, offset);
    case VTDNav.FORMAT_UTF8:
        return UTF8_Coder.decode(input, offset);
    case VTDNav.FORMAT_ISO_8859_1:
        return ISO8859_1Coder.decode(input, offset);
    case VTDNav.FORMAT_UTF_16LE:
        return UTF16LE_Coder.decode(input, offset);
    case VTDNav.FORMAT_UTF_16BE:
        return UTF16BE_Coder.decode(input, offset);
    default:
        throw new com.ximpleware.TranscodeException("Unsupported encoding");
    }
}
 
开发者ID:CoolBalance,项目名称:vtd-xml,代码行数:27,代码来源:Transcoder.java

示例4: encode

import com.ximpleware.TranscodeException; //导入依赖的package包/类
/**
 * 
 * @param output
 * @param offset
 * @param ch
 * @param output_encoding
 * @return
 * @throws TranscodeException
 *  
 */
public static final int encode(byte[] output, int offset, int ch,
        int output_encoding) throws TranscodeException {
    switch (output_encoding) {
    case VTDNav.FORMAT_ASCII:
        return ASCII_Coder.encode(output, offset, ch);
    case VTDNav.FORMAT_UTF8:
        return UTF8_Coder.encode(output, offset, ch);
    case VTDNav.FORMAT_ISO_8859_1:
        return ISO8859_1Coder.encode(output, offset, ch);
    case VTDNav.FORMAT_UTF_16LE:
        return UTF16LE_Coder.encode(output, offset, ch);
    case VTDNav.FORMAT_UTF_16BE:
        return UTF16BE_Coder.encode(output, offset, ch);
    default:
        throw new com.ximpleware.TranscodeException("Unsupported encoding");
    }
}
 
开发者ID:CoolBalance,项目名称:vtd-xml,代码行数:28,代码来源:Transcoder.java

示例5: encodeAndWrite

import com.ximpleware.TranscodeException; //导入依赖的package包/类
public static final void encodeAndWrite(OutputStream os, int ch,
        int output_encoding) throws TranscodeException, IOException {
    switch (output_encoding) {
    case VTDNav.FORMAT_ASCII:
         ASCII_Coder.encodeAndWrite(os, ch);
    	 return;
    case VTDNav.FORMAT_UTF8:
         UTF8_Coder.encodeAndWrite(os,  ch);
    	 return;
    case VTDNav.FORMAT_ISO_8859_1:
         ISO8859_1Coder.encodeAndWrite(os, ch);
    	 return;
    case VTDNav.FORMAT_UTF_16LE:
         UTF16LE_Coder.encodeAndWrite(os, ch);
    	 return;
    case VTDNav.FORMAT_UTF_16BE:
         UTF16BE_Coder.encodeAndWrite(os, ch);
    	 return;
    default:
        throw new com.ximpleware.TranscodeException("Unsupported encoding");
    }
}
 
开发者ID:CoolBalance,项目名称:vtd-xml,代码行数:23,代码来源:Transcoder.java

示例6: encodeAndWrite

import com.ximpleware.TranscodeException; //导入依赖的package包/类
public static final void encodeAndWrite(OutputStream os, int ch)
throws IOException, TranscodeException {
    
    if (ch<0x10000){ 
        //output[offset] =  (byte)((ch & 0xff00) >> 8);
        os.write((ch & 0xff00) >> 8);
        //output[offset+1] = (byte)(ch & 0xff);
        os.write(ch);
        //return 2 + offset;
    } else {
        int tmp = ch-0x10000;
        int w1 = 0xd800 | (tmp & 0xffc00);
        int w2 = 0xdc00 | (tmp & 0x3ff);
        os.write((byte)((w1 & 0xff00) >> 8));
        os.write((byte)(w1 & 0xff));
        os.write((byte)((w2 & 0xff00) >> 8));
        os.write((byte)(w2 & 0xff));
    }
}
 
开发者ID:CoolBalance,项目名称:vtd-xml,代码行数:20,代码来源:UTF16BE_Coder.java

示例7: VersionTransferWriter

import com.ximpleware.TranscodeException; //导入依赖的package包/类
/**
 * Constructs a new instance of this class. During construction, the file
 * specified will be read and stored in a buffer.
 * 
 * @param file
 *            File to be read, must not be {@code null}
 * @throws IOException
 * @throws TranscodeException
 * @throws NavException
 * @throws ModifyException
 */
public VersionTransferWriter(final File pFile, final String pOwnVersionOrNull)
		throws IOException, ModifyException, NavException, TranscodeException {
	notNull(pFile, "File specified is null");
	file = pFile;
	insertVersionIntoOriginalIfNecessary(pOwnVersionOrNull);

	final char[] buffer = new char[1024];
	try (final Reader rd = new BufferedReader(new FileReader(file))) {
		int readChars = rd.read(buffer);
		while (readChars != -1) {
			original.append(buffer, 0, readChars);
			readChars = rd.read(buffer);
		}
	}

}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:28,代码来源:VersionTransferWriter.java

示例8: insertVersionIntoOriginalIfNecessary

import com.ximpleware.TranscodeException; //导入依赖的package包/类
private void insertVersionIntoOriginalIfNecessary(final String pOwnVersionOrNull)
		throws ModifyException, NavException, UnsupportedEncodingException, IOException, TranscodeException {
	if (pOwnVersionOrNull != null) {
		final VTDGen gen = new VTDGen();
		gen.enableIgnoredWhiteSpace(true);
		final XMLModifier modifier = new XMLModifier();

		if (gen.parseFile(file.getAbsolutePath(), false)) {
			final VTDNav vn = gen.getNav();
			modifier.bind(vn);

			if (vn.toElement(FC, ARTIFACT_ID)) {
				final long l = vn.expandWhiteSpaces(vn.getElementFragment(), WS_LEADING);
				final ByteArrayOutputStream out = new ByteArrayOutputStream();
				vn.dumpFragment(l, out);
				final String version = new String(out.toByteArray()).replaceAll(ARTIFACT_ID_PATTERN,
						format(VERSION_FORMAT, pOwnVersionOrNull));
				modifier.insertAfterElement(version);
			}
		}

		try (final FileOutputStream out = new FileOutputStream(file)) {
			modifier.output(out);
		}
	}
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:27,代码来源:VersionTransferWriter.java

示例9: updateProjectParentVersion

import com.ximpleware.TranscodeException; //导入依赖的package包/类
void updateProjectParentVersion(MavenProject project, Version version) throws MojoExecutionException {
    try {
        VTDGen gen = new VTDGen();
        gen.enableIgnoredWhiteSpace(true);
        gen.parseFile(project.getFile().getAbsolutePath(), true);

        VTDNav nav = gen.getNav();
        AutoPilot ap = new AutoPilot(nav);
        ap.selectXPath("namespace-uri(.)");
        String ns = ap.evalXPathToString();

        nav.toElementNS(VTDNav.FIRST_CHILD, ns, "parent");
        nav.toElementNS(VTDNav.FIRST_CHILD, ns, "version");
        int pos = nav.getText();

        XMLModifier mod = new XMLModifier(nav);
        mod.updateToken(pos, version.toString());

        try (OutputStream out = new FileOutputStream(project.getFile())) {
            mod.output(out);
        }
    } catch (IOException | ModifyException | NavException | XPathParseException | TranscodeException e) {
        throw new MojoExecutionException("Failed to update the parent version of project " + project, e);
    }
}
 
开发者ID:revapi,项目名称:revapi,代码行数:26,代码来源:AbstractVersionModifyingMojo.java

示例10: transcode

import com.ximpleware.TranscodeException; //导入依赖的package包/类
/**
 * 
 * @param input
 * @param offset
 * @param length
 * @param input_encoding
 * @param output_encoding
 * @return
 *  
 */
public static byte[] transcode(byte[] input, int offset, int length,
        int input_encoding, int output_encoding) throws TranscodeException {
    //check input and output encoding

    // calculate the length of the output byte array
    int i = getOutLength(input, offset, length, input_encoding,
            output_encoding);
    // allocate the byte array
    byte[] output = new byte[i];
    // fill the byte array with output encoding
    transcodeAndFill(input, output, offset, length, input_encoding,
            output_encoding);
    return output;
}
 
开发者ID:CoolBalance,项目名称:vtd-xml,代码行数:25,代码来源:Transcoder.java

示例11: getOutLength

import com.ximpleware.TranscodeException; //导入依赖的package包/类
/**
 * 
 * @param input
 * @param offset
 * @param length
 * @param input_encoding
 * @param output_encoding
 * @return
 * @throws TranscodeException
 *  
 */
public static final int getOutLength(byte[] input, int offset, int length,
        int input_encoding, int output_encoding) throws TranscodeException {
    int len = 0;
    int k = offset;
    int c;
    while (k < offset + length) {
        long l = decode(input, k, input_encoding);
        k = (int) (l >>32);
        c = (int) l;
        len = len + getLen(c, output_encoding);
    }
    return len;
}
 
开发者ID:CoolBalance,项目名称:vtd-xml,代码行数:25,代码来源:Transcoder.java

示例12: transcodeAndFill

import com.ximpleware.TranscodeException; //导入依赖的package包/类
/**
 * Fill the byte array with transcoded characters
 * 
 * @param input
 * @param output
 * @param offset
 * @param length
 * @param input_encoding
 * @param output_encoding
 *  
 */
public static final void transcodeAndFill(byte[] input, byte[] output,
        int offset, int length, int input_encoding, int output_encoding)
        throws TranscodeException {
    //int len = 0;
    int k = offset;
    int c, i = 0;
    while (k < offset + length) {
        long l = decode(input, k, input_encoding);
        k = (int) (l >> 32);
        c = (int) l;
        i = encode(output, i, c, output_encoding);
    }
}
 
开发者ID:CoolBalance,项目名称:vtd-xml,代码行数:25,代码来源:Transcoder.java

示例13: transcodeAndWrite

import com.ximpleware.TranscodeException; //导入依赖的package包/类
public static final void transcodeAndWrite(byte[] input, 
        java.io.OutputStream os,
        int offset, int length, int input_encoding, int output_encoding)
        throws TranscodeException,
        IOException {
    //int len = 0;
    int k = offset;
    int c;
    while (k < offset + length) {
        long l = decode(input, k, input_encoding);
        k = (int) (l >> 32);
        c = (int) l;
        encodeAndWrite(os, c, output_encoding);
    }
}
 
开发者ID:CoolBalance,项目名称:vtd-xml,代码行数:16,代码来源:Transcoder.java

示例14: encodeAndWrite

import com.ximpleware.TranscodeException; //导入依赖的package包/类
public static final void encodeAndWrite(OutputStream os, int ch)
throws IOException, TranscodeException {
    if (ch<0x10000){ 
        os.write((ch & 0xff));
        os.write((ch & 0xff00) >> 8);
    } else {
        int tmp = ch - 0x10000;
        int w1 = 0xd800 | (tmp & 0xffc00);
        int w2 = 0xdc00 | (tmp & 0x3ff);
        os.write(w1 & 0xff);
        os.write((w1 & 0xff00) >> 8);
        os.write(w2 & 0xff);
        os.write((w2 & 0xff00) >> 8);
    }
}
 
开发者ID:CoolBalance,项目名称:vtd-xml,代码行数:16,代码来源:UTF16LE_Coder.java

示例15: save

import com.ximpleware.TranscodeException; //导入依赖的package包/类
/**
 * 保存文件
 * @param xm
 * @throws IOException
 * @throws ParseException
 * @throws TranscodeException
 * @throws ModifyException
 *             ;
 */
private void save(XMLModifier xm) throws IOException, ParseException, TranscodeException, ModifyException {
	vn = xm.outputAndReparse();
	IByteBuffer buffer = vn.getXML();

	// 写隐藏文件,在Windows 平台下不能使用 FileOutputStream。会抛出“拒绝访问”的异常。因此采用 RandomAccessFile
	RandomAccessFile raf = new RandomAccessFile(xlpPath, "rw");
	raf.setLength(0); // 清除文件内容
	raf.seek(0); // 设置文件指针到文件起始位置
	raf.write(buffer.getBytes());
	raf.close();
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:21,代码来源:XLPHandler.java


注:本文中的com.ximpleware.TranscodeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。