@@ -253,6 +253,10 @@ private long processGroup(String baseName, int segment, List<CdiRep.Item> items,
253253 entry = new EventEntry (name , (CdiRep .EventID ) it , segment , origin );
254254 } else if (it instanceof CdiRep .StringRep ) {
255255 entry = new StringEntry (name , (CdiRep .StringRep ) it , segment , origin );
256+ } else if (it instanceof CdiRep .ActionButtonRep ) {
257+ entry = new ActionButtonEntry (name , (CdiRep .ActionButtonRep ) it , segment , origin );
258+ } else if (it instanceof CdiRep .UnknownRep ) {
259+ entry = new UnknownEntry (name , (CdiRep .UnknownRep ) it , segment , origin );
256260 } else {
257261 logger .log (Level .SEVERE , "could not process CDI entry type of {0}" , it );
258262 }
@@ -303,12 +307,16 @@ public void visitEntry(CdiEntry e) {
303307 visitInt ((IntegerEntry ) e );
304308 } else if (e instanceof EventEntry ) {
305309 visitEvent ((EventEntry ) e );
310+ } else if (e instanceof ActionButtonEntry ) {
311+ visitActionButton ((ActionButtonEntry ) e );
306312 } else if (e instanceof GroupRep ) {
307313 visitGroupRep ((GroupRep ) e );
308314 } else if (e instanceof GroupEntry ) {
309315 visitGroup ((GroupEntry ) e );
310316 } else if (e instanceof SegmentEntry ) {
311317 visitSegment ((SegmentEntry ) e );
318+ } else if (e instanceof UnknownEntry ) {
319+ visitUnknown ((UnknownEntry ) e );
312320 } else if (e instanceof CdiContainer ) {
313321 visitContainer ((CdiContainer ) e );
314322 } else {
@@ -331,6 +339,10 @@ public void visitEvent(EventEntry e) {
331339 visitLeaf (e );
332340 }
333341
342+ public void visitActionButton (ActionButtonEntry e ) {
343+ visitLeaf (e );
344+ }
345+
334346 public void visitGroupRep (GroupRep e ) {
335347 visitContainer (e );
336348 }
@@ -343,6 +355,10 @@ public void visitSegment(SegmentEntry e) {
343355 visitContainer (e );
344356 }
345357
358+ public void visitUnknown (UnknownEntry e ) {
359+ visitLeaf (e );
360+ }
361+
346362 public void visitContainer (CdiContainer c ) {
347363 for (CdiEntry e : c .getEntries ()) {
348364 visitEntry (e );
@@ -700,4 +716,97 @@ public void setValue(String value) {
700716 }
701717 }
702718
719+ /**
720+ * Represents an unknown variable, perhaps due to a more-recent schema
721+ */
722+ public class UnknownEntry extends CdiEntry {
723+ public CdiRep .UnknownRep rep ;
724+
725+ UnknownEntry (String name , CdiRep .UnknownRep rep , int segment , long origin ) {
726+ this .key = name ;
727+ this .space = segment ;
728+ this .origin = origin ;
729+ this .rep = rep ;
730+ this .size = rep .getSize ();
731+ }
732+
733+ @ Override
734+ public CdiRep .Item getCdiItem () {
735+ return rep ;
736+ }
737+
738+ @ Override
739+ protected void updateVisibleValue () {
740+ lastVisibleValue = getValue ();
741+ }
742+
743+ @ Override
744+ public boolean isNullTerminated () {
745+ return size > 64 ;
746+ }
747+
748+ public String getValue () {
749+ MemorySpaceCache cache = getCacheForSpace (space );
750+ byte [] b = cache .read (origin , size );
751+ if (b == null ) return null ;
752+ // We search for a terminating null byte and clip the string there.
753+ int len = 0 ;
754+ while (len < b .length && b [len ] != 0 ) ++len ;
755+ byte [] rep = new byte [len ];
756+ System .arraycopy (b , 0 , rep , 0 , len );
757+ String ret = new String (rep , UTF8 );
758+ return ret ;
759+ }
760+
761+ public void setValue (String value ) {
762+ MemorySpaceCache cache = getCacheForSpace (space );
763+ byte [] f ;
764+ f = value .getBytes (UTF8 );
765+ byte [] b = new byte [Math .min (size , f .length + 1 )];
766+ System .arraycopy (f , 0 , b , 0 , Math .min (f .length , b .length - 1 ));
767+ cache .write (this .origin , b , this );
768+ }
769+ }
770+
771+ /**
772+ * Represents an action button variable.
773+ */
774+ public class ActionButtonEntry extends CdiEntry {
775+ public CdiRep .ActionButtonRep rep ;
776+
777+ ActionButtonEntry (String name , CdiRep .ActionButtonRep rep , int segment , long origin ) {
778+ this .key = name ;
779+ this .space = segment ;
780+ this .origin = origin ;
781+ this .rep = rep ;
782+ this .size = rep .getSize ();
783+ }
784+
785+ @ Override
786+ public CdiRep .Item getCdiItem () {
787+ return rep ;
788+ }
789+
790+ @ Override
791+ protected void updateVisibleValue () {
792+ // does nothing in this class
793+ }
794+
795+ public long getValue () {
796+ // should not be called
797+ logger .log (Level .SEVERE , "ActionButtonEntry.getValue should not be called" );
798+ return -1 ;
799+ }
800+
801+ public void setValue (long value ) {
802+ MemorySpaceCache cache = getCacheForSpace (space );
803+ byte [] b = new byte [size ];
804+ for (int i = size - 1 ; i >= 0 ; --i ) {
805+ b [i ] = (byte )(value & 0xff );
806+ value >>= 8 ;
807+ }
808+ cache .write (origin , b , this );
809+ }
810+ }
811+
703812}
0 commit comments