All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dyuproject.protostuff.compiler.java_bean_me.stg Maven / Gradle / Ivy

group java_bean_me : base;

map_literal_value_prefix ::= [
    "Bytes": "\"",
    "String": "\"",
    default: 
]

map_literal_value_suffix ::= [
    "Int64": "l",
    "UInt64": "l",
    "SInt64": "l",
    "Fixed64": "l",
    "SFixed64": "l",
    "Float": "f",
    "Double": "d",
    "Bytes": "\"",
    "String": "\"",
    default:
]

map_primitive_value_prefix ::= [
    "Int64":  "new Long(",
    "UInt64":  "new Long(",
    "SInt64":  "new Long(",
    "Fixed64":  "new Long(",
    "SFixed64":  "new Long(",
    "Float": "new Float(",
    "Double": "new Double(",
    "Bool": "new Boolean(",
    "Bytes": "ByteString.bytesDefaultValue(",
    "String": "ByteString.stringDefaultValue(",
    "EnumField": ,
    default: "new Integer("
]

map_primitive_value_suffix ::= [
    "EnumField": ,
    default: ")"
]

map_primitive_wrapper ::= [
    "int": "Integer",
    "long": "Long",
    "float": "Float",
    "double": "Double",
    "boolean": "Boolean",
    default: key
]

map_primitive_number_suffix ::= [
    "Int64": "l",
    "UInt64": "l",
    "SInt64": "l",
    "Fixed64": "l",
    "SFixed64": "l",
    "Float": "f",
    "Double": "d",
    default: 
]

map_value_prefix(t) ::= <<

>>

map_value_suffix(t) ::= <<

>>
//#enum begin

enum_block(eg, module, options, nested) ::= <<




public interface 
{
     = }; separator=";\n">;
}

>>

enum_header(eg, module, options) ::= <<


package ;

>>

enum_switch_case(value, options) ::= <<
case : return ;
>>

//#message begin

message_block(message, module, options, nested) ::= <<




public static final class  
{
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}

>>

message_header(message, module, options) ::= <<


package ;

import java.io.IOException;

import java.util.Vector;




import com.dyuproject.protostuff.me.ByteString;


import com.dyuproject.protostuff.me.ByteString;



import com.dyuproject.protostuff.me.Input;
import com.dyuproject.protostuff.me.Message;
import com.dyuproject.protostuff.me.Output;

import com.dyuproject.protostuff.me.Pipe;


import com.dyuproject.protostuff.me.Schema;

import com.dyuproject.protostuff.me.UninitializedMessageException;



>>

message_impl_declaration(message, options) ::= <<

, 

implements 

Message, Schema
>>

message_default_instance(message, options) ::= <<

public static Schema getSchema()
{
    return DEFAULT_INSTANCE;
}

public static  getDefaultInstance()
{
    return DEFAULT_INSTANCE;
}

static final  DEFAULT_INSTANCE = new ();

>>

field_defaults_declaration(field, options) ::= <<




static final  DEFAULT_ = ;

static final  DEFAULT_ = ;


static final  DEFAULT_ = ;



>>

field_default_value(field, options) ::= <<













>>

field_declaration(field, options, modifier) ::= <<

Vector ;

 ;

>>

field_singular_type(field, options) ::= <<


Integer

int
















>>

field_assign_defaults(field, options) ::= <<



 = 


 = DEFAULT_


>>

message_constructor(message, options) ::= <<

public ()
{
    
}


public (
    
)
{
    
}



>>

field_declare_constructor_singular(field, options) ::= <<


Integer 

int 



 


>>

field_assign_constructor_singular(field, options) ::= <<

this. = ;

>>

message_getters_and_setters(message, options) ::= <<
// getters and setters

>>

field_getters_and_setters(field, options, message) ::= <<

// 


public Vector getList()
{
    return ;
}

public  setList(Vector )
{
    this. = ;
    
}


public Integer get(int index)
{
    return  == null ? null : (Integer).elementAt(index);
}

public int getCount()
{
    return  == null ? 0 : .size();
}

public  add(Integer )
{
    if(this. == null)
        this. = new Vector();
    this..addElement();
    
}





public  get()
{
    return ;
}

public  set( )
{
    this. = ;
    
}


>>

builder_pattern_return_type(field, options, type) ::= <<



void

>>

builder_pattern_return(field, options) ::= <<

return this;

>>

message_impl_message(message, options) ::= <<
// message method

public Schema cachedSchema()
{
    return DEFAULT_INSTANCE;
}

>>

message_impl_schema(message, options) ::= <<
// schema methods

public Object /**/ newMessage()
{
    return new ();
}

public Class typeClass()
{
    return .class;
}

public String messageName()
{
    return "";
}

public String messageFullName()
{
    return .class.getName();
}





>>

message_method_is_initialized(message, options) ::= <<

public boolean isInitialized(Object /**/ messageObj)
{
     message = ()messageObj;
    return 
        ;
}

public boolean isInitialized(Object /**/ message)
{
    return true;
}

>>

field_is_initialized(field, options, name) ::= <<

. != null

>>

message_field_merge(message, options, name) ::= <<

public void mergeFrom(Input input, Object /**/ Obj) throws IOException
{
      = ()Obj;
    for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
    {
        switch(number)
        {
            case 0:
                return;
            
            default:
                input.handleUnknownField(number, this);
        }   
    }
}

*/ Obj)
{
      = ()Obj;
    
}
!>

>>

field_merge_switch(field, options, name) ::= <<
case :
    
    
    
