public JsonElement sendXMLHttpGETRequest( final String url, final boolean async ) { ( ( EventFiringWebDriver ) driver ).manage().timeouts().setScriptTimeout( 20, TimeUnit.SECONDS ); StrBuilder builder = new StrBuilder( "var callback = arguments[arguments.length - 1];\n" ); builder.appendln( "var xhr = new XMLHttpRequest();" ); builder.append( "xhr.open( 'GET', '" ).append( url ).append( "', '" ).append( async ).append( "' );" ); builder.appendln( "xhr.onreadystatechange = function() { " ); builder.appendln( " if (xhr.readyState == 4) { " ); builder.appendln( " callback(xhr.responseText);" ); builder.appendln( " }" ); builder.appendln( "}" ); builder.appendln( "xhr.send();" ); Object response = executeAsyncScript( builder.toString() ); Gson gson = new Gson(); return gson.fromJson( ( String ) response, JsonElement.class ); }
public static StrBuilder readFileWithFileSizeBuffer(Path file ) throws IOException { FileChannel inChannel = null; RandomAccessFile aFile = null; StrBuilder builder = new StrBuilder(); try { aFile = new RandomAccessFile( file.toString(), "r" ); inChannel = aFile.getChannel(); long fileSize = inChannel.size(); ByteBuffer buffer = ByteBuffer.allocate( ( int ) fileSize ); inChannel.read( buffer ); buffer.flip(); for ( int i = 0; i < fileSize; i++ ) { builder.append( ( char ) buffer.get() ); } return builder.trim(); } finally { if( null != inChannel ) inChannel.close(); if( null != aFile ) aFile.close(); } }
/** * Atomically multicast command. * * @param command * @return A FutureDecision that can be waited on */ public void amcast(Command command) throws FSError { // right now, it either sends to the given partition or to the global // ring byte ringid = GLOBAL_RING; if (command.getInvolvedPartitions().size() == 1) { ringid = command.getInvolvedPartitions().iterator().next().byteValue(); } // TODO: right now its not possible to submit to rings the replica is // not part of. Make the replica act as a proxy to one of the responsible replicas? log.debug(new StrBuilder().append("Submitting command to ring ").append(ringid).toString()); Proposer p = this.proposers.get(Byte.valueOf(ringid)); // TSerializer is not threadsafe, create a new one for each amcast. Is // this too expensive? final TSerializer serializer = new TSerializer(); try { p.propose(serializer.serialize(command)); } catch (TException e) { e.printStackTrace(); throw new FSError(Errno.EREMOTEIO, "Error serializing message"); } }
private void applyRelease(Command c, CommandResult res) throws FSError { log.debug(new StrBuilder().append("release ").append(c.getRelease().getPath()).toString()); ReleaseCmd rel = c.getRelease(); FileNode f = openFiles.remove(Long.valueOf(rel.getFileHandle().getId())); if (f == null) { throw new FSError(FuseException.EBADF, "Bad file descriptor"); } if (c.getInvolvedPartitions().size() > 1) { // wait for other signals for (Byte part : c.getInvolvedPartitions()) { if (part == localPartition) continue; //this.waitForSignal(c.getReqId(), part.byteValue()); } } res.setSuccess(true); res.setResponse(null); }
private void applyTruncate(Command c, CommandResult res) throws FSError { log.debug(new StrBuilder().append("truncate ").append(c.getTruncate().getPath()).toString()); TruncateCmd t = c.getTruncate(); Node f = fs.get(t.getPath()); if (f == null) { throw new FSError(FuseException.ENOENT, "File not found"); } else if (!f.isFile()) { throw new FSError(FuseException.EINVAL, "Not a file"); } ((FileNode) f).truncate(t.getSize()); f.getAttributes().setCtime(c.getReqTime()); f.getAttributes().setMtime(c.getReqTime()); if (c.getInvolvedPartitions().size() > 1) { // wait for other signals for (Byte part : c.getInvolvedPartitions()) { if (part == localPartition) continue; //this.waitForSignal(c.getReqId(), part.byteValue()); } } res.setSuccess(true); res.setResponse(null); }
private void applyChmod(Command c, CommandResult res) throws FSError { log.debug(new StrBuilder().append("chmod ").append(c.getChmod().getPath()).toString()); ChmodCmd chmod = c.getChmod(); Node f = fs.get(chmod.getPath()); if (f == null) { throw new FSError(FuseException.ENOENT, "File not found"); } f.getAttributes().setMode(chmod.getMode()); f.getAttributes().setCtime(c.getReqTime()); if (c.getInvolvedPartitions().size() > 1) { // wait for other signals for (Byte part : c.getInvolvedPartitions()) { if (part == localPartition) continue; //this.waitForSignal(c.getReqId(), part.byteValue()); } } res.setSuccess(true); res.setResponse(null); }
private void applyReadlink(Command c, CommandResult res) throws FSError { log.debug(new StrBuilder().append("readlink ").append(c.getReadlink().getPath()).toString()); Node n = fs.get(c.getReadlink().getPath()); if (!n.isLink()) { throw new FSError(FuseException.ENOLINK, "Not a link"); } String response = ((LinkNode) n).getTarget(); if (c.getInvolvedPartitions().size() > 1) { // wait for other signals for (Byte part : c.getInvolvedPartitions()) { if (part == localPartition) continue; //this.waitForSignal(c.getReqId(), part.byteValue()); } } res.setSuccess(true); res.setResponse(response); }
private void applyRmdir(Command c, CommandResult res) throws FSError { log.debug(new StrBuilder().append("rmdir ").append(c.getRmdir().getPath()).toString()); fs.removeDir(c.getRmdir().getPath()); if (c.getInvolvedPartitions().size() > 1) { // wait for other signals for (Byte part : c.getInvolvedPartitions()) { if (part == localPartition) continue; //this.waitForSignal(c.getReqId(), part.byteValue()); } } res.setSuccess(true); res.setResponse(null); }
private void applyUnlink(Command c, CommandResult res) throws FSError { log.debug(new StrBuilder().append("unlink ").append(c.getUnlink().getPath()).toString()); fs.removeFileOrLink(c.getUnlink().getPath()); if (c.getInvolvedPartitions().size() > 1) { // wait for other signals for (Byte part : c.getInvolvedPartitions()) { if (part == localPartition) continue; //this.waitForSignal(c.getReqId(), part.byteValue()); } } res.setSuccess(true); res.setResponse(null); }
private void applyMkdir(Command c, CommandResult res) throws FSError { log.debug(new StrBuilder().append("mkdir ").append(c.getMkdir().getPath()).toString()); fs.createDir(c.getMkdir().getPath(), c.getMkdir().getMode(), c.getReqTime(), c.getMkdir().getUid(), c.getMkdir().getGid()); if (c.getInvolvedPartitions().size() > 1) { // wait for other signals for (Byte part : c.getInvolvedPartitions()) { if (part == localPartition) continue; //this.waitForSignal(c.getReqId(), part.byteValue()); } } res.setSuccess(true); res.setResponse(null); }
private void applyGetdir(Command c, CommandResult res) throws FSError { log.debug(new StrBuilder().append("getdir ").append(c.getGetdir().getPath()).toString()); Node n = fs.get(c.getGetdir().getPath()); if (!n.isDir()) { throw new FSError(FuseException.ENOTDIR, "Not a directory"); } DirNode dir = (DirNode) n; List<DirEntry> entries = new LinkedList<DirEntry>(); for (String child : dir.getChildren()) { entries.add(new DirEntry(child, 0, dir.getChild(child).typeMode())); } if (c.getInvolvedPartitions().size() > 1) { // wait for other signals for (Byte part : c.getInvolvedPartitions()) { if (part == localPartition) continue; //this.waitForSignal(c.getReqId(), part.byteValue()); } } res.setSuccess(true); res.setResponse(entries); }
private void applyMknod(Command c, CommandResult res) throws FSError { log.debug(new StrBuilder().append("mknod ").append(c.getMknod().getPath()).toString()); // if the create fails here, there is no need for signals, // the other partitions also fail fs.createFile(c.getMknod().getPath(), c.getMknod().getMode(), c.getReqTime(), c.getMknod().getUid(), c.getMknod().getGid()); if (c.getInvolvedPartitions().size() > 1) { // wait for other signals for (Byte part : c.getInvolvedPartitions()) { if (part == localPartition) continue; //this.waitForSignal(c.getReqId(), part.byteValue()); } } res.setSuccess(true); res.setResponse(null); }
/** * List available algorithms. This is displayed to the user when no valid * algorithm is given in the program parameterization. * * @return usage string listing available algorithms */ private static String getAlgorithmsListing() { StrBuilder strBuilder = new StrBuilder(); strBuilder .appendNewLine() .appendln("Select an algorithm to view usage: flink run examples/flink-gelly-examples_<version>.jar --algorithm <algorithm>") .appendNewLine() .appendln("Available algorithms:"); for (Driver algorithm : driverFactory) { strBuilder.append(" ") .appendFixedWidthPadRight(algorithm.getName(), 30, ' ') .append(algorithm.getShortDescription()).appendNewLine(); } return strBuilder.toString(); }
private static String getUsage(String message) { return new StrBuilder() .appendNewLine() .appendln("A Graph500 generator using the Recursive Matrix (RMat) graph generator.") .appendNewLine() .appendln(WordUtils.wrap("The graph matrix contains 2^scale vertices although not every vertex will" + " be represented in an edge. The number of edges is edge_factor * 2^scale edges" + " although some edges may be duplicates.", 80)) .appendNewLine() .appendln("Note: this does not yet implement permutation of vertex labels or edges.") .appendNewLine() .appendln("usage: Graph500 --directed <true | false> --simplify <true | false> --output <print | hash | csv [options]>") .appendNewLine() .appendln("options:") .appendln(" --output print") .appendln(" --output hash") .appendln(" --output csv --output_filename FILENAME [--output_line_delimiter LINE_DELIMITER] [--output_field_delimiter FIELD_DELIMITER]") .appendNewLine() .appendln("Usage error: " + message) .toString(); }
@Override public String getLongDescription() { return new StrBuilder() .appendln("Computes metrics on a directed or undirected graph.") .appendNewLine() .appendln("Vertex metrics:") .appendln("- number of vertices") .appendln("- number of edges") .appendln("- number of unidirectional edges (directed only)") .appendln("- number of bidirectional edges (directed only)") .appendln("- average degree") .appendln("- number of triplets") .appendln("- maximum degree") .appendln("- maximum out degree (directed only)") .appendln("- maximum in degree (directed only)") .appendln("- maximum number of triplets") .appendNewLine() .appendln("Edge metrics:") .appendln("- number of triangle triplets") .appendln("- number of rectangle triplets") .appendln("- maximum number of triangle triplets") .append("- maximum number of rectangle triplets") .toString(); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AsciiParagraph ap = new AsciiParagraph();", "class ObjectHasTextCluster implements HasTextCluster{", " @Override", " public Collection<String> getTextAsCollection() {", "ArrayList<String> text = new ArrayList<>();", "text.add(new LoremIpsum().getWords(10));", "text.add(new LoremIpsum().getWords(10));", "text.add(new LoremIpsum().getWords(10));", "return text;", " }", "}", "", "ap.addText(new ObjectHasTextCluster());", "System.out.println(ap.render());", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AP_Context ctx = new AP_Context();", "ctx.setAlignment(AP_Alignment.LEFT);", "", "AsciiParagraph ap = new AsciiParagraph(ctx);", "ap.addText(\"A sentence with some normal text, not specific to LaTeX.\");", "ap.addText(\"Now for some characters that require conversion: # % &.\");", "ap.addText(\"And some more: © § ¤.\");", "ap.addText(\"And even more: È É Ê Ë.\");", "ap.addText(\"And some arrows as well: ← ↑ → ↓ ↔\");", "System.out.println(ap.render(35));", "", "ctx.setTargetTranslator(new Text2Latex());", "System.out.println(ap.render(35));", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AP_Context ctx = new AP_Context();", "ctx.setAlignment(AP_Alignment.LEFT);", "ctx.setWidth(60);", "", "AsciiParagraph ap = new AsciiParagraph(ctx);", "ap.addText(new LoremIpsum().getWords(29));", "", "System.out.println(ap.render());", "", "ctx.setTextLeftMargin(5);", "System.out.println(ap.render());", "", "ctx.setTextLeftMargin(10);", "ctx.setTextLeftChar('>');", "System.out.println(ap.render());", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AsciiParagraph ap = new AsciiParagraph();", "class ObjectHasText implements HasText{", " @Override", " public String getText() {", " return new LoremIpsum().getWords(10);", " }", "}", "", "ap.addText(new ObjectHasText());", "System.out.println(ap.render());", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AsciiParagraph ap = new AsciiParagraph();", "", "ap.addText(\"c2 c2\");", "ap.addText(\"c3 c3\");", "ap.addText(\"c4 c4\");", "", "ap.addText(\"t1 t1\");", "ap.addText(\"t2 t2\");", "ap.addText(\"t3 t3\");", "ap.addText(\"t4\t\t\t\tt4\");", "", "ap.addText(\"word followed by \" + StringUtils.CR + \" followed by\" + StringUtils.LF + \" followed by \\n\");", "", "ap.getContext().setWidth(60).setAlignment(AP_Alignment.LEFT);", "System.out.println(ap.render());" }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AP_Context ctx = new AP_Context();", "ctx.setAlignment(AP_Alignment.CENTER);", "ctx.setFrame(UTF_Frames.borderLight());", "ctx.setFrameTopBottomMargin(1);", "ctx.setTextTopBottomMargin(1);", "ctx.setTextLeftRightMargin(1);", "", "AsciiParagraph ap = new AsciiParagraph(ctx);", "ap.addText(new LoremIpsum().getWords(9));", "System.out.println(ap.render(25));", "", "ctx.setFrameMode(TA_FrameOptions.THEME_CORNERS_ONLY);", "ctx.setFrameTopBottomMargin(0);", "ctx.setTextTopBottomMargin(0);", "ctx.setTextLeftRightMargin(0);", "System.out.println(ap.render(25));", "", "ctx.setFrameMode(TA_FrameOptions.THEME_LINE_TOPBOTTOM);", "System.out.println(ap.render(25));", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AsciiParagraph ap = new AsciiParagraph();", "class ObjectWHasText implements HasText{", " @Override", " public String getText() {", " return new LoremIpsum().getWords(10);", " }", "}", "", "ap.addText(new ObjectWHasText());", "System.out.println(ap.render());", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AP_Context ctx = new AP_Context();", "ctx.setAlignment(AP_Alignment.RIGHT);", "ctx.setWidth(29);", "ctx.setEndString(\"|\");", "", "AsciiParagraph ap = new AsciiParagraph(ctx);", "ap.addText(new LoremIpsum().getWords(29));", "System.out.println(ap.render());", "", "ctx.setTextRightMargin(5);", "System.out.println(ap.render());", "", "ctx.setTextRightMargin(10);", "ctx.setTextRightChar('<');", "System.out.println(ap.render());", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AP_Context ctx = new AP_Context();", "ctx.setAlignment(AP_Alignment.JUSTIFIED);", "ctx.setWidth(50);", "", "AsciiParagraph ap = new AsciiParagraph(ctx);", "ap.addText(new LoremIpsum().getWords(29));", "", "System.out.println(ap.render());", "", "ctx.setStartString(\"// \");", "System.out.println(ap.render());", "", "ctx.setEndString(\" -->\");", "System.out.println(ap.render());", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AsciiParagraph ap = new AsciiParagraph();", "ap.addText(new LoremIpsum().getWords(20));", "ap.getContext().setAlignment(AP_Alignment.LEFT);", "", "ap.getContext().setWidth(50);", "System.out.println(ap.render());", "", "ap.getContext().setWidth(40);", "System.out.println(ap.render());", "", "ap.getContext().setWidth(30);", "System.out.println(ap.render());" }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AP_Context ctx = new AP_Context();", "AsciiParagraph ap = new AsciiParagraph(ctx);", "ap.addText(new LoremIpsum().getWords(29));", "", "System.out.println(ap.render(35));", "", "ctx.setFormat(AP_Format.FIRST_LINE);", "System.out.println(ap.render(35));", "", "ctx.setFormat(AP_Format.HANGING);", "System.out.println(ap.render(35));", "", "ctx.setFormat(AP_Format.DROPCAP);", "System.out.println(ap.render(35));", "", "ctx.setDropCapLib(new FigletOldBanner_6L());", "System.out.println(ap.render(35));", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AP_Context ctx = new AP_Context();", "AsciiParagraph ap = new AsciiParagraph(ctx);", "ap.addText(new LoremIpsum().getWords(29));", "", "System.out.println(ap.render(50));", "", "ctx.getStrings().setStartString(\"// \");", "System.out.println(ap.render(50));", "", "ctx.getStrings().setEndString(\" -->\");", "System.out.println(ap.render(50));", "", "ctx.getMargins().setTextLeftMargin(10);", "System.out.println(ap.render(50));", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "AP_Context ctx = new AP_Context();", "ctx.setAlignment(AP_Alignment.LEFT);", "ctx.setTargetTranslator(new Text2Html());", "", "AsciiParagraph ap = new AsciiParagraph(ctx);", "ap.addText(\"A sentence with some normal text, not specific to HTML.\");", "ap.addText(\"Now for some characters that require conversion: # % & < >.\");", "ap.addText(\"And some more: © § ¤.\");", "ap.addText(\"And even more: Ē ē Ĕ ĕ Ė ė Ę ę Ě ě.\");", "ap.addText(\"And some arrows as well: ← ↑ → ↓ ↔ ↕\");", "System.out.println(ap.render(36));", "", "ctx.setTargetTranslator(new Text2Html());", "System.out.println(ap.render(36));", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public <LI extends AsciiListItem> StrBuilder getItemString(LI item, int index) { StrBuilder ret = new StrBuilder(20); ret .appendPadding(this.getItemMargin(), this.getItemChar()) .append(this.getLeftLabelString()) .appendPadding(this.getLabelLeftMargin(), this.getLabelLeftChar()) ; if(item instanceof DescriptionListItem){ ret.append(((DescriptionListItem) item).getKey()); } ret .appendPadding(this.getLabelRightMargin(), this.getLabelRightChar()) .append(this.getRightLabelString()) ; if(item instanceof DescriptionListItem){ ret.appendPadding(this.getTextLeftMargin(), this.getTextLeftChar()); } return ret; }
@Override public <LI extends AsciiListItem> StrBuilder getItemString(LI item, int index) { StrBuilder ret = new StrBuilder(20); ret .appendPadding(this.getItemMargin(), this.getItemChar()) .append(this.getLeftLabelString()) .appendPadding(this.getLabelLeftMargin(), this.getLabelLeftChar()) ; if(item instanceof ChecklistItem){ ret.append(this.getStyle().getLabel(this.getLevel(), ((ChecklistItem) item).isChecked())); } else{ ret.append(this.getStyle().getLabel(this.getLevel(), false)); } ret.appendPadding(this.getLabelRightMargin(), this.getLabelRightChar()) .append(this.getRightLabelString()) .appendPadding(this.getTextLeftMargin(), this.getTextLeftChar()) ; return ret; }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "Checklist list = new Checklist();", "list.addItem(\"item unchecked\", false);", "list.addItem(\"item checked\", true);", "System.out.println(list.render());", "", "list.getContext().setStyle(U8_Checklists.ballotBox());", "System.out.println(list.render());", "", "list.getContext().setStyle(U8_Checklists.ballotBoxX());", "System.out.println(list.render());", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
@Override public StrBuilder getSource(){ String[] source = new String[]{ "EnumerateList list = new EnumerateList()", " .addItem(\"item 1\")", " .addItem(\"item 2\")", " .addItem(\"item 3\")", ";", "list.getContext().setLeftLabelString(\"E\");", "list.getContext().setSeparatorAfterLastNumber(false);", "list.getContext().setStyle(U8_EnumerateLists.numberSubscript());", ";", "System.out.println(list.render());", }; return new StrBuilder().appendWithSeparators(source, "\n"); }
private static String buildFluentPathExpression(LinkedList<ContentPathSegment<?, ?>> segments) { StrBuilder builder = new StrBuilder(); ElementPathSegment elemSegment; for (ContentPathSegment<?, ?> segment : segments) { builder.appendSeparator(SdcctStringUtils.PERIOD_CHAR); builder.append(segment.getLocalName()); if ((segment instanceof ElementPathSegment) && (elemSegment = ((ElementPathSegment) segment)).hasIndex()) { builder.append(SdcctStringUtils.L_BRACKET_CHAR); builder.append(elemSegment.getIndex()); builder.append(SdcctStringUtils.R_BRACKET_CHAR); } } return builder.build(); }
private static String buildJsonPointerExpression(LinkedList<ContentPathSegment<?, ?>> segments) { StrBuilder builder = new StrBuilder(); ElementPathSegment elemSegment; for (ContentPathSegment<?, ?> segment : segments) { builder.append(SdcctStringUtils.SLASH_CHAR); builder.append(segment.getLocalName()); if ((segment instanceof ElementPathSegment) && (elemSegment = ((ElementPathSegment) segment)).hasIndex()) { builder.append(SdcctStringUtils.SLASH_CHAR); builder.append(elemSegment.getIndex()); } } return builder.build(); }
@Nullable public static String getStringValue(@Nullable Sequence seq) { if (seq == null) { return null; } if (seq instanceof AtomicValue) { return ((AtomicValue) seq).getStringValue(); } else if (seq instanceof Item) { return ((Item) seq).getStringValue(); } else { try { SequenceIterator seqIterator = seq.iterate(); StrBuilder builder = new StrBuilder(); Item seqItem; while ((seqItem = seqIterator.next()) != null) { Optional.ofNullable(getStringValue(seqItem)).ifPresent(builder::append); } return builder.build(); } catch (XPathException e) { throw new SaxonApiUncheckedException(e); } } }
public static String buildSafeFileName(String fileName) { char[] fileNameChars = FilenameUtils.getName(fileName).toCharArray(); StrBuilder fileNameBuilder = new StrBuilder(fileNameChars.length); char fileNameChar; for (int a = 0; a < fileNameChars.length; a++) { if (!CharUtils.isAscii((fileNameChar = fileNameChars[a]))) { continue; } if (Character.isWhitespace(fileNameChar)) { while (((a + 1) < fileNameChars.length) && Character.isWhitespace(fileNameChars[(a + 1)])) { a++; } if (!fileNameBuilder.isEmpty() && ((a + 2) < fileNameChars.length)) { fileNameBuilder.append(StringUtils.SPACE); } } else if (Character.isLetterOrDigit(fileNameChar) || (fileNameChar == CrigttStringUtils.HYPHEN_CHAR) || (fileNameChar == CrigttStringUtils.PERIOD_CHAR) || (fileNameChar == CrigttStringUtils.UNDERSCORE_CHAR)) { fileNameBuilder.append(fileNameChar); } } return fileNameBuilder.build(); }
@Override public String toString() { StrBuilder sb = new StrBuilder(); sb.setNewLineText("\n"); sb.appendNewLine(); sb.append("&6Clone Min Location: &b").append(min).appendNewLine(); sb.append("&6Clone Max Location: &b").append(max).appendNewLine(); sb.append("&aClone to Location: &5").append(cloneTo).appendNewLine(); sb.appendNewLine(); sb.append("&6Mask: "); if (mask.isEmpty()) sb.append("&bNot Set"); else sb.append("&b").append(mask); sb.appendNewLine(); sb.append("&6Mode: "); if (mode.isEmpty()) sb.append("&bNot Set"); else sb.append("&b").append(mode); sb.appendNewLine(); return TextProcessor.stripColor(sb.toString()); }
/** * Boxed announcement. * * @param color the color * @param color2 the color 2 * @param style the style * @param character the character * @param hColor the h color * @param hStyle the h style * @param heading the heading * @param messages the messages * @return the string */ public static String boxedAnnouncement(final ChatColor color, final ChatColor color2, final ChatColor style, char character, final ChatColor hColor, ChatColor hStyle, String heading, String... messages) { StrBuilder sb = new StrBuilder(); sb.setNewLineText("\n"); sb.append(" ").appendNewLine().append(" ").appendNewLine().append(" ").appendNewLine(); sb.append(fullLine(color, color2, style, character)).appendNewLine(); sb.append(" ").appendNewLine(); sb.append(centeredHeading(hColor, hStyle, heading)).appendNewLine(); sb.append(" ").appendNewLine(); sb.append(ChatColor.translateAlternateColorCodes('&', messages[0])).appendNewLine(); sb.append(" ").appendNewLine(); sb.append(fullLine(color2, color, style, character)).appendNewLine(); return sb.toString(); }