org.apache.commons.lang3.text.WordUtils Java Examples

The following examples show how to use org.apache.commons.lang3.text.WordUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodeEditor.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
protected static String truncate(String w) {
		boolean truncated = false;
		if (w.length() > 2048) {
			w = w.substring(0, 2048);
			truncated = true;
		}
		String lines[] = w.split("\\r?\\n");
		StringBuffer sb = new StringBuffer();
		int i = 0;
		for (String line : lines) {
			if (i++ == 40) {
				truncated = true;
				break;
			}
			sb.append(WordUtils.wrap(line, 40));			
		}
		if (truncated) {
			sb.append("\n\nThis error message was truncated.");
		}
		return sb.toString();
//		
//		List<String> s = w.lines().map(x -> x.substring(0, Integer.min(80, x.length()))).collect(Collectors.toList());
//		return Util.sep(s.subList(0, Integer.min(s.size(), 80)), "\n");
	}
 
Example #2
Source File: ProgWidget.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void renderExtraInfo(){
    if(getExtraStringInfo() != null) {
        GL11.glPushMatrix();
        GL11.glScaled(0.5, 0.5, 0.5);
        FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
        String[] splittedInfo = WordUtils.wrap(getExtraStringInfo(), 40).split(System.getProperty("line.separator"));
        for(int i = 0; i < splittedInfo.length; i++) {
            int stringLength = fr.getStringWidth(splittedInfo[i]);
            int startX = getWidth() / 2 - stringLength / 4;
            int startY = getHeight() / 2 - (fr.FONT_HEIGHT + 1) * (splittedInfo.length - 1) / 4 + (fr.FONT_HEIGHT + 1) * i / 2 - fr.FONT_HEIGHT / 4;
            Gui.drawRect(startX * 2 - 1, startY * 2 - 1, startX * 2 + stringLength + 1, startY * 2 + fr.FONT_HEIGHT + 1, 0xFFFFFFFF);
            fr.drawString(splittedInfo[i], startX * 2, startY * 2, 0xFF000000);
        }
        GL11.glPopMatrix();
        GL11.glColor4d(1, 1, 1, 1);
    }
}
 
Example #3
Source File: TypeChooser.java    From Shuffle-Move with GNU General Public License v3.0 6 votes vote down vote up
public void setSelectedType(PkmType type) {
   String toSelect = null;
   if (type != null) {
      if (shouldRebuild) {
         refill();
      }
      toSelect = WordUtils.capitalizeFully(type.toString());
      DefaultComboBoxModel<String> model = (DefaultComboBoxModel<String>) getModel();
      if (model.getIndexOf(toSelect) == -1) {
         shouldRebuild = true;
         insertItemAt(toSelect, 0);
      } else {
         shouldRebuild = false;
      }
   }
   setSelectedItem(toSelect);
}
 
Example #4
Source File: HypixelPaintballListener.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
@Override
public void onMatch(ServerHypixel.Paintball gameMode, String key, IPatternResult match) {
	if (gameMode.getState() == GameState.LOBBY) {
		if (key.equals("starting")) {
			gameMode.setTime(System.currentTimeMillis() + Integer.parseInt(match.get(0)) * 1000);
		}
	}
	if (gameMode.getState() == GameState.GAME) {
		if (key.equals("paintball.kill")) {
			gameMode.setKills(gameMode.getKills() + 1);
		}
		if (key.equals("paintball.death")) {
			gameMode.setDeaths(gameMode.getDeaths() + 1);
		}
	}
	if (key.equals("paintball.team")) {
		gameMode.setTeam(WordUtils.capitalize(match.get(0).toLowerCase(Locale.ROOT)));
	}
}
 
Example #5
Source File: StringUtilsTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testSwapCase_String() {
    assertEquals(null, StringUtils.swapCase(null));
    assertEquals("", StringUtils.swapCase(""));
    assertEquals("  ", StringUtils.swapCase("  "));
    
    assertEquals("i", WordUtils.swapCase("I") );
    assertEquals("I", WordUtils.swapCase("i") );
    assertEquals("I AM HERE 123", StringUtils.swapCase("i am here 123") );
    assertEquals("i aM hERE 123", StringUtils.swapCase("I Am Here 123") );
    assertEquals("I AM here 123", StringUtils.swapCase("i am HERE 123") );
    assertEquals("i am here 123", StringUtils.swapCase("I AM HERE 123") );
    
    String test = "This String contains a TitleCase character: \u01C8";
    String expect = "tHIS sTRING CONTAINS A tITLEcASE CHARACTER: \u01C9";
    assertEquals(expect, WordUtils.swapCase(test));
}
 
