All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.thisptr.jackson.jq.internal.functions.AtHtmlFunction Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package net.thisptr.jackson.jq.internal.functions;

import com.google.auto.service.AutoService;

import net.thisptr.jackson.jq.BuiltinFunction;
import net.thisptr.jackson.jq.Function;

@AutoService(Function.class)
@BuiltinFunction("@html/0")
public class AtHtmlFunction extends AbstractAtFormattingFunction {
	@Override
	public String convert(final String text) {
		final StringBuilder builder = new StringBuilder();
		for (final char ch : text.toCharArray()) {
			switch (ch) {
				case '<':
					builder.append("<");
					break;
				case '>':
					builder.append(">");
					break;
				case '\'':
					builder.append("'");
					break;
				case '"':
					builder.append(""");
					break;
				case '&':
					builder.append("&");
					break;
				case '\0':
					builder.append("\\0");
					break;
				default:
					builder.append(ch);
					break;
			}
		}
		return builder.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy