Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Сейчас всё намного приятнее:
Например JavaScript
var builder = new StarWebPrintBuilder();
var request = '';
request += builder.createInitializationElement();
request += builder.createTextElement({characterspace:2});
request += builder.createAlignmentElement({position:'right'});
request += builder.createLogoElement({number:1});
request += builder.createTextElement({data:'TEL 9999-99-9999\n'});
request += builder.createAlignmentElement({position:'left'});
request += builder.createTextElement({data:'\n'});
request += builder.createTextElement({data:'Apple $20.00\n'});
request += builder.createTextElement({emphasis:true});
request += builder.createTextElement({width:2, data:'Total'});
request += builder.createTextElement({width:1, data:' '});
request += builder.createTextElement({width:2, data:'$210.00\n'});
request += builder.createTextElement({width:1});
request += builder.createTextElement({emphasis:false});
request += builder.createTextElement({data:'\n'});
request += builder.createCutPaperElement({feed:true});Тот же код из Java (JS Interop)
StarWebPrintBuilder builder = new StarWebPrintBuilder();
String request = new StringBuilder()
.append(builder.createInitializationElement(new Iep()))
.append(builder.createTextElement(new Tep() {{ characterspace = 2; }}))
.append(builder.createAlignmentElement(new Aep() {{ position = "right"; }}))
.append(builder.createLogoElement(new Lep() {{ number = 1;}}))
.append(builder.createTextElement(new Tep() {{ data = "TEL 9999-99-9999\n"; }}))
.append(builder.createAlignmentElement(new Aep() {{ position = "left"; }}))
.append(builder.createTextElement(new Tep() {{ data = "\n"; }}))
.append(builder.createTextElement(new Tep() {{ data = "Apple $20.00\n"; }}))
.append(builder.createTextElement(new Tep() {{ emphasis = true; }}))
.append(builder.createTextElement(new Tep() {{ width = 2; data = "Total"; }}))
.append(builder.createTextElement(new Tep() {{ width = 1; data = " "; }}))
.append(builder.createTextElement(new Tep() {{ width = 2; data = "$210.00\n"; }}))
.append(builder.createTextElement(new Tep() {{ width = 1; }}))
.append(builder.createTextElement(new Tep() {{ emphasis = false; }}))
.append(builder.createTextElement(new Tep() {{ data = "\n"; }}))
.append(builder.createCutPaperElement(new Cpep() {{ feed = true; }}))
.toString();Тот же код из Java (JS Interop + Custom builder on Java)
String request = new GwtPrintBuilder()
.init()
.text(characterSpace(2))
.align(right)
.logo(number(1))
.text("TEL 9999-99-9999")
.align(left)
.text(line())
.text("Apple", "$20.00", lineLengt)
.text(emphasis(true))
.text("Total", "210.00", lineLengt, 2)
.text(emphasis(false))
.text(line())
.cut(feed(true))
.build();
Практическое использование multiple bounds generic в Java