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


Java SerializeWriter.write方法代码示例

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


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

示例1: write

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void write(JSONSerializer serializer, Object fieldName, Type fieldType, int features) throws IOException {
    SerializeWriter writer = serializer.out;

    if ((features & BrowserSecureMask) != 0 || (writer.isEnabled(BrowserSecureMask))) {
        writer.write(SECURITY_PREFIX);
    }

    writer.write(function);
    writer.write('(');
    for (int i = 0; i < parameters.size(); ++i) {
        if (i != 0) {
            writer.write(',');
        }
        serializer.write(parameters.get(i));
    }
    writer.write(')');
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:JSONPObject.java

示例2: write

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
    Image image = (Image) object;

    SerializeWriter out = serializer.getWriter();
    out.write('[');
    
    out.writeInt(image.getHeight());
    out.write(',');
    out.writeInt(image.getWidth());
    out.write(',');
    out.writeString(image.getSize().name(), ',');
    out.writeString(image.getTitle(), ',');
    out.writeString(image.getUri());
    
    out.write(']');
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:ImageSerializer.java

示例3: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();

    SerializeWriter writer = new SerializeWriter(out, 10);
    Assert.assertEquals(10, writer.getBufferLength());

    int blockSize = 21;
    for (char ch = 'a'; ch <= 'z'; ++ch) {
        char[] chars = new char[blockSize];
        for (int i = 0; i < blockSize; ++i) {
            chars[i] = ch;
        }
        writer.write(new String(chars));
    }
    writer.close();

    String text = out.toString();
    Assert.assertEquals(26 * blockSize, text.length());

    for (int i = 0; i < 26; ++i) {
        for (int j = 0; j < blockSize; ++j) {
            Assert.assertEquals(text.charAt(i * blockSize + j), (char) ('a' + i));
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:StreamWriterTest_writeString1.java

示例4: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();

    SerializeWriter writer = new SerializeWriter(out, 10);
    Assert.assertEquals(10, writer.getBufferLength());

    int blockSize = 21;
    for (char ch = 'a'; ch <= 'z'; ++ch) {
        char[] chars = new char[blockSize];
        for (int i = 0; i < blockSize; ++i) {
            chars[i] = ch;
        }
        writer.write(new String(chars), 0, chars.length);
    }
    writer.close();

    String text = out.toString();
    Assert.assertEquals(26 * blockSize, text.length());

    for (int i = 0; i < 26; ++i) {
        for (int j = 0; j < blockSize; ++j) {
            Assert.assertEquals(text.charAt(i * blockSize + j), (char) ('a' + i));
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:StreamWriterTest_writeString.java

示例5: write

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void write(JSONSerializer serializer, //
                  Object object, Object fieldName, Type fieldType, int features) throws IOException {
    SerializeWriter out = serializer.getWriter();
    Json json = (Json) object;
    String value = json.value();
    out.write(value);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:SwaggerJsonSerializer.java

示例6: write

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void write(JSONSerializer serializer, Object fieldName, Type fieldType) throws IOException {
    SerializeWriter writer = serializer.getWriter();
    writer.write(this.function);
    writer.write('(');
    for (int i = 0; i < this.parameters.size(); i++) {
        if (i != 0) {
            writer.write(',');
        }
        serializer.write(this.parameters.get(i));
    }
    writer.write(')');
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:13,代码来源:JSONPObject.java

示例7: test_error_5

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_error_5() throws Exception {
    Exception error = null;
    try {
        SerializeWriter out = new SerializeWriter(16);
        out.write(new char[0], 0, 1);
    } catch (IndexOutOfBoundsException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:SerializeWriterTest.java

示例8: write

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
@Override
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)
        throws IOException{
    SerializeWriter out = serializer.out;
    if (object == null) {
        out.writeNull();
        return;
    }
    JSONString jsonString = (JSONString) object;
    out.write(jsonString.toString());
}
 
开发者ID:bubicn,项目名称:bubichain-sdk-java,代码行数:12,代码来源:JSONStringSerializer.java

示例9: write

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
@Override
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType,
                  int features) throws IOException {
    Model model = (Model) object;
    SerializeWriter out = serializer.getWriter();
    out.writeFieldValue('{', "ID", model.id);
    out.write('}');
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:CustomSerializerTest.java

示例10: write

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void write(JSONSerializer serializer, Object fieldName, Type fieldType, int features) throws IOException {
    SerializeWriter writer = serializer.getWriter();
    writer.write(function);
    writer.write('(');
    for (int i = 0; i < parameters.size(); ++i) {
        if (i != 0) {
            writer.write(',');
        }
        serializer.write(parameters.get(i));
    }
    writer.write(')');
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:13,代码来源:JSONPObject.java

示例11: test_error_4

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_error_4() throws Exception {
    Exception error = null;
    try {
        SerializeWriter out = new SerializeWriter(16);
        out.write(new char[0], 0, -1);
    } catch (IndexOutOfBoundsException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:SerializeWriterTest.java

示例12: test_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_0() throws Exception {
    StringWriter out = new StringWriter();
    
    SerializeWriter writer = new SerializeWriter(out, 10);
    Assert.assertEquals(10, writer.getBufferLength());
    
    writer.write("abcde");
    writer.writeInt(12345678);
    writer.close();
    
    String text = out.toString();
    Assert.assertEquals("abcde12345678", text);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:StreamWriterTest_writeInt.java

示例13: write

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
@Override
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)
        throws IOException{
    SerializeWriter out = serializer.out;
    if (object == null) {
        out.writeNull();
        return;
    }
    JSONBean jsonBean = (JSONBean) object;
    out.write(jsonBean.toString());
}
 
开发者ID:bubicn,项目名称:bubichain-sdk-java,代码行数:12,代码来源:JSONBeanSerializer.java

示例14: test_erro_4

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_erro_4() throws Exception {
    SerializeWriter out = new SerializeWriter();
    Exception error = null;
    try {
        out.write(new char[] { '0', '0' }, 1, Integer.MAX_VALUE);
    } catch (Exception ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
    out.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SerializeWriterTest_10.java

示例15: test_erro_0

import com.alibaba.fastjson.serializer.SerializeWriter; //导入方法依赖的package包/类
public void test_erro_0() throws Exception {
    SerializeWriter out = new SerializeWriter();
    Exception error = null;
    try {
        out.write(new char[0], -1, 0);
    } catch (Exception ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
    out.close();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SerializeWriterTest_10.java


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