KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > render > afp > modca > InvokeMediumMap


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
18 /* $Id: InvokeMediumMap.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.render.afp.modca;
21
22 import java.io.IOException JavaDoc;
23 import java.io.OutputStream JavaDoc;
24 import java.io.UnsupportedEncodingException JavaDoc;
25
26 import org.apache.fop.render.afp.tools.BinaryUtils;
27
28 /**
29  * The Invoke Medium Map structured field identifies the Medium Map that is to
30  * become active for the document. An Invoke Medium Map structured field affects
31  * the document's current environment. The Medium Map's effect on current environment
32  * parameter values lasts until a new Medium Map is invoked.
33  */

34 public class InvokeMediumMap extends AbstractNamedAFPObject {
35
36     /**
37      * Constructor for the Invoke Medium Map
38      * @param mediumMapName Name of the medium map
39      */

40     public InvokeMediumMap(String JavaDoc mediumMapName) {
41
42         super(mediumMapName);
43
44     }
45
46     /**
47      * Accessor method to write the AFP datastream for the Invoke Medium Map
48      * @param os The stream to write to
49      * @throws java.io.IOException
50      */

51     public void writeDataStream(OutputStream JavaDoc os)
52         throws IOException JavaDoc {
53
54         byte[] data = new byte[17];
55
56         data[0] = 0x5A;
57
58         // Set the total record length
59
byte[] rl1 = BinaryUtils.convert(16, 2); //Ignore first byte
60
data[1] = rl1[0];
61         data[2] = rl1[1];
62
63         // Structured field ID for a IPO
64
data[3] = (byte) 0xD3;
65         data[4] = (byte) 0xAB;
66         data[5] = (byte) 0xCC;
67
68         data[6] = 0x00; // Reserved
69
data[7] = 0x00; // Reserved
70
data[8] = 0x00; // Reserved
71

72         for (int i = 0; i < _nameBytes.length; i++) {
73
74             data[9 + i] = _nameBytes[i];
75
76         }
77
78         os.write(data);
79
80     }
81
82 }
Popular Tags