id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
e1c0612c-0ac6-4935-bf27-3fcb4b420614 | public void setCidade(String cidade) {
this.cidade = cidade;
} |
91a86d9b-9ea3-414b-a170-b408e371c325 | @Column(name="cep")
public String getCep() {
return cep;
} |
c42c9cb8-83a4-4ab2-8553-fd04e0622aa8 | public void setCep(String cep) {
this.cep = cep;
} |
18712dfa-7191-4314-998a-01b094517ea2 | @Column(name="dataNasc")
public Date getDataNasc() {
return dataNasc;
} |
59dc1feb-e18f-4d6d-89a5-603a3d286b2a | public void setDataNasc(Date dataNasc) {
this.dataNasc = dataNasc;
} |
e8fbefea-4d07-429a-8822-b6b3c2355985 | @Column(name="telefone")
public String getTelefone() {
return telefone;
} |
4bed1c9d-9073-4cf5-bc67-5e890334e5d5 | public void setTelefone(String telefone) {
this.telefone = telefone;
} |
90656aa7-f8d8-4b0e-989f-2c94e99025dd | public static Session getSession() {
return sessionFactory.openSession();
} |
bbd23a61-4cf5-495b-920e-f85bff10e5fa | public HibernateMeuMysql5Dialect(){
super();
registerColumnType(Types.BOOLEAN, "bit");
registerColumnType(Types.DATE, "datatime");
} |
91dc300e-5158-48c5-8e03-6949d8e7c8b0 | public void salvar(Produto produto){
Session session = HibernateUtil.getSession();
Transaction tx = session.beginTransaction();
session.saveOrUpdate(produto);
tx.commit();
session.close();
} |
ea1e1feb-f823-469b-8940-f00b1f74cba2 | @SuppressWarnings("unchecked")
public List<Produto> listar() {
Session session = HibernateUtil.getSession();
try {
return session.createCriteria(Produto.class).addOrder(Order.asc("nome")).list();
} finally {
session.close();
}
} |
f70005c5-fa6b-4779-a4ba-9256855724d5 | public void salvar(Cliente cliente){
Session session = HibernateUtil.getSession();
Transaction tx = session.beginTransaction();
session.saveOrUpdate(cliente);
tx.commit();
session.close();
} |
59ecd18a-2056-42c2-ad17-ea71eeae1adb | @SuppressWarnings("unchecked")
public List<Cliente> listar() {
Session session = HibernateUtil.getSession();
try {
return session.createCriteria(Cliente.class).addOrder(Order.asc("nome")).list();
} finally {
session.close();
}
} |
1bdbdb88-4faa-48c9-a899-12f770a838b4 | public ProdutoManagedBean(){
this.produto = new Produto();
this.produtos = new ProdutoDAO().listar();
} |
776d90a7-1887-489c-bbeb-73ce472a1b8b | public String listar(){
this.produtos = new ProdutoDAO().listar();
return "produtoLista";
} |
8a14cbd3-c120-43aa-99ad-2ef937d4bcdf | public String salvar(){
new ProdutoDAO().salvar(this.produto);
return "produtoForm";
} |
ebd57387-ecae-4a33-8191-67560a125eb0 | public void uploadAction (FileUploadEvent event){
try {
// pegando a foto
foto = event.getFile().getContents();
Date data = new Date();
//pegando o nome da foto com o caminho
String nome = (data.getTime() + ".jpg");
//pegando o caminho que a foto vai ser gravada
FacesContext facesContext = FacesContext.getCurrentInstance();
ServletContext scontext = (ServletContext) facesContext.getExternalContext().getContext();
arquivo = scontext.getRealPath("/resources/images/" + nome);
//setando o nome da foto no banco
this.produto.setUrl(nome);
if(foto != null) {
FacesMessage msg = new FacesMessage("Sucesso", event.getFile().getFileName() + "Foi upada!");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}catch (Exception ex){
FacesMessage msg = new FacesMessage("ERRO", event.getFile().getFileName() + "Não foi upada!");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
} |
bc6386dd-8db6-42a2-b0b7-e056154fad3e | public void gravar(){
FileOutputStream fos;
try {
//passando o caminho;
fos = new FileOutputStream(arquivo);
//passando o arquivo;
fos.write(foto);
fos.close();
} catch (FileNotFoundException ex) {
Logger.getLogger(ProdutoManagedBean.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(ProdutoManagedBean.class.getName()).log(Level.SEVERE, null, ex);
}
} |
200ad13a-eb85-4e9a-8b73-40e8b7f0e89d | public Produto getProduto() {
return produto;
} |
57ffea3b-60d9-42c8-9b97-34a234d9a4e1 | public void setProduto(Produto produto) {
this.produto = produto;
} |
94ff6e37-6dee-4573-a063-b107935f8a75 | public List<Produto> getProdutos() {
return produtos;
} |
a5baeb6c-95f5-45cc-a698-0a87e09bf2e1 | public void setProdutos(List<Produto> produtos) {
this.produtos = produtos;
} |
c44463f0-ab5b-4d07-ba2b-0c14b126f2bb | public ClienteManagedBean(){
this.cliente = new Cliente();
this.clientes = new ClienteDAO().listar();
} |
3ef9a6a6-1d5e-4ceb-8912-3445ccd87f84 | public String salvar(){
new ClienteDAO().salvar(this.cliente);
return listar();
} |
61a460ff-4b79-4f06-9d4b-e4815730ec05 | public String listar(){
this.clientes = new ClienteDAO().listar();
return "clienteLista.jsf";
} |
2927e4ed-6a2a-4b47-ba52-825ddefb09b2 | public String incluir(){
return "clienteForm";
} |
7f32ee8a-1cff-4994-9f89-79d14f1a39b1 | public Cliente getCliente() {
return cliente;
} |
44add7a6-7376-496d-ac44-62588adf3f62 | public void setCliente(Cliente cliente) {
this.cliente = cliente;
} |
96b583eb-685d-49da-8bc4-e284a27c4463 | public List<Cliente> getClientes() {
return clientes;
} |
b9873e71-4c07-4ac7-9c27-65f7f7859838 | public void setClientes(List<Cliente> clientes) {
this.clientes = clientes;
} |
7039740a-9c0f-4d93-90d0-b5c1301e5ce7 | public static void main(String[] args) {
String imgPath = "C:/Users/HP/Desktop/9787030195371.jpg";
BufferedImage img = null;
try {
img = ImageIO.read(new File(imgPath));
} catch (IOException e) {
e.printStackTrace();
}
String EAN13 = readEAN13(img);
// 校验
if (computeCheckcode(EAN13) == Character.getNumericValue(EAN13
.charAt(12)))
System.out.print("解码结果:" + EAN13);
else
System.out.print("解码失败");
System.out.print("\n\n\n-------该书在校图书馆可外借的信息--------\n");
System.out.print(LibraryInfo.getLibraryInfo(EAN13));
} |
c32c4881-ce63-4f45-ad6f-cdba99ab42be | private static String readEAN13(BufferedImage img) {
int x = 0;
int y = img.getHeight() / 2;
int in;
int width = img.getWidth();
int pixelCount = 0;
int base = 2;
boolean change = false;
color currentColor, preColor = getColor(img.getRGB(x, y));
String value = "";
String EAN13 = "";
// 寻找起始的像素点位置
for (in = 0; in < width; in++) { // 初始值
if (getColor(img.getRGB(in, y)) == color.black) {
break;
}
}
// 生成value
for (x = in; x < width; x++) {
currentColor = getColor(img.getRGB(x, y));
if (currentColor != color.gray) {
change = (currentColor == preColor) ? false : true;
if (!change) {
pixelCount++;
} else {
value += (pixelCount / base);
pixelCount = 1;
}
preColor = currentColor;
} else
continue;
}
// 存储左侧数据与右侧数据
String[] left = new String[6];
String[] right = new String[6];
for (int i = 4; i < 28; i += 4) {
left[(i / 4) - 1] = value.substring(i, i + 4);
}
for (int i = 33; i < 57; i += 4) {
right[(i - 33) / 4] = value.substring(i, i + 4);
}
// 转换成EAN13
String table = "";
for (int i = 0; i < 6; i++) {// 转换左侧数据
for (int j = 0; j < 20; j++) {
if (left[i].equals(LEFT_TABLE[j])) {
EAN13 += (j % 10);
if (j < 10)
table += "A"; // 位于A集合
else
table += "B";// 位于B集合
}
}
}
for (int i = 0; i < 6; i++) { // 转换右侧数据
for (int j = 0; j < 10; j++) {
if (right[i].equals(RIGHT_TABLE[j]))
EAN13 += (j % 10);
}
}
// 加上前置码
for (int i = 0; i < 10; i++) {
if (table.equals(TABLE[i])) {
EAN13 = i + EAN13;
break;
}
}
return EAN13;
} |
a77bb019-08dd-4b5a-b4be-d2e5a520d10f | private static color getColor(int rgb) {
int r = (rgb >> 16) & 255;
int g = (rgb >> 8) & 255;
int b = rgb & 255;
double avg = 0.299 * r + 0.587 * g + 0.114 * b; // 计算灰度值
if ((int) avg > 200)
return color.white;// white
else if ((int) avg < 50)
return color.black;// black
else
return color.gray;// gray
} |
7a96b60c-8f77-43b3-8968-fb211f24d046 | private static int computeCheckcode(String str) {
int sum_even = 0;// 偶数位之和
int sum_odd = 0;// 奇数位之和
for (int i = 0; i < 12; i++) {
if (i % 2 == 0) {
sum_odd += Character.getNumericValue(str.charAt(i));
} else {
sum_even += Character.getNumericValue(str.charAt(i));
}
}
int checkcode = (10 - (sum_even * 3 + sum_odd) % 10) % 10;
return checkcode;
} |
cb40965d-9c19-474d-be2e-8c9e5c02c475 | public static String Get(String s, int width, int height)
{
int sum_even = 0;//偶数位之和
int sum_odd = 0;//奇数位之和
for (int i = 0; i < 12; i++)
{
if (i % 2 == 0)
{
sum_odd += Character.getNumericValue(s.charAt(i));
}
else
{
sum_even += Character.getNumericValue(s.charAt(i));
}
}
//校验码
int checkcode = (10 - (sum_even * 3 + sum_odd) % 10) % 10;
//变成13位
s += checkcode;
// 00000000000101左侧42个01010右侧35个校验7个1010000000
String resultBin = "";//二进制串
//起始符
resultBin += "00000000000101";
String type = ean13type(s.charAt(0));
//左侧数据符
for (int i = 1; i < 7; i++)
{
resultBin += ean13(s.charAt(i), type.charAt(i - 1));
}
//中间分隔符
resultBin += "01010";
//右侧数据符
for (int i = 7; i < 13; i++)
{
resultBin += ean13(s.charAt(i), 'C');//右侧数据符及校验符均用字符集中的C子集表示
}
//终止符
resultBin += "1010000000";
return resultBin;
} |
85c66421-1c9d-459e-ab99-9b65d02c205e | private static String ean13(char c, char type)
{
switch (type)
{
case 'A':
{
switch (c)
{
case '0': return "0001101";
case '1': return "0011001";
case '2': return "0010011";
case '3': return "0111101";//011101
case '4': return "0100011";
case '5': return "0110001";
case '6': return "0101111";
case '7': return "0111011";
case '8': return "0110111";
case '9': return "0001011";
default: return "Error!";
}
}
case 'B':
{
switch (c)
{
case '0': return "0100111";
case '1': return "0110011";
case '2': return "0011011";
case '3': return "0100001";
case '4': return "0011101";
case '5': return "0111001";
case '6': return "0000101";//000101
case '7': return "0010001";
case '8': return "0001001";
case '9': return "0010111";
default: return "Error!";
}
}
case 'C':
{
switch (c)
{
case '0': return "1110010";
case '1': return "1100110";
case '2': return "1101100";
case '3': return "1000010";
case '4': return "1011100";
case '5': return "1001110";
case '6': return "1010000";
case '7': return "1000100";
case '8': return "1001000";
case '9': return "1110100";
default: return "Error!";
}
}
default: return "Error!";
}
} |
700101e9-6af7-4fd4-b33d-593b7d0c2a55 | private static String ean13type(char c)
{
switch (c)
{
case '0': return "AAAAAA";
case '1': return "AABABB";
case '2': return "AABBAB";
case '3': return "AABBBA";
case '4': return "ABAABB";
case '5': return "ABBAAB";
case '6': return "ABBBAA";//中国
case '7': return "ABABAB";
case '8': return "ABABBA";
case '9': return "ABBABA";
default: return "Error!";
}
} |
43911c93-c443-4160-8541-4dba50cc9fd9 | public static void main(String[] args) {
String imgPath = "C:/Users/HP/Desktop/2.jpg";
BufferedImage img = null;
try {
img = ImageIO.read(new File(imgPath));
} catch (IOException e) {
e.printStackTrace();
}
int x = 0;
int y = img.getHeight() / 2;
int in;
int width = img.getWidth();
int pixelCount = 0;
int base = 2;
boolean change = false;
color currentColor, preColor = getColor(img.getRGB(x, y));
String value = "";
String EAN13 = "";
// 寻找起始的像素点位置
for (in = 0; in < width; in++) { // 初始值
if (getColor(img.getRGB(in, y)) == color.black) {
break;
}
}
// 生成value
for (x = in; x < width; x++) {
currentColor = getColor(img.getRGB(x, y));
if (currentColor != color.gray) {
change = (currentColor == preColor) ? false : true;
if (!change) {
pixelCount++;
} else {
value += (pixelCount / base);
pixelCount = 1;
}
preColor = currentColor;
} else
continue;
}
// 存储左侧数据与右侧数据
String[] left = new String[6];
String[] right = new String[6];
for (int i = 4; i < 28; i += 4) {
left[(i / 4) - 1] = value.substring(i, i + 4);
}
for (int i = 33; i < 57; i += 4) {
right[(i - 33) / 4] = value.substring(i, i + 4);
}
// 转换成EAN13
String table = "";
for (int i = 0; i < 6; i++) {// 转换左侧数据
for (int j = 0; j < 20; j++) {
if (left[i].equals(LEFT_TABLE[j])) {
EAN13 += (j % 10);
if (j < 10)
table += "A"; // 位于A集合
else
table += "B";// 位于B集合
}
}
}
for (int i = 0; i < 6; i++) { // 转换右侧数据
for (int j = 0; j < 10; j++) {
if (right[i].equals(RIGHT_TABLE[j]))
EAN13 += (j % 10);
}
}
// 加上前置码
for (int i = 0; i < 10; i++) {
if (table.equals(TABLE[i])) {
EAN13 = i + EAN13;
break;
}
}
// 校验
if (computeCheckcode(EAN13) == Character.getNumericValue(EAN13
.charAt(12)))
System.out.print("解码结果:" + EAN13);
else
System.out.print("解码失败");
} |
0b93b21c-85d3-4843-9d1d-e135d62016e9 | private static color getColor(int rgb) {
int r = (rgb >> 16) & 255;
int g = (rgb >> 8) & 255;
int b = rgb & 255;
double avg = 0.299 * r + 0.587 * g + 0.114 * b; // 计算灰度值
if ((int) avg > 200)
return color.white;// white
else if ((int) avg < 50)
return color.black;// black
else
return color.gray;// gray
} |
8965355a-8ba8-486f-8ecc-b9eb92536096 | private static int computeCheckcode(String str) {
int sum_even = 0;// 偶数位之和
int sum_odd = 0;// 奇数位之和
for (int i = 0; i < 12; i++) {
if (i % 2 == 0) {
sum_odd += Character.getNumericValue(str.charAt(i));
} else {
sum_even += Character.getNumericValue(str.charAt(i));
}
}
int checkcode = (10 - (sum_even * 3 + sum_odd) % 10) % 10;
return checkcode;
} |
a36d3099-919a-4b8e-a9fc-bd5270b80e0d | public static String getLibraryInfo(String EAN13Code) {
String url = "http://202.120.82.40/search*chx/i?SEARCH=" + EAN13Code
+ "&sortdropdown=-&availlim=1";
String content = getHtmlReadLine(url);
if (getContent(content) != "")
return getContent(content);
else
return "该书不再校图书馆中/该书不可外借";
} |
1e3e485e-514d-4bb1-bdd5-5f0311bce027 | private static String getContent(String content) {
if (content.indexOf("<tr class=\"bibItemsEntry\">") == -1
|| content.indexOf("<center><form method=\"post\" action=") == -1)
return "";
String str = content.substring(
content.indexOf("<tr class=\"bibItemsEntry\">"),
content.indexOf("<center><form method=\"post\" action="));
Pattern p = Pattern.compile("<(\\S*?)[^>]*>.*?| <.*? />");
Matcher m = p.matcher(str);
String rs = new String(str);
while (m.find()) {
rs = rs.replace(m.group(), "");
}
rs = rs.replace(" ", "");
return rs;
} |
ee619870-a31e-4efc-b211-4133ca1f42cf | private static String getHtmlReadLine(String httpurl) {
String CurrentLine = "";
String TotalString = "";
InputStream urlStream;
String content = "";
try {
URL url = new URL(httpurl);
HttpURLConnection connection = (HttpURLConnection) url
.openConnection();
connection.connect();
urlStream = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(
urlStream, "utf-8"));
while ((CurrentLine = reader.readLine()) != null) {
TotalString += CurrentLine + "\n";
}
content = TotalString;
} catch (Exception e) {
e.printStackTrace();
}
return content;
} |
42fc410c-8048-48d7-bf22-57d1491a849d | public static void main(String[] args) throws Exception {
System.out.println("请输入12位代码:");
// 读取用户输入
InputStreamReader is_reader = new InputStreamReader(System.in);
String str = new BufferedReader(is_reader).readLine();
if (str.length() != 12) {
System.out.print("输入的代码不是12位!");
} else {
// 将字符串转换为二进制代码
String EAN13code = EAN13.Get(str, width, height);
// 生成校验位
str += computeCheckcode(str);
// 图像路径
File file = new File("C:/Users/HP/Desktop/" + str + ".jpg");
// 画出条形码
drawEAN13Barcode(EAN13code);
drawString(str);
// 保存图像
ImageIO.write(bi, "jpg", file);
System.out.println("条形码图片已生成");
}
} |
70d4931f-1f3c-4535-a380-884f2740b764 | private static int computeCheckcode(String str) {
int sum_even = 0;// 偶数位之和
int sum_odd = 0;// 奇数位之和
for (int i = 0; i < 12; i++) {
if (i % 2 == 0) {
sum_odd += Character.getNumericValue(str.charAt(i));
} else {
sum_even += Character.getNumericValue(str.charAt(i));
}
}
int checkcode = (10 - (sum_even * 3 + sum_odd) % 10) % 10;
return checkcode;
} |
6d0ec155-455d-47b4-b9c7-09e5af11e16e | private static void drawBlackLine(int x, int y, int h) {
g2.setPaint(Color.BLACK);
g2.drawLine(x, y, x, y + h);
g2.drawLine(x + 1, y, x + 1, y + h);
} |
8bff7cd7-397d-4c5b-ad5c-d7cfe3b15688 | private static void drawWhiteLine(int x, int y, int h) {
g2.setPaint(Color.WHITE);
g2.drawLine(x, y, x, y + h);
g2.drawLine(x + 1, y, x + 1, y + h);
} |
5ffffa57-d477-4d1c-afa1-5fe69c4d3d13 | private static void drawEAN13Barcode(String s) {
// 生成图像,设置背景色为白色
g2.setBackground(Color.WHITE);
g2.clearRect(0, 0, width, height);
// 画出条形码
int location = 36;
int bin;
for (int i = 0; i < 113; i++) {
bin = s.charAt(i) - '0';
switch (bin) {
case 0:
drawWhiteLine(location, 60, 100);
break;
case 1:
drawBlackLine(location, 60, 100);
break;
}
location += 2;
}
// 加长警戒条
drawBlackLine(58, 160, 10);
drawBlackLine(62, 160, 10);
drawBlackLine(150, 160, 10);
drawBlackLine(154, 160, 10);
drawBlackLine(242, 160, 10);
drawBlackLine(246, 160, 10);
} |
60695746-eb26-4059-af18-f576467e8fd1 | private static void drawString(String str) {
// 处理字符串
String s1 = str.substring(0, 1);
String s2 = str.substring(1, 7);
String s3 = str.substring(7, 13);
String newStr = s1 + " " + s2 + " " + s3;
// 画出商品代码
Font font = new Font("Dialog", Font.BOLD, 24);
g2.setFont(font);
g2.setPaint(Color.BLACK);
g2.drawString(newStr, 40, 182);
} |
03fc008c-4b98-499f-829c-d3e3c0485205 | InputFilter(final Plugin plugin, final char formatCode, final String chat) {
this.plugin = plugin;
this.formatCode = formatCode;
this.chat = chat;
} |
f8a5da04-5818-4190-a642-3e1e81b6304f | @EventHandler
public void onServerCommand(final ServerCommandEvent event) {
String command = event.getCommand();
if (command.startsWith("/")) {
command = command.substring(1);
} else {
command = ChatColor.translateAlternateColorCodes(this.formatCode, MessageFormat.format(this.chat, command));
}
event.setCommand(command);
} |
a64189f7-3a8c-40c7-b754-58dc05591a08 | public boolean isEnabled() {
return this.enabled;
} |
9d250033-220a-46f0-8e5d-b6fcdfed0300 | public void enable() {
Bukkit.getPluginManager().registerEvents(this, this.plugin);
this.enabled = true;
} |
c4feb5c0-a626-4f78-b675-6fbaaae5dc5c | public void disable() {
HandlerList.unregisterAll(this);
this.enabled = false;
} |
5154b0d4-6e49-45d0-a69e-de9c20ff7d53 | @Override
public void onLoad() {
this.putConfigMinimum("1.1.0");
this.putConfigMinimum("language.yml", "1.1.2");
} |
f8fe4819-c43c-4862-9e9c-eb4096a3a25e | @Override
public void onEnable() {
this.reloadConfig();
Main.courier = ConfigurationCourier.Factory.create(this).setBase(this.loadConfig("language.yml")).setFormatCode("format-code").build();
final InputFilter filter = new InputFilter(this, this.getConfig().getString("format-code").charAt(0), this.getConfig().getString("chat"));
if (this.getConfig().getBoolean("default-enable")) {
filter.enable();
Main.courier.send(Bukkit.getConsoleSender(), "enabled");
}
this.getCommand("consolechat:toggle").setExecutor(new Toggle(filter));
this.getCommand("consolechat:reload").setExecutor(new Reload(this));
} |
d3c24228-1edc-483e-a1d9-63451c9e0974 | @Override
public void onDisable() {
Main.courier = null;
} |
a2ff253f-f96f-4887-85b3-51d19c5a55ad | public Version(final String version) {
this.original = version;
if (version == null) {
this.major = null;
this.minor = null;
this.revision = null;
this.type = null;
this.build = null;
return;
}
final Matcher m = Pattern.compile("(\\d+)\\.(\\d+).(\\d+)(a|b|rc|$)(\\d+)?").matcher(this.original);
if (!m.find())
throw new IllegalArgumentException("Unrecognized version format \"" + version + "\"; Expected <Major>.<Minor>.<Revision>[<Type><Build>]");
this.major = Integer.parseInt(m.group(1));
this.minor = Integer.parseInt(m.group(2));
this.revision = Integer.parseInt(m.group(3));
this.type = Type.parse(m.group(4));
this.build = (m.group(5) != null ? Integer.parseInt(m.group(5)) : null);
} |
78dedbd4-3300-4fa7-9dbc-e009c238abb0 | @Override
public String toString() {
return this.original;
} |
5de86336-56eb-460e-89ba-06a0a3d57457 | @Override
public int compareTo(final Version other) {
// Null instances are less than any non-null instances
if (other == null) return 1;
if (this.original != null && other.original == null) return 1;
if (this.original == null && other.original == null) return 0;
if (this.original == null && other.original != null) return -1;
if (this.original.equals(other.original)) return 0;
// Determine what is different, favoring the more important segments first
if (this.major != other.major) return this.major.compareTo(other.major);
if (this.minor != other.minor) return this.minor.compareTo(other.minor);
if (this.revision != other.revision) return this.revision.compareTo(other.revision);
if (this.type != other.type) return this.type.compareTo(other.type);
return (this.build == null ? -1 : this.build.compareTo(other.build));
} |
d408eabc-1f8f-4395-a460-af786b379d84 | public static Type parse(final String designator) {
for (final Type type : Type.known)
if (type.designator.equals(designator))
return type;
throw new IllegalArgumentException("Unknown designator: " + designator);
} |
f0aae222-605d-4300-802e-d5ad57cfe4bc | private Type(final String designator, final int level) {
this.designator = designator;
this.level = level;
Type.known.add(this);
} |
4e285036-3c1d-496e-a1e7-625fcdd44e88 | @Override
public int compareTo(final Type other) {
return (other == null ? 1 : this.level.compareTo(other.level));
} |
4e81e405-c0d7-4e43-84da-b2ecfc82a823 | public void putConfigMinimum(final String version) {
this.putConfigMinimum(CustomPlugin.CONFIGURATION_FILE, version);
} |
f1cc7e4c-2ada-4dd1-9157-8abc38ef2f08 | public void putConfigMinimum(final String resource, final String version) {
this.configurationMinimums.put(resource, new Version(version));
} |
7f4c65e4-f663-49c6-b60d-c7022ee28bd1 | public CustomPlugin setPathSeparator(final char separator) {
this.pathSeparator = separator;
return this;
} |
72feb8dd-cc0b-4952-b688-440ff1a76786 | @Override
public FileConfiguration getConfig() {
if (this.config == null) this.reloadConfig();
return this.config;
} |
3561208f-db49-4f68-b390-cc96e5c15a48 | @Override
public void reloadConfig() {
this.config = this.loadConfig(CustomPlugin.CONFIGURATION_FILE);
this.setLogLevel(this.getConfig().getString("log-level"));
this.getLogger().log(Level.FINEST, "YAML configuration file encoding: {0}", CustomPlugin.CONFIGURATION_TARGET);
} |
a474f0fd-8ad9-4450-a12c-6e6ce93a6afd | @Override
public void saveDefaultConfig() {
this.extractConfig(CustomPlugin.CONFIGURATION_FILE, false);
} |
c21da5c0-c9bb-4792-b40c-f09179c07dfb | public FileConfiguration loadConfig(final String resource) {
return this.loadConfig(resource, this.pathSeparator, this.configurationMinimums.get(resource));
} |
74bd4edc-eaa7-40a0-b915-f1b491603e39 | public FileConfiguration loadConfig(final String resource, final char pathSeparator, final Version required) {
// extract default if not existing
this.extractConfig(resource, false);
final File existing = new File(this.getDataFolder(), resource);
final YamlConfiguration yaml = new YamlConfiguration();
yaml.options().pathSeparator(pathSeparator);
try {
yaml.load(existing);
} catch (final InvalidConfigurationException e) {
throw new IllegalStateException("Unable to load configuration file: " + existing.getPath() + " (Ensure file is encoded as " + CustomPlugin.CONFIGURATION_TARGET + ")", e);
} catch (final Exception e) {
throw new RuntimeException("Unable to load configuration file: " + existing.getPath(), e);
}
yaml.setDefaults(this.loadEmbeddedConfig(resource));
if (required == null) return yaml;
// verify required or later version
final Version version = new Version(yaml.getString("version", null));
if (version.compareTo(required) >= 0) return yaml;
this.archiveConfig(resource, version);
// extract default and reload
return this.loadConfig(resource, this.pathSeparator, null);
} |
269e6991-4518-4eaf-94f4-c0b1f08b8b05 | public void extractConfig(final String resource, final boolean replace) {
final File config = new File(this.getDataFolder(), resource);
if (config.exists() && !replace) return;
this.getLogger().log(Level.FINE, "Extracting configuration file {1} {0} as {2}", new Object[] { resource, CustomPlugin.CONFIGURATION_SOURCE.name(), CustomPlugin.CONFIGURATION_TARGET.name() });
config.getParentFile().mkdirs();
final char[] cbuf = new char[1024]; int read;
try {
final Reader in = new BufferedReader(new InputStreamReader(this.getResource(resource), CustomPlugin.CONFIGURATION_SOURCE));
final Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(config), CustomPlugin.CONFIGURATION_TARGET));
while((read = in.read(cbuf)) > 0) out.write(cbuf, 0, read);
out.close(); in.close();
} catch (final Exception e) {
throw new IllegalArgumentException("Could not extract configuration file \"" + resource + "\" to " + config.getPath() + "\"", e);
}
} |
805bff50-e76c-4eb8-8e91-3b2b3222cec5 | public void archiveConfig(final String resource, final Version version) {
final File backup = new File(this.getDataFolder(), MessageFormat.format(CustomPlugin.CONFIGURATION_ARCHIVE, resource.replaceAll("(?i)\\.yml$", ""), version, new Date()));
final File existing = new File(this.getDataFolder(), resource);
if (!existing.renameTo(backup))
throw new IllegalStateException("Unable to archive configuration file \"" + existing.getPath() + "\" with version \"" + version + "\" to \"" + backup.getPath() + "\"");
this.getLogger().warning("Archived configuration file \"" + existing.getPath() + "\" with version \"" + version + "\" to \"" + backup.getPath() + "\"");
} |
87eb1394-2d51-41f3-be35-4d287ef9289e | public Configuration loadEmbeddedConfig(final String resource) {
final YamlConfiguration config = new YamlConfiguration();
final InputStream defaults = this.getResource(resource);
if (defaults == null) return config;
final InputStreamReader reader = new InputStreamReader(defaults, CustomPlugin.CONFIGURATION_SOURCE);
final StringBuilder builder = new StringBuilder();
final BufferedReader input = new BufferedReader(reader);
try {
try {
String line;
while ((line = input.readLine()) != null)
builder.append(line).append(CustomPlugin.LINE_SEPARATOR);
} finally {
input.close();
}
config.loadFromString(builder.toString());
} catch (final Exception e) {
throw new RuntimeException("Unable to load embedded configuration: " + resource, e);
}
return config;
} |
ad5e008e-e11a-4571-8615-2939474ab047 | public void setLogLevel(final String name) {
Level level;
try { level = Level.parse(name); } catch (final Exception e) {
level = CustomPlugin.DEFAULT_LOG;
this.getLogger().warning("Log level defaulted to " + level.getName() + "; Unrecognized java.util.logging.Level: " + name + "; " + e);
}
// only set the parent handler lower if necessary, otherwise leave it alone for other configurations that have set it
for (final Handler h : this.getLogger().getParent().getHandlers())
if (h.getLevel().intValue() > level.intValue()) h.setLevel(level);
this.getLogger().setLevel(level);
this.getLogger().log(Level.CONFIG, "Log level set to: {0} ({1,number,#})"
, new Object[] { this.getLogger().getLevel(), this.getLogger().getLevel().intValue() });
} |
3cb99bc4-4e3f-416e-8321-3767281a62da | public Toggle(final InputFilter filter) {
this.filter = filter;
} |
96b6a4f5-2215-47cf-988f-8309cd241581 | @Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (!(sender instanceof ConsoleCommandSender)) {
Main.courier.send(sender, "requires-console", label);
return true;
}
if (this.filter.isEnabled()) { this.filter.disable(); } else { this.filter.enable(); }
Main.courier.send(sender, ( this.filter.isEnabled() ? "enabled" : "disabled" ));
return true;
} |
e286789e-f828-419c-8db2-b4fffbb79f84 | public Reload(final Plugin plugin) {
this.plugin = plugin;
} |
c2a3bf98-e9e3-4b5b-8b90-68d44b8b0bd2 | @Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
this.plugin.onDisable();
this.plugin.onEnable();
Main.courier.send(sender, "reload", this.plugin.getName());
return true;
} |
e7387da2-52d3-4f3f-a296-9c3edc562c0b | public ServerPlayers() {
super(Server.BROADCAST_CHANNEL_USERS);
} |
e229c354-c1c5-4673-8cda-41350ada15d2 | @Override
public Confirmation deliver(final Message message) {
final Confirmation confirmation = super.deliver(message);
return new Confirmation(Level.FINEST, confirmation.getReceived(), "[BROADCAST({1})] {0}", message, confirmation.getReceived());
} |
18a32914-36e6-463f-9d91-21d88113ee1c | public Confirmation(final Level level, final int received, final String pattern, final Object... arguments) {
super(pattern, arguments);
this.level = level;
this.received = received;
} |
4bf1dc57-6f0c-4d51-855a-3561f46aeda9 | public Level getLevel() {
return this.level;
} |
2750090b-5471-4f5b-a7c0-1e1c881ac8a6 | public int getReceived() {
return this.received;
} |
c8a9284e-ec1f-41fb-9853-2fcbb1b0b6fd | public LogRecord toLogRecord() {
final LogRecord record = new LogRecord(this.level, this.original);
record.setParameters(this.arguments);
return record;
} |
f4eac83f-f23e-4deb-a217-384f9b677a7a | protected ConfigurationCourier(final ConfigurationCourier.Factory parameters) {
super(parameters);
this.base = parameters.base;
this.formatCode = parameters.formatCode;
} |
47ef97f7-c722-44e9-ada3-e8790c71a6b1 | public ConfigurationSection getBase() {
return this.base;
} |
4fec7e28-77e0-4a32-8e11-34b89b306af4 | public ConfigurationSection getSection(final String path) {
return this.base.getConfigurationSection(path);
} |
48641c71-7d9c-4637-af17-761765b06122 | public char getFormatCode() {
return this.formatCode;
} |
0c691f59-22df-4de1-8e68-5761649eff76 | public String translate(final String key) {
final String pattern = this.base.getString(key);
if (pattern.equals("")) {
this.plugin.getLogger().log(Level.FINEST, "String value not found for {0} in {1}", new Object[] { key, ( this.base.getCurrentPath().equals("") ? "(root)" : this.base.getCurrentPath() ) });
return null;
}
return ( this.formatCode == ChatColor.COLOR_CHAR ? pattern : ChatColor.translateAlternateColorCodes(this.formatCode, pattern) );
} |
0f420175-f658-4cc7-ac0e-6433348f8c72 | public Message compose(final String key, final Object... arguments) {
final String pattern = this.translate(key);
if (pattern == null) return null;
return this.draft(pattern, arguments);
} |
557ad2d8-c97d-4eb1-8cf5-73eb27e321f1 | public String format(final String key, final Object... arguments) {
final String pattern = this.translate(key);
if (pattern == null) return null;
return this.formatMessage(pattern, arguments);
} |
5f3897ee-27d9-4674-9b9d-ac65ccb5b1f8 | public void send(final CommandSender sender, final String key, final Object... arguments) {
final String pattern = this.translate(key);
if (pattern == null) return;
this.sendMessage(sender, pattern, arguments);
} |
5285a33a-792a-439d-ac64-632a03c0abc8 | public void broadcast(final String key, final Object... arguments) {
final String pattern = this.translate(key);
if (pattern == null) return;
this.broadcastMessage(pattern, arguments);
} |
19529602-96ca-42bf-aec6-f3fee970899a | public void world(final World world, final String key, final Object... arguments) {
final String pattern = this.translate(key);
if (pattern == null) return;
this.worldMessage(world, pattern, arguments);
} |
e2fa8c7b-7c97-44e4-80f4-decb7a4517d7 | public void publish(final String permission, final String key, final Object... arguments) {
final String pattern = this.translate(key);
if (pattern == null) return;
this.publishMessage(permission, pattern, arguments);
} |
a3869b83-6317-4c13-9134-c7b1a83bc917 | public static Factory create(final Plugin plugin) {
return Factory.create(plugin);
} |
9d018314-f4df-4033-b00b-88ffbbe9138f | public static Factory create(final Plugin plugin) {
return new Factory(plugin);
} |
871dfcbe-35d4-43d1-ab46-aac2527df431 | protected Factory(final Plugin plugin) {
super(plugin);
this.setBase(plugin.getConfig());
} |
4b985cce-a13a-4d74-b4c2-79a17778f181 | public Factory setBase(final ConfigurationSection section) {
if (section == null) throw new IllegalArgumentException("ConfigurationSection can not be null");
this.base = section;
return this;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.