>>

field_copy(field, options, name) ::= <<



>>

singular_field_merge_switch(field, options, name) ::= <<

. = ()input.mergeObject(., .getSchema());
break;

. = new Integer(input.readEnum())input.readEnum();
break;

. = input.read();
break;

. = input.read();
break;

. = input.readBool() ? Boolean.TRUE : Boolean.FALSE;
break;


. = new (input.read());


. = input.read();

. = new (input.read());



break;

>>

repeated_field_merge_switch(field, options, name) ::= <<

if(. == null)
    . = new Vector();
..addElement(input.mergeObject(null, .getSchema()));
break;

if(. == null)
    . = new Vector();
..addElement(new Integer(input.readEnum()));
break;

if(. == null)
    . = new Vector();
..addElement(input.read());
break;

if(. == null)
    . = new Vector();
..addElement(input.read());
break;

if(. == null)
    . = new Vector();
..addElement(input.readBool() ? Boolean.TRUE : Boolean.FALSE);
break;

if(. == null)
    . = new Vector();
..addElement(new (input.read()));
break;

>>

singular_field_copy(field, options, name) ::= <<

if(. == null) {
    this. = null;
} else {
    this. = ()..newMessage();
    this..mergeFrom(().);
}

this. = .;

>>

repeated_field_copy(field, options, name) ::= <<
this. = new Vector();
if(. != null) {
    for(int i = 0; i \< ..size(); i++) {
        
         origElt = ()..elementAt(i);
         newElt = ()origElt.newMessage();
        newElt.mergeFrom(()..elementAt(i));
        this..addElement(newElt);
        
        this..addElement(..elementAt(i));
        
    }
}
>>

message_field_write(message, options, name) ::= <<

public void writeTo(Output output, Object /**/ Obj) throws IOException
{
      = ()Obj;
    
}

>>

field_write_switch(field, options, name) ::= <<





>>

singular_field_write_switch(field, options, name) ::= <<

if(. == null)
    throw new UninitializedMessageException();

output.writeObject(, ., .getSchema(), false);

output.writeEnum(, ..intValue(), false);

output.write(, ., false);

output.write(, ., false);

output.write(, ..Value(), false);




     output.writeObject(, ., .getSchema(), false);

output.writeEnum(, ., false);


    output.write(, ., false);


    output.write(, ., false);




    output.write(, ., false);

    output.write(, ..Value(), false);


    output.write(, ..Value(), false);



>>

repeated_field_write_switch(field, options, name) ::= <<

if(. != null)
{
    for(int i = 0; i \< ..size(); i++)
    {
          = ()..elementAt(i);
        if( != null)
            output.writeObject(, , .getSchema(), true);
    }
}

if(. != null)
{
    for(int i = 0; i \< ..size(); i++)
    {
        Integer  = (Integer)..elementAt(i);
        if( != null)
            output.writeEnum(, .intValue(), true);
    }
}

if(. != null)
{
    for(int i = 0; i \< ..size(); i++)
    {
          = ()..elementAt(i);
        if( != null)
            output.write(, , true);
    }
}

if(. != null)
{
    for(int i = 0; i \< ..size(); i++)
    {
          = ()..elementAt(i);
        if( != null)
            output.write(, , true);
    }
}

if(. != null)
{
    for(int i = 0; i \< ..size(); i++)
    {
          = ()..elementAt(i);
        if( != null)
            output.write(, .Value(), true);
    }
}

>>

singular_field_write_check(field, options) ::= <<




if(. != DEFAULT_)

if(. != null && . != DEFAULT_)


if(. != null && . != DEFAULT_)


if(. != null)




if(. != 0)

if(. != null)


if(. != null)


>>

message_field_map(message, options) ::= <<

public String getFieldName(int number)
{
    switch(number)
    {
        
        default: return null;
    }
}

public int getFieldNumber(String name)
{
    final Integer number = (Integer)__fieldMap.get(name);
    return number == null ? 0 : number.intValue();
}

private static final java.util.Hashtable __fieldMap = new java.util.Hashtable();
static
{
    
}

public String getFieldName(int number)
{
    return Integer.toString(number);
}

public int getFieldNumber(String name)
{
    return Integer.parseInt(name);
}

>>

field_switch_case(field, options) ::= <<

case : return "f";

case : return "";

>>

field_map(field, options, mapVar) ::= <<

.put("f", new Integer());

.put("", new Integer());

>>

message_static_schema_ref(message, options) ::= <<
DEFAULT_INSTANCE
>>

message_pipe_schema(message, options) ::= <<
static final Pipe.Schema PIPE_SCHEMA = new Pipe.Schema()
{
    protected void transfer(Pipe pipe, Input input, Output output) throws IOException
    {
        for(int number = input.readFieldNumber(wrappedSchema);; number = input.readFieldNumber(wrappedSchema))
        {
            switch(number)
            {
                case 0:
                    return;
                
                default:
                    input.handleUnknownField(number, wrappedSchema);
            }
        }
    }
};

public static Pipe.Schema getPipeSchema()
{
    return PIPE_SCHEMA;
}

>>

field_transfer_switch(field, options) ::= <<
case :
    
>>

field_transfer_switch_body(field, options) ::= <<

output.writeObject(number, pipe, .getPipeSchema(), );
break;

output.writeEnum(number, input.readEnum(), ); 
break;

input.transferByteRangeTo(output, true, number, );
break;

input.transferByteRangeTo(output, false, number, );
break;

output.write(number, input.read(), );
break;

>>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy