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


Java Codec类代码示例

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


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

示例1: create_codec

import org.omg.IOP.Codec; //导入依赖的package包/类
/**
 * Creates a codec of the given encoding.  The only format recognized
 * by this factory is ENCODING_CDR_ENCAPS, versions 1.0 through
 * 1.(MAX_MINOR_VERSION_SUPPORTED).
 *
 * @exception UnknownEncoding Thrown if this factory cannot create a
 *   Codec of the given encoding.
 */
public Codec create_codec ( Encoding enc )
    throws UnknownEncoding
{
    if( enc == null ) nullParam();

    Codec result = null;

    // This is the only format we can currently create codecs for:
    if( (enc.format == ENCODING_CDR_ENCAPS.value) &&
        (enc.major_version == 1) )
    {
        if( (enc.minor_version >= 0) &&
            (enc.minor_version <= MAX_MINOR_VERSION_SUPPORTED) )
        {
            result = codecs[enc.minor_version];
        }
    }

    if( result == null ) {
        throw new UnknownEncoding();
    }

    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:CodecFactoryImpl.java

示例2: create_codec

import org.omg.IOP.Codec; //导入依赖的package包/类
/**
 * Creates the Codec for the given encoding.
 *
 * @param for_encoding the encoding for that the Codec must be created.
 *
 * @return the suitable Codec.
 *
 * @throws UnknownEncoding if the encoding is not a ENCODING_CDR_ENCAPS.
 */
public Codec create_codec(Encoding for_encoding) throws UnknownEncoding
{
  if (for_encoding.format != ENCODING_CDR_ENCAPS.value)
    throw new UnknownEncoding("Only ENCODING_CDR_ENCAPS is " +
      "supported by this factory."
    );

  return new CdrEncapsCodecImpl(orb,
    new Version(for_encoding.major_version, for_encoding.minor_version)
  );
}
 
开发者ID:vilie,项目名称:javify,代码行数:21,代码来源:gnuCodecFactory.java

示例3: addEncodeStatements

import org.omg.IOP.Codec; //导入依赖的package包/类
@Override
public void addEncodeStatements(TypeMirror type, CodeGeneratorContext ctx) {
	String codecFieldName = Util.varName(type.toString()) + CODEC_POSTFIX;
	ctx.builder().addStatement("this.$N.encode(writer, $L, encoderContext)",
			codecFieldName, ctx.getter());

	ctx.instanceFields()
			.add(ImmutableInstanceField.builder().type(ClassName.get(Codec.class))
					.name(codecFieldName).codecForClass(TypeName.get(type)).build());
}
 
开发者ID:ralscha,项目名称:bsoncodec-apt,代码行数:11,代码来源:DefaultDelegate.java

示例4: addEncodeStatements

import org.omg.IOP.Codec; //导入依赖的package包/类
@Override
public void addEncodeStatements(CodeGeneratorContext ctx) {
	FieldModel field = ctx.field();
	IdModel idModel = field.idModel();
	Builder builder = ctx.builder();

	if (idModel != null && idModel.generatorName() != null) {
		builder.addStatement("$T id", UUID.class)
				.beginControlFlow("if ($L == null)", ctx.getter())
				.addStatement("id = ($T)this.$N.generate()", UUID.class,
						idModel.generatorName());

		if (idModel.conversion() == IdConversion.HEX_UUID) {
			builder.addStatement(ctx.setter("id.toString()"));
		}
		else if (idModel.conversion() == IdConversion.BASE64_UUID) {
			builder.addStatement("$T bb = $T.wrap(new byte[16])", ByteBuffer.class,
					ByteBuffer.class);
			builder.addStatement("bb.putLong(id.getMostSignificantBits())");
			builder.addStatement("bb.putLong(id.getLeastSignificantBits())");
			builder.addStatement(
					ctx.setter("$T.getUrlEncoder().encodeToString(bb.array())"),
					Base64.class);
		}
		builder.nextControlFlow("else");

		if (idModel.conversion() == IdConversion.HEX_UUID) {
			builder.addStatement("id = $T.fromString($L)", UUID.class, ctx.getter());
		}
		else if (idModel.conversion() == IdConversion.BASE64_UUID) {
			builder.addStatement("$T bb = $T.wrap($T.getUrlDecoder().decode($L))",
					ByteBuffer.class, ByteBuffer.class, Base64.class, ctx.getter());
			builder.addStatement("id = new $T(bb.getLong(), bb.getLong())",
					UUID.class);
		}
		builder.endControlFlow();
	}
	else {
		if (idModel != null) {
			if (idModel.conversion() == IdConversion.HEX_UUID) {
				builder.addStatement("$T id = $T.fromString($L)", UUID.class,
						UUID.class, ctx.getter());
			}
			else if (idModel.conversion() == IdConversion.BASE64_UUID) {
				builder.addStatement("$T bb = $T.wrap($T.getUrlDecoder().decode($L))",
						ByteBuffer.class, ByteBuffer.class, Base64.class,
						ctx.getter());
				builder.addStatement("$T id = new $T(bb.getLong(), bb.getLong())",
						UUID.class, UUID.class);
			}
		}
	}

	ctx.builder().addStatement("writer.writeName($S)", field.name())
			.addStatement("this.uUIDCodec.encode(writer, id, encoderContext)");

	ctx.instanceFields()
			.add(ImmutableInstanceField.builder().type(ClassName.get(Codec.class))
					.name("uUIDCodec").codecForClass(ClassName.get(UUID.class))
					.build());
}
 
开发者ID:ralscha,项目名称:bsoncodec-apt,代码行数:62,代码来源:ConversionUUIDCodeGen.java


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