View Javadoc
1   /*
2    * Copyright 2008, 2009 Ange Optimization ApS
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package eu.simuline.octave.io.impl;
17  
18  import java.io.BufferedReader;
19  
20  import eu.simuline.octave.exception.OctaveParseException;
21  import eu.simuline.octave.type.OctaveString;
22  
23  /**
24   * The name is {@link OctaveSqStringReader} 
25   * instead of <code>StringSqReader</code> 
26   * to be consistent with {@link OctaveStringReader}. 
27   * The reader for the octave type "sq_string" 
28   * reading an {@link OctaveString} from a {@link BufferedReader}. 
29   */
30  public final class OctaveSqStringReader extends AbstractOctaveStringReader {
31  
32      @Override
33      public String octaveType() {
34          return "sq_string";
35      }
36  
37      @Override
38      public OctaveString read(final BufferedReader reader) {
39          final String string = readImpl(reader).getString();
40          if (string.contains("\\")) {
41              throw new OctaveParseException
42  		("Handling of escape char (\\) not done, line='" + 
43  		 string + "'");
44          }
45          return new OctaveString(string);
46      }
47  
48  }