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


Java MapSchema.MessageFactory方法代码示例

本文整理汇总了Java中io.protostuff.MapSchema.MessageFactory方法的典型用法代码示例。如果您正苦于以下问题:Java MapSchema.MessageFactory方法的具体用法?Java MapSchema.MessageFactory怎么用?Java MapSchema.MessageFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.protostuff.MapSchema的用法示例。


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

示例1: newEnumMapFactory

import io.protostuff.MapSchema; //导入方法依赖的package包/类
private static <E extends Enum<E>> MapSchema.MessageFactory newEnumMapFactory(
        final EnumIO<E> eio)
{
    return new MapSchema.MessageFactory()
    {
        @Override
        @SuppressWarnings("unchecked")
        public <K, V> Map<K, V> newMessage()
        {
            return (Map<K, V>) eio.newEnumMap();
        }

        @Override
        public Class<?> typeClass()
        {
            return EnumMap.class;
        }
    };
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:20,代码来源:EnumIO.java

示例2: writeMapIdTo

import io.protostuff.MapSchema; //导入方法依赖的package包/类
@Override
protected void writeMapIdTo(Output output, int fieldNumber, Class<?> clazz)
        throws IOException
{
    final MapSchema.MessageFactory factory = mapMapping.get(clazz);
    if (factory == null && clazz.getName().startsWith("java.util"))
    {
        // jdk map
        // better not to register the jdk map if using this strategy
        // as it saves space by not writing the full package
        output.writeString(fieldNumber, clazz.getSimpleName(), false);
    }
    else
    {
        output.writeString(fieldNumber, clazz.getName(), false);
    }
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:18,代码来源:DefaultIdStrategy.java

示例3: resolveMapFrom

import io.protostuff.MapSchema; //导入方法依赖的package包/类
@Override
protected MapSchema.MessageFactory resolveMapFrom(Input input)
        throws IOException
{
    final String className = input.readString();
    MapSchema.MessageFactory factory = mapMapping.get(className);
    if (factory == null)
    {
        if (className.indexOf('.') == -1)
        {
            factory = MapSchema.MessageFactories.valueOf(className);
        }
        else
        {
            factory = new RuntimeMapFactory(RuntimeEnv.loadClass(className));
            MapSchema.MessageFactory f = mapMapping.putIfAbsent(className,
                    factory);
            if (f != null)
                factory = f;
        }
    }

    return factory;
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:25,代码来源:DefaultIdStrategy.java

示例4: getMapFactory

import io.protostuff.MapSchema; //导入方法依赖的package包/类
@Override
protected MapSchema.MessageFactory getMapFactory(Class<?> clazz)
{
    final String className = clazz.getName();
    MapSchema.MessageFactory factory = mapMapping.get(className);
    if (factory == null)
    {
        if (className.startsWith("java.util"))
        {
            factory = MapSchema.MessageFactories.valueOf(clazz
                    .getSimpleName());
        }
        else
        {
            factory = new RuntimeMapFactory(clazz);
            MapSchema.MessageFactory f = mapMapping.putIfAbsent(className,
                    factory);
            if (f != null)
                factory = f;
        }
    }

    return factory;
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:25,代码来源:DefaultIdStrategy.java

示例5: registerMap

import io.protostuff.MapSchema; //导入方法依赖的package包/类
/**
 * Map ids start at 1.
 */
@Override
public <T extends Map<?, ?>> Registry registerMap(
        MapSchema.MessageFactory factory, int id)
{
    if (id < 1)
        throw new IllegalArgumentException("map ids start at 1.");

    if (id >= strategy.mapIdStart)
        throw new IllegalArgumentException("map ids must be lesser than " + strategy.mapIdStart);
    else if (strategy.maps.get(id) != null)
    {
        throw new IllegalArgumentException("Duplicate id registration: " + id +
                " (" + factory.typeClass() + ")");
    }

    RuntimeMapFactory rf = new RuntimeMapFactory();
    rf.id = id;
    rf.factory = factory;
    strategy.maps.set(id, rf);
    // just in case
    if (strategy.mapMapping.put(factory.typeClass(), rf) != null)
        throw new IllegalArgumentException("Duplicate registration for: " + factory.typeClass());

    return this;
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:29,代码来源:IncrementalIdStrategy.java

示例6: registerMap

import io.protostuff.MapSchema; //导入方法依赖的package包/类
/**
 * Map ids start at 1.
 */
@Override
public <T extends Map<?, ?>> Registry registerMap(
        MapSchema.MessageFactory factory, int id)
{
    if (id < 1)
        throw new IllegalArgumentException("map ids start at 1.");

    if (id >= strategy.maps.size())
        grow(strategy.maps, id + 1);
    else if (strategy.maps.get(id) != null)
    {
        throw new IllegalArgumentException("Duplicate id registration: " + id +
                " (" + factory.typeClass() + ")");
    }

    RegisteredMapFactory rf = new RegisteredMapFactory(id, factory);
    strategy.maps.set(id, rf);
    // just in case
    if (strategy.mapMapping.put(factory.typeClass(), rf) != null)
        throw new IllegalArgumentException("Duplicate registration for: " + factory.typeClass());

    return this;
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:27,代码来源:ExplicitIdStrategy.java

示例7: getMapFactory

import io.protostuff.MapSchema; //导入方法依赖的package包/类
@Override
protected MapSchema.MessageFactory getMapFactory(Class<?> clazz)
{
    final RegisteredMapFactory rf = mapMapping.get(clazz);
    if (rf == null)
    {
        if (clazz.getName().startsWith("java.util"))
            return MapSchema.MessageFactories.valueOf(clazz.getSimpleName());

        throw new UnknownTypeException("map: " + clazz);
    }

    return rf;
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:15,代码来源:ExplicitIdStrategy.java

示例8: getEnumMapFactory

import io.protostuff.MapSchema; //导入方法依赖的package包/类
/**
 * Returns the factory for an EnumMap (lazy).
 */
public MapSchema.MessageFactory getEnumMapFactory()
{
    MapSchema.MessageFactory enumMapFactory = this.enumMapFactory;
    if (enumMapFactory == null)
    {
        synchronized (this)
        {
            if ((enumMapFactory = this.enumMapFactory) == null)
                this.enumMapFactory = enumMapFactory = newEnumMapFactory(this);
        }
    }
    return enumMapFactory;
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:17,代码来源:EnumIO.java

示例9: resolveMapFrom

import io.protostuff.MapSchema; //导入方法依赖的package包/类
@Override
protected MapSchema.MessageFactory resolveMapFrom(Input input)
        throws IOException
{
    final int id = input.readUInt32();

    final MapSchema.MessageFactory factory = id < maps.size() ? maps.get(id) : null;
    if (factory == null)
        throw new UnknownTypeException("map id: " + id + " (Outdated registry)");

    return factory;
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:13,代码来源:ExplicitIdStrategy.java

示例10: resolveMapFrom

import io.protostuff.MapSchema; //导入方法依赖的package包/类
@Override
protected MapSchema.MessageFactory resolveMapFrom(Input input)
        throws IOException
{
    final int id = input.readUInt32();

    final RuntimeMapFactory factory = id < maps.size() ? maps.get(id) : null;
    if (factory == null)
        throw new UnknownTypeException("Unknown map id: " + id);

    return factory;
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:13,代码来源:IncrementalIdStrategy.java

示例11: RegisteredMapFactory

import io.protostuff.MapSchema; //导入方法依赖的package包/类
public RegisteredMapFactory(int id, MapSchema.MessageFactory factory)
{
    this.id = id;
    this.factory = factory;
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:6,代码来源:ExplicitIdStrategy.java

示例12: resolveMapFrom

import io.protostuff.MapSchema; //导入方法依赖的package包/类
protected abstract MapSchema.MessageFactory resolveMapFrom(Input input)
throws IOException;
 
开发者ID:BFergerson,项目名称:Beam,代码行数:3,代码来源:IdStrategy.java

示例13: getMapFactory

import io.protostuff.MapSchema; //导入方法依赖的package包/类
@Override
protected MapSchema.MessageFactory getMapFactory(Class<?> clazz)
{
    return getRuntimeMapFactory(clazz);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:6,代码来源:IncrementalIdStrategy.java

示例14: getMapFactory

import io.protostuff.MapSchema; //导入方法依赖的package包/类
/**
 * Returns the {@link MapSchema.MessageFactory}. The callers (internal field factories}) are responsible that the
 * class provided implements {@link Map}.
 */
protected abstract MapSchema.MessageFactory getMapFactory(Class<?> clazz);
 
开发者ID:BFergerson,项目名称:Beam,代码行数:6,代码来源:IdStrategy.java

示例15: registerMap

import io.protostuff.MapSchema; //导入方法依赖的package包/类
/**
 * Map ids start at 1.
 */
public <T extends Map<?, ?>> Registry registerMap(
        MapSchema.MessageFactory factory, int id);
 
开发者ID:protostuff,项目名称:protostuff,代码行数:6,代码来源:NumericIdStrategy.java


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