Example #6
Source File: CommandHelpFormatter.java    From rug-cli with GNU General Public License v3.0 6 votes vote down vote up
public String printCommandHelp(CommandInfo description) {
    StringBuilder sb = new StringBuilder();

    sb.append(String.format("Usage: %s%s\n", Style.bold(Constants.command()),
            Style.bold(description.usage())));
    if (!description.aliases().isEmpty()) {
        sb.append(String.format("%s: %s\n",
                com.atomist.rug.cli.utils.StringUtils.puralize("Alias", "Aliases",
                        description.aliases()),
                Style.bold(
                        StringUtils.collectionToDelimitedString(description.aliases(), ", "))));
    }
    sb.append(String.format("%s.\n", description.description()));

    printOptions(description.globalOptions(), sb, Style.bold("Options"));
    printOptions(description.options(), sb, Style.bold("Command Options"));

    sb.append("\n");
    sb.append(WordUtils.wrap(description.detail(), WRAP));
    sb.append(WordUtils.wrap(HELP_FOOTER, WRAP));

    return sb.toString();

}
 
Example #7
Source File: ApiOperationStep.java    From camunda-bpm-swagger with Apache License 2.0 6 votes vote down vote up
public void annotate(final MethodStep methodStep, final Method m) {

    // resources are not annotated at all, because the resource itself will contain a method
    // that will get into the public API. It is a method with GET annotation and empty path.
    if (!TypeHelper.isResource(methodStep.getReturnType())) {
      final String description = restOperation != null && restOperation.getDescription() != null ? restOperation.getDescription() : WordUtils.capitalize(StringHelper.splitCamelCase(m.getName()));

      getMethod().annotate(ApiOperation.class) //
        .param("value", StringHelper.firstSentence(description))
        .param("notes", description)
      ;

      if (restOperation != null && restOperation.getExternalDocUrl() != null) {
        getMethod().annotate(ExternalDocs.class)
          .param("value", "Reference Guide")
          .param("url", restOperation.getExternalDocUrl())
        ;
      }
    }
  }
 
Example #8
Source File: ResponseParser.java    From bunk with MIT License 6 votes vote down vote up
private Student processLogin(String loginJson) {
    JsonObject login;
    try {
        login = this.jsonParser.parse(loginJson).getAsJsonObject();
    } catch (Exception e) {
        throw new InvalidResponseException();
    }

    if (!login.has("status") || !login.has("name")) {
        throw new InvalidResponseException();
    }

    if (!login.get("status").getAsString().equals("success")) {
        throw new InvalidCredentialsException();
    }

    Student student = new Student();
    student.name = WordUtils.capitalizeFully(login.get("name").getAsString());

    return student;
}
 
Example #9
Source File: WidgetFluidRequest.java    From ExtraCells1 with MIT License 6 votes vote down vote up
@Override
public void drawWidget(int posX, int posY)
{
	Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
	GL11.glPushMatrix();
	GL11.glDisable(GL11.GL_LIGHTING);
	GL11.glColor3f(1.0F, 1.0F, 1.0F);
	if (fluid != null && fluid.getIcon() != null)
	{
		drawTexturedModelRectFromIcon(posX + 1, posY + 1, fluid.getIcon(), sizeX - 2, sizeY - 2);
		GL11.glScalef(0.5F, 0.5F, 0.5F);
		String str = StatCollector.translateToLocal("AppEng.Terminal.Craft");
		str = WordUtils.capitalize(str.toLowerCase());
		Minecraft.getMinecraft().fontRenderer.drawString(EnumChatFormatting.WHITE + str, 52 + posX - str.length(), posY + 24, 0);
	}
	GL11.glEnable(GL11.GL_LIGHTING);
	GL11.glPopMatrix();
}
 
