class JsonHandler extends HandlerBase {

	protected JsonObjectBuilder showAESAudioMetadata(AESAudioMetadata aes) {
		JsonObjectBuilder aesBuilder = Json.createObjectBuilder();

		_sampleRate = aes.getSampleRate();

		String s = aes.getAnalogDigitalFlag();
		if (s != null) {
			aesBuilder.add("aes:analogDigitalFlag", s);
		}
		s = aes.getSchemaVersion();
		if (s != null) {
			aesBuilder.add("aes:schemaVersion", s);
		}
		s = aes.getFormat();
		if (s != null) {
			aesBuilder.add("aes:format", s);
		}
		s = aes.getSpecificationVersion();
		if (s != null) {
			aesBuilder.add("aes:specificationVersion", s);
		}
		s = aes.getAppSpecificData();
		if (s != null) {
			aesBuilder.add("aes:appSpecificData", s);
		}
		s = aes.getAudioDataEncoding();
		if (s != null) {
			aesBuilder.add("aes:audioDataEncoding", s);
		}
		int in = aes.getByteOrder();
		if (in != AESAudioMetadata.NULL) {
			aesBuilder.add("aes:byteOrder", (in == AESAudioMetadata.BIG_ENDIAN ? "BIG_ENDIAN" : "LITTLE_ENDIAN"));
		}
		long lin = aes.getFirstSampleOffset();
		if (lin != AESAudioMetadata.NULL) {
			aesBuilder.add("aes:firstSampleOffset", lin);
		}
		String[] use = aes.getUse();
		if (use != null) {
			aesBuilder.add("aes:use",
					Json.createObjectBuilder().add("aes:useType", use[0]).add("aes:otherType", use[1]));
		}
		s = aes.getPrimaryIdentifier();
		if (s != null) {
			String t = aes.getPrimaryIdentifierType();
			aesBuilder.add("aes:primaryIdentifier", s);
			if (t != null) {
				aesBuilder.add("aes:primaryIdentifierType", t);
			}
		}
		List<AESAudioMetadata.Face> facelist = aes.getFaceList();
		if (facelist != null && !facelist.isEmpty()) {
			// Add the face information, which is mostly filler.
			AESAudioMetadata.Face f = facelist.get(0);
			JsonObjectBuilder faceBuilder = Json.createObjectBuilder();

			AESAudioMetadata.TimeDesc startTime = f.getStartTime();
			if (startTime != null) {
				faceBuilder.add("aes:timeline", writeAESTimeRange(startTime, f.getDuration()));
			}
			int nchan = aes.getNumChannels();
			if (nchan != AESAudioMetadata.NULL) {
				faceBuilder.add("aes:numChannels", nchan);
			}
			String[] locs = aes.getMapLocations();
			JsonArrayBuilder streamsBuilder = Json.createArrayBuilder();
			for (int ch = 0; ch < nchan; ch++) {
				// write a stream description for each channel
				streamsBuilder
						.add(Json.createObjectBuilder().add("aes:channelNum", ch).add("aes:mapLocation", locs[ch]));
			}
			faceBuilder.add("aes:streams", streamsBuilder);
			aesBuilder.add("aes:face", faceBuilder);
		}

		// In the general case, a FormatList can contain multiple
		// FormatRegions. This doesn't happen with any of the current
		// modules; if it's needed in the future, simply set up an
		// iteration loop on formatList.
		List<AESAudioMetadata.FormatRegion> flist = aes.getFormatList();
		if (flist != null && !flist.isEmpty()) {
			AESAudioMetadata.FormatRegion rgn = flist.get(0);
			int bitDepth = rgn.getBitDepth();
			double sampleRate = rgn.getSampleRate();
			int wordSize = rgn.getWordSize();
			String[] bitRed = rgn.getBitrateReduction();
			// Build a FormatRegion subtree if at least one piece of data
			// that goes into it is present.
			JsonArrayBuilder formatListBuilder = Json.createArrayBuilder();
			JsonObjectBuilder formatRegionBuilder = Json.createObjectBuilder();
			if (bitDepth != AESAudioMetadata.NULL || sampleRate != AESAudioMetadata.NILL
					|| wordSize != AESAudioMetadata.NULL) {
				if (bitDepth != AESAudioMetadata.NULL) {
					formatRegionBuilder.add("aes:bitDepth", bitDepth);
				}
				if (sampleRate != AESAudioMetadata.NILL) {
					formatRegionBuilder.add("aes:sampleRate", sampleRate);
				}
				if (wordSize != AESAudioMetadata.NULL) {
					formatRegionBuilder.add("aes:wordSize", wordSize);
				}
				if (bitRed != null) {
					formatRegionBuilder.add("aes:bitrateReduction", Json.createObjectBuilder()
							.add("aes:codecName", bitRed[0]).add("aes:codecNameVersion", bitRed[1])
							.add("aes:codecCreatorApplication", bitRed[2])
							.add("aes:codecCreatorApplicationVersion", bitRed[3]).add("aes:codecQuality", bitRed[4])
							.add("aes:dataRate", bitRed[5]).add("aes:dataRateMode", bitRed[6]));
				}

				formatListBuilder.add(formatRegionBuilder);
				aesBuilder.add("aes:formatList", formatListBuilder);
			}
		}
		return aesBuilder;
	}

	public  JsonHandler();
	public  JsonHandler(String name, String release, int[] date, String note, String rights);

}