Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptor.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptor.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptor.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptor.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,194 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors; + +import com.sun.star.sdbcx.comp.postgresql.comphelper.PropertySetAdapter.PropertyGetter; +import com.sun.star.sdbcx.comp.postgresql.comphelper.PropertySetAdapter.PropertySetter; +import com.sun.star.sdbcx.comp.postgresql.sdbcx.ODescriptor; +import com.sun.star.sdbcx.comp.postgresql.util.PropertyIds; +import com.sun.star.uno.Type; + +public class SdbcxColumnDescriptor extends ODescriptor { + protected int type; + protected String typeName; + protected int precision; + protected int scale; + protected int isNullable; + protected boolean isAutoIncrement; + protected boolean isRowVersion; + protected String description; + protected String defaultValue; + protected boolean isCurrency; + + protected SdbcxColumnDescriptor(Object lock, boolean isCaseSensitive) { + super(lock, "", isCaseSensitive, false); + registerProperties(); + } + + public static SdbcxColumnDescriptor create(boolean isCaseSensitive) { + final Object lock = new Object(); + return new SdbcxColumnDescriptor(lock, isCaseSensitive); + } + + private void registerProperties() { + registerProperty(PropertyIds.TYPE.name, PropertyIds.TYPE.id, Type.LONG, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return type; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + type = (int) value; + } + }); + registerProperty(PropertyIds.TYPENAME.name, PropertyIds.TYPENAME.id, Type.STRING, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return typeName; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + typeName = (String) value; + } + }); + registerProperty(PropertyIds.PRECISION.name, PropertyIds.PRECISION.id, Type.LONG, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return precision; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + precision = (Integer) value; + } + }); + registerProperty(PropertyIds.SCALE.name, PropertyIds.SCALE.id, Type.LONG, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return scale; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + scale = (Integer) value; + } + }); + registerProperty(PropertyIds.ISNULLABLE.name, PropertyIds.ISNULLABLE.id, Type.LONG, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return isNullable; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + isNullable = (Integer) value; + } + }); + registerProperty(PropertyIds.ISAUTOINCREMENT.name, PropertyIds.ISAUTOINCREMENT.id, Type.BOOLEAN, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return isAutoIncrement; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + isAutoIncrement = (Boolean) value; + } + }); + registerProperty(PropertyIds.ISROWVERSION.name, PropertyIds.ISROWVERSION.id, Type.BOOLEAN, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return isRowVersion; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + isRowVersion = (Boolean) value; + } + }); + registerProperty(PropertyIds.DESCRIPTION.name, PropertyIds.DESCRIPTION.id, Type.STRING, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return description; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + description = (String) value; + } + }); + registerProperty(PropertyIds.DEFAULTVALUE.name, PropertyIds.DEFAULTVALUE.id, Type.STRING, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return defaultValue; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + defaultValue = (String) value; + } + }); + registerProperty(PropertyIds.ISCURRENCY.name, PropertyIds.ISCURRENCY.id, Type.BOOLEAN, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return isCurrency; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + isCurrency = (Boolean) value; + } + }); + } +}
Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptor.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptorContainer.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptorContainer.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptorContainer.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptorContainer.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,36 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors; + +import com.sun.star.beans.XPropertySet; + +public class SdbcxColumnDescriptorContainer extends SdbcxDescriptorContainer { + + public SdbcxColumnDescriptorContainer(Object lock, boolean isCaseSensitive) { + super(lock, isCaseSensitive); + } + + @Override + public XPropertySet createDescriptor() { + return SdbcxColumnDescriptor.create(isCaseSensitive()); + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxColumnDescriptorContainer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,59 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors; + +import java.util.Collections; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbcx.comp.postgresql.sdbcx.OContainer; +import com.sun.star.sdbcx.comp.postgresql.sdbcx.Resources; +import com.sun.star.sdbcx.comp.postgresql.sdbcx.SharedResources; +import com.sun.star.sdbcx.comp.postgresql.util.StandardSQLState; + +public abstract class SdbcxDescriptorContainer extends OContainer { + public SdbcxDescriptorContainer(Object lock, boolean isCaseSensitive) { + super(lock, isCaseSensitive, Collections.<String>emptyList()); + } + + @Override + public XPropertySet createObject(String name) throws SQLException { + // This should never be called. DescriptorContainer always starts off empty, + // and only grows as a result of appending. + String error = SharedResources.getInstance().getResourceString( + Resources.STR_ERRORMSG_SEQUENCE); + throw new SQLException(error, this, StandardSQLState.SQL_FUNCTION_SEQUENCE_ERROR.text(), 0, null); + } + + @Override + public void dropObject(int index, String name) throws SQLException { + } + + @Override + public void impl_refresh() { + } + + @Override + public XPropertySet appendObject(String _rForName, XPropertySet descriptor) throws SQLException { + return cloneDescriptor(descriptor); + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexColumnDescriptor.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexColumnDescriptor.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexColumnDescriptor.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexColumnDescriptor.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,58 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors; + +import com.sun.star.sdbcx.comp.postgresql.comphelper.PropertySetAdapter.PropertyGetter; +import com.sun.star.sdbcx.comp.postgresql.comphelper.PropertySetAdapter.PropertySetter; +import com.sun.star.sdbcx.comp.postgresql.util.PropertyIds; +import com.sun.star.uno.Type; + +public class SdbcxIndexColumnDescriptor extends SdbcxColumnDescriptor { + protected boolean isAscending; + + protected SdbcxIndexColumnDescriptor(Object lock, boolean isCaseSensitive) { + super(lock, isCaseSensitive); + registerProperties(); + } + + public static SdbcxIndexColumnDescriptor create(boolean isCaseSensitive) { + final Object lock = new Object(); + return new SdbcxIndexColumnDescriptor(lock, isCaseSensitive); + } + + private void registerProperties() { + registerProperty(PropertyIds.ISASCENDING.name, PropertyIds.ISASCENDING.id, Type.BOOLEAN, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return isAscending; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + isAscending = (boolean) value; + } + }); + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexColumnDescriptor.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexColumnDescriptorContainer.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexColumnDescriptorContainer.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexColumnDescriptorContainer.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexColumnDescriptorContainer.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,35 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors; + +import com.sun.star.beans.XPropertySet; + +public class SdbcxIndexColumnDescriptorContainer extends SdbcxDescriptorContainer { + public SdbcxIndexColumnDescriptorContainer(Object lock, boolean isCaseSensitive) { + super(lock, isCaseSensitive); + } + + @Override + public XPropertySet createDescriptor() { + return SdbcxIndexColumnDescriptor.create(isCaseSensitive()); + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexColumnDescriptorContainer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexDescriptor.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexDescriptor.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexDescriptor.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexDescriptor.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,94 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors; + +import com.sun.star.sdbcx.XColumnsSupplier; +import com.sun.star.sdbcx.comp.postgresql.comphelper.PropertySetAdapter.PropertyGetter; +import com.sun.star.sdbcx.comp.postgresql.comphelper.PropertySetAdapter.PropertySetter; +import com.sun.star.sdbcx.comp.postgresql.sdbcx.ODescriptor; +import com.sun.star.sdbcx.comp.postgresql.util.PropertyIds; +import com.sun.star.uno.Type; + +public class SdbcxIndexDescriptor extends ODescriptor implements XColumnsSupplier { + protected String catalog = ""; + protected boolean isUnique; + protected boolean isClustered; + + private SdbcxIndexColumnDescriptorContainer columns; + + protected SdbcxIndexDescriptor(Object lock, boolean isCaseSensitive) { + super(lock, "", isCaseSensitive, false); + columns = new SdbcxIndexColumnDescriptorContainer(this.lock, isCaseSensitive()); + registerProperties(); + } + + public static SdbcxIndexDescriptor create(boolean isCaseSensitive) { + final Object lock = new Object(); + return new SdbcxIndexDescriptor(lock, isCaseSensitive); + } + + private void registerProperties() { + registerProperty(PropertyIds.CATALOG.name, PropertyIds.CATALOG.id, Type.STRING, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return catalog; + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + catalog = (String) value; + } + }); + registerProperty(PropertyIds.ISUNIQUE.name, PropertyIds.ISUNIQUE.id, Type.BOOLEAN, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return isUnique; + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + isUnique = (boolean) value; + } + }); + registerProperty(PropertyIds.ISCLUSTERED.name, PropertyIds.ISCLUSTERED.id, Type.BOOLEAN, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return isClustered; + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + isClustered = (boolean) value; + } + }); + } + + public SdbcxIndexColumnDescriptorContainer getColumns() { + return columns; + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexDescriptor.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexDescriptorContainer.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexDescriptorContainer.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexDescriptorContainer.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexDescriptorContainer.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,44 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbcx.comp.postgresql.util.DbTools; + +public class SdbcxIndexDescriptorContainer extends SdbcxDescriptorContainer { + public SdbcxIndexDescriptorContainer(Object lock, boolean isCaseSensitive) { + super(lock, isCaseSensitive); + } + + @Override + public XPropertySet createDescriptor() { + return SdbcxIndexDescriptor.create(isCaseSensitive()); + } + + @Override + public XPropertySet appendObject(String _rForName, XPropertySet descriptor) throws SQLException { + XPropertySet newDescriptor = cloneDescriptor(descriptor); + DbTools.cloneDescriptorColumns(descriptor, newDescriptor); + return newDescriptor; + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxIndexDescriptorContainer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyColumnDescriptor.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyColumnDescriptor.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyColumnDescriptor.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyColumnDescriptor.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,58 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors; + +import com.sun.star.sdbcx.comp.postgresql.comphelper.PropertySetAdapter.PropertyGetter; +import com.sun.star.sdbcx.comp.postgresql.comphelper.PropertySetAdapter.PropertySetter; +import com.sun.star.sdbcx.comp.postgresql.util.PropertyIds; +import com.sun.star.uno.Type; + +public class SdbcxKeyColumnDescriptor extends SdbcxColumnDescriptor { + protected String relatedColumn; + + protected SdbcxKeyColumnDescriptor(Object lock, boolean isCaseSensitive) { + super(lock, isCaseSensitive); + registerProperties(); + } + + public static SdbcxKeyColumnDescriptor create(boolean isCaseSensitive) { + final Object lock = new Object(); + return new SdbcxKeyColumnDescriptor(lock, isCaseSensitive); + } + + private void registerProperties() { + registerProperty(PropertyIds.RELATEDCOLUMN.name, PropertyIds.RELATEDCOLUMN.id, Type.STRING, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return relatedColumn; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + relatedColumn = (String) value; + } + }); + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyColumnDescriptor.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyColumnDescriptorContainer.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyColumnDescriptorContainer.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyColumnDescriptorContainer.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyColumnDescriptorContainer.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,35 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors; + +import com.sun.star.beans.XPropertySet; + +public class SdbcxKeyColumnDescriptorContainer extends SdbcxDescriptorContainer { + public SdbcxKeyColumnDescriptorContainer(Object lock, boolean isCaseSensitive) { + super(lock, isCaseSensitive); + } + + @Override + public XPropertySet createDescriptor() { + return SdbcxKeyColumnDescriptor.create(isCaseSensitive()); + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyColumnDescriptorContainer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyDescriptor.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyDescriptor.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyDescriptor.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyDescriptor.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,113 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors; + +import com.sun.star.container.XNameAccess; +import com.sun.star.sdbcx.XColumnsSupplier; +import com.sun.star.sdbcx.comp.postgresql.comphelper.PropertySetAdapter.PropertyGetter; +import com.sun.star.sdbcx.comp.postgresql.comphelper.PropertySetAdapter.PropertySetter; +import com.sun.star.sdbcx.comp.postgresql.sdbcx.ODescriptor; +import com.sun.star.sdbcx.comp.postgresql.util.PropertyIds; +import com.sun.star.uno.Type; + +public class SdbcxKeyDescriptor extends ODescriptor implements XColumnsSupplier { + protected int type; + protected String referencedTable; + protected int updateRule; + protected int deleteRule; + + private SdbcxKeyColumnDescriptorContainer columns; + + protected SdbcxKeyDescriptor(Object lock, boolean isCaseSensitive) { + super(lock, "", isCaseSensitive, false); + registerProperties(); + columns = new SdbcxKeyColumnDescriptorContainer(this.lock, isCaseSensitive()); + } + + public static SdbcxKeyDescriptor create(boolean isCaseSensitive) { + final Object lock = new Object(); + return new SdbcxKeyDescriptor(lock, isCaseSensitive); + } + + private void registerProperties() { + registerProperty(PropertyIds.TYPE.name, PropertyIds.TYPE.id, Type.LONG, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return type; + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + type = (int) value; + } + }); + registerProperty(PropertyIds.REFERENCEDTABLE.name, PropertyIds.REFERENCEDTABLE.id, Type.STRING, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return referencedTable; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + referencedTable = (String) value; + } + }); + registerProperty(PropertyIds.UPDATERULE.name, PropertyIds.UPDATERULE.id, Type.LONG, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return updateRule; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + updateRule = (int) value; + } + }); + registerProperty(PropertyIds.DELETERULE.name, PropertyIds.DELETERULE.id, Type.LONG, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return deleteRule; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + deleteRule = (int) value; + } + }); + } + + @Override + public XNameAccess getColumns() { + return columns; + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyDescriptor.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyDescriptorContainer.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyDescriptorContainer.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyDescriptorContainer.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyDescriptorContainer.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,44 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbcx.comp.postgresql.util.DbTools; + +public class SdbcxKeyDescriptorContainer extends SdbcxDescriptorContainer { + public SdbcxKeyDescriptorContainer(Object lock, boolean isCaseSensitive) { + super(lock, isCaseSensitive); + } + + @Override + public XPropertySet createDescriptor() { + return SdbcxKeyDescriptor.create(isCaseSensitive()); + } + + @Override + public XPropertySet appendObject(String _rForName, XPropertySet descriptor) throws SQLException { + XPropertySet newDescriptor = cloneDescriptor(descriptor); + DbTools.cloneDescriptorColumns(descriptor, newDescriptor); + return newDescriptor; + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxKeyDescriptorContainer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxTableDescriptor.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxTableDescriptor.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxTableDescriptor.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxTableDescriptor.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,109 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.sdbcx.XColumnsSupplier; +import com.sun.star.sdbcx.XKeysSupplier; +import com.sun.star.sdbcx.comp.postgresql.comphelper.PropertySetAdapter.PropertyGetter; +import com.sun.star.sdbcx.comp.postgresql.comphelper.PropertySetAdapter.PropertySetter; +import com.sun.star.sdbcx.comp.postgresql.sdbcx.OContainer; +import com.sun.star.sdbcx.comp.postgresql.sdbcx.ODescriptor; +import com.sun.star.sdbcx.comp.postgresql.util.PropertyIds; +import com.sun.star.uno.Type; + +public class SdbcxTableDescriptor extends ODescriptor implements XColumnsSupplier, XKeysSupplier { + protected String catalogName; + protected String schemaName; + protected String description; + + private OContainer columns; + private OContainer keys; + + protected SdbcxTableDescriptor(Object lock, boolean isCaseSensitive) { + super(lock, "", isCaseSensitive, false); + columns = new SdbcxColumnDescriptorContainer(this.lock, isCaseSensitive()); + keys = new SdbcxKeyDescriptorContainer(this.lock, isCaseSensitive()); + registerProperties(); + } + + public static SdbcxTableDescriptor create(boolean isCaseSensitive) { + final Object lock = new Object(); + return new SdbcxTableDescriptor(lock, isCaseSensitive); + } + + private void registerProperties() { + registerProperty(PropertyIds.CATALOGNAME.name, PropertyIds.CATALOGNAME.id, Type.STRING, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return catalogName; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + catalogName = (String) value; + } + }); + registerProperty(PropertyIds.SCHEMANAME.name, PropertyIds.SCHEMANAME.id, Type.STRING, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return schemaName; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + schemaName = (String) value; + } + }); + registerProperty(PropertyIds.DESCRIPTION.name, PropertyIds.DESCRIPTION.id, Type.STRING, (short)0, + new PropertyGetter() { + @Override + public Object getValue() { + return description; + + } + }, + new PropertySetter() { + @Override + public void setValue(Object value) { + description = (String) value; + } + }); + } + + @Override + public XNameAccess getColumns() { + return columns; + } + + @Override + public XIndexAccess getKeys() { + return keys; + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxTableDescriptor.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/ComposeRule.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/ComposeRule.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/ComposeRule.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/ComposeRule.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,31 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.util; + +public enum ComposeRule { + InTableDefinitions, + InIndexDefinitions, + InDataManipulation, + InProcedureCalls, + InPrivilegeDefinitions, + Complete +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/ComposeRule.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DBTypeConversion.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DBTypeConversion.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DBTypeConversion.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DBTypeConversion.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,426 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.util; + +import java.util.StringTokenizer; + +import com.sun.star.util.Date; +import com.sun.star.util.DateTime; +import com.sun.star.util.Time; + +public class DBTypeConversion { + private static final int MAX_DAYS = 3636532; + private static Date standardDate = new Date((short)1, (short)1, (short)1900); + private static int aDaysInMonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + private static final double fMilliSecondsPerDay = 86400000.0; + + public static double safeParseDouble(String value) { + try { + return Double.parseDouble(value); + } catch (NumberFormatException numberFormatException) { + return 0.0; + } + } + + public static float safeParseFloat(String value) { + try { + return Float.parseFloat(value); + } catch (NumberFormatException numberFormatException) { + return 0.0f; + } + } + + public static int safeParseInt(String value) { + try { + return Integer.parseInt(value); + } catch (NumberFormatException numberFormatException) { + return 0; + } + } + + public static long safeParseLong(String value) { + try { + return Long.parseLong(value); + } catch (NumberFormatException numberFormatException) { + return 0; + } + } + + public static float unsignedLongToFloat(long value) { + float f = value & 0x7fffFFFFffffFFFFL; + if (value < 0) { + f += 0x1p63f; + } + return f; + } + + public static double unsignedLongToDouble(long value) { + double d = value & 0x7fffFFFFffffFFFFL; + if (value < 0) { + d += 0x1p63f; + } + return d; + } + + public static void addDays(int nDays, Date _rDate) { + int nTempDays = implRelativeToAbsoluteNull( _rDate ); + + nTempDays += nDays; + if ( nTempDays > MAX_DAYS ) + { + _rDate.Day = 31; + _rDate.Month = 12; + _rDate.Year = 9999; + } + else if ( nTempDays <= 0 ) + { + _rDate.Day = 1; + _rDate.Month = 1; + _rDate.Year = 00; + } + else + implBuildFromRelative( nTempDays, _rDate ); + } + + public static void subDays(int nDays, Date _rDate) { + int nTempDays = implRelativeToAbsoluteNull( _rDate ); + + nTempDays -= nDays; + if ( nTempDays > MAX_DAYS ) + { + _rDate.Day = 31; + _rDate.Month = 12; + _rDate.Year = 9999; + } + else if ( nTempDays <= 0 ) + { + _rDate.Day = 1; + _rDate.Month = 1; + _rDate.Year = 00; + } + else + implBuildFromRelative( nTempDays, _rDate ); + } + + public static int getMsFromTime(final Time rVal) { + int nHour = rVal.Hours; + int nMin = rVal.Minutes; + int nSec = rVal.Seconds; + int n100Sec = rVal.HundredthSeconds; + + return ((nHour*3600000)+(nMin*60000)+(nSec*1000)+(n100Sec*10)); + } + + public static Date getStandardDate() { + return standardDate; + } + + private static int implDaysInMonth(int _nMonth, int _nYear) { + if (_nMonth != 2) + return aDaysInMonth[_nMonth-1]; + else { + if (implIsLeapYear(_nYear)) + return aDaysInMonth[_nMonth-1] + 1; + else + return aDaysInMonth[_nMonth-1]; + } + } + + private static void implBuildFromRelative( int nDays, Date date ) { + int nTempDays; + int i = 0; + boolean bCalc; + + do { + nTempDays = nDays; + date.Year = (short)((nTempDays / 365) - i); + nTempDays -= (date.Year-1) * 365; + nTempDays -= ((date.Year-1) / 4) - ((date.Year-1) / 100) + ((date.Year-1) / 400); + bCalc = false; + if ( nTempDays < 1 ) + { + i++; + bCalc = true; + } + else + { + if ( nTempDays > 365 ) + { + if ( (nTempDays != 366) || !implIsLeapYear( date.Year ) ) + { + i--; + bCalc = true; + } + } + } + } + while ( bCalc ); + + date.Month = 1; + while ( nTempDays > implDaysInMonth( date.Month, date.Year ) ) + { + nTempDays -= implDaysInMonth( date.Month, date.Year ); + date.Month++; + } + date.Day = (short)nTempDays; + } + + private static boolean implIsLeapYear(int _nYear) { + return ( ( ((_nYear % 4) == 0) + && ((_nYear % 100) != 0) + ) + ) + || ((_nYear % 400) == 0) + ; + } + + + private static int implRelativeToAbsoluteNull(final Date _rDate) { + int nDays = 0; + + // ripped this code from the implementation of tools::Date + int nNormalizedYear = _rDate.Year - 1; + nDays = nNormalizedYear * 365; + // leap years + nDays += (nNormalizedYear / 4) - (nNormalizedYear / 100) + (nNormalizedYear / 400); + + for (int i = 1; i < _rDate.Month; ++i) + nDays += implDaysInMonth(i, _rDate.Year); + + nDays += _rDate.Day; + return nDays; + } + + public static int toDays(Date rVal) { + return toDays(rVal, getStandardDate()); + } + + public static int toDays(Date rVal, Date rNullDate) { + return implRelativeToAbsoluteNull(rVal) - implRelativeToAbsoluteNull(rNullDate); + } + + public static double toDouble(Date rVal) { + return toDouble(rVal, getStandardDate()); + } + + public static double toDouble(Date rVal, Date _rNullDate) { + return (double)toDays(rVal, _rNullDate); + } + + public static double toDouble(DateTime _rVal) { + return toDouble(_rVal, getStandardDate()); + } + + public static double toDouble(DateTime _rVal, Date _rNullDate) { + long nTime = toDays(new Date(_rVal.Day, _rVal.Month, _rVal.Year), _rNullDate); + Time aTimePart = new Time(); + + aTimePart.Hours = _rVal.Hours; + aTimePart.Minutes = _rVal.Minutes; + aTimePart.Seconds = _rVal.Seconds; + aTimePart.HundredthSeconds = _rVal.HundredthSeconds; + + return ((double)nTime) + toDouble(aTimePart); + } + + public static double toDouble(Time rVal) { + return (double)getMsFromTime(rVal) / fMilliSecondsPerDay; + } + + public static Date toDate(double dVal) { + return toDate(dVal, getStandardDate()); + } + + public static Date toDate(double dVal, Date _rNullDate) { + Date aRet = _rNullDate; + + if (dVal >= 0) + addDays((int)dVal,aRet); + else + subDays((int)(-dVal),aRet); + // x -= (sal_uInt32)(-nDays); + + return aRet; + } + + public static Date toDate(String value) { + String[] tokens = value.split("-"); + + short nYear = 0, + nMonth = 0, + nDay = 0; + if (tokens.length > 0) { + nYear = (short)safeParseInt(tokens[0]); + } + if (tokens.length > 1) { + nMonth = (short)safeParseInt(tokens[1]); + } + if (tokens.length > 2) { + nDay = (short)safeParseInt(tokens[2]); + } + + return new Date(nDay,nMonth,nYear); + } + + public static DateTime toDateTime(double dVal) { + return toDateTime(dVal, getStandardDate()); + } + + public static DateTime toDateTime(double dVal, Date _rNullDate) { + Date aDate = toDate(dVal, _rNullDate); + Time aTime = toTime(dVal); + + DateTime xRet = new DateTime(); + + xRet.Day = aDate.Day; + xRet.Month = aDate.Month; + xRet.Year = aDate.Year; + + xRet.HundredthSeconds = aTime.HundredthSeconds; + xRet.Minutes = aTime.Minutes; + xRet.Seconds = aTime.Seconds; + xRet.Hours = aTime.Hours; + + + return xRet; + } + + public static DateTime toDateTime(String _sSQLString) { + // the date part + int nSeparation = _sSQLString.indexOf( ' ' ); + String dateString; + String timeString = ""; + if (nSeparation >= 0) { + dateString = _sSQLString.substring(0, nSeparation); + timeString = _sSQLString.substring(nSeparation + 1); + } else { + dateString = _sSQLString; + } + Date aDate = toDate(dateString); + Time aTime = new Time(); + + if ( -1 != nSeparation ) + aTime = toTime( timeString ); + + return new DateTime(aTime.HundredthSeconds,aTime.Seconds,aTime.Minutes,aTime.Hours,aDate.Day,aDate.Month,aDate.Year); + } + + public static Time toTime(int _nVal) { + Time aReturn = new Time(); + aReturn.Hours = (short)(((int)(_nVal >= 0 ? _nVal : _nVal*-1)) / 1000000); + aReturn.Minutes = (short)((((int)(_nVal >= 0 ? _nVal : _nVal*-1)) / 10000) % 100); + aReturn.Seconds = (short)((((int)(_nVal >= 0 ? _nVal : _nVal*-1)) / 100) % 100); + aReturn.HundredthSeconds = (short)(((int)(_nVal >= 0 ? _nVal : _nVal*-1)) % 100); + return aReturn; + } + + public static Time toTime(double dVal) { + int nDays = (int)dVal; + int nMS = (int)((dVal - (double)nDays) * fMilliSecondsPerDay + 0.5); + + short nSign; + if ( nMS < 0 ) + { + nMS *= -1; + nSign = -1; + } + else + nSign = 1; + + Time xRet = new Time(); + // Zeit normalisieren + // we have to sal_Int32 here because otherwise we get an overflow + int nHundredthSeconds = nMS/10; + int nSeconds = nHundredthSeconds / 100; + int nMinutes = nSeconds / 60; + + xRet.HundredthSeconds = (short)(nHundredthSeconds % 100); + xRet.Seconds = (short)(nSeconds % 60); + xRet.Hours = (short)(nMinutes / 60); + xRet.Minutes = (short)(nMinutes % 60); + + // Zeit zusammenbauen + int nTime = (int)(xRet.HundredthSeconds + (xRet.Seconds*100) + (xRet.Minutes*10000) + (xRet.Hours*1000000)) * nSign; + + if(nTime < 0) + { + xRet.HundredthSeconds = 99; + xRet.Minutes = 59; + xRet.Seconds = 59; + xRet.Hours = 23; + } + return xRet; + } + + public static Time toTime(String _sSQLString) { + short nHour = 0, + nMinute = 0, + nSecond = 0, + nHundredthSeconds = 0; + StringTokenizer tokenizer = new StringTokenizer(_sSQLString, ":"); + if (tokenizer.hasMoreTokens()) { + nHour = (short)safeParseInt(tokenizer.nextToken()); + } + if (tokenizer.hasMoreTokens()) { + nMinute = (short)safeParseInt(tokenizer.nextToken()); + } + if (tokenizer.hasMoreTokens()) { + String secondAndNano = tokenizer.nextToken(); + int dot = secondAndNano.indexOf("."); + if (dot >= 0) { + nSecond = (short)safeParseInt(secondAndNano.substring(0, dot)); + String nano = secondAndNano.substring(dot + 1); + nano = nano.substring(0, 2); + nano = nano + "00".substring(0, 2 - nano.length()); + nHundredthSeconds = (short)safeParseInt(nano); + } else { + nSecond = (short)safeParseInt(secondAndNano); + } + } + return new Time(nHundredthSeconds,nSecond,nMinute,nHour); + } + + public static String toDateString(Date date) { + return String.format("%04d-%02d-%02d", + Short.toUnsignedInt(date.Year), + Short.toUnsignedInt(date.Month), + Short.toUnsignedInt(date.Day)); + } + + public static String toTimeString(Time time) { + return String.format("%02d:%02d:%02d", + Short.toUnsignedInt(time.Hours), + Short.toUnsignedInt(time.Minutes), + Short.toUnsignedInt(time.Seconds)); + } + + public static String toDateTimeString(DateTime dateTime) { + return String.format("%04d-%02d-%02d %02d:%02d:%02d.%d", + Short.toUnsignedInt(dateTime.Year), + Short.toUnsignedInt(dateTime.Month), + Short.toUnsignedInt(dateTime.Day), + Short.toUnsignedInt(dateTime.Hours), + Short.toUnsignedInt(dateTime.Minutes), + Short.toUnsignedInt(dateTime.Seconds), + Short.toUnsignedInt(dateTime.HundredthSeconds)); + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DBTypeConversion.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DatabaseMetaDataResultSet.java URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DatabaseMetaDataResultSet.java?rev=1805579&view=auto ============================================================================== --- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DatabaseMetaDataResultSet.java (added) +++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DatabaseMetaDataResultSet.java Sun Aug 20 19:16:28 2017 @@ -0,0 +1,489 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +package com.sun.star.sdbcx.comp.postgresql.util; + +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicBoolean; + +import com.sun.star.beans.PropertyVetoException; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.XPropertyChangeListener; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.beans.XVetoableChangeListener; +import com.sun.star.container.XNameAccess; +import com.sun.star.io.XInputStream; +import com.sun.star.lang.DisposedException; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lib.uno.helper.ComponentBase; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XArray; +import com.sun.star.sdbc.XBlob; +import com.sun.star.sdbc.XClob; +import com.sun.star.sdbc.XCloseable; +import com.sun.star.sdbc.XColumnLocate; +import com.sun.star.sdbc.XRef; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XResultSetMetaData; +import com.sun.star.sdbc.XResultSetMetaDataSupplier; +import com.sun.star.sdbc.XRow; +import com.sun.star.sdbcx.CompareBookmark; +import com.sun.star.sdbcx.XColumnsSupplier; +import com.sun.star.sdbcx.XRowLocate; +import com.sun.star.sdbcx.comp.postgresql.PostgresqlResultSetMetaData; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.Date; +import com.sun.star.util.DateTime; +import com.sun.star.util.Time; + +public class DatabaseMetaDataResultSet extends ComponentBase + implements XResultSet, XCloseable, XColumnsSupplier, XRowLocate, XPropertySet, XColumnLocate, XRow, XResultSetMetaDataSupplier { + + private XCloseable implCloseable; + private XResultSetMetaDataSupplier implResultSetMetaDataSupplier; + private XColumnLocate implColumnLocate; + private XPropertySet implPropertySet; + private XColumnsSupplier implColumnSupplier; + private ArrayList<ORowSetValue[]> rows; + private AtomicBoolean isDisposed = new AtomicBoolean(false); + /// 0-based: + private int currentRow = -1; + /// 1-based: + private int currentColumn; + + public DatabaseMetaDataResultSet(XResultSet impl, ArrayList<ORowSetValue[]> rows) { + implCloseable = UnoRuntime.queryInterface(XCloseable.class, impl); + implPropertySet = UnoRuntime.queryInterface(XPropertySet.class, impl); + implColumnSupplier = UnoRuntime.queryInterface(XColumnsSupplier.class, impl); + implColumnLocate = UnoRuntime.queryInterface(XColumnLocate.class, impl); + implResultSetMetaDataSupplier = UnoRuntime.queryInterface(XResultSetMetaDataSupplier.class, impl); + this.rows = rows; + } + + // XComponent: + @Override + protected void postDisposing() { + isDisposed.set(true); + try { + implCloseable.close(); + } catch (SQLException sqlException) { + } + } + + private void checkDisposed() throws DisposedException { + if (isDisposed.get()) { + throw new DisposedException(); + } + } + + // XCloseable: + + public void close() throws SQLException { + dispose(); + } + + // XResultSet: + + private ORowSetValue getField(int columnIndex) throws SQLException { + if (isBeforeFirst() || isAfterLast()) { + throw new SQLException("Row out of range"); + } + ORowSetValue[] fields = rows.get(currentRow); + if (columnIndex < 1 || fields.length < columnIndex) { + throw new SQLException("Column out of range"); + } + currentColumn = columnIndex; + return fields[columnIndex - 1]; + } + + public synchronized boolean absolute(int position) throws SQLException { + checkDisposed(); + if (position >= 0) { + currentRow = position; + } else { + currentRow = rows.size() + position; + } + if (currentRow <= -1) { + currentRow = -1; + return false; + } + if (currentRow >= rows.size()) { + currentRow = rows.size(); + return false; + } + return true; + } + + public synchronized void afterLast() throws SQLException { + checkDisposed(); + currentRow = rows.size(); + } + + public synchronized void beforeFirst() throws SQLException { + checkDisposed(); + currentRow = -1; + } + + public synchronized boolean first() throws SQLException { + checkDisposed(); + currentRow = 0; + return true; + } + + public synchronized int getRow() throws SQLException { + checkDisposed(); + return currentRow + 1; + } + + public Object getStatement() throws SQLException { + checkDisposed(); + return null; + } + + public synchronized boolean isAfterLast() throws SQLException { + checkDisposed(); + return currentRow == rows.size(); + } + + public synchronized boolean isBeforeFirst() throws SQLException { + checkDisposed(); + return currentRow == -1; + } + + public synchronized boolean isFirst() throws SQLException { + checkDisposed(); + return currentRow == 0; + } + + public synchronized boolean isLast() throws SQLException { + checkDisposed(); + return currentRow == (rows.size() - 1); + } + + public synchronized boolean last() throws SQLException { + checkDisposed(); + currentRow = rows.size() - 1; + return true; + } + + public synchronized boolean next() throws SQLException { + checkDisposed(); + if (currentRow < rows.size()) { + ++currentRow; + } + return currentRow < rows.size(); + } + + public synchronized boolean previous() throws SQLException { + checkDisposed(); + if (currentRow > -1) { + --currentRow; + } + return currentRow > -1; + } + + public void refreshRow() throws SQLException { + checkDisposed(); + } + + public synchronized boolean relative(int offset) throws SQLException { + checkDisposed(); + currentRow += offset; + if (currentRow <= -1) { + currentRow = -1; + return false; + } + if (currentRow >= rows.size()) { + currentRow = rows.size(); + return false; + } + return true; + } + + public boolean rowDeleted() throws SQLException { + checkDisposed(); + return false; + } + + public boolean rowInserted() throws SQLException { + checkDisposed(); + return false; + } + + public boolean rowUpdated() throws SQLException { + checkDisposed(); + return false; + } + + // XResultSetMetaDataSupplier: + + public XResultSetMetaData getMetaData() throws SQLException { + checkDisposed(); + return new PostgresqlResultSetMetaData(implResultSetMetaDataSupplier.getMetaData()); + } + + // XRow: + + public XArray getArray(int columnIndex) throws SQLException { + checkDisposed(); + return null; + } + + public XInputStream getBinaryStream(int columnIndex) throws SQLException { + checkDisposed(); + return null; + } + + public XBlob getBlob(int columnIndex) throws SQLException { + checkDisposed(); + return null; + } + + public synchronized boolean getBoolean(int columnIndex) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.getBoolean(); + } + + public synchronized byte getByte(int columnIndex) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.getInt8(); + } + + public synchronized byte[] getBytes(int columnIndex) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.getSequence(); + } + + public XInputStream getCharacterStream(int columnIndex) throws SQLException { + checkDisposed(); + return null; + } + + public XClob getClob(int columnIndex) throws SQLException { + checkDisposed(); + return null; + } + + public synchronized Date getDate(int columnIndex) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.getDate(); + } + + public synchronized double getDouble(int columnIndex) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.getDouble(); + } + + public synchronized float getFloat(int columnIndex) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.getFloat(); + } + + public synchronized int getInt(int columnIndex) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.getInt32(); + } + + public synchronized long getLong(int columnIndex) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.getLong(); + } + + public synchronized Object getObject(int columnIndex, XNameAccess arg1) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.makeAny(); + } + + public XRef getRef(int columnIndex) throws SQLException { + checkDisposed(); + return null; + } + + public synchronized short getShort(int columnIndex) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.getInt16(); + } + + public synchronized String getString(int columnIndex) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.getString(); + } + + public synchronized Time getTime(int columnIndex) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.getTime(); + } + + public synchronized DateTime getTimestamp(int columnIndex) throws SQLException { + checkDisposed(); + ORowSetValue field = getField(columnIndex); + return field.getDateTime(); + } + + public synchronized boolean wasNull() throws SQLException { + checkDisposed(); + ORowSetValue field = getField(currentColumn); + return field.isNull(); + } + + // XColumnLocate: + + public int findColumn(String arg0) throws SQLException { + checkDisposed(); + return implColumnLocate.findColumn(arg0); + } + + // XPropertySet: + + public void addPropertyChangeListener(String arg0, XPropertyChangeListener arg1) throws UnknownPropertyException, WrappedTargetException { + checkDisposed(); + implPropertySet.addPropertyChangeListener(arg0, arg1); + } + + public void addVetoableChangeListener(String arg0, XVetoableChangeListener arg1) throws UnknownPropertyException, WrappedTargetException { + checkDisposed(); + implPropertySet.addVetoableChangeListener(arg0, arg1); + } + + public XPropertySetInfo getPropertySetInfo() { + checkDisposed(); + return implPropertySet.getPropertySetInfo(); + } + + public Object getPropertyValue(String arg0) throws UnknownPropertyException, WrappedTargetException { + checkDisposed(); + return implPropertySet.getPropertyValue(arg0); + } + + public void removePropertyChangeListener(String arg0, XPropertyChangeListener arg1) throws UnknownPropertyException, WrappedTargetException { + checkDisposed(); + implPropertySet.removePropertyChangeListener(arg0, arg1); + } + + public void removeVetoableChangeListener(String arg0, XVetoableChangeListener arg1) throws UnknownPropertyException, WrappedTargetException { + checkDisposed(); + implPropertySet.removeVetoableChangeListener(arg0, arg1); + } + + public void setPropertyValue(String arg0, Object arg1) + throws UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException { + checkDisposed(); + implPropertySet.setPropertyValue(arg0, arg1); + } + + // XRowLocate: + + public int compareBookmarks(Object arg0, Object arg1) throws SQLException { + checkDisposed(); + + int bookmark1, bookmark2; + try { + bookmark1 = AnyConverter.toInt(arg0); + bookmark2 = AnyConverter.toInt(arg1); + } catch (IllegalArgumentException illegalArgumentException) { + return CompareBookmark.NOT_COMPARABLE; + } + + if (bookmark1 < bookmark2) { + return CompareBookmark.LESS; + } else if (bookmark1 > bookmark2) { + return CompareBookmark.GREATER; + } else { + return CompareBookmark.EQUAL; + } + } + + public Object getBookmark() throws SQLException { + checkDisposed(); + return currentRow; + } + + public boolean hasOrderedBookmarks() throws SQLException { + checkDisposed(); + return true; + } + + public int hashBookmark(Object arg0) throws SQLException { + checkDisposed(); + int bookmark; + try { + bookmark = AnyConverter.toInt(arg0); + } catch (IllegalArgumentException illegalArgumentException) { + throw new SQLException("Bad bookmark", this, StandardSQLState.SQL_INVALID_BOOKMARK_VALUE.text(), 0, null); + } + return bookmark; + } + + public boolean moveRelativeToBookmark(Object arg0, int arg1) throws SQLException { + checkDisposed(); + int bookmark; + boolean moved = false; + try { + bookmark = AnyConverter.toInt(arg0); + moved = absolute(bookmark); + if (moved) { + moved = relative(arg1); + } + } catch (IllegalArgumentException illegalArgumentException) { + } + if (!moved) { + afterLast(); + } + return moved; + } + + public boolean moveToBookmark(Object arg0) throws SQLException { + checkDisposed(); + int bookmark; + boolean moved = false; + try { + bookmark = AnyConverter.toInt(arg0); + moved = absolute(bookmark); + } catch (IllegalArgumentException illegalArgumentException) { + } + if (!moved) { + afterLast(); + } + return moved; + } + + // XColumnSupplier: + + public XNameAccess getColumns() { + checkDisposed(); + return implColumnSupplier.getColumns(); + } +} Propchange: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DatabaseMetaDataResultSet.java ------------------------------------------------------------------------------ svn:eol-style = native