Example #10
Source File: StringUtilsTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testSwapCase_String() {
    assertEquals(null, StringUtils.swapCase(null));
    assertEquals("", StringUtils.swapCase(""));
    assertEquals("  ", StringUtils.swapCase("  "));
    
    assertEquals("i", WordUtils.swapCase("I") );
    assertEquals("I", WordUtils.swapCase("i") );
    assertEquals("I AM HERE 123", StringUtils.swapCase("i am here 123") );
    assertEquals("i aM hERE 123", StringUtils.swapCase("I Am Here 123") );
    assertEquals("I AM here 123", StringUtils.swapCase("i am HERE 123") );
    assertEquals("i am here 123", StringUtils.swapCase("I AM HERE 123") );
    
    String test = "This String contains a TitleCase character: \u01C8";
    String expect = "tHIS sTRING CONTAINS A tITLEcASE CHARACTER: \u01C9";
    assertEquals(expect, WordUtils.swapCase(test));
}
 
Example #11
Source File: ComponentLookupGenerator.java    From Entitas-Java with MIT License 6 votes vote down vote up
private JavaClassSource generateIndicesLookup(String contextName, List<ComponentData> dataList) {
    String pkgDestiny = targetPackageConfig.getTargetPackage();

    JavaClassSource codeGen = Roaster.parse(JavaClassSource.class, String.format("public class %1$s {}",
            WordUtils.capitalize(contextName) + DEFAULT_COMPONENT_LOOKUP_TAG));
    if (dataList.size() > 0 && !pkgDestiny.endsWith(dataList.get(0).getSubDir()) ) {
       // pkgDestiny += "." + dataList.get(0).getSubDir();

    }
    codeGen.setPackage(pkgDestiny);

    addIndices(dataList, codeGen);
    addComponentNames(dataList, codeGen);
    addComponentTypes(dataList, codeGen);
    System.out.println(codeGen);

    return codeGen;
}
 
Example #12
Source File: SignalStatusRenderer.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void render(TileEntitySignalBase te, double x, double y,
		double z, float partialTicks, int destroyStage, float alpha) {
	String message = te.getMessage();
	if(message.equals("")) return;
	
	GlStateManager.pushMatrix();
	GlStateManager.translate((float)x + 0.5F, (float)y + 1.0, (float)z + 0.5F);
	GlStateManager.rotate(180 + Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, -1.0F, 0.0F);
	GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, -1.0F, 0.0F,0.0F);
	double scale = 1/32D;
	GlStateManager.scale(scale, -scale, scale);
	
	String[] splitted = WordUtils.wrap(message, 40).split("\r\n");
	FontRenderer f = Minecraft.getMinecraft().fontRenderer;
	for(int i = 0; i < splitted.length; i++){
		String line = splitted[i];
		f.drawString(line, -f.getStringWidth(line) / 2, (i - splitted.length + 1) * (f.FONT_HEIGHT + 1), 0xFFFFFFFF);
	}
	
	GlStateManager.popMatrix();
}
 
Example #13
Source File: AwsResourceNameService.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
private String instanceName(Object[] parts) {
    checkArgs(INSTANCE_NAME_PART_COUNT, parts);
    String name;
    String stackName = String.valueOf(parts[0]);
    String instanceGroupName = WordUtils.initials(String.valueOf(parts[1]).replaceAll("_", " "));
    String privateId = String.valueOf(parts[2]);

    name = normalize(stackName);
    name = adjustPartLength(name);
    name = appendPart(name, normalize(instanceGroupName));
    name = appendPart(name, privateId);
    name = appendHash(name, new Date());
    name = adjustBaseLength(name, maxResourceNameLength);

    return name;
}
 
Example #14
Source File: CharacterScreen.java    From xibalba with MIT License 6 votes vote down vote up
private void updateSkillsGroup() {
  skillsGroup.clear();

  skillsGroup.addActor(new Label("Skills", Main.skin));
  skillsGroup.addActor(new Label("", Main.skin));

  for (Map.Entry<String, Integer> entry : skills.levels.entrySet()) {
    String skill = entry.getKey();
    Integer level = entry.getValue();

    if (level > 0) {
      String name = WordUtils.capitalize(skill);

      skillsGroup.addActor(new Label(
          "[LIGHT_GRAY]" + name + " [WHITE]" + level + "[DARK_GRAY]d", Main.skin
      ));
    }
  }
}
 
Example #15
Source File: CharacterScreen.java    From xibalba with MIT License 6 votes vote down vote up
private void updateTraitsGroup() {
  traitsGroup.clear();

  traitsGroup.addActor(new Label("Traits", Main.skin));
  traitsGroup.addActor(new Label("", Main.skin));

  for (TraitData traitData : this.traits) {
    if (WorldManager.entityHelpers.hasTrait(WorldManager.player, traitData.name)) {
      traitsGroup.addActor(
          new Label(
              "[GREEN]" + traitData.name + "\n[DARK_GRAY]" + WordUtils.wrap(
                  traitData.description, 50
              ), Main.skin
          )
      );
    }
  }
}
 
