mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-09 08:52:51 +00:00
@@ -113,8 +113,9 @@ public abstract class HtmlTemplate {
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void register(String name, String value) {
|
||||
public HtmlTemplate register(String name, String value) {
|
||||
variables.put(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
68
src/main/java/com/l2jserver/util/jaxb/CoordinateAdapter.java
Normal file
68
src/main/java/com/l2jserver/util/jaxb/CoordinateAdapter.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.util.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
import com.l2jserver.util.jaxb.CoordinateAdapter.CoordinateElement;
|
||||
|
||||
/**
|
||||
* This adapter converts an simple set of attributes <tt>x</tt>, <tt>y</tt> and
|
||||
* <tt>z</tt> to an {@link Coordinate} object. Please note that the tag name is
|
||||
* indifferent.
|
||||
*
|
||||
* <pre>
|
||||
* <coordinate x="200" y="100" z="0" />
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CoordinateAdapter extends
|
||||
XmlAdapter<CoordinateElement, Coordinate> {
|
||||
@Override
|
||||
public CoordinateElement marshal(Coordinate coordinate) throws Exception {
|
||||
return new CoordinateElement(coordinate.getX(), coordinate.getY(),
|
||||
coordinate.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coordinate unmarshal(CoordinateElement elem) throws Exception {
|
||||
return Coordinate.fromXYZ(elem.x, elem.y, elem.z);
|
||||
|
||||
}
|
||||
|
||||
public static class CoordinateElement {
|
||||
@XmlAttribute(name = "x")
|
||||
public int x;
|
||||
@XmlAttribute(name = "y")
|
||||
public int y;
|
||||
@XmlAttribute(name = "z")
|
||||
public int z;
|
||||
|
||||
protected CoordinateElement() {
|
||||
}
|
||||
|
||||
public CoordinateElement(int x, int y, int z) {
|
||||
super();
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.util.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.model.id.template.TeleportationTemplateID;
|
||||
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
|
||||
import com.l2jserver.model.id.template.provider.TeleportationTemplateIDProvider;
|
||||
|
||||
/**
|
||||
* TODO this should use an {@link ItemTemplateIDProvider}!
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class TeleportationTemplateIDAdapter extends
|
||||
XmlAdapter<String, TeleportationTemplateID> {
|
||||
private final TeleportationTemplateIDProvider provider;
|
||||
|
||||
@Inject
|
||||
public TeleportationTemplateIDAdapter(
|
||||
TeleportationTemplateIDProvider provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TeleportationTemplateID unmarshal(String v) throws Exception {
|
||||
if (v == null)
|
||||
return null;
|
||||
return provider.createID(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String marshal(TeleportationTemplateID v) throws Exception {
|
||||
if (v == null)
|
||||
return null;
|
||||
return v.getID();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user