Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* ************************************************************************
  #
  #  DivConq
  #
  #  http://divconq.com/
  #
  #  Copyright:
  #    Copyright 2014 eTimeline, LLC. All rights reserved.
  #
 #  License:
 #    See the license.txt file in the project's top-level directory for details.
 #
 #  Authors:
 #    * Andy White
 #
 ************************************************************************ */
 package divconq.test;
 
 
 public class TestSchema {
 	public static void main(String[] args) {
 		try {
 			HubResources resources = new HubResources();
 			OperationResult or = resources.init();
 			
 			if (or.hasErrors()) {
 				Logger.error("Unable to continue, hub resources not properly initialized");
 				return;
 			}
 			
 			SchemaManager schemaman = resources.getSchema();
 
 			// typed ResultMessage record
 			RecordStruct msg1 = schemaman.newRecord("ResultMessage");
 			
 			..println("----------------");
 			
 			msg1.setField("Level""Info");
 			msg1.setField("Code", 3);
 			msg1.setField("Message""Howday partner!");
 			
 			..println("----------------");
 			
 			..println("----------------");
 			
 			//rec.setField("Level", "What!!");
 			//rec.removeField("Code");
 			
 			//System.out.println("----------------");
 			//System.out.println(rec.validate().toString());
 			
 			..println("-------------------------------------------------------");
 
 			// typed ResponseMessage record
 			RecordStruct resp = schemaman.newRecord("ResponseMessage");
 			
 			
 			resp.setField("Service""Reply");
 			resp.setField("Result", 6);
 			
 			..println("----------------");
 			
 			..println("----------------");
 			
 			..println("-------------------------------------------------------");
 			
 			FuncResult<Structmsgs = resp.getOrAllocateField("Messages"); 
 			
 			((ListStructmsgs.getResult()).addItem(msg1);
 			
 			..println("----------------");
 			
 			..println("----------------");
 			
 			..println("-------------------------------------------------------");
 			
 			// untyped record attempting to merge with typed
 			RecordStruct msg2 = new RecordStruct();
 			
 			msg2.setField("Level""Exit");
 			msg2.setField("Code", 5);
			msg2.setField("Message""Goodday partner!");
			((ListStructmsgs.getResult()).addItem(msg2);
			..println("----------------");
			..println("----------------");
			..println("-------------------------------------------------------");
		catch (Exception x) {
			..println("Error in loop: " + x);
		}
	}
New to GrepCode? Check out our FAQ X