Example #16
Source File: StringUtils.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
public static SpannableString getDateStringDayAndTime (Date dateValue) {
    DateFormat timeFormat = new SimpleDateFormat("  h:mm", Locale.US);
    DateFormat ampmFormat = new SimpleDateFormat(" a", Locale.US);
    DateFormat dateFormat = new SimpleDateFormat("EEE", Locale.US);
    DateFormat dateFormatWithTime = new SimpleDateFormat("    h:mm a", Locale.US);

    if (dateValue == null) {
        return new SpannableString(ArcusApplication.getContext().getString(R.string.unknown_time_value));
    }

    // Date is today; just show the time
    else if (StringUtils.isDateToday(dateValue)) {
        return StringUtils.getSuperscriptSpan(ArcusApplication.getContext().getString(R.string.today), dateFormatWithTime.format(dateValue));
    }

    // Date is yesterday; show "YESTERDAY"
    else if (StringUtils.isDateYesterday(dateValue)) {
        return new SpannableString(ArcusApplication.getContext().getString(R.string.yesterday));
    }

    // Date is in the past; show date
    else {
        return StringUtils.getSuperscriptSpan(WordUtils.capitalize(dateFormat.format(dateValue)), dateFormatWithTime.format(dateValue));
    }
}
 
Example #17
Source File: CharacterScreen.java    From xibalba with MIT License 6 votes vote down vote up
private void updateDefectsGroup() {
  defectsGroup.clear();

  defectsGroup.addActor(new Label("Defects", Main.skin));
  defectsGroup.addActor(new Label("", Main.skin));

  for (DefectData defectData : this.defects) {
    if (WorldManager.entityHelpers.hasDefect(WorldManager.player, defectData.name)) {
      defectsGroup.addActor(
          new Label(
              "[RED]" + defectData.name + "\n[DARK_GRAY]" + WordUtils.wrap(
                  defectData.description, 50
              ), Main.skin
          )
      );
    }
  }
}
 
Example #18
Source File: Core.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static String[] capitalizeStringArray(String[] array)
{
	String[] outArray = new String[array.length];
	for(int i = 0; i < array.length; i++)
	{
		outArray[i] = WordUtils.capitalize(array[i]);
	}
	return outArray;
}
 
Example #19
Source File: DateUtils.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
public static String formatSunriseSunset(@NonNull TimeOfDay timeOfDay) {
    String riseSet = WordUtils.capitalize(timeOfDay.getSunriseSunset().name().toLowerCase());
    int offset = timeOfDay.getOffset();
    if (offset == 0) {
        return String.format("At %s", riseSet);
    }
    else {
        boolean before = offset < 0;
        return String.format("%s Min %s %s", Math.abs(offset), before ? "Before" : "After", riseSet);
    }
}
 
Example #20
Source File: Downloads.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
private static Download toDownload(final String artifactId, final String classifier, final String version, final String format, String artifactUrl) {
    String url = DIST_RELEASE + version + "/" + artifactId + "-" + version + "-" + classifier + "." + format;
    String downloadUrl;
    String sha512 = null;
    if (urlExists(url)) {
        // artifact exists on dist.a.o
        downloadUrl = MIRROR_RELEASE + version + "/" + artifactId + "-" + version + "-" + classifier + "." + format;
    }
    else {
        url = ARCHIVE_RELEASE + version + "/" + artifactId + "-" + version + "-" + classifier + "." + format;
        if (urlExists(url)) {
            // artifact exists on archive.a.o
            downloadUrl = url;
        }
        else {
            // falling back to Maven URL
            downloadUrl = artifactUrl;
            url = artifactUrl;
        }
    }

    if (urlExists(url + ".sha512")) {
        sha512 = url + ".sha512";
    }

    return new Download(
            WordUtils.capitalize(artifactId.replace('-', ' ')),
            classifier,
            version,
            format,
            downloadUrl,
            url + ".sha1",
            sha512,
            url + ".asc",
            artifactUrl);
}
 
