Skip to main content
summaryrefslogtreecommitdiffstats
blob: e90b9b9a0fc3e29979f0842d8536ed8d20983563 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*******************************************************************************
 * Copyright (c) 2009 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0, which accompanies this distribution
 * and is available at http://www.eclipse.org/legal/epl-v10.html.
 * 
 * Contributors:
 *     Oracle - initial API and implementation
 ******************************************************************************/
package org.eclipse.jpt.db.internal.vendor;

import java.util.ArrayList;

import org.eclipse.datatools.modelbase.sql.schema.Database;
import org.eclipse.jpt.utility.internal.StringTools;

class Sybase
	extends AbstractVendor
{
	private final String dtpVendorName;

	static final Vendor ASA = new Sybase("Sybase_ASA"); //$NON-NLS-1$
	static final Vendor ASE = new Sybase("Sybase_ASE"); //$NON-NLS-1$

	static Vendor asa() {
		return ASA;
	}

	static Vendor ase() {
		return ASE;
	}

	/**
	 * Ensure only static instances.
	 */
	private Sybase(String dtpVendorName) {
		super();
		this.dtpVendorName = dtpVendorName;
	}

	@Override
	public String getDTPVendorName() {
		return this.dtpVendorName;
	}

	@Override
	CatalogStrategy getCatalogStrategy() {
		return SimpleCatalogStrategy.instance();
	}

	/**
	 * By default, Sybase identifiers are case-sensitive, even without
	 * delimiters. This can depend on the collation setting....
	 */
	@Override
	FoldingStrategy getFoldingStrategy() {
		return NonFoldingStrategy.instance();
	}

	/**
	 * Sybase will use the user-requested database; if that database is not
	 * found, it will default to 'master'.
	 */
	@Override
	void addDefaultCatalogNamesTo(Database database, String userName, ArrayList<String> names) {
		names.add(database.getName());
		names.add(MASTER_CATALOG_NAME);
	}
	private static final String MASTER_CATALOG_NAME = "master";  //$NON-NLS-1$

	/**
	 * The typical default schema on Sybase for any database (catalog) is
	 * 'dbo'.
	 * 
	 * Actually, the default schema is more like a search path:
	 * The server looks for a schema object (e.g. a table) first in the user's
	 * schema, then it looks for the schema object in the database owner's
	 * schema (dbo). As a result, it's really not possible to specify
	 * the "default" schema without knowing the schema object we are
	 * looking for.
	 * 
	 * (Note: the current 'user' is not the same thing as the current
	 * 'login' - see sp_adduser and sp_addlogin; so we probably can't
	 * use ConnectionProfile#getUserName().)
	 */
	@Override
	void addDefaultSchemaNamesTo(Database database, String userName, ArrayList<String> names) {
		names.add(DEFAULT_SCHEMA_NAME);
	}
	private static final String DEFAULT_SCHEMA_NAME = "dbo";  //$NON-NLS-1$

	@Override
	char[] getExtendedRegularNameStartCharacters() {
		return EXTENDED_REGULAR_NAME_START_CHARACTERS;
	}
	private static final char[] EXTENDED_REGULAR_NAME_START_CHARACTERS = new char[] { '_', '@' };

	@Override
	char[] getExtendedRegularNamePartCharacters() {
		return EXTENDED_REGULAR_NAME_PART_CHARACTERS;
	}
	private static final char[] EXTENDED_REGULAR_NAME_PART_CHARACTERS = new char[] { '$', '¥', '£', '#' };

	/**
	 * By default, Sybase delimits identifiers with brackets ([]); but it
	 * can also be configured to use double-quotes.
	 */
	@Override
	boolean identifierIsDelimited(String identifier) {
		return StringTools.stringIsBracketed(identifier)
					|| super.identifierIsDelimited(identifier);
	}

}

Back to the top