Skip to content

Commit

Permalink
Merge branch 'local.master' into sf.core
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Pelaia II committed Sep 1, 2015
2 parents 6063602 + 4c494e9 commit ee1f31c
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<!-- Copy the core's site specific resources into the compile directory -->
<copy todir="${core.intermediates.resources}" quiet="true" failonerror="false" overwrite="true">
<fileset dir="${site.core.resources}" />
<fileset dir="${site.core.root}/resources" />
</copy>
</sequential>
</macrodef>
Expand Down
74 changes: 74 additions & 0 deletions src/xal/Info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Info.java
*
* Created on September 1, 2015, 10:38 AM
*/

package xal;

import xal.tools.ResourceManager;
import xal.tools.coding.json.JSONCoder;

import java.util.*;
import java.net.*;
import java.io.*;


/**
* Info about the current Open XAL.
*/
public class Info {
/** Label for this version of Open XAL */
final private static String LABEL;


// static initializer
static {
// assign the default label
String label = "Open XAL";

// attempt to load info properties from the "info.json" file
System.out.println( "Getting info resource..." );
final URL infoLocation = ResourceManager.getResourceURL( Info.class, "info.json" );
if ( infoLocation != null ) {
try {
//System.out.println( "Attempting to load Info from URL: " + infoLocation );
final StringBuffer buffer = new StringBuffer();
final InputStream infoStream = infoLocation.openStream();
final BufferedReader infoReader = new BufferedReader( new InputStreamReader( infoStream ) );
while( true ) {
final String nextLine = infoReader.readLine();
if ( nextLine != null ) {
buffer.append( nextLine );
buffer.append( "\n" );
} else {
break; // end of input
}
}
infoStream.close();

//System.out.println( "Buffer: " + buffer.toString() );

@SuppressWarnings("unchecked")
final Map<String,Object> infoMap = (Map<String,Object>)JSONCoder.defaultDecode( buffer.toString() );

//System.out.println( "Info map: " + infoMap );

label = (String)infoMap.get("label");
} catch( Exception exception ) {
System.err.println( "Exception attempting to load Open XAL info from: " + infoLocation );
exception.printStackTrace();
System.err.println( "Will revert to default info label: " + label );
}
}

// assign the Info propreties
LABEL = label;
}


/** Get the label for this version of Open XAL */
static public String getLabel() {
return LABEL;
}
}

0 comments on commit ee1f31c

Please sign in to comment.