Example #21
Source File: OperatorDiscoverer.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
private JSONArray enrichProperties(String operatorClass, JSONArray properties) throws JSONException
{
  JSONArray result = new JSONArray();
  for (int i = 0; i < properties.length(); i++) {
    JSONObject propJ = properties.getJSONObject(i);
    String propName = WordUtils.capitalize(propJ.getString("name"));
    String getPrefix = (propJ.getString("type").equals("boolean") || propJ.getString("type").equals("java.lang.Boolean")) ? "is" : "get";
    String setPrefix = "set";
    OperatorClassInfo oci = getOperatorClassWithGetterSetter(operatorClass, setPrefix + propName, getPrefix + propName);
    if (oci == null) {
      result.put(propJ);
      continue;
    }
    MethodInfo setterInfo = oci.setMethods.get(setPrefix + propName);
    MethodInfo getterInfo = oci.getMethods.get(getPrefix + propName);

    if ((getterInfo != null && getterInfo.omitFromUI) || (setterInfo != null && setterInfo.omitFromUI)) {
      continue;
    }
    if (setterInfo != null) {
      addTagsToProperties(setterInfo, propJ);
    } else if (getterInfo != null) {
      addTagsToProperties(getterInfo, propJ);
    }
    result.put(propJ);
  }
  return result;
}
 
Example #22
Source File: CommandHelpFormatter.java    From rug-cli with GNU General Public License v3.0 5 votes vote down vote up
public String printGestureHelp(Gesture gesture) {
    StringBuilder sb = new StringBuilder();

    sb.append(String.format("Usage: %s%s\n", Style.bold(Constants.command()),
            Style.bold(gesture.usage())));
    sb.append(String.format("%s.\n", gesture.description()));

    sb.append("\n");
    sb.append(WordUtils.wrap(gesture.detail(), WRAP));
    sb.append(WordUtils.wrap(HELP_FOOTER, WRAP));

    return sb.toString();
}
 
Example #23
Source File: AzureStorage.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private String getPersistentStorageName(String prefix, AzureCredentialView acv, String region, String resourceGroup) {
    String subscriptionIdPart = StringUtils.isBlank(resourceGroup)
            ? acv.getSubscriptionId().replaceAll("-", "").toLowerCase()
            : encodeString(acv.getSubscriptionId().replaceAll("-", "").toLowerCase());
    String regionInitials = WordUtils.initials(Region.findByLabelOrName(region).label(), ' ').toLowerCase();
    String resourceGroupPart = encodeString(resourceGroup);
    String result = String.format("%s%s%s%s", prefix, regionInitials, subscriptionIdPart, resourceGroupPart);
    if (result.length() > MAX_LENGTH_OF_RESOURCE_NAME) {
        result = result.substring(0, MAX_LENGTH_OF_RESOURCE_NAME);
    }
    LOGGER.debug("Storage account name: {}", result);
    return result;
}
 
Example #24
Source File: SimpleWikiProvider.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public String getWikiURL(World world, MovingObjectPosition pos) {
	String name = getBlockName(world, pos);
	if(name == null)
		return null;

	if(lowercase) {
		return String.format(urlBase, name.toLowerCase().replaceAll(" ", replacement));
	} else {
		return String.format(urlBase, WordUtils.capitalizeFully(name).replaceAll(" ", replacement));
	}
}
 
Example #25
Source File: GenerateCommand.java    From rug-cli with GNU General Public License v3.0 5 votes vote down vote up
@Command
public void run(Rugs rugs, ArtifactDescriptor artifact,
        @Argument(index = 1) String fqArtifactName, @Argument(index = 2) String projectName,
        @Argument(start = 3) ParameterValues arguments, @Option("change-dir") String root,
        @Option("repo") boolean createRepo, @Option("force") boolean overwrite,
        RugResolver resolver) {

    String generatorName = OperationUtils.extractRugTypeName(fqArtifactName);
    Optional<ProjectGenerator> opt = asJavaCollection(rugs.generators()).stream()
            .filter(g -> g.name().equals(generatorName)).findFirst();
    if (opt.isPresent()) {
        arguments = validate(artifact, opt.get(), arguments);
        invoke(artifact, opt.get(), arguments, projectName, root, createRepo, overwrite,
                resolver);
    }
    else {
        if (rugs.generators().nonEmpty()) {
            log.newline();
            log.info(Style.cyan(Constants.DIVIDER) + " " + Style.bold("Generators"));
            asJavaCollection(rugs.generators())
                    .forEach(e -> log.info(Style.yellow("  %s", e.name()) + "\n    "
                            + WordUtils.wrap(
                                    org.apache.commons.lang3.StringUtils
                                            .capitalize(e.description()),
                                    Constants.WRAP_LENGTH, "\n    ", false)));
            StringUtils.printClosestMatch(generatorName, artifact, rugs.generatorNames());
        }
        throw new CommandException(
                String.format("Specified generator %s could not be found in %s:%s",
                        generatorName, artifact.group(), artifact.artifact()));
    }
}
 
