public static Map<String,SLDDataInterface> readLayers(String filename,SLDOutputFormatEnum outputFormat){
  if (filename == null) {
    return null;
  }
  File intermediateFile=new File(filename);
  if (!intermediateFile.exists()) {
    return null;
  }
  MXDParser parser=new MXDParser();
  MXDInfo mxdInfo=new MXDInfo();
  mxdInfo.setIntermediateFile(intermediateFile);
  JsonObject mxdJSON=convertFileToJSON(filename);
  String mxdFilename="";
  JsonElement mxdFilenameJson=mxdJSON.get("mxd");
  if (mxdFilenameJson != null) {
    mxdFilename=mxdFilenameJson.getAsString();
    mxdInfo.setMxdFilename(mxdFilename);
  }
  File f=new File(mxdFilename);
  String mxdName=f.getName();
  int pos=mxdName.lastIndexOf("\\");
  if (pos > 0) {
    mxdName=mxdName.substring(pos + 1);
  }
  mxdInfo.setMxdName(mxdName);
  Map<String,SLDDataInterface> layerMap=new HashMap<String,SLDDataInterface>();
  JsonArray layerList=mxdJSON.getAsJsonArray("layers");
  for (int index=0; index < layerList.size(); index++) {
    JsonObject layer=(JsonObject)layerList.get(index);
    JsonElement layerNameElement=layer.get("name");
    if (layerNameElement != null) {
      String layerName=layerNameElement.getAsString();
      SLDDataInterface sldData=parser.importLayer(layer,outputFormat);
      layerMap.put(layerName,sldData);
    }
  }
  return layerMap;
}

public static Map < String , SLDDataInterface > readLayers ( String filename , SLDOutputFormatEnum outputFormat ) { if ( filename == null ) { return null ; } File intermediateFile = new File ( filename ) ; if ( ! intermediateFile . exists ( ) ) { return null ; } MXDParser parser = new MXDParser ( ) ; MXDInfo mxdInfo = new MXDInfo ( ) ; mxdInfo . setIntermediateFile ( intermediateFile ) ; JsonObject mxdJSON = convertFileToJSON ( filename ) ; String mxdFilename = "" ; JsonElement mxdFilenameJson = mxdJSON . get ( "mxd" ) ; if ( mxdFilenameJson != null ) { mxdFilename = mxdFilenameJson . getAsString ( ) ; mxdInfo . setMxdFilename ( mxdFilename ) ; } File f = new File ( mxdFilename ) ; String mxdName = f . getName ( ) ; int pos = mxdName . lastIndexOf ( "\\" ) ; if ( pos > 0 ) { mxdName = mxdName . substring ( pos + 1 ) ; } mxdInfo . setMxdName ( mxdName ) ; Map < String , SLDDataInterface > layerMap = new HashMap < String , SLDDataInterface > ( ) ; JsonArray layerList = mxdJSON . getAsJsonArray ( "layers" ) ; for ( int index = 0 ; index < layerList . size ( ) ; index ++ ) { JsonObject layer = ( JsonObject ) layerList . get ( index ) ; JsonElement layerNameElement = layer . get ( "name" ) ; if ( layerNameElement != null ) { String layerName = layerNameElement . getAsString ( ) ; SLDDataInterface sldData = parser . importLayer ( layer , outputFormat ) ; layerMap . put ( layerName , sldData ) ; } } return layerMap ; }
read layers from intermediate mxd files .
