1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.graphviz;
14 import java.io.PrintStream;
15 import java.util.HashMap;
19 * Default implementation for IAttributeContainer.
21 * @author Hannu Niemistö
23 public class AbstractAttributeContainer implements IAttributeContainer {
25 Map<String,String> attributes = new HashMap<String,String>();
27 public void set(String key, String value) {
28 attributes.put(key, value);
31 public String get(String key) {
32 return attributes.get(key);
35 protected void writeAttributes(PrintStream s) {
38 for(Map.Entry<String, String> ent : attributes.entrySet()) {
39 String key = ent.getKey();
40 String value = ent.getValue();
46 if(!value.isEmpty() && value.charAt(0) == '<' && value.charAt(value.length()-1) == '>') {
52 s.print(escape(value));
59 static String escape(String str) {
60 str = str.replace("\"", "\\\"");