|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright (c) 2013 <Project SWG> |
| 3 | + * |
| 4 | + * This File is part of NGECore2. |
| 5 | + * |
| 6 | + * This program is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU Lesser General Public License as published by |
| 8 | + * the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU Lesser General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Lesser General Public License |
| 17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + * |
| 19 | + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. |
| 20 | + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. |
| 21 | + ******************************************************************************/ |
| 22 | +package resources.common; |
| 23 | + |
| 24 | +import org.apache.mina.core.buffer.IoBuffer; |
| 25 | + |
| 26 | +import resources.z.exp.objects.Baseline; |
| 27 | +import resources.objects.Delta; |
| 28 | + |
| 29 | +import com.sleepycat.persist.model.Persistent; |
| 30 | + |
| 31 | +@Persistent |
| 32 | +public class Stf extends Delta { |
| 33 | + |
| 34 | + private AString stfFilename; |
| 35 | + private int spacer = 0; |
| 36 | + private AString stfName; |
| 37 | + |
| 38 | + public Stf(String stfFilename, int spacer, String stfName) { |
| 39 | + this.stfFilename = new AString(stfFilename); |
| 40 | + this.spacer = spacer; |
| 41 | + this.stfName = new AString(stfName); |
| 42 | + } |
| 43 | + |
| 44 | + public Stf() { |
| 45 | + |
| 46 | + } |
| 47 | + |
| 48 | + public String getStfFilename() { |
| 49 | + synchronized(objectMutex) { |
| 50 | + return stfFilename.get(); |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + public void setStfFilename(String stfFilename) { |
| 55 | + synchronized(objectMutex) { |
| 56 | + this.stfFilename = new AString(stfFilename); |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + public int getSpacer() { |
| 61 | + synchronized(objectMutex) { |
| 62 | + return spacer; |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + public void setSpacer(int spacer) { |
| 67 | + synchronized(objectMutex) { |
| 68 | + this.spacer = spacer; |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + public String getStfName() { |
| 73 | + synchronized(objectMutex) { |
| 74 | + return stfName.get(); |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + public void setStfName(String stfName) { |
| 79 | + synchronized(objectMutex) { |
| 80 | + this.stfName = new AString(stfName); |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + public byte[] getBytes() { |
| 85 | + synchronized(objectMutex) { |
| 86 | + int size = stfFilename.getBytes().length + 4 + stfName.getBytes().length; |
| 87 | + |
| 88 | + IoBuffer buffer = Baseline.createBuffer(size); |
| 89 | + buffer.put(stfFilename.getBytes()); |
| 90 | + buffer.putInt(spacer); |
| 91 | + buffer.put(stfName.getBytes()); |
| 92 | + buffer.flip(); |
| 93 | + |
| 94 | + return buffer.array(); |
| 95 | + } |
| 96 | + } |
| 97 | + |
| 98 | +} |
0 commit comments