OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2014, the Dart project authors. |
| 3 * |
| 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
| 5 * in compliance with the License. You may obtain a copy of the License at |
| 6 * |
| 7 * http://www.eclipse.org/legal/epl-v10.html |
| 8 * |
| 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
| 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
| 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
| 12 * the License. |
| 13 */ |
| 14 |
| 15 package com.google.dart.engine.internal.index.file; |
| 16 |
| 17 import com.google.dart.engine.index.Relationship; |
| 18 |
| 19 /** |
| 20 * A helper that encodes/decodes {@link Relationship}s to/from integers. |
| 21 * |
| 22 * @coverage dart.engine.index |
| 23 */ |
| 24 public class RelationshipCodec { |
| 25 private final StringCodec stringCodec; |
| 26 |
| 27 public RelationshipCodec(StringCodec stringCodec) { |
| 28 this.stringCodec = stringCodec; |
| 29 } |
| 30 |
| 31 public Relationship decode(int idIndex) { |
| 32 String id = stringCodec.decode(idIndex); |
| 33 return Relationship.getRelationship(id); |
| 34 } |
| 35 |
| 36 public int encode(Relationship relationship) { |
| 37 String id = relationship.getIdentifier(); |
| 38 return stringCodec.encode(id); |
| 39 } |
| 40 } |
OLD | NEW |