本文整理汇总了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(')');
}
示例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(']');
}
示例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));
}
}
}
示例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));
}
}
}
示例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);
}
示例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(')');
}
示例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);
}
示例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());
}
示例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('}');
}
示例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(')');
}
示例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);
}
示例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);
}
示例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());
}
示例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();
}
示例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();
}