1 16 package org.outerj.daisy.repository.commonimpl; 17 18 import org.outerj.daisy.repository.LockInfo; 19 import org.outerj.daisy.repository.LockType; 20 import org.outerx.daisy.x10.LockInfoDocument; 21 22 import java.util.Date ; 23 import java.util.GregorianCalendar ; 24 25 public class LockInfoImpl implements LockInfo { 26 private boolean hasLock; 27 private long userId; 28 private Date timeAcquired; 29 private long duration; 30 private LockType lockType; 31 32 public LockInfoImpl() { 33 this.hasLock = false; 34 } 35 36 public LockInfoImpl(long userId, Date timeAcquired, long duration, LockType lockType) { 37 this.hasLock = true; 38 this.userId = userId; 39 this.timeAcquired = timeAcquired; 40 this.duration = duration; 41 this.lockType = lockType; 42 } 43 44 public long getUserId() { 45 return userId; 46 } 47 48 public Date getTimeAcquired() { 49 return timeAcquired; 50 } 51 52 public long getDuration() { 53 return duration; 54 } 55 56 public LockType getType() { 57 return lockType; 58 } 59 60 public boolean hasLock() { 61 return hasLock; 62 } 63 64 public LockInfoDocument getXml() { 65 LockInfoDocument lockInfoDocument = LockInfoDocument.Factory.newInstance(); 66 LockInfoDocument.LockInfo lockInfoXml = lockInfoDocument.addNewLockInfo(); 67 68 if (!hasLock) { 69 lockInfoXml.setHasLock(false); 70 } else { 71 lockInfoXml.setHasLock(true); 72 lockInfoXml.setUserId(userId); 73 GregorianCalendar timeAcquiredCalendar = new GregorianCalendar (); 74 timeAcquiredCalendar.setTime(timeAcquired); 75 lockInfoXml.setTimeAcquired(timeAcquiredCalendar); 76 lockInfoXml.setDuration(duration); 77 lockInfoXml.setType(LockInfoDocument.LockInfo.Type.Enum.forString(lockType.toString())); 78 } 79 80 return lockInfoDocument; 81 } 82 } 83 | Popular Tags |