1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18package javax.sound.midi; 19 20import java.util.Collections; 21import java.util.HashMap; 22import java.util.Map; 23 24public class MidiFileFormat { 25 public static final int UNKNOWN_LENGTH = -1; 26 27 protected int byteLength; 28 29 protected float divisionType; 30 31 protected long microsecondLength; 32 33 protected int resolution; 34 35 protected int type; 36 37 private HashMap<String, Object> properties; 38 39 public MidiFileFormat(int type, float divisionType, int resolution, int bytes, 40 long microseconds) { 41 this.type = type; 42 this.divisionType = divisionType; 43 this.resolution = resolution; 44 this.byteLength = bytes; 45 this.microsecondLength = microseconds; 46 this.properties = new HashMap<String, Object>(); 47 } 48 49 public MidiFileFormat(int type, float divisionType, int resolution, int bytes, 50 long microseconds, Map<String, Object> properties) { 51 this.type = type; 52 this.divisionType = divisionType; 53 this.resolution = resolution; 54 this.byteLength = bytes; 55 this.microsecondLength = microseconds; 56 57 this.properties = new HashMap<String, Object>(); 58 this.properties.putAll(properties); 59 } 60 61 public int getByteLength() { 62 return byteLength; 63 } 64 65 public float getDivisionType() { 66 return divisionType; 67 } 68 69 public long getMicrosecondLength() { 70 return microsecondLength; 71 } 72 73 public Object getProperty(String key) { 74 return properties.get(key); 75 } 76 77 public int getResolution() { 78 return resolution; 79 } 80 81 public int getType() { 82 return type; 83 } 84 85 public Map<String, Object> properties() { 86 return Collections.unmodifiableMap(properties); 87 88 } 89} 90