Example #26
Source File: ActionWidgetDropdown.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public ActionWidgetDropdown(WidgetComboBox widget){
    super(widget);
    width = widget.width;
    height = widget.height;
    widget.setText(I18n.format("remote.dropdown.name"));
    widget.setTooltip(WordUtils.wrap(I18n.format("remote.dropdown.tooltip"), 50).split(System.getProperty("line.separator")));
}
 
Example #27
Source File: Application.java    From Jabit with Apache License 2.0 5 votes vote down vote up
private void show(Plaintext message) {
    System.out.println();
    System.out.println("From:    " + message.getFrom());
    System.out.println("To:      " + message.getTo());
    System.out.println("Subject: " + message.getSubject());
    System.out.println();
    System.out.println(WordUtils.wrap(message.getText(), 120));
    System.out.println();
    System.out.println(message.getLabels().stream().map(Label::toString).collect(
        Collectors.joining(", ", "Labels: ", "")));
    System.out.println();
    ctx.labeler().markAsRead(message);
    ctx.messages().save(message);
    String command;
    do {
        System.out.println("r) reply");
        System.out.println("d) delete");
        System.out.println("a) archive");
        System.out.println(COMMAND_BACK);
        command = commandLine.nextCommand();
        switch (command) {
            case "r":
                compose(message.getTo(), message.getFrom(), "RE: " + message.getSubject());
                break;
            case "d":
                ctx.labeler().delete(message);
                ctx.messages().save(message);
                return;
            case "a":
                ctx.labeler().archive(message);
                ctx.messages().save(message);
                return;
            case "b":
                return;
            default:
                System.out.println(ERROR_UNKNOWN_COMMAND);
        }
    } while (!"b".equalsIgnoreCase(command));
}
 
Example #28
Source File: Words.java    From OpenModsLib with MIT License 5 votes vote down vote up
public static IGenerator capitalizeFully(IGenerator gen) {
	return new Transformer(gen) {
		@Override
		protected String transform(String input) {
			return WordUtils.capitalizeFully(input);
		}
	};
}
 
Example #29
Source File: Label.java    From gremlin-ogm with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("PMD.ShortMethodName")
public static String of(Class<? extends Element> elementType) {
  String label = alias(elementType, Alias::label);
  if (label == null) {
    label = name(elementType);
    if (is(elementType, Edge.class)) {
      label = WordUtils.uncapitalize(label);
    }
  }
  return label;
}
 
Example #30
Source File: AutoGrading.java    From mobilecloud-15 with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

		// Ensure that this application is run within the correct working directory
		File f = new File("./src/main/java/org/magnum/dataup/Application.java");
		if (!f.exists()) {
			System.out
					.println(WordUtils
							.wrap("You must run the AutoGrading application from the root of the "
									+ "project directory containing src/main/java. If you right-click->Run As->Java Application "
									+ "in Eclipse, it will automatically use the correct classpath and working directory "
									+ "(assuming that you have Gradle and the project setup correctly).",
									80));
			System.exit(1);
		}

		// Ensure that the server is running and accessible on port 8080
		try {
			URL url = new URL("http://localhost:8080");
			HttpURLConnection connection = (HttpURLConnection) url
					.openConnection();
			connection.setRequestMethod(GET);
			connection.connect();
			connection.getResponseCode();
		} catch (Exception e) {
			System.out
					.println(WordUtils
							.wrap("Unable to connect to your server on http://localhost:8080. Are you sure the server is running? "
									+ "In order to run the autograder, you must first launch your application "
									+ "by right-clicking on the Application class in Eclipse, and"
									+ "choosing Run As->Java Application. If you have already done this, make sure that"
									+ " you can access your server by opening the http://localhost:8080 url in a browser. "
									+ "If you can't access the server in a browser, it probably indicates you have a firewall "
									+ "or some other issue that is blocking access to port 8080 on localhost.",
									80));
			System.exit(1);
		}

		HandinUtil.generateHandinPackage("Asgn1", new File("./"),
				InternalAutoGradingTest